From 39e7789acd28f23fc80c631c34109d9a6418c95d Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Wed, 24 Feb 2016 11:16:19 +0100 Subject: [PATCH] Revert "utility: headless parsing" This reverts commit 76697d8b6e09f5d640fe6c865c6badf2f21c949f. --- CMakeLists.txt | 1 - script/build.sh | 18 ++-- src/app/main.cpp | 75 +++++---------- src/lib/Application.cpp | 58 +++--------- src/lib/Application.h | 1 - .../qt/commandline/QtCommandLineParser.cpp | 93 +++++++------------ .../qt/commandline/QtCommandLineParser.h | 9 +- src/lib_gui/qt/window/QtSplashScreen.cpp | 4 +- src/lib_gui/qt/window/QtSplashScreen.h | 4 +- 9 files changed, 82 insertions(+), 181 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index feaa94a5..a475b9f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,7 +50,6 @@ project(${PROJECT_NAME}) if(UNIX AND NOT APPLE) set(CMAKE_SKIP_BUILD_RPATH FALSE) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib/:$$ORIGIN/lib/") include(cmake/external.cmake) endif() diff --git a/script/build.sh b/script/build.sh index 4286e221..2f376d6f 100755 --- a/script/build.sh +++ b/script/build.sh @@ -12,38 +12,38 @@ then if [ "$2" = "test" ] then #echo "release test" - cmake --build build/Release --target Coati_test && cd bin/test && Release/Coati_test + ninja -C build/Release Coati_test && cd bin/test && Release/Coati_test elif [ "$2" = "trial" ] then - cmake --build build/Release --target Coati_trial && cd bin/app && Release/Coati_trial + ninja -C build/Release Coati_trial && cd bin/app && Release/Coati_trial elif [ "$2" = "keygen" ] then #echo "release keygen" - cmake --build build/Release --target Coati_license_generator && cd bin/license_generator && Release/Coati_license_generator + ninja -C build/Release Coati_license_generator && cd bin/license_generator && Release/Coati_license_generator else #echo "release app" - cmake --build build/Release --target Coati && cd bin/app && Release/Coati + ninja -C build/Release Coati && cd bin/app && Release/Coati fi elif [ "$1" = "debug" ] || [ "$1" = "d" ] then if [ "$2" = "test" ] then #echo "debug test" - cmake --build build/Debug --target Coati_test && cd bin/test && Debug/Coati_test + ninja -C build/Debug Coati_test && cd bin/test && Debug/Coati_test elif [ "$2" = "trial" ] then - cmake --build build/Debug --target Coati_trial && cd bin/app && Debug/Coati_trial + ninja -C build/Debug Coati_trial && cd bin/app && Debug/Coati_trial elif [ "$2" = "keygen" ] then #echo "debug keygen" - cmake --build build/Debug --target Coati_license_generator && cd bin/license_generator && Debug/Coati_license_generator_d + ninja -C build/Debug Coati_license_generator && cd bin/license_generator && Debug/Coati_license_generator_d else #echo "debug app" - cmake --build build/Debug --target Coati && cd bin/app && Debug/Coati + ninja -C build/Debug Coati && cd bin/app && Debug/Coati fi elif [ "$1" = "package" ] || [ "$1" = "p" ] then - cmake --target package --build build/Release Coati + ninja package -C build/Release Coati mkdir -p distr && cp build/Release/Coati*.tar.gz distr #&& cp build/Release/Coati*.deb distr echo "Packages copied into the distr folder" else diff --git a/src/app/main.cpp b/src/app/main.cpp index 7d2f2b7f..54ebe450 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -18,21 +18,7 @@ #include "version.h" #include "settings/ProjectSettings.h" -#include "utility/messaging/MessageListener.h" -#include "utility/messaging/type/MessageFinishedParsing.h" - - -class Quitter : public MessageListener -{ -public: - Quitter(QCoreApplication* app){}; - virtual ~Quitter(){}; -private: - virtual void handleMessage(MessageFinishedParsing* message) - { - QCoreApplication::exit(0); - } -}; +#include "utility/solution/SolutionParserCompilationDatabase.h" void init() { @@ -44,6 +30,8 @@ void init() fileLogger->setLogLevel(Logger::LOG_ALL); FileLogger::setFilePath(UserPaths::getLogPath()); LogManager::getInstance()->addLogger(fileLogger); + + utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf"); } int main(int argc, char *argv[]) @@ -52,52 +40,33 @@ int main(int argc, char *argv[]) Version version = Version::fromString(GIT_VERSION_NUMBER); QApplication::setApplicationVersion(version.toDisplayString().c_str()); - QCoreApplication* qtApp = new QCoreApplication(argc, argv); setup(argc, argv); - if(AppPath::getAppPath().empty()) + QtApplication qtApp(argc, argv); + + qtApp.setAttribute(Qt::AA_UseHighDpiPixmaps); + + init(); + + QtCommandLineParser commandLineParser; + commandLineParser.setup(); + commandLineParser.process(qtApp); + + QtViewFactory viewFactory; + QtNetworkFactory networkFactory; + + if(AppPath::getAppPath().empty()) { AppPath::setAppPath(QCoreApplication::applicationDirPath().toStdString()); } - init(); + LicenseChecker checker; - QtCommandLineParser commandLineParser; - commandLineParser.setup(); - commandLineParser.process(*qtApp); - commandLineParser.evaluateCommandline(); - std::shared_ptr app; + std::shared_ptr app = Application::create(version, &viewFactory, &networkFactory); - if(commandLineParser.noGUI()) - { - app = Application::create( version ); - commandLineParser.projectLoad(); + checker.setApp(app.get()); - Quitter quitter(qtApp); - return qtApp->exec(); - } - else - { - // replace the qt app with a gui qt app - // FIXME qtApp to shared_ptr - qtApp->quit(); - delete qtApp; - qtApp = new QtApplication(argc, argv); - qtApp->setAttribute(Qt::AA_UseHighDpiPixmaps); + commandLineParser.parseCommandline(); - utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf"); - - QtViewFactory viewFactory; - QtNetworkFactory networkFactory; - - LicenseChecker checker; - - app = Application::create(version, &viewFactory, &networkFactory); - - checker.setApp(app.get()); - - commandLineParser.projectLoad(); - return qtApp->exec(); - } + return qtApp.exec(); } - diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index 1c0f94e5..18b58133 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -50,20 +50,6 @@ std::shared_ptr Application::create( return ptr; } -std::shared_ptr Application::create(const Version& version) -{ - Version::setApplicationVersion(version); - loadSettings(); - - std::shared_ptr ptr(new Application()); - ptr->m_storageCache = std::make_shared(); - - ptr->m_project = Project::create(ptr->m_storageCache.get()); - ptr->startMessagingAndScheduling(); - - return ptr; -} - void Application::loadSettings() { ApplicationSettings::getInstance()->load(FilePath(UserPaths::getAppSettingsPath())); @@ -80,10 +66,7 @@ Application::~Application() { MessageQueue::getInstance()->stopMessageLoop(); TaskScheduler::getInstance()->stopSchedulerLoop(); - if(m_mainView) - { - m_mainView->saveLayout(); - } + m_mainView->saveLayout(); } void Application::loadProject(const FilePath& projectSettingsFilePath) @@ -93,20 +76,18 @@ void Application::loadProject(const FilePath& projectSettingsFilePath) loadSettings(); updateRecentProjects(projectSettingsFilePath); - m_storageCache->clear(); + m_mainView->setTitle( + "Coati - " + + projectSettingsFilePath.fileName()); + + m_storageCache->clear(); + m_componentManager->refreshViews(); m_project = Project::create(m_storageCache.get()); m_project->load(projectSettingsFilePath); - if(m_mainView) - { - m_componentManager->refreshViews(); - m_mainView->setTitle( - "Coati - " + - projectSettingsFilePath.fileName()); - m_mainView->updateRecentProjectMenu(); - m_mainView->hideStartScreen(); - } + m_mainView->updateRecentProjectMenu(); + m_mainView->hideStartScreen(); } void Application::refreshProject() @@ -114,10 +95,7 @@ void Application::refreshProject() MessageStatus("Refreshing Project").dispatch(); m_storageCache->clear(); - if(m_componentManager) - { - m_componentManager->refreshViews(); - } + m_componentManager->refreshViews(); m_project->reload(); } @@ -132,27 +110,19 @@ void Application::saveProject(const FilePath& projectSettingsFilePath) void Application::showLicenseScreen() { - if(m_mainView) - { - m_mainView->showLicenseScreen(); - } + m_mainView->showLicenseScreen(); } void Application::handleMessage(MessageActivateWindow* message) { - if(m_mainView) - { - m_mainView->activateWindow(); - } + m_mainView->activateWindow(); } void Application::handleMessage(MessageFinishedParsing* message) { m_project->logStats(); - if(m_mainView) - { - MessageRefresh().refreshUiOnly().dispatch(); - } + + MessageRefresh().refreshUiOnly().dispatch(); } void Application::handleMessage(MessageLoadProject* message) diff --git a/src/lib/Application.h b/src/lib/Application.h index 7be2bebe..9c8be457 100644 --- a/src/lib/Application.h +++ b/src/lib/Application.h @@ -28,7 +28,6 @@ class Application { public: static std::shared_ptr create(const Version& version, ViewFactory* viewFactory, NetworkFactory* networkFactory); - static std::shared_ptr create(const Version& version); static void loadSettings(); ~Application(); diff --git a/src/lib_gui/qt/commandline/QtCommandLineParser.cpp b/src/lib_gui/qt/commandline/QtCommandLineParser.cpp index 152a6d1c..376efd11 100644 --- a/src/lib_gui/qt/commandline/QtCommandLineParser.cpp +++ b/src/lib_gui/qt/commandline/QtCommandLineParser.cpp @@ -7,8 +7,6 @@ QtCommandLineParser::QtCommandLineParser() - : m_projectFileString("") - , m_noGUI(false) { } @@ -27,72 +25,45 @@ void QtCommandLineParser::setup() QCoreApplication::translate("main", "Load Coati with the a Coatiprojectfile ."), QCoreApplication::translate("main", "CoatiProject")); addOption(projectOption); - QCommandLineOption parseProjectWithoutGUIOption(QStringList() << "d" << "database", - QCoreApplication::translate("main", "Start coati to parse the Coatiprojectfile . Result *.coatidb"), - QCoreApplication::translate("main", "CoatiProject")); - addOption(parseProjectWithoutGUIOption); } -void QtCommandLineParser::evaluateCommandline() +void QtCommandLineParser::parseCommandline() { - if (isSet("database")) - { - m_noGUI = true; - processProjectfile(value("database").toStdString()); - } if(isSet("project")) { - processProjectfile(value("project").toStdString()); - } -} + QString projectfilename = value("project") ; + FilePath projectfile(projectfilename.toStdString()); + bool isValidProjectfile = true; + std::stringstream errorstring("Provided Projectfile is not valid: "); + errorstring << "Provided Projectfile('" << projectfile.fileName() << ") "; + if(!projectfile.exists()) + { + errorstring << "does not exist"; + isValidProjectfile = false; + } -void QtCommandLineParser::projectLoad() -{ - if (!m_projectFileString.empty()) - { - MessageLoadProject(m_projectFileString, false).dispatch(); - } -} + if(projectfile.extension() != ".coatiproject") + { + errorstring << "has a wrong fileending"; + isValidProjectfile = false; + } -void QtCommandLineParser::processProjectfile(const std::string& file) -{ - FilePath projectfile(file); - bool isValidProjectfile = true; - std::stringstream errorstring("Provided Projectfile is not valid: "); - errorstring << "Provided Projectfile('" << projectfile.fileName() << ") "; - if(!projectfile.exists()) - { - errorstring << "does not exist"; - isValidProjectfile = false; - } + std::shared_ptr configManager = ConfigManager::createEmpty(); + if(!configManager->load(TextAccess::createFromFile(projectfile.str()))) + { + errorstring << "could not be loaded"; + isValidProjectfile = false; + } - if(projectfile.extension() != ".coatiproject") - { - errorstring << "has a wrong fileending"; - isValidProjectfile = false; + if(isValidProjectfile) + { + MessageLoadProject(projectfile.str(), false).dispatch(); + } + else + { + MessageStatus(errorstring.str(), true).dispatch(); + LOG_ERROR(errorstring.str()); + } } - - std::shared_ptr configManager = ConfigManager::createEmpty(); - if(!configManager->load(TextAccess::createFromFile(projectfile.str()))) - { - errorstring << "could not be loaded"; - isValidProjectfile = false; - } - - if(isValidProjectfile) - { - m_projectFileString = projectfile.str(); - } - else - { - MessageStatus(errorstring.str(), true).dispatch(); - LOG_ERROR(errorstring.str()); - } -} - -bool QtCommandLineParser::noGUI() -{ - return m_noGUI; -} - +} \ No newline at end of file diff --git a/src/lib_gui/qt/commandline/QtCommandLineParser.h b/src/lib_gui/qt/commandline/QtCommandLineParser.h index 4ef12974..08cd2f5f 100644 --- a/src/lib_gui/qt/commandline/QtCommandLineParser.h +++ b/src/lib_gui/qt/commandline/QtCommandLineParser.h @@ -1,7 +1,6 @@ #ifndef QTCOMMANDLINEPARSER_H #define QTCOMMANDLINEPARSER_H -#include #include #include "Application.h" @@ -11,16 +10,10 @@ public: QtCommandLineParser(); ~QtCommandLineParser(); void setup(); - void evaluateCommandline(); - void projectLoad(); - bool noGUI(); + void parseCommandline(); private: - std::string m_projectFileString; - bool m_noGUI; - void processProjectfile(const std::string& file); }; #endif //QTCOMMANDLINEPARSER_H - diff --git a/src/lib_gui/qt/window/QtSplashScreen.cpp b/src/lib_gui/qt/window/QtSplashScreen.cpp index 1c302c9c..bfb5e1d0 100644 --- a/src/lib_gui/qt/window/QtSplashScreen.cpp +++ b/src/lib_gui/qt/window/QtSplashScreen.cpp @@ -1,6 +1,6 @@ #include "qt/window/QtSplashScreen.h" -#include +#include #include #include @@ -38,7 +38,7 @@ QtSplashScreen::~QtSplashScreen() { } -void QtSplashScreen::exec(QCoreApplication& app) +void QtSplashScreen::exec(QApplication& app) { m_state = 0; QTimer* timer = new QTimer(this); diff --git a/src/lib_gui/qt/window/QtSplashScreen.h b/src/lib_gui/qt/window/QtSplashScreen.h index d813507d..7748ed7a 100644 --- a/src/lib_gui/qt/window/QtSplashScreen.h +++ b/src/lib_gui/qt/window/QtSplashScreen.h @@ -5,7 +5,7 @@ #include #include -class QCoreApplication; +class QApplication; class QPixmap; class QtSplashScreen @@ -17,7 +17,7 @@ public: QtSplashScreen(const QPixmap& pixmap, Qt::WindowFlags f = 0); virtual ~QtSplashScreen(); - void exec(QCoreApplication& app); + void exec(QApplication& app); void setMessage(const QString& str); void setVersion(const QString& str);