Commit b0316bdb authored by Jan Möbius's avatar Jan Möbius

Try to get the right module location

parent d52fb19b
......@@ -54,15 +54,26 @@ void startup() {
SetErrorMode(0); // 0: Use the system default, which is to display all error dialog boxes.
#endif
pybind11::initialize_interpreter();
// Interpreter is already running, so we don't need this!
//pybind11::initialize_interpreter();
char arg0[] = "OpenFlipper";
char* argv[] = { &arg0[0], NULL };
char arg1[] = "-c";
char arg2[] = "-d";
char* argv[] = { &arg0[0], &arg1[0], &arg2[0] , NULL };
int argc = (int)(sizeof(argv) / sizeof(argv[0])) - 1;
OpenFlipper::Options::argc(&argc);
//OpenFlipper::Options::argv(&argv);
pybind11::object module = pybind11::module::import("libopenflipperpython");
QString modulepath = QString(module.attr("__file__").cast<std::string>().c_str());
QString moduleDirectory = modulepath.section("/",0,-2);
OpenFlipper::Options::setApplicationDir(moduleDirectory);
// Set organization and application names
QCoreApplication::setOrganizationName("VCI");
QCoreApplication::setApplicationName(TOSTRING(PRODUCT_STRING));
......@@ -70,16 +81,15 @@ void startup() {
// initialize a core application to check for initialization Paths
QCoreApplication* coreApp = new QCoreApplication(argc, argv);
OpenFlipper::Options::initializeSettings();
// only one application is allowed so delete the core application
// once cmdline parsing is done
delete coreApp;
OpenFlipper::Options::windowTitle(TOSTRING(PRODUCT_STRING)" v" + OpenFlipper::Options::coreVersion());
if ( !OpenFlipper::Options::nogui() ) {
// OpenGL check
......@@ -113,13 +123,13 @@ void startup() {
std::cerr << "This system has no OpenGL support.\n";
return ;
}
std::cerr << "ssss" << std::endl;
// create core ( this also reads the ini files )
Core * w = new Core( );
#ifdef PYTHON_ENABLED
//setCorePointer(w);
#endif
std::cerr << "AAddddA" << std::endl;
QString tLang = OpenFlipperSettings().value("Core/Language/Translation","en_US").toString();
if (tLang == "locale")
......
......@@ -64,7 +64,7 @@ static QString compilerInfo_ = "";
static OpenFlipperQSettings* settings_ = 0;
/// Stores the base Path of the application
static QDir applicationDir_;
static QString applicationDir_ = QString("");
/// Stores the base Path of the application
static QDir configDir_;
......@@ -263,6 +263,9 @@ QString dirSeparator() {
}
QDir applicationDir() { return applicationDir_; }
void setApplicationDir(QString _dir) { applicationDir_ = _dir; }
QDir configDir() { return configDir_; }
QDir pluginDir() { return pluginDir_; }
QDir shaderDir() { return shaderDir_; }
......@@ -278,7 +281,7 @@ QDir currentDir() { return currentDir_; }
QDir currentScriptDir() { return currentScriptDir_; }
QDir currentTextureDir(){ return currentTextureDir_; }
QString applicationDirStr() { return applicationDir_.absolutePath(); }
QString applicationDirStr() { return applicationDir_; }
QString configDirStr() { return configDir_.absolutePath(); }
QString pluginDirStr() { return pluginDir_.absolutePath(); }
QString shaderDirStr() { return shaderDir_.absolutePath(); }
......@@ -931,22 +934,29 @@ bool initializeSettings() {
//==================================================================================================
// Remember the main application directory (assumed to be one above executable Path)
applicationDir_.setPath( QCoreApplication::applicationDirPath() );
applicationDir_.setPath("/home/jan/projects/build-OpenFlipper-Free-Desktop_Qt_5_14_1_GCC_64bit-Release/Build/bin");
foreach (const QString &path, QCoreApplication::libraryPaths())
std::cerr << path.toStdString() << std::endl;
if ( applicationDirStr() == "") {
std::cerr << "Application dir unset" << std::endl;
applicationDir_ = QCoreApplication::applicationDirPath();
//applicationDir_.setPath("/home/jan/projects/build-OpenFlipper-Free-Desktop_Qt_5_14_1_GCC_64bit-Release/Build/bin");
} else {
std::cerr << "Application dir already set to " << applicationDirStr().toStdString() << std::endl;
}
std::cerr << "Application Dir " << QCoreApplication::applicationFilePath().toStdString() << std::endl;
std::cerr << "Application Dir is now " << QCoreApplication::applicationFilePath().toStdString() << std::endl;
// When using cmake, we get the absolute path to the Application directory via a define
applicationDir_.cd(OPENFLIPPER_APPDIR);
QDir appDir = QDir(applicationDir_);
appDir.cd(OPENFLIPPER_APPDIR);
applicationDir_ = appDir.absolutePath();
//==================================================================================================
// Setup directory containing plugins
//==================================================================================================
// start at application directory
pluginDir_ = applicationDir_;
pluginDir_ = appDir;
// cmake style: Path is directly given from define!
pluginDir_.cd(OPENFLIPPER_PLUGINDIR);
......
......@@ -168,6 +168,12 @@ namespace Options {
DLLEXPORT
QDir applicationDir();
/// Set the base Path of the application
/// It's usually done automatically, but if OpenFlipper runs as a python module,
/// it has to be set via pybind
DLLEXPORT
void setApplicationDir(QString _dir);
/// Returns the Path to the Standard Plugins
DLLEXPORT
QDir pluginDir();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment