From 9e3f59364143c5e8a9193feb452b0fafe2e6ed16 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 1 Feb 2022 21:39:31 +0800 Subject: [PATCH] - enhancement: theme now have default icon set - fix: wrong icons for file associations --- NEWS.md | 2 ++ RedPandaIDE/RedPandaIDE.pro | 2 +- RedPandaIDE/settings.cpp | 2 +- .../environmentappearencewidget.cpp | 15 +++++++++++++++ .../settingsdialog/environmentappearencewidget.h | 2 ++ RedPandaIDE/thememanager.cpp | 11 +++++++++++ RedPandaIDE/thememanager.h | 4 ++++ RedPandaIDE/themes/contrast.json | 1 + RedPandaIDE/themes/dark.json | 1 + RedPandaIDE/themes/default.json | 1 + 10 files changed, 39 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 52496c72..69833f7e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,6 +9,8 @@ Red Panda C++ Version 0.14.1 - enhancement: new header dialog for project - enhancement: new contrast icon set, contributed by Alan-CRL - enhancement: new contrast theme, contributed by Alan-CRL + - enhancement: theme now have default icon set + - fix: wrong icons for file associations Red Panda C++ Version 0.14.0 - enhancement: custom icon set ( in the configuration folder) diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index cafac87f..2d68307c 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -381,7 +381,7 @@ RESOURCES += \ icons.qrc \ translations.qrc -RC_ICONS = images/devcpp.ico images/associations/c.ico images/associations/cpp.ico images/associations/h.ico images/associations/hpp.ico images/associations/dev.ico +RC_ICONS = images/devcpp.ico images/associations/c.ico images/associations/cpp.ico images/associations/dev.ico images/associations/c.ico images/associations/cpp.ico images/associations/h.ico images/associations/hpp.ico # fixed lrelease.prf diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 894b734f..155c976c 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -2902,7 +2902,7 @@ void Settings::Environment::doLoad() mInterfaceFont = stringValue("interface_font",defaultFontName); mInterfaceFontSize = intValue("interface_font_size",12); mLanguage = stringValue("language", QLocale::system().name()); - mIconSet = stringValue("icon_set","newlook"); + mIconSet = stringValue("icon_set","contrast"); mUseCustomIconSet = boolValue("use_custom_icon_set", false); mUseCustomTheme = boolValue("use_custom_theme", false); diff --git a/RedPandaIDE/settingsdialog/environmentappearencewidget.cpp b/RedPandaIDE/settingsdialog/environmentappearencewidget.cpp index c24dc375..9ec2fff3 100644 --- a/RedPandaIDE/settingsdialog/environmentappearencewidget.cpp +++ b/RedPandaIDE/settingsdialog/environmentappearencewidget.cpp @@ -101,3 +101,18 @@ void EnvironmentAppearenceWidget::init() } SettingsWidget::init(); } + +void EnvironmentAppearenceWidget::on_cbTheme_currentIndexChanged(int /* index */) +{ + ThemeManager themeManager; + PAppTheme appTheme = themeManager.theme(ui->cbTheme->currentData().toString()); + if (appTheme && !appTheme->defaultIconSet().isEmpty()) { + for (int i=0; icbIconSet->count();i++) { + if (ui->cbIconSet->itemData(i) == appTheme->defaultIconSet()) { + ui->cbIconSet->setCurrentIndex(i); + break; + } + } + } +} + diff --git a/RedPandaIDE/settingsdialog/environmentappearencewidget.h b/RedPandaIDE/settingsdialog/environmentappearencewidget.h index 5495ad5b..74e13c69 100644 --- a/RedPandaIDE/settingsdialog/environmentappearencewidget.h +++ b/RedPandaIDE/settingsdialog/environmentappearencewidget.h @@ -43,6 +43,8 @@ protected: // SettingsWidget interface public: void init() override; +private slots: + void on_cbTheme_currentIndexChanged(int index); }; #endif // ENVIRONMENTAPPEARENCEWIDGET_H diff --git a/RedPandaIDE/thememanager.cpp b/RedPandaIDE/thememanager.cpp index a5732ef6..6a918483 100644 --- a/RedPandaIDE/thememanager.cpp +++ b/RedPandaIDE/thememanager.cpp @@ -196,6 +196,7 @@ void AppTheme::load(const QString &filename) mDisplayName = localeName; mIsDark = obj["isDark"].toBool(false); mDefaultColorScheme = obj["default scheme"].toString(); + mDefaultIconSet = obj["default iconset"].toString(); QJsonObject colors = obj["palette"].toObject(); const QMetaObject &m = *metaObject(); QMetaEnum e = m.enumerator(m.indexOfEnumerator("ColorRole")); @@ -237,6 +238,16 @@ QPalette AppTheme::initialPalette() return palette; } +const QString &AppTheme::defaultIconSet() const +{ + return mDefaultIconSet; +} + +void AppTheme::setDefaultIconSet(const QString &newDefaultIconSet) +{ + mDefaultIconSet = newDefaultIconSet; +} + const QString &AppTheme::name() const { return mName; diff --git a/RedPandaIDE/thememanager.h b/RedPandaIDE/thememanager.h index 2c04dc8e..2f35934f 100644 --- a/RedPandaIDE/thememanager.h +++ b/RedPandaIDE/thememanager.h @@ -89,6 +89,9 @@ public: const QString &name() const; + const QString &defaultIconSet() const; + void setDefaultIconSet(const QString &newDefaultIconSet); + private: static QPalette initialPalette(); private: @@ -97,6 +100,7 @@ private: QString mDisplayName; bool mIsDark; QString mDefaultColorScheme; + QString mDefaultIconSet; }; using PAppTheme = std::shared_ptr; diff --git a/RedPandaIDE/themes/contrast.json b/RedPandaIDE/themes/contrast.json index 46e28a1c..fab4ba10 100644 --- a/RedPandaIDE/themes/contrast.json +++ b/RedPandaIDE/themes/contrast.json @@ -3,6 +3,7 @@ "name_zh_CN": "高对比度主题", "isDark": true, "default scheme": "Twilight", + "default iconset": "contrast", "palette": { "PaletteWindow":"#000000", "PaletteWindowText":"#FFFFFF", diff --git a/RedPandaIDE/themes/dark.json b/RedPandaIDE/themes/dark.json index 50f2dafc..6a88df97 100644 --- a/RedPandaIDE/themes/dark.json +++ b/RedPandaIDE/themes/dark.json @@ -3,6 +3,7 @@ "name_zh_CN": "深色主题", "isDark": true, "default scheme": "VS Code", + "default iconset": "contrast", "palette": { "PaletteWindow":"#19232D", "PaletteWindowText":"#E0E1E3", diff --git a/RedPandaIDE/themes/default.json b/RedPandaIDE/themes/default.json index f6e83631..80915681 100644 --- a/RedPandaIDE/themes/default.json +++ b/RedPandaIDE/themes/default.json @@ -3,6 +3,7 @@ "name_zh_CN":"浅色主题", "isDark":false, "default scheme": "Intellij Classic", + "default iconset": "newlook", "palette": { "PaletteHighlight":"#ffdddddd", "PaletteHighlightedText":"#ff000000"