ui: added ApplicationSettingsScreen

* opens on first start autmatically
* open from the menu under Preferences
* show version number on splash screen
* added recent projects markup to app settings template
* moved all qt window classes to qt/window
* put common form stuff from project setup and app settings into QtSettingsWindow
This commit is contained in:
Eberhard Graether
2015-09-04 14:38:30 +02:00
parent 5ab627b735
commit 1ba802dd9b
25 changed files with 450 additions and 196 deletions
+8 -6
View File
@@ -27,6 +27,8 @@ std::shared_ptr<Application> Application::create(ViewFactory* viewFactory)
ptr->m_componentManager->setup(ptr->m_mainView.get());
ptr->m_mainView->loadLayout();
ptr->m_project = Project::create(ptr->m_storageCache.get());
return ptr;
}
@@ -53,9 +55,9 @@ Application::~Application()
m_mainView->saveLayout();
}
void Application::loadProject(const std::string& projectSettingsFilePath)
void Application::loadProject(const FilePath& projectSettingsFilePath)
{
MessageStatus("Loading Project: " + projectSettingsFilePath).dispatch();
MessageStatus("Loading Project: " + projectSettingsFilePath.str()).dispatch();
m_storageCache->clear();
m_componentManager->refreshViews();
@@ -78,7 +80,7 @@ void Application::reloadProject()
m_project->parseCode();
}
void Application::saveProject(const std::string& projectSettingsFilePath)
void Application::saveProject(const FilePath& projectSettingsFilePath)
{
if (!m_project->saveProjectSettings(projectSettingsFilePath))
{
@@ -140,13 +142,13 @@ void Application::handleMessage(MessageSaveProject* message)
saveProject(message->projectSettingsFilePath);
}
void Application::updateRecentProjects(const std::string& projectSettingsFilePath)
void Application::updateRecentProjects(const FilePath& projectSettingsFilePath)
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
std::vector<std::string> recentProjects = appSettings->getRecentProjects();
std::vector<FilePath> recentProjects = appSettings->getRecentProjects();
if (recentProjects.size())
{
std::vector<std::string>::iterator it = std::find(recentProjects.begin(), recentProjects.end(), projectSettingsFilePath);
std::vector<FilePath>::iterator it = std::find(recentProjects.begin(), recentProjects.end(), projectSettingsFilePath);
if (it != recentProjects.end())
{
recentProjects.erase(it);
+3 -4
View File
@@ -27,10 +27,9 @@ public:
~Application();
void loadProject(const std::string& projectSettingsFilePath);
void loadSource(const std::string& sourceDirectoryPath);
void saveProject(const std::string& projectSettingsFilePath);
void loadProject(const FilePath& projectSettingsFilePath);
void reloadProject();
void saveProject(const FilePath& projectSettingsFilePath);
private:
Application();
@@ -40,7 +39,7 @@ private:
virtual void handleMessage(MessageRefresh* message);
virtual void handleMessage(MessageSaveProject* message);
void updateRecentProjects(const std::string& projectSettingsFilePath);
void updateRecentProjects(const FilePath& projectSettingsFilePath);
std::shared_ptr<Project> m_project;
std::shared_ptr<StorageCache> m_storageCache;
+12 -7
View File
@@ -21,7 +21,7 @@ Project::~Project()
{
}
bool Project::loadProjectSettings(const std::string& projectSettingsFile)
bool Project::loadProjectSettings(const FilePath& projectSettingsFile)
{
bool success = ProjectSettings::getInstance()->load(projectSettingsFile);
if (success)
@@ -34,28 +34,28 @@ bool Project::loadProjectSettings(const std::string& projectSettingsFile)
return success;
}
bool Project::saveProjectSettings(const std::string& projectSettingsFile)
bool Project::saveProjectSettings(const FilePath& projectSettingsFile)
{
if (projectSettingsFile.size())
if (!projectSettingsFile.empty())
{
m_projectSettingsFilepath = projectSettingsFile;
}
if (!m_projectSettingsFilepath.size())
if (m_projectSettingsFilepath.empty())
{
return false;
}
ProjectSettings::getInstance()->save(m_projectSettingsFilepath);
LOG_INFO_STREAM(<< "ProjectSettings saved to file: " << m_projectSettingsFilepath);
LOG_INFO_STREAM(<< "ProjectSettings saved to file: " << m_projectSettingsFilepath.str());
return true;
}
void Project::clearProjectSettings()
{
m_projectSettingsFilepath.clear();
m_projectSettingsFilepath = FilePath();
ProjectSettings::getInstance()->clear();
m_fileManager.reset();
@@ -63,7 +63,7 @@ void Project::clearProjectSettings()
void Project::reloadProjectSettings()
{
if (m_projectSettingsFilepath.size())
if (!m_projectSettingsFilepath.empty())
{
ProjectSettings::getInstance()->load(m_projectSettingsFilepath);
updateFileManager();
@@ -78,6 +78,11 @@ void Project::clearStorage()
void Project::parseCode()
{
if (m_projectSettingsFilepath.empty())
{
return;
}
std::shared_ptr<ProjectSettings> projSettings = ProjectSettings::getInstance();
m_fileManager.fetchFilePaths();
+3 -3
View File
@@ -17,8 +17,8 @@ public:
~Project();
bool loadProjectSettings(const std::string& projectSettingsFile);
bool saveProjectSettings(const std::string& projectSettingsFile);
bool loadProjectSettings(const FilePath& projectSettingsFile);
bool saveProjectSettings(const FilePath& projectSettingsFile);
void clearProjectSettings();
void reloadProjectSettings();
@@ -38,7 +38,7 @@ private:
StorageAccessProxy* const m_storageAccessProxy;
std::string m_projectSettingsFilepath;
FilePath m_projectSettingsFilepath;
FileManager m_fileManager;
std::shared_ptr<Storage> m_storage;
+26 -5
View File
@@ -26,11 +26,21 @@ std::vector<FilePath> ApplicationSettings::getHeaderSearchPaths() const
return getPathValues("source/HeaderSearchPaths/HeaderSearchPath");
}
bool ApplicationSettings::setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths)
{
return setPathValues("source/HeaderSearchPaths/HeaderSearchPath", headerSearchPaths);
}
std::vector<FilePath> ApplicationSettings::getFrameworkSearchPaths() const
{
return getPathValues("source/FrameworkSearchPaths/FrameworkSearchPath");
}
bool ApplicationSettings::setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths)
{
return setPathValues("source/FrameworkSearchPaths/FrameworkSearchPath", frameworkSearchPaths);
}
std::vector<std::string> ApplicationSettings::getCompilerFlags() const
{
std::vector<std::string> defaultValues;
@@ -101,11 +111,22 @@ ApplicationSettings::ApplicationSettings()
{
}
std::vector<std::string> ApplicationSettings::getRecentProjects() const {
std::vector<std::string> recentProjects;
return getValues("recentProjects/projectFilePath", recentProjects);
std::vector<FilePath> ApplicationSettings::getRecentProjects() const
{
return getPathValues("user/recent_projects/recent_project");
}
bool ApplicationSettings::setRecentProjects(const std::vector<std::string> &recentProjects) {
return setValues("recentProjects/projectFilePath", recentProjects);
bool ApplicationSettings::setRecentProjects(const std::vector<FilePath> &recentProjects)
{
return setPathValues("user/recent_projects/recent_project", recentProjects);
}
bool ApplicationSettings::getUserHasSeenSettings() const
{
return getValue<bool>("user/has_seen_settings", false);
}
void ApplicationSettings::setUserHasSeenSettings(bool hasSeenSettings)
{
setValue<bool>("user/has_seen_settings", hasSeenSettings);
}
+11 -4
View File
@@ -16,7 +16,11 @@ public:
// source
std::vector<FilePath> getHeaderSearchPaths() const;
bool setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths);
std::vector<FilePath> getFrameworkSearchPaths() const;
bool setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths);
std::vector<std::string> getCompilerFlags() const;
// application
@@ -29,10 +33,6 @@ public:
std::string getColorSchemePath() const;
void setColorSchemePath(const std::string& colorSchemePath);
//recent projects
std::vector<std::string> getRecentProjects() const;
bool setRecentProjects(const std::vector<std::string>& recentProjects);
// code
int getCodeTabWidth() const;
void setCodeTabWidth(int codeTabWidth);
@@ -43,6 +43,13 @@ public:
int getCodeSnippetExpandRange() const;
void setCodeSnippetExpandRange(int range);
// user
bool getUserHasSeenSettings() const;
void setUserHasSeenSettings(bool hasSeenSettings);
std::vector<FilePath> getRecentProjects() const;
bool setRecentProjects(const std::vector<FilePath>& recentProjects);
private:
ApplicationSettings();
ApplicationSettings(const ApplicationSettings&);