diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/citra_qt/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | src/citra_qt/configuration/config.cpp | 2 | ||||
| -rw-r--r-- | src/citra_qt/configuration/configure_general.cpp | 9 | ||||
| -rw-r--r-- | src/citra_qt/configuration/configure_general.ui | 28 | ||||
| -rw-r--r-- | src/citra_qt/main.cpp | 21 | ||||
| -rw-r--r-- | src/citra_qt/main.h | 1 | ||||
| -rw-r--r-- | src/citra_qt/ui_settings.h | 7 |
7 files changed, 73 insertions, 2 deletions
diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 9572d3e28..f364b2284 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | set(CMAKE_AUTOMOC ON) | 1 | set(CMAKE_AUTOMOC ON) |
| 2 | set(CMAKE_AUTORCC ON) | ||
| 2 | set(CMAKE_INCLUDE_CURRENT_DIR ON) | 3 | set(CMAKE_INCLUDE_CURRENT_DIR ON) |
| 3 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules) | 4 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules) |
| 4 | 5 | ||
| @@ -75,6 +76,8 @@ set(UIS | |||
| 75 | main.ui | 76 | main.ui |
| 76 | ) | 77 | ) |
| 77 | 78 | ||
| 79 | file(GLOB_RECURSE THEMES ${CMAKE_SOURCE_DIR}/dist/qt_themes/*) | ||
| 80 | |||
| 78 | create_directory_groups(${SRCS} ${HEADERS} ${UIS}) | 81 | create_directory_groups(${SRCS} ${HEADERS} ${UIS}) |
| 79 | 82 | ||
| 80 | if (Qt5_FOUND) | 83 | if (Qt5_FOUND) |
| @@ -86,10 +89,10 @@ endif() | |||
| 86 | if (APPLE) | 89 | if (APPLE) |
| 87 | set(MACOSX_ICON "../../dist/citra.icns") | 90 | set(MACOSX_ICON "../../dist/citra.icns") |
| 88 | set_source_files_properties(${MACOSX_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) | 91 | set_source_files_properties(${MACOSX_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) |
| 89 | add_executable(citra-qt MACOSX_BUNDLE ${SRCS} ${HEADERS} ${UI_HDRS} ${MACOSX_ICON}) | 92 | add_executable(citra-qt MACOSX_BUNDLE ${SRCS} ${HEADERS} ${UI_HDRS} ${THEMES} ${MACOSX_ICON}) |
| 90 | set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) | 93 | set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) |
| 91 | else() | 94 | else() |
| 92 | add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS}) | 95 | add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS} ${THEMES}) |
| 93 | endif() | 96 | endif() |
| 94 | target_link_libraries(citra-qt PRIVATE audio_core common core input_common network video_core) | 97 | target_link_libraries(citra-qt PRIVATE audio_core common core input_common network video_core) |
| 95 | target_link_libraries(citra-qt PRIVATE Boost::boost glad nihstro-headers Qt5::OpenGL Qt5::Widgets) | 98 | target_link_libraries(citra-qt PRIVATE Boost::boost glad nihstro-headers Qt5::OpenGL Qt5::Widgets) |
diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 40142b6d9..75abb4ce6 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp | |||
| @@ -141,6 +141,7 @@ void Config::ReadValues() { | |||
| 141 | qt_config->endGroup(); | 141 | qt_config->endGroup(); |
| 142 | 142 | ||
| 143 | qt_config->beginGroup("UI"); | 143 | qt_config->beginGroup("UI"); |
| 144 | UISettings::values.theme = qt_config->value("theme", UISettings::themes[0].second).toString(); | ||
| 144 | 145 | ||
| 145 | qt_config->beginGroup("UILayout"); | 146 | qt_config->beginGroup("UILayout"); |
| 146 | UISettings::values.geometry = qt_config->value("geometry").toByteArray(); | 147 | UISettings::values.geometry = qt_config->value("geometry").toByteArray(); |
| @@ -281,6 +282,7 @@ void Config::SaveValues() { | |||
| 281 | qt_config->endGroup(); | 282 | qt_config->endGroup(); |
| 282 | 283 | ||
| 283 | qt_config->beginGroup("UI"); | 284 | qt_config->beginGroup("UI"); |
| 285 | qt_config->setValue("theme", UISettings::values.theme); | ||
| 284 | 286 | ||
| 285 | qt_config->beginGroup("UILayout"); | 287 | qt_config->beginGroup("UILayout"); |
| 286 | qt_config->setValue("geometry", UISettings::values.geometry); | 288 | qt_config->setValue("geometry", UISettings::values.geometry); |
diff --git a/src/citra_qt/configuration/configure_general.cpp b/src/citra_qt/configuration/configure_general.cpp index a21176c34..939379717 100644 --- a/src/citra_qt/configuration/configure_general.cpp +++ b/src/citra_qt/configuration/configure_general.cpp | |||
| @@ -12,6 +12,11 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent) | |||
| 12 | : QWidget(parent), ui(new Ui::ConfigureGeneral) { | 12 | : QWidget(parent), ui(new Ui::ConfigureGeneral) { |
| 13 | 13 | ||
| 14 | ui->setupUi(this); | 14 | ui->setupUi(this); |
| 15 | |||
| 16 | for (auto theme : UISettings::themes) { | ||
| 17 | ui->theme_combobox->addItem(theme.first, theme.second); | ||
| 18 | } | ||
| 19 | |||
| 15 | this->setConfiguration(); | 20 | this->setConfiguration(); |
| 16 | 21 | ||
| 17 | ui->toggle_cpu_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn()); | 22 | ui->toggle_cpu_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn()); |
| @@ -26,11 +31,15 @@ void ConfigureGeneral::setConfiguration() { | |||
| 26 | 31 | ||
| 27 | // The first item is "auto-select" with actual value -1, so plus one here will do the trick | 32 | // The first item is "auto-select" with actual value -1, so plus one here will do the trick |
| 28 | ui->region_combobox->setCurrentIndex(Settings::values.region_value + 1); | 33 | ui->region_combobox->setCurrentIndex(Settings::values.region_value + 1); |
| 34 | |||
| 35 | ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme)); | ||
| 29 | } | 36 | } |
| 30 | 37 | ||
| 31 | void ConfigureGeneral::applyConfiguration() { | 38 | void ConfigureGeneral::applyConfiguration() { |
| 32 | UISettings::values.gamedir_deepscan = ui->toggle_deepscan->isChecked(); | 39 | UISettings::values.gamedir_deepscan = ui->toggle_deepscan->isChecked(); |
| 33 | UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); | 40 | UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); |
| 41 | UISettings::values.theme = | ||
| 42 | ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString(); | ||
| 34 | Settings::values.region_value = ui->region_combobox->currentIndex() - 1; | 43 | Settings::values.region_value = ui->region_combobox->currentIndex() - 1; |
| 35 | Settings::values.use_cpu_jit = ui->toggle_cpu_jit->isChecked(); | 44 | Settings::values.use_cpu_jit = ui->toggle_cpu_jit->isChecked(); |
| 36 | Settings::Apply(); | 45 | Settings::Apply(); |
diff --git a/src/citra_qt/configuration/configure_general.ui b/src/citra_qt/configuration/configure_general.ui index c739605a4..eedf2cbb0 100644 --- a/src/citra_qt/configuration/configure_general.ui +++ b/src/citra_qt/configuration/configure_general.ui | |||
| @@ -132,6 +132,34 @@ | |||
| 132 | </widget> | 132 | </widget> |
| 133 | </item> | 133 | </item> |
| 134 | <item> | 134 | <item> |
| 135 | <widget class="QGroupBox" name="theme_group_box"> | ||
| 136 | <property name="title"> | ||
| 137 | <string>Theme</string> | ||
| 138 | </property> | ||
| 139 | <layout class="QHBoxLayout" name="theme_qhbox_layout"> | ||
| 140 | <item> | ||
| 141 | <layout class="QVBoxLayout" name="theme_qvbox_layout"> | ||
| 142 | <item> | ||
| 143 | <layout class="QHBoxLayout" name="theme_qhbox_layout_2"> | ||
| 144 | <item> | ||
| 145 | <widget class="QLabel" name="theme_label"> | ||
| 146 | <property name="text"> | ||
| 147 | <string>Theme:</string> | ||
| 148 | </property> | ||
| 149 | </widget> | ||
| 150 | </item> | ||
| 151 | <item> | ||
| 152 | <widget class="QComboBox" name="theme_combobox"> | ||
| 153 | </widget> | ||
| 154 | </item> | ||
| 155 | </layout> | ||
| 156 | </item> | ||
| 157 | </layout> | ||
| 158 | </item> | ||
| 159 | </layout> | ||
| 160 | </widget> | ||
| 161 | </item> | ||
| 162 | <item> | ||
| 135 | <widget class="QGroupBox" name="groupBox_3"> | 163 | <widget class="QGroupBox" name="groupBox_3"> |
| 136 | <property name="title"> | 164 | <property name="title"> |
| 137 | <string>Hotkeys</string> | 165 | <string>Hotkeys</string> |
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 4f5b2ddab..02bfdca3d 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp | |||
| @@ -71,6 +71,8 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { | |||
| 71 | 71 | ||
| 72 | game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan); | 72 | game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan); |
| 73 | 73 | ||
| 74 | UpdateUITheme(); | ||
| 75 | |||
| 74 | QStringList args = QApplication::arguments(); | 76 | QStringList args = QApplication::arguments(); |
| 75 | if (args.length() >= 2) { | 77 | if (args.length() >= 2) { |
| 76 | BootGame(args[1]); | 78 | BootGame(args[1]); |
| @@ -606,6 +608,7 @@ void GMainWindow::OnConfigure() { | |||
| 606 | auto result = configureDialog.exec(); | 608 | auto result = configureDialog.exec(); |
| 607 | if (result == QDialog::Accepted) { | 609 | if (result == QDialog::Accepted) { |
| 608 | configureDialog.applyConfiguration(); | 610 | configureDialog.applyConfiguration(); |
| 611 | UpdateUITheme(); | ||
| 609 | config->Save(); | 612 | config->Save(); |
| 610 | } | 613 | } |
| 611 | } | 614 | } |
| @@ -791,6 +794,24 @@ void GMainWindow::filterBarSetChecked(bool state) { | |||
| 791 | emit(OnToggleFilterBar()); | 794 | emit(OnToggleFilterBar()); |
| 792 | } | 795 | } |
| 793 | 796 | ||
| 797 | void GMainWindow::UpdateUITheme() { | ||
| 798 | if (UISettings::values.theme != UISettings::themes[0].second) { | ||
| 799 | QString theme_uri(":" + UISettings::values.theme + "/style.qss"); | ||
| 800 | QFile f(theme_uri); | ||
| 801 | if (!f.exists()) { | ||
| 802 | LOG_ERROR(Frontend, "Unable to set style, stylesheet file not found"); | ||
| 803 | } else { | ||
| 804 | f.open(QFile::ReadOnly | QFile::Text); | ||
| 805 | QTextStream ts(&f); | ||
| 806 | qApp->setStyleSheet(ts.readAll()); | ||
| 807 | GMainWindow::setStyleSheet(ts.readAll()); | ||
| 808 | } | ||
| 809 | } else { | ||
| 810 | qApp->setStyleSheet(""); | ||
| 811 | GMainWindow::setStyleSheet(""); | ||
| 812 | } | ||
| 813 | } | ||
| 814 | |||
| 794 | #ifdef main | 815 | #ifdef main |
| 795 | #undef main | 816 | #undef main |
| 796 | #endif | 817 | #endif |
diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index 952a50974..360de2ced 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h | |||
| @@ -42,6 +42,7 @@ class GMainWindow : public QMainWindow { | |||
| 42 | 42 | ||
| 43 | public: | 43 | public: |
| 44 | void filterBarSetChecked(bool state); | 44 | void filterBarSetChecked(bool state); |
| 45 | void UpdateUITheme(); | ||
| 45 | GMainWindow(); | 46 | GMainWindow(); |
| 46 | ~GMainWindow(); | 47 | ~GMainWindow(); |
| 47 | 48 | ||
diff --git a/src/citra_qt/ui_settings.h b/src/citra_qt/ui_settings.h index bc37f81c5..025c73f84 100644 --- a/src/citra_qt/ui_settings.h +++ b/src/citra_qt/ui_settings.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 7 | #include <vector> | 8 | #include <vector> |
| 8 | #include <QByteArray> | 9 | #include <QByteArray> |
| 9 | #include <QString> | 10 | #include <QString> |
| @@ -14,6 +15,10 @@ namespace UISettings { | |||
| 14 | using ContextualShortcut = std::pair<QString, int>; | 15 | using ContextualShortcut = std::pair<QString, int>; |
| 15 | using Shortcut = std::pair<QString, ContextualShortcut>; | 16 | using Shortcut = std::pair<QString, ContextualShortcut>; |
| 16 | 17 | ||
| 18 | static const std::array<std::pair<QString, QString>, 2> themes = { | ||
| 19 | {std::make_pair(QString("Default"), QString("default")), | ||
| 20 | std::make_pair(QString("Dark"), QString("qdarkstyle"))}}; | ||
| 21 | |||
| 17 | struct Values { | 22 | struct Values { |
| 18 | QByteArray geometry; | 23 | QByteArray geometry; |
| 19 | QByteArray state; | 24 | QByteArray state; |
| @@ -39,6 +44,8 @@ struct Values { | |||
| 39 | bool gamedir_deepscan; | 44 | bool gamedir_deepscan; |
| 40 | QStringList recent_files; | 45 | QStringList recent_files; |
| 41 | 46 | ||
| 47 | QString theme; | ||
| 48 | |||
| 42 | // Shortcut name <Shortcut, context> | 49 | // Shortcut name <Shortcut, context> |
| 43 | std::vector<Shortcut> shortcuts; | 50 | std::vector<Shortcut> shortcuts; |
| 44 | }; | 51 | }; |