utility: Headless Coati
switch from qt to boost commandlineoptions coati can now parse a coatiproject without gui with commandline flag -d show all commandline options with flag --hidden
This commit is contained in:
+25
-11
@@ -98,48 +98,52 @@ execute_process(
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
# Add shared files to full and trial version
|
||||
AddSharedToComponent(FULLVERSION)
|
||||
AddSharedToComponent(TRIALVERSION)
|
||||
AddSharedToComponent(FULL)
|
||||
AddSharedToComponent(TRIAL)
|
||||
|
||||
INSTALL(DIRECTORY
|
||||
${CMAKE_SOURCE_DIR}/ide_plugins/sublime_text
|
||||
DESTINATION plugin
|
||||
COMPONENT FULLVERSION
|
||||
COMPONENT FULL
|
||||
)
|
||||
|
||||
INSTALL(FILES
|
||||
${CMAKE_SOURCE_DIR}/setup/Linux/coati.desktop
|
||||
${CMAKE_SOURCE_DIR}/setup/Linux/application-x-coati.xml
|
||||
${CMAKE_SOURCE_DIR}/setup/Linux/coati-mime.xml
|
||||
DESTINATION setup
|
||||
COMPONENT FULLVERSION
|
||||
COMPONENT FULL
|
||||
)
|
||||
|
||||
INSTALL(PROGRAMS
|
||||
${CMAKE_SOURCE_DIR}/setup/Linux/install.sh
|
||||
${CMAKE_SOURCE_DIR}/setup/Linux/deinstall.sh
|
||||
${CMAKE_SOURCE_DIR}/setup/Linux/removeConfigs.sh
|
||||
DESTINATION setup
|
||||
COMPONENT FULL
|
||||
)
|
||||
|
||||
INSTALL(PROGRAMS
|
||||
${CMAKE_SOURCE_DIR}/setup/Linux/Coati_trial.sh
|
||||
DESTINATION .
|
||||
COMPONENT TRIALVERSION
|
||||
COMPONENT TRIAL
|
||||
)
|
||||
|
||||
INSTALL(PROGRAMS
|
||||
${CMAKE_SOURCE_DIR}/setup/Linux/Coati.sh
|
||||
DESTINATION .
|
||||
COMPONENT FULLVERSION
|
||||
COMPONENT FULL
|
||||
)
|
||||
|
||||
INSTALL(PROGRAMS
|
||||
${CMAKE_SOURCE_DIR}/bin/app/Release/Coati_upx
|
||||
DESTINATION .
|
||||
COMPONENT FULLVERSION
|
||||
COMPONENT FULL
|
||||
RENAME Coati
|
||||
)
|
||||
|
||||
INSTALL(PROGRAMS
|
||||
${CMAKE_SOURCE_DIR}/bin/app/Release/Coati_trial_upx
|
||||
DESTINATION .
|
||||
COMPONENT TRIALVERSION
|
||||
COMPONENT TRIAL
|
||||
RENAME Coati_trial
|
||||
)
|
||||
|
||||
@@ -150,7 +154,15 @@ SET(CPACK_ARCHIVE_COMPONENT_INSTALL "ON")
|
||||
string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_VERSION_NUMBER}")
|
||||
string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_VERSION_NUMBER}")
|
||||
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_VERSION_NUMBER}")
|
||||
set(VERSION_NUMBER "${VERSION_MAJOR}_${VERSION_MINOR}_${VERSION_PATCH}")
|
||||
if(${GIT_VERSION_NUMBER} STREQUAL ${VERSION_PATCH})
|
||||
SET(VERSIONA_PATCH 0)
|
||||
endif()
|
||||
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_VERSION_NUMBER}")
|
||||
if(${GIT_VERSION_NUMBER} STREQUAL ${VERSION_COMMIT})
|
||||
set(VERSION_NUMBER "${VERSION_MAJOR}_${VERSION_MINOR}_${VERSION_PATCH}")
|
||||
else()
|
||||
set(VERSION_NUMBER "${VERSION_MAJOR}_${VERSION_MINOR}_${VERSION_PATCH}_${VERSION_COMMIT}")
|
||||
endif()
|
||||
|
||||
SET(CPACK_PACKAGE_NAME "Coati")
|
||||
SET(CPACK_PACKAGING_INSTALL_PREFIX "")
|
||||
@@ -159,8 +171,10 @@ SET(CPACK_PACKAGE_VERSION ${VERSION_NUMBER})
|
||||
SET(CPACK_PACKAGE_VENDOR "Coati Software")
|
||||
SET(CPACK_INSTALL_SCRIPT "${CMAKE_SOURCE_DIR}/cmake/pre_install_linux.cmake")
|
||||
SET(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}")
|
||||
SET(CPACK_PACKAGE_FILE_NAME "Coati_${VERSION_NUMBER}_${CPACK_SYSTEM_NAME}")
|
||||
#SET(CPACK_PACKAGE_EXECUTABLES "Coati")
|
||||
SET(CPACK_STRIP_FILES "coati/Coati")
|
||||
SET(CPACK_PACKAGE_CONTACT "astallinger@coati.io")
|
||||
|
||||
INCLUDE(CPack)
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ done
|
||||
COATI_PATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
#setup data folder
|
||||
echo $COATI_PATH
|
||||
if [ ! -d "${HOME}/.config/coati" ]; then
|
||||
# Control will enter here if $DIRECTORY doesn't exist.
|
||||
mkdir ${HOME}/.config/coati
|
||||
@@ -21,4 +20,4 @@ fi
|
||||
export LD_LIBRARY_PATH="$COATI_PATH/lib:LD_LIBRARY_PATH"
|
||||
export QT_XKB_CONFIG_ROOT="/usr/share/X11/xkb:$QT_XKB_CONFIG_ROOT"
|
||||
export QT_QPA_FONTDIR="$COATI_PATH/data/fonts:$QT_QPA_FONTDIR"
|
||||
exec $COATI_PATH/Coati
|
||||
exec $COATI_PATH/Coati $@
|
||||
|
||||
@@ -10,9 +10,10 @@ case ${ans:=y} in [yY]*) ;; *) exit ;; esac
|
||||
echo "Run this script as root"
|
||||
|
||||
rm /usr/bin/Coati
|
||||
rm /usr/share/mime/packages/application-x-coatiproject
|
||||
rm /usr/share/mime/packages/coati-mime.xml
|
||||
rm /usr/share/applications/coati.desktop
|
||||
rm /usr/share/icons/coati.png
|
||||
rm /usr/share/icons/project-coati.png
|
||||
rm /opt/coati -rf
|
||||
update-mime/database /usr/share/mime
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
MY_PATH=`dirname "$0"`
|
||||
MY_PATH=../$MY_PATH
|
||||
|
||||
cat EULA.txt
|
||||
cat ../EULA.txt
|
||||
echo "Agree to the EULA"
|
||||
printf 'enter [y/n] '
|
||||
read ans
|
||||
@@ -10,10 +10,12 @@ case ${ans:=y} in [yY]*) ;; *) exit ;; esac
|
||||
|
||||
echo "Run this script as root"
|
||||
|
||||
ln -s $MY_PATH/Coati.sh /usr/bin/Coati
|
||||
cp $MY_PATH/setup/application-x-coatiproject /usr/share/mime/packages
|
||||
cp $MY_PATH/setup/coati.desktop /usr/share/applications/
|
||||
cp $MY_PATH/data/gui/icon/logo_1024_1024.png /usr/share/icon/coati.png
|
||||
cp $MY_PATH/data/gui/icon/project_256_256.png /usr/share/icons/project-coati.png
|
||||
update-mime-database /usr/share/mime
|
||||
cp -rf $MY_PATH/ /opt/coati/ > /dev/null
|
||||
cp $MY_PATH/setup/coati-mime.xml /usr/share/mime/packages > /dev/null
|
||||
cp $MY_PATH/setup/coati.desktop /usr/share/applications/ > /dev/null
|
||||
cp $MY_PATH/data/gui/icon/logo_1024_1024.png /usr/share/icons/coati.png > /dev/null
|
||||
cp $MY_PATH/data/gui/icon/project_256_256.png /usr/share/icons/project-coati.png > /dev/null
|
||||
update-mime-database /usr/share/mime > /dev/null
|
||||
|
||||
ln -s /opt/coati/coati.sh /usr/bin/coati > /dev/null
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@ add_files(
|
||||
|
||||
data/parser/cxx/TaskParseCxx.cpp
|
||||
|
||||
utility/commandline/CommandLineParser.cpp
|
||||
utility/commandline/CommandLineParser.h
|
||||
|
||||
isTrial.cpp
|
||||
LicenseChecker.h
|
||||
main.cpp
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "utility/messaging/type/MessageProjectNew.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "License.h"
|
||||
#include "PublicKey.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
+46
-18
@@ -1,4 +1,5 @@
|
||||
#include "utility/AppPath.h"
|
||||
#include "utility/commandline/CommandLineParser.h"
|
||||
#include "utility/logging/ConsoleLogger.h"
|
||||
#include "utility/logging/FileLogger.h"
|
||||
#include "utility/logging/LogManager.h"
|
||||
@@ -9,9 +10,9 @@
|
||||
#include "Application.h"
|
||||
#include "includes.h" // defines 'void setup(int argc, char *argv[])'
|
||||
#include "LicenseChecker.h"
|
||||
#include "qt/commandline/QtCommandLineParser.h"
|
||||
#include "qt/network/QtNetworkFactory.h"
|
||||
#include "qt/QtApplication.h"
|
||||
#include "qt/QtCoreApplication.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/view/QtViewFactory.h"
|
||||
#include "qt/window/QtMainWindow.h"
|
||||
@@ -30,8 +31,17 @@ void init()
|
||||
fileLogger->setLogLevel(Logger::LOG_ALL);
|
||||
FileLogger::setFilePath(UserPaths::getLogPath());
|
||||
LogManager::getInstance()->addLogger(fileLogger);
|
||||
}
|
||||
|
||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
||||
void prepare(int argc, char *argv[])
|
||||
{
|
||||
if (AppPath::getAppPath().empty())
|
||||
{
|
||||
AppPath::setAppPath(QCoreApplication::applicationDirPath().toStdString() + "/");
|
||||
}
|
||||
setup(argc, argv);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -41,31 +51,49 @@ int main(int argc, char *argv[])
|
||||
Version version = Version::fromString(GIT_VERSION_NUMBER);
|
||||
QApplication::setApplicationVersion(version.toDisplayString().c_str());
|
||||
|
||||
QtApplication qtApp(argc, argv);
|
||||
if(AppPath::getAppPath().empty())
|
||||
CommandLineParser commandLineParser(argc, argv, version.toString());
|
||||
if (commandLineParser.exitApplication())
|
||||
{
|
||||
AppPath::setAppPath(QCoreApplication::applicationDirPath().toStdString());
|
||||
return 0;
|
||||
}
|
||||
setup(argc, argv);
|
||||
|
||||
qtApp.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
if (commandLineParser.runWithoutGUI())
|
||||
{
|
||||
// headless Coati
|
||||
QtCoreApplication qtApp(argc, argv);
|
||||
prepare(argc,argv);
|
||||
|
||||
init();
|
||||
std::shared_ptr<Application> app = Application::create( version );
|
||||
|
||||
QtCommandLineParser commandLineParser;
|
||||
commandLineParser.setup();
|
||||
commandLineParser.process(qtApp);
|
||||
if (commandLineParser.startedWithLicense())
|
||||
{
|
||||
qtApp.saveLicense(commandLineParser.getLicense());
|
||||
return 0;
|
||||
}
|
||||
|
||||
QtViewFactory viewFactory;
|
||||
QtNetworkFactory networkFactory;
|
||||
commandLineParser.projectLoad();
|
||||
|
||||
LicenseChecker checker;
|
||||
return qtApp.exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
QtApplication qtApp(argc, argv);
|
||||
prepare(argc,argv);
|
||||
qtApp.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
||||
std::shared_ptr<Application> app = Application::create(version, &viewFactory, &networkFactory);
|
||||
QtViewFactory viewFactory;
|
||||
QtNetworkFactory networkFactory;
|
||||
|
||||
checker.setApp(app.get());
|
||||
LicenseChecker checker;
|
||||
|
||||
commandLineParser.parseCommandline();
|
||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
||||
std::shared_ptr<Application> app = Application::create(version, &viewFactory, &networkFactory);
|
||||
|
||||
return qtApp.exec();
|
||||
checker.setApp(app.get());
|
||||
|
||||
commandLineParser.projectLoad();
|
||||
|
||||
return qtApp.exec();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
#include "utility/commandline/CommandLineParser.h"
|
||||
|
||||
#include "boost/program_options.hpp"
|
||||
|
||||
#include "License.h"
|
||||
#include "PublicKey.h"
|
||||
#include "utility/ConfigManager.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
|
||||
namespace po = boost::program_options;
|
||||
|
||||
CommandLineParser::CommandLineParser(int argc, char** argv, const std::string& version)
|
||||
: m_withoutGUI(false)
|
||||
, m_quit(false)
|
||||
, m_withLicense(false)
|
||||
, m_force(false)
|
||||
{
|
||||
std::string projectfile;
|
||||
std::string projectfile_db;
|
||||
std::string licensefile;
|
||||
std::string licensetext;
|
||||
po::options_description desc("Coati");
|
||||
desc.add_options()
|
||||
("help,h", "Print this help message")
|
||||
("version,v", "Version of Coati")
|
||||
("project,p", "Load Coati with a Coatiprojectfile")
|
||||
;
|
||||
po::positional_options_description positionalOption;
|
||||
positionalOption.add("project-file", 1);
|
||||
|
||||
po::options_description hidden_desc("hidden commandlineflags");
|
||||
hidden_desc.add_options()
|
||||
("force,f", "Force coati to parse if database exists")
|
||||
("licenseFile,z", po::value<std::string>(&licensefile), "Enter license via Licensefile")
|
||||
("license,l", po::value<std::string>(&licensetext), "Enter licenes via commandline")
|
||||
("hidden", "Print this help message with hidden arguments")
|
||||
("database,d", "Start coati to parse a Coati projectfile to get a coatidatabase")
|
||||
("project-file", po::value<std::string>(&projectfile), "Coati project file");
|
||||
;
|
||||
po::options_description all("Allowed options");
|
||||
all.add(desc).add(hidden_desc);
|
||||
|
||||
po::variables_map vm;
|
||||
po::store(po::command_line_parser(argc,argv).options(all).positional(positionalOption).run(), vm);
|
||||
po::notify(vm);
|
||||
|
||||
if (vm.count("help"))
|
||||
{
|
||||
std::cout << desc << std::endl;
|
||||
m_quit = true;
|
||||
}
|
||||
|
||||
if (vm.count("hidden"))
|
||||
{
|
||||
std::cout << all << std::endl;
|
||||
m_quit = true;
|
||||
}
|
||||
|
||||
if (vm.count("force"))
|
||||
{
|
||||
m_force = true;
|
||||
}
|
||||
|
||||
if (vm.count("license"))
|
||||
{
|
||||
processLicense(m_license.loadFromString(licensetext));
|
||||
}
|
||||
|
||||
if (vm.count("licenseFile"))
|
||||
{
|
||||
std::cout << "licensefile flag" << std::endl;
|
||||
if (FileSystem::exists(licensefile))
|
||||
{
|
||||
std::cout << "licensefile exists" << std::endl;
|
||||
processLicense(m_license.loadFromFile(licensefile));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << licensefile << " not found" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (vm.count("version"))
|
||||
{
|
||||
std::cout << "Coati Version " << version << std::endl;
|
||||
m_quit = true;
|
||||
}
|
||||
|
||||
if (vm.count("project-file"))
|
||||
{
|
||||
processProjectfile(projectfile);
|
||||
if (vm.count("database"))
|
||||
{
|
||||
m_withoutGUI = true;
|
||||
}
|
||||
}
|
||||
else if (vm.count("database") || vm.count("project") ) {
|
||||
std::cout << "A project file is needed for this option" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineParser::processLicense(const bool isLoaded)
|
||||
{
|
||||
if (!isLoaded)
|
||||
{
|
||||
std::cout << "Could not load License" << std::endl;
|
||||
}
|
||||
m_license.loadPublicKeyFromString(PublicKey);
|
||||
if (!m_license.isValid())
|
||||
{
|
||||
std::cout << "License is not valid" << std::endl;
|
||||
}
|
||||
m_withLicense = true;
|
||||
m_withoutGUI = true;
|
||||
}
|
||||
|
||||
CommandLineParser::~CommandLineParser()
|
||||
{
|
||||
}
|
||||
|
||||
bool CommandLineParser::runWithoutGUI()
|
||||
{
|
||||
return m_withoutGUI;
|
||||
}
|
||||
|
||||
bool CommandLineParser::exitApplication()
|
||||
{
|
||||
return m_quit;
|
||||
}
|
||||
|
||||
bool CommandLineParser::startedWithLicense()
|
||||
{
|
||||
return m_withLicense;
|
||||
}
|
||||
|
||||
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() + ") ";
|
||||
if (!projectfile.exists())
|
||||
{
|
||||
errorstring += errorProjectfile + " does not exist\n";
|
||||
isValidProjectfile = false;
|
||||
}
|
||||
|
||||
if (projectfile.extension() != ".coatiproject")
|
||||
{
|
||||
errorstring += errorProjectfile + " has a wrong fileending\n";
|
||||
isValidProjectfile = false;
|
||||
}
|
||||
|
||||
std::shared_ptr<ConfigManager> configManager = ConfigManager::createEmpty();
|
||||
if (!configManager->load(TextAccess::createFromFile(projectfile.str())))
|
||||
{
|
||||
errorstring += errorProjectfile + " could not be loaded\n";
|
||||
isValidProjectfile = false;
|
||||
}
|
||||
|
||||
if (isValidProjectfile)
|
||||
{
|
||||
m_projectFile = projectfile.absolute().str();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << errorstring << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineParser::projectLoad()
|
||||
{
|
||||
if (!m_projectFile.empty())
|
||||
{
|
||||
MessageLoadProject(m_projectFile, m_force).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
License CommandLineParser::getLicense()
|
||||
{
|
||||
return m_license;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef COMMANDLINEPARSER_H
|
||||
#define COMMANDLINEPARSER_H
|
||||
|
||||
#include <string>
|
||||
#include "Application.h"
|
||||
#include "License.h"
|
||||
|
||||
class CommandLineParser
|
||||
{
|
||||
public:
|
||||
CommandLineParser(int argc, char** argv, const std::string& version);
|
||||
~CommandLineParser();
|
||||
|
||||
bool runWithoutGUI();
|
||||
bool exitApplication();
|
||||
void projectLoad();
|
||||
bool startedWithLicense();
|
||||
License getLicense();
|
||||
private:
|
||||
void processProjectfile(const std::string& file);
|
||||
void processLicense(const bool isLoaded);
|
||||
std::string m_projectFile;
|
||||
bool m_withoutGUI;
|
||||
bool m_quit;
|
||||
bool m_force;
|
||||
bool m_withLicense;
|
||||
License m_license;
|
||||
};
|
||||
|
||||
#endif //COMMANDLINEPARSER_H
|
||||
+70
-29
@@ -50,15 +50,31 @@ std::shared_ptr<Application> Application::create(
|
||||
return ptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<Application> Application::create(const Version& version)
|
||||
{
|
||||
Version::setApplicationVersion(version);
|
||||
loadSettings();
|
||||
|
||||
std::shared_ptr<Application> ptr(new Application(false));
|
||||
|
||||
ptr->m_storageCache = std::make_shared<StorageCache>();
|
||||
ptr->m_project = Project::create(ptr->m_storageCache.get());
|
||||
|
||||
ptr->startMessagingAndScheduling();
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void Application::loadSettings()
|
||||
{
|
||||
ApplicationSettings::getInstance()->load(FilePath(UserPaths::getAppSettingsPath()));
|
||||
ColorScheme::getInstance()->load(ApplicationSettings::getInstance()->getColorSchemePath());
|
||||
|
||||
ColorScheme::getInstance()->load(ApplicationSettings::getInstance()->getColorSchemePath());
|
||||
GraphViewStyle::loadStyleSettings();
|
||||
}
|
||||
|
||||
Application::Application()
|
||||
Application::Application(bool withGUI)
|
||||
: m_hasGUI(withGUI)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -66,7 +82,15 @@ Application::~Application()
|
||||
{
|
||||
MessageQueue::getInstance()->stopMessageLoop();
|
||||
TaskScheduler::getInstance()->stopSchedulerLoop();
|
||||
m_mainView->saveLayout();
|
||||
if (m_hasGUI)
|
||||
{
|
||||
m_mainView->saveLayout();
|
||||
}
|
||||
}
|
||||
|
||||
bool Application::hasGUI()
|
||||
{
|
||||
return m_hasGUI;
|
||||
}
|
||||
|
||||
void Application::loadProject(const FilePath& projectSettingsFilePath)
|
||||
@@ -76,18 +100,21 @@ void Application::loadProject(const FilePath& projectSettingsFilePath)
|
||||
loadSettings();
|
||||
updateRecentProjects(projectSettingsFilePath);
|
||||
|
||||
m_mainView->setTitle(
|
||||
"Coati - " +
|
||||
projectSettingsFilePath.fileName());
|
||||
|
||||
m_storageCache->clear();
|
||||
m_componentManager->refreshViews();
|
||||
|
||||
m_project = Project::create(m_storageCache.get());
|
||||
m_project->load(projectSettingsFilePath);
|
||||
|
||||
m_mainView->updateRecentProjectMenu();
|
||||
m_mainView->hideStartScreen();
|
||||
if (m_hasGUI)
|
||||
{
|
||||
m_mainView->setTitle(
|
||||
"Coati - " +
|
||||
projectSettingsFilePath.fileName());
|
||||
|
||||
m_mainView->updateRecentProjectMenu();
|
||||
m_mainView->hideStartScreen();
|
||||
m_componentManager->refreshViews();
|
||||
}
|
||||
}
|
||||
|
||||
void Application::refreshProject()
|
||||
@@ -95,7 +122,10 @@ void Application::refreshProject()
|
||||
MessageStatus("Refreshing Project").dispatch();
|
||||
|
||||
m_storageCache->clear();
|
||||
m_componentManager->refreshViews();
|
||||
if (m_hasGUI)
|
||||
{
|
||||
m_componentManager->refreshViews();
|
||||
}
|
||||
|
||||
m_project->reload();
|
||||
}
|
||||
@@ -110,19 +140,27 @@ void Application::saveProject(const FilePath& projectSettingsFilePath)
|
||||
|
||||
void Application::showLicenseScreen()
|
||||
{
|
||||
m_mainView->showLicenseScreen();
|
||||
if (m_hasGUI)
|
||||
{
|
||||
m_mainView->showLicenseScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void Application::handleMessage(MessageActivateWindow* message)
|
||||
{
|
||||
m_mainView->activateWindow();
|
||||
if (m_hasGUI)
|
||||
{
|
||||
m_mainView->activateWindow();
|
||||
}
|
||||
}
|
||||
|
||||
void Application::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
m_project->logStats();
|
||||
|
||||
MessageRefresh().refreshUiOnly().dispatch();
|
||||
if (m_hasGUI)
|
||||
{
|
||||
MessageRefresh().refreshUiOnly().dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
void Application::handleMessage(MessageLoadProject* message)
|
||||
@@ -180,23 +218,26 @@ void Application::startMessagingAndScheduling()
|
||||
|
||||
void Application::updateRecentProjects(const FilePath& projectSettingsFilePath)
|
||||
{
|
||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||
std::vector<FilePath> recentProjects = appSettings->getRecentProjects();
|
||||
if (recentProjects.size())
|
||||
if (m_hasGUI)
|
||||
{
|
||||
std::vector<FilePath>::iterator it = std::find(recentProjects.begin(), recentProjects.end(), projectSettingsFilePath);
|
||||
if (it != recentProjects.end())
|
||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||
std::vector<FilePath> recentProjects = appSettings->getRecentProjects();
|
||||
if (recentProjects.size())
|
||||
{
|
||||
recentProjects.erase(it);
|
||||
std::vector<FilePath>::iterator it = std::find(recentProjects.begin(), recentProjects.end(), projectSettingsFilePath);
|
||||
if (it != recentProjects.end())
|
||||
{
|
||||
recentProjects.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recentProjects.insert(recentProjects.begin(), projectSettingsFilePath);
|
||||
if (recentProjects.size() > 7)
|
||||
{
|
||||
recentProjects.pop_back();
|
||||
}
|
||||
recentProjects.insert(recentProjects.begin(), projectSettingsFilePath);
|
||||
if (recentProjects.size() > 7)
|
||||
{
|
||||
recentProjects.pop_back();
|
||||
}
|
||||
|
||||
appSettings->setRecentProjects(recentProjects);
|
||||
appSettings->save(UserPaths::getAppSettingsPath());
|
||||
appSettings->setRecentProjects(recentProjects);
|
||||
appSettings->save(UserPaths::getAppSettingsPath());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ class Application
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<Application> create(const Version& version, ViewFactory* viewFactory, NetworkFactory* networkFactory);
|
||||
static std::shared_ptr<Application> create(const Version& version);
|
||||
static void loadSettings();
|
||||
|
||||
~Application();
|
||||
@@ -36,9 +37,10 @@ public:
|
||||
void refreshProject();
|
||||
void saveProject(const FilePath& projectSettingsFilePath);
|
||||
void showLicenseScreen();
|
||||
bool hasGUI();
|
||||
|
||||
private:
|
||||
Application();
|
||||
Application(bool withGUI=true);
|
||||
|
||||
virtual void handleMessage(MessageActivateWindow* message);
|
||||
virtual void handleMessage(MessageFinishedParsing* message);
|
||||
@@ -50,6 +52,7 @@ private:
|
||||
|
||||
void updateRecentProjects(const FilePath& projectSettingsFilePath);
|
||||
|
||||
bool m_hasGUI;
|
||||
std::shared_ptr<Project> m_project;
|
||||
std::shared_ptr<StorageCache> m_storageCache;
|
||||
|
||||
|
||||
@@ -2,21 +2,17 @@
|
||||
|
||||
#include "AppPath.h"
|
||||
|
||||
std::string ResourcePaths::m_colorSchemesPath = AppPath::getAppPath() + "data/color_schemes/";
|
||||
std::string ResourcePaths::m_fontsPath = AppPath::getAppPath() + "data/fonts/";
|
||||
std::string ResourcePaths::m_guiPath = AppPath::getAppPath() + "data/gui/";
|
||||
|
||||
std::string ResourcePaths::getColorSchemesPath()
|
||||
{
|
||||
return m_colorSchemesPath;
|
||||
return AppPath::getAppPath() + "data/color_schemes/";
|
||||
}
|
||||
|
||||
std::string ResourcePaths::getFontsPath()
|
||||
{
|
||||
return m_fontsPath;
|
||||
return AppPath::getAppPath() + "data/fonts/";
|
||||
}
|
||||
|
||||
std::string ResourcePaths::getGuiPath()
|
||||
{
|
||||
return m_guiPath;
|
||||
}
|
||||
return AppPath::getAppPath() + "data/gui/";
|
||||
}
|
||||
|
||||
@@ -9,11 +9,6 @@ public:
|
||||
static std::string getColorSchemesPath();
|
||||
static std::string getFontsPath();
|
||||
static std::string getGuiPath();
|
||||
|
||||
private:
|
||||
static std::string m_colorSchemesPath;
|
||||
static std::string m_fontsPath;
|
||||
static std::string m_guiPath;
|
||||
};
|
||||
|
||||
#endif // RESOURCE_PATHS_H
|
||||
#endif // RESOURCE_PATHS_H
|
||||
|
||||
@@ -6,9 +6,6 @@ add_files(
|
||||
platform_includes/includesMac.h
|
||||
platform_includes/includesWindows.h
|
||||
|
||||
qt/commandline/QtCommandLineParser.cpp
|
||||
qt/commandline/QtCommandLineParser.h
|
||||
|
||||
qt/element/QtAutocompletionList.cpp
|
||||
qt/element/QtAutocompletionList.h
|
||||
qt/element/QtCodeArea.cpp
|
||||
@@ -148,4 +145,6 @@ add_files(
|
||||
|
||||
qt/QtApplication.cpp
|
||||
qt/QtApplication.h
|
||||
qt/QtCoreApplication.cpp
|
||||
qt/QtCoreApplication.h
|
||||
)
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "qt/QtCoreApplication.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/AppPath.h"
|
||||
#include "utility/UserPaths.h"
|
||||
#include "License.h"
|
||||
|
||||
QtCoreApplication::QtCoreApplication(int argc, char **argv )
|
||||
: QCoreApplication(argc, argv)
|
||||
{
|
||||
}
|
||||
|
||||
QtCoreApplication::~QtCoreApplication()
|
||||
{
|
||||
}
|
||||
|
||||
void QtCoreApplication::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
std::cout << "Finished parsing" << std::endl;
|
||||
LOG_INFO("Finished parsing");
|
||||
this->quit();
|
||||
}
|
||||
|
||||
bool QtCoreApplication::saveLicense(License license)
|
||||
{
|
||||
if (license.isValid())
|
||||
{
|
||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||
std::string appLocation = AppPath::getAppPath();
|
||||
appSettings->setLicenseString(license.getLicenseEncodedString(appLocation));
|
||||
FilePath p(appLocation);
|
||||
appSettings->setLicenseCheck(license.hashLocation(p.absolute().str()));
|
||||
appSettings->save(UserPaths::getAppSettingsPath());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR( "The entered license key is invalid.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef QT_COREAPPLICTION_H
|
||||
#define QT_COREAPPLICTION_H
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
|
||||
class License;
|
||||
|
||||
class QtCoreApplication
|
||||
: public QCoreApplication
|
||||
, public MessageListener<MessageFinishedParsing>
|
||||
{
|
||||
public:
|
||||
QtCoreApplication(int argc, char **argv);
|
||||
virtual ~QtCoreApplication();
|
||||
bool saveLicense(License license);
|
||||
signals:
|
||||
void quitSignal();
|
||||
private:
|
||||
virtual void handleMessage(MessageFinishedParsing* message);
|
||||
};
|
||||
|
||||
|
||||
#endif // QT_COREAPPLICATION
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
#include "qt/commandline/QtCommandLineParser.h"
|
||||
|
||||
#include "utility/ConfigManager.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
|
||||
|
||||
QtCommandLineParser::QtCommandLineParser()
|
||||
{
|
||||
}
|
||||
|
||||
QtCommandLineParser::~QtCommandLineParser()
|
||||
{
|
||||
}
|
||||
|
||||
void QtCommandLineParser::setup()
|
||||
{
|
||||
|
||||
setApplicationDescription("Coati helper");
|
||||
addVersionOption();
|
||||
addHelpOption();
|
||||
|
||||
QCommandLineOption projectOption(QStringList() << "p" << "project",
|
||||
QCoreApplication::translate("main", "Load Coati with the a Coatiprojectfile <CoatiProject>."),
|
||||
QCoreApplication::translate("main", "CoatiProject"));
|
||||
addOption(projectOption);
|
||||
}
|
||||
|
||||
void QtCommandLineParser::parseCommandline()
|
||||
{
|
||||
|
||||
if(isSet("project"))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
if(projectfile.extension() != ".coatiproject")
|
||||
{
|
||||
errorstring << "has a wrong fileending";
|
||||
isValidProjectfile = false;
|
||||
}
|
||||
|
||||
std::shared_ptr<ConfigManager> configManager = ConfigManager::createEmpty();
|
||||
if(!configManager->load(TextAccess::createFromFile(projectfile.str())))
|
||||
{
|
||||
errorstring << "could not be loaded";
|
||||
isValidProjectfile = false;
|
||||
}
|
||||
|
||||
if(isValidProjectfile)
|
||||
{
|
||||
MessageLoadProject(projectfile.str(), false).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageStatus(errorstring.str(), true).dispatch();
|
||||
LOG_ERROR(errorstring.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
#ifndef QTCOMMANDLINEPARSER_H
|
||||
#define QTCOMMANDLINEPARSER_H
|
||||
|
||||
#include <QCommandLineParser>
|
||||
#include "Application.h"
|
||||
|
||||
class QtCommandLineParser : public QCommandLineParser
|
||||
{
|
||||
public:
|
||||
QtCommandLineParser();
|
||||
~QtCommandLineParser();
|
||||
void setup();
|
||||
void parseCommandline();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif //QTCOMMANDLINEPARSER_H
|
||||
Reference in New Issue
Block a user