diff --git a/src/app/main.cpp b/src/app/main.cpp index 88d24340..9c636f64 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -145,7 +145,14 @@ int main(int argc, char *argv[]) return 0; } - commandLineParser.projectLoad(); + if (commandLineParser.hasError() ) + { + std::cout << commandLineParser.getError() << std::endl; + } + else + { + commandLineParser.projectLoad(); + } return qtApp.exec(); } else @@ -176,7 +183,14 @@ int main(int argc, char *argv[]) Application::getInstance()->addProjectFactoryModule(std::make_shared()); Application::getInstance()->addProjectFactoryModule(std::make_shared()); - commandLineParser.projectLoad(); + if (commandLineParser.hasError()) + { + Application::getInstance()->handleDialog(commandLineParser.getError()); + } + else + { + commandLineParser.projectLoad(); + } utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf"); utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".ttf"); diff --git a/src/lib/utility/commandline/CommandLineParser.cpp b/src/lib/utility/commandline/CommandLineParser.cpp index 09ed2514..c0a0f771 100644 --- a/src/lib/utility/commandline/CommandLineParser.cpp +++ b/src/lib/utility/commandline/CommandLineParser.cpp @@ -120,6 +120,16 @@ void CommandLineParser::processLicense(const bool isLoaded) m_withoutGUI = true; } +bool CommandLineParser::hasError() +{ + return !m_errorString.empty(); +} + +std::string CommandLineParser::getError() +{ + return m_errorString; +} + CommandLineParser::~CommandLineParser() { } @@ -142,36 +152,28 @@ bool CommandLineParser::startedWithLicense() void CommandLineParser::processProjectfile(const std::string& file) { FilePath projectfile(file); - bool isValidProjectfile = true; - std::string errorstring = "Provided Projectfile is not valid:\n"; - std::string errorProjectfile = "\tProvided Projectfile('" + projectfile.fileName() + ") "; + const std::string errorstring = + "Provided Projectfile is not valid:\n* Provided Projectfile('" + projectfile.fileName() + "') "; if (!projectfile.exists()) { - errorstring += errorProjectfile + " does not exist\n"; - isValidProjectfile = false; + m_errorString = errorstring + " does not exist"; + return; } if (projectfile.extension() != ".coatiproject") { - errorstring += errorProjectfile + " has a wrong fileending\n"; - isValidProjectfile = false; + m_errorString = errorstring + " has a wrong fileending"; + return; } std::shared_ptr configManager = ConfigManager::createEmpty(); if (!configManager->load(TextAccess::createFromFile(projectfile.str()))) { - errorstring += errorProjectfile + " could not be loaded\n"; - isValidProjectfile = false; + m_errorString = errorstring + " could not be loaded(invalid)"; + return; } - if (isValidProjectfile) - { - m_projectFile = projectfile; - } - else - { - std::cout << errorstring << std::endl; - } + m_projectFile = projectfile; } void CommandLineParser::projectLoad() diff --git a/src/lib/utility/commandline/CommandLineParser.h b/src/lib/utility/commandline/CommandLineParser.h index b1a019b2..c86bc679 100644 --- a/src/lib/utility/commandline/CommandLineParser.h +++ b/src/lib/utility/commandline/CommandLineParser.h @@ -16,6 +16,8 @@ public: bool exitApplication(); void projectLoad(); bool startedWithLicense(); + bool hasError(); + std::string getError(); License getLicense(); private: void processProjectfile(const std::string& file); @@ -27,6 +29,7 @@ private: bool m_withLicense; bool m_withoutGUI; + std::string m_errorString; License m_license; }; diff --git a/src/lib_gui/qt/window/QtStartScreen.cpp b/src/lib_gui/qt/window/QtStartScreen.cpp index 7020aaf4..49e8d2c2 100644 --- a/src/lib_gui/qt/window/QtStartScreen.cpp +++ b/src/lib_gui/qt/window/QtStartScreen.cpp @@ -78,7 +78,6 @@ QtStartScreen::QtStartScreen(QWidget *parent) : QtWindow(parent) { this->raise(); - setWindowModality(Qt::ApplicationModal); } QSize QtStartScreen::sizeHint() const