diff options
| author | JosJuice <josjuice@gmail.com> | 2020-05-01 16:31:47 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2020-05-02 02:13:01 +0200 |
| commit | aab694e6b5c595590cb4153ddca7a89cdb2c2a2d (patch) | |
| tree | fc84cf75d47869f7f361ec935261caa729ad3062 /Source/Core | |
| parent | 66c91b9dfbb9f56713d8d71bd4f3dc6d6152e863 (diff) | |
DolphinQt: Store name of user style, not path
This makes user styles not break when for instance
moving a portable.txt install between different folders.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/DolphinQt/Settings.cpp | 16 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/Settings.h | 2 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/Settings/InterfacePane.cpp | 8 |
3 files changed, 15 insertions, 11 deletions
diff --git a/Source/Core/DolphinQt/Settings.cpp b/Source/Core/DolphinQt/Settings.cpp index c1a93939d9..9571ce055c 100644 --- a/Source/Core/DolphinQt/Settings.cpp +++ b/Source/Core/DolphinQt/Settings.cpp @@ -7,6 +7,7 @@ #include <QApplication> #include <QDir> #include <QFile> +#include <QFileInfo> #include <QSize> #include "AudioCommon/AudioCommon.h" @@ -72,17 +73,22 @@ void Settings::SetThemeName(const QString& theme_name) QString Settings::GetCurrentUserStyle() const { - return GetQSettings().value(QStringLiteral("userstyle/path"), false).toString(); + if (GetQSettings().contains(QStringLiteral("userstyle/name"))) + return GetQSettings().value(QStringLiteral("userstyle/name")).toString(); + + // Migration code for the old way of storing this setting + return QFileInfo(GetQSettings().value(QStringLiteral("userstyle/path")).toString()).fileName(); } -void Settings::SetCurrentUserStyle(const QString& stylesheet_path) +void Settings::SetCurrentUserStyle(const QString& stylesheet_name) { QString stylesheet_contents; - if (!stylesheet_path.isEmpty() && AreUserStylesEnabled()) + if (!stylesheet_name.isEmpty() && AreUserStylesEnabled()) { // Load custom user stylesheet - QFile stylesheet(stylesheet_path); + QDir directory = QDir(QString::fromStdString(File::GetUserPath(D_STYLES_IDX))); + QFile stylesheet(directory.filePath(stylesheet_name)); if (stylesheet.open(QFile::ReadOnly)) stylesheet_contents = QString::fromUtf8(stylesheet.readAll().data()); @@ -90,7 +96,7 @@ void Settings::SetCurrentUserStyle(const QString& stylesheet_path) qApp->setStyleSheet(stylesheet_contents); - GetQSettings().setValue(QStringLiteral("userstyle/path"), stylesheet_path); + GetQSettings().setValue(QStringLiteral("userstyle/name"), stylesheet_name); } bool Settings::AreUserStylesEnabled() const diff --git a/Source/Core/DolphinQt/Settings.h b/Source/Core/DolphinQt/Settings.h index 7aa169dee0..0af6357515 100644 --- a/Source/Core/DolphinQt/Settings.h +++ b/Source/Core/DolphinQt/Settings.h @@ -47,7 +47,7 @@ public: // UI void SetThemeName(const QString& theme_name); - void SetCurrentUserStyle(const QString& stylesheet_path); + void SetCurrentUserStyle(const QString& stylesheet_name); QString GetCurrentUserStyle() const; void SetUserStylesEnabled(bool enabled); diff --git a/Source/Core/DolphinQt/Settings/InterfacePane.cpp b/Source/Core/DolphinQt/Settings/InterfacePane.cpp index 51422f237b..af5545565f 100644 --- a/Source/Core/DolphinQt/Settings/InterfacePane.cpp +++ b/Source/Core/DolphinQt/Settings/InterfacePane.cpp @@ -136,10 +136,8 @@ void InterfacePane::CreateUI() for (const std::string& path : userstyle_search_results) { - std::string name; - SplitPath(path, nullptr, &name, nullptr); - const QString qt_name = QString::fromStdString(name); - m_combobox_userstyle->addItem(qt_name, QString::fromStdString(path)); + const QFileInfo file_info(QString::fromStdString(path)); + m_combobox_userstyle->addItem(file_info.completeBaseName(), file_info.fileName()); } // Checkboxes @@ -216,7 +214,7 @@ void InterfacePane::LoadConfig() m_combobox_theme->findText(QString::fromStdString(SConfig::GetInstance().theme_name))); const QString userstyle = Settings::Instance().GetCurrentUserStyle(); - const int index = m_combobox_userstyle->findText(QFileInfo(userstyle).baseName()); + const int index = m_combobox_userstyle->findData(QFileInfo(userstyle).fileName()); if (index > 0) m_combobox_userstyle->setCurrentIndex(index); |
