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:
Andreas Stallinger
2016-03-07 16:38:53 +01:00
parent b761db9b22
commit fec17e452d
19 changed files with 455 additions and 174 deletions
+70 -29
View File
@@ -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());
}
}
+4 -1
View File
@@ -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;
+4 -8
View File
@@ -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/";
}
+1 -6
View File
@@ -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