diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/frontend/qt_sdl/Config.cpp | 2 | ||||
-rw-r--r-- | src/frontend/qt_sdl/Config.h | 1 | ||||
-rw-r--r-- | src/frontend/qt_sdl/InterfaceSettingsDialog.cpp | 23 | ||||
-rw-r--r-- | src/frontend/qt_sdl/InterfaceSettingsDialog.ui | 23 | ||||
-rw-r--r-- | src/frontend/qt_sdl/main.cpp | 12 | ||||
-rw-r--r-- | src/frontend/qt_sdl/main.h | 2 |
6 files changed, 59 insertions, 4 deletions
diff --git a/src/frontend/qt_sdl/Config.cpp b/src/frontend/qt_sdl/Config.cpp index 02f43de..215ad0b 100644 --- a/src/frontend/qt_sdl/Config.cpp +++ b/src/frontend/qt_sdl/Config.cpp @@ -142,6 +142,7 @@ bool MouseHide; int MouseHideSeconds; bool PauseLostFocus; +std::string UITheme; int64_t RTCOffset; @@ -344,6 +345,7 @@ ConfigEntry ConfigFile[] = {"MouseHide", 1, &MouseHide, false, false}, {"MouseHideSeconds", 0, &MouseHideSeconds, 5, false}, {"PauseLostFocus", 1, &PauseLostFocus, false, false}, + {"UITheme", 2, &UITheme, (std::string)"", false}, {"RTCOffset", 3, &RTCOffset, (int64_t)0, true}, diff --git a/src/frontend/qt_sdl/Config.h b/src/frontend/qt_sdl/Config.h index 11644dc..1893065 100644 --- a/src/frontend/qt_sdl/Config.h +++ b/src/frontend/qt_sdl/Config.h @@ -185,6 +185,7 @@ extern bool EnableCheats; extern bool MouseHide; extern int MouseHideSeconds; extern bool PauseLostFocus; +extern std::string UITheme; extern int64_t RTCOffset; diff --git a/src/frontend/qt_sdl/InterfaceSettingsDialog.cpp b/src/frontend/qt_sdl/InterfaceSettingsDialog.cpp index 75497bc..851e7ab 100644 --- a/src/frontend/qt_sdl/InterfaceSettingsDialog.cpp +++ b/src/frontend/qt_sdl/InterfaceSettingsDialog.cpp @@ -16,15 +16,16 @@ with melonDS. If not, see http://www.gnu.org/licenses/. */ +#include <QStyleFactory> #include "InterfaceSettingsDialog.h" #include "ui_InterfaceSettingsDialog.h" #include "types.h" #include "Platform.h" #include "Config.h" +#include "main.h" InterfaceSettingsDialog* InterfaceSettingsDialog::currentDlg = nullptr; - InterfaceSettingsDialog::InterfaceSettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::InterfaceSettingsDialog) { ui->setupUi(this); @@ -35,6 +36,18 @@ InterfaceSettingsDialog::InterfaceSettingsDialog(QWidget* parent) : QDialog(pare ui->spinMouseHideSeconds->setValue(Config::MouseHideSeconds); ui->cbPauseLostFocus->setChecked(Config::PauseLostFocus != 0); ui->spinMaxFPS->setValue(Config::MaxFPS); + + const QList<QString> themeKeys = QStyleFactory::keys(); + const QString currentTheme = qApp->style()->objectName(); + + ui->cbxUITheme->addItem("System default", ""); + + for (int i = 0; i < themeKeys.length(); i++) + { + ui->cbxUITheme->addItem(themeKeys[i], themeKeys[i]); + if (!Config::UITheme.empty() && themeKeys[i].compare(currentTheme, Qt::CaseInsensitive) == 0) + ui->cbxUITheme->setCurrentIndex(i + 1); + } } InterfaceSettingsDialog::~InterfaceSettingsDialog() @@ -63,8 +76,16 @@ void InterfaceSettingsDialog::done(int r) Config::PauseLostFocus = ui->cbPauseLostFocus->isChecked() ? 1:0; Config::MaxFPS = ui->spinMaxFPS->value(); + QString themeName = ui->cbxUITheme->currentData().toString(); + Config::UITheme = themeName.toStdString(); + Config::Save(); + if (!Config::UITheme.empty()) + qApp->setStyle(themeName); + else + qApp->setStyle(*systemThemeName); + emit updateMouseTimer(); } diff --git a/src/frontend/qt_sdl/InterfaceSettingsDialog.ui b/src/frontend/qt_sdl/InterfaceSettingsDialog.ui index 01ba4a4..21d8434 100644 --- a/src/frontend/qt_sdl/InterfaceSettingsDialog.ui +++ b/src/frontend/qt_sdl/InterfaceSettingsDialog.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>337</width> - <height>233</height> + <height>275</height> </rect> </property> <property name="sizePolicy"> @@ -20,13 +20,30 @@ <string>Interface settings - melonDS</string> </property> <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0"> - <item alignment="Qt::AlignTop"> + <item> <widget class="QGroupBox" name="groupBox"> <property name="title"> - <string>Main window</string> + <string>User interface</string> </property> <layout class="QVBoxLayout" name="verticalLayout_2"> <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Theme</string> + </property> + <property name="buddy"> + <cstring>cbxUITheme</cstring> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="cbxUITheme"/> + </item> + </layout> + </item> + <item> <widget class="QCheckBox" name="cbMouseHide"> <property name="text"> <string>Hide mouse after inactivity</string> diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index 3a5c1a1..7e34e6a 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -114,6 +114,7 @@ QStringList NdsRomExtensions { ".nds", ".srl", ".dsi", ".ids" }; QString GbaRomMimeType = "application/x-gba-rom"; QStringList GbaRomExtensions { ".gba", ".agb" }; +QString* systemThemeName; // This list of supported archive formats is based on libarchive(3) version 3.6.2 (2022-12-09). QStringList ArchiveMimeTypes @@ -292,6 +293,11 @@ int main(int argc, char** argv) qputenv("QT_SCALE_FACTOR", "1"); +#if QT_VERSION_MAJOR == 6 && defined(__WIN32__) + // Allow using the system dark theme palette on Windows + qputenv("QT_QPA_PLATFORM", "windows:darkmode=2"); +#endif + printf("melonDS " MELONDS_VERSION "\n"); printf(MELONDS_URL "\n"); @@ -360,6 +366,12 @@ int main(int argc, char** argv) camManager[0]->setXFlip(Config::Camera[0].XFlip); camManager[1]->setXFlip(Config::Camera[1].XFlip); + systemThemeName = new QString(QApplication::style()->objectName()); + + if (!Config::UITheme.empty()) + { + QApplication::setStyle(QString::fromStdString(Config::UITheme)); + } Input::JoystickID = Config::JoystickID; Input::OpenJoystick(); diff --git a/src/frontend/qt_sdl/main.h b/src/frontend/qt_sdl/main.h index 51157c6..5751f22 100644 --- a/src/frontend/qt_sdl/main.h +++ b/src/frontend/qt_sdl/main.h @@ -44,4 +44,6 @@ public: bool event(QEvent* event) override; }; +extern QString* systemThemeName; + #endif // MAIN_H |