logic: use colorscheme name instead of path in appsettings
* With respect to a portable app package this makes sense ;)
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
#include "utility/UserPaths.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
const size_t ApplicationSettings::VERSION = 3;
|
||||
const size_t ApplicationSettings::VERSION = 4;
|
||||
|
||||
std::shared_ptr<ApplicationSettings> ApplicationSettings::s_instance;
|
||||
|
||||
@@ -74,6 +74,17 @@ bool ApplicationSettings::load(const FilePath& filePath)
|
||||
}
|
||||
}
|
||||
));
|
||||
migrator.addMigration(4, std::make_shared<SettingsMigrationLambda>(
|
||||
[](const SettingsMigration* migration, Settings* settings)
|
||||
{
|
||||
std::wstring colorSchemePathString = migration->getValueFromSettings<std::wstring>(settings, "application/color_scheme", L"");
|
||||
if (!colorSchemePathString.empty())
|
||||
{
|
||||
FilePath colorSchemePath(colorSchemePathString);
|
||||
migration->setValueInSettings(settings, "application/color_scheme", colorSchemePath.withoutExtension().fileName());
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
bool migrated = migrator.migrate(this, ApplicationSettings::VERSION);
|
||||
|
||||
@@ -147,10 +158,15 @@ void ApplicationSettings::setShowBuiltinTypesInGraph(bool showBuiltinTypes)
|
||||
setValue<bool>("application/builtin_types_in_graph", showBuiltinTypes);
|
||||
}
|
||||
|
||||
std::wstring ApplicationSettings::getColorSchemeName() const
|
||||
{
|
||||
return getValue<std::wstring>("application/color_scheme", L"bright");
|
||||
}
|
||||
|
||||
FilePath ApplicationSettings::getColorSchemePath() const
|
||||
{
|
||||
FilePath defaultPath(ResourcePaths::getColorSchemesPath().concatenate(L"bright.xml"));
|
||||
FilePath path(getValue<std::wstring>("application/color_scheme", defaultPath.wstr()));
|
||||
FilePath path(ResourcePaths::getColorSchemesPath().concatenate(getColorSchemeName() + L".xml"));
|
||||
|
||||
if (path != defaultPath && !path.exists())
|
||||
{
|
||||
@@ -160,9 +176,9 @@ FilePath ApplicationSettings::getColorSchemePath() const
|
||||
return path;
|
||||
}
|
||||
|
||||
void ApplicationSettings::setColorSchemePath(const FilePath& colorSchemePath)
|
||||
void ApplicationSettings::setColorSchemeName(const std::wstring& colorSchemeName)
|
||||
{
|
||||
setValue<std::string>("application/color_scheme", colorSchemePath.str());
|
||||
setValue("application/color_scheme", colorSchemeName);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getFontSizeMax() const
|
||||
|
||||
@@ -35,8 +35,9 @@ public:
|
||||
std::string getTextEncoding() const;
|
||||
void setTextEncoding(const std::string& textEncoding);
|
||||
|
||||
std::wstring getColorSchemeName() const;
|
||||
FilePath getColorSchemePath() const;
|
||||
void setColorSchemePath(const FilePath& colorSchemePath);
|
||||
void setColorSchemeName(const std::wstring& colorSchemeName);
|
||||
|
||||
int getFontSizeMax() const;
|
||||
void setFontSizeMax(const int fontSizeMax);
|
||||
|
||||
@@ -449,7 +449,7 @@ void QtProjectWizzardContentPreferences::load()
|
||||
|
||||
void QtProjectWizzardContentPreferences::save()
|
||||
{
|
||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||
std::shared_ptr<ApplicationSettings> appSettings = ApplicationSettings::getInstance();
|
||||
|
||||
appSettings->setFontName(m_fontFace->currentText().toStdString());
|
||||
|
||||
@@ -458,7 +458,7 @@ void QtProjectWizzardContentPreferences::save()
|
||||
|
||||
appSettings->setTextEncoding(m_textEncoding->currentText().toStdString());
|
||||
|
||||
appSettings->setColorSchemePath(m_colorSchemePaths[m_colorSchemes->currentIndex()]);
|
||||
appSettings->setColorSchemeName(m_colorSchemePaths[m_colorSchemes->currentIndex()].withoutExtension().fileName());
|
||||
m_oldColorSchemeIndex = -1;
|
||||
|
||||
appSettings->setUseAnimations(m_useAnimations->isChecked());
|
||||
|
||||
Reference in New Issue
Block a user