From 086da07b533d20601384d4f959e3cfe09ab6c39c Mon Sep 17 00:00:00 2001 From: BearOso Date: Sat, 19 Aug 2023 16:30:11 -0500 Subject: [PATCH] Qt: White icons for dark color schemes. --- qt/src/BindingPanel.cpp | 10 ++- qt/src/ControllerPanel.cpp | 8 +++ qt/src/EmuMainWindow.cpp | 24 ++++--- qt/src/EmuSettingsWindow.cpp | 14 ++++ qt/src/main.cpp | 1 + qt/src/resources/snes9x.qrc | 21 ++++++ qt/src/resources/whiteicons/a.svg | 71 ++++++++++++++++++ qt/src/resources/whiteicons/b.svg | 71 ++++++++++++++++++ qt/src/resources/whiteicons/display.svg | 1 + qt/src/resources/whiteicons/down.svg | 62 ++++++++++++++++ qt/src/resources/whiteicons/emulation.svg | 1 + qt/src/resources/whiteicons/folders.svg | 1 + qt/src/resources/whiteicons/joypad.svg | 47 ++++++++++++ qt/src/resources/whiteicons/key.svg | 87 +++++++++++++++++++++++ qt/src/resources/whiteicons/keyboard.svg | 1 + qt/src/resources/whiteicons/l.svg | 81 +++++++++++++++++++++ qt/src/resources/whiteicons/left.svg | 63 ++++++++++++++++ qt/src/resources/whiteicons/r.svg | 79 ++++++++++++++++++++ qt/src/resources/whiteicons/right.svg | 63 ++++++++++++++++ qt/src/resources/whiteicons/select.svg | 67 +++++++++++++++++ qt/src/resources/whiteicons/settings.svg | 1 + qt/src/resources/whiteicons/shader.svg | 1 + qt/src/resources/whiteicons/sound.svg | 1 + qt/src/resources/whiteicons/start.svg | 67 +++++++++++++++++ qt/src/resources/whiteicons/up.svg | 62 ++++++++++++++++ qt/src/resources/whiteicons/x.svg | 71 ++++++++++++++++++ qt/src/resources/whiteicons/y.svg | 71 ++++++++++++++++++ 27 files changed, 1036 insertions(+), 11 deletions(-) create mode 100644 qt/src/resources/whiteicons/a.svg create mode 100644 qt/src/resources/whiteicons/b.svg create mode 100644 qt/src/resources/whiteicons/display.svg create mode 100644 qt/src/resources/whiteicons/down.svg create mode 100644 qt/src/resources/whiteicons/emulation.svg create mode 100644 qt/src/resources/whiteicons/folders.svg create mode 100644 qt/src/resources/whiteicons/joypad.svg create mode 100644 qt/src/resources/whiteicons/key.svg create mode 100644 qt/src/resources/whiteicons/keyboard.svg create mode 100644 qt/src/resources/whiteicons/l.svg create mode 100644 qt/src/resources/whiteicons/left.svg create mode 100644 qt/src/resources/whiteicons/r.svg create mode 100644 qt/src/resources/whiteicons/right.svg create mode 100644 qt/src/resources/whiteicons/select.svg create mode 100644 qt/src/resources/whiteicons/settings.svg create mode 100644 qt/src/resources/whiteicons/shader.svg create mode 100644 qt/src/resources/whiteicons/sound.svg create mode 100644 qt/src/resources/whiteicons/start.svg create mode 100644 qt/src/resources/whiteicons/up.svg create mode 100644 qt/src/resources/whiteicons/x.svg create mode 100644 qt/src/resources/whiteicons/y.svg diff --git a/qt/src/BindingPanel.cpp b/qt/src/BindingPanel.cpp index fd2cc040..d4c976cd 100644 --- a/qt/src/BindingPanel.cpp +++ b/qt/src/BindingPanel.cpp @@ -1,5 +1,6 @@ #include "BindingPanel.hpp" #include "EmuApplication.hpp" +#include #include BindingPanel::BindingPanel(EmuApplication *app) @@ -11,8 +12,11 @@ BindingPanel::BindingPanel(EmuApplication *app) void BindingPanel::setTableWidget(QTableWidget *bindingTableWidget, EmuBinding *binding, int width, int height) { - keyboard_icon.addFile(":/icons/blackicons/key.svg"); - joypad_icon.addFile(":/icons/blackicons/joypad.svg"); + QString iconset = ":/icons/blackicons/"; + if (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark) + iconset = ":/icons/whiteicons/"; + keyboard_icon.addFile(iconset + "key.svg"); + joypad_icon.addFile(iconset + "joypad.svg"); this->binding_table_widget = bindingTableWidget; this->binding = binding; table_width = width; @@ -50,6 +54,8 @@ void BindingPanel::showEvent(QShowEvent *event) void BindingPanel::hideEvent(QHideEvent *event) { + if (awaiting_binding) + updateCellFromBinding(cell_row, cell_column); awaiting_binding = false; setRedirectInput(false); app->joypads_changed_callback = nullptr; diff --git a/qt/src/ControllerPanel.cpp b/qt/src/ControllerPanel.cpp index b86abd13..dc8804af 100644 --- a/qt/src/ControllerPanel.cpp +++ b/qt/src/ControllerPanel.cpp @@ -6,6 +6,7 @@ #include #include #include +#include ControllerPanel::ControllerPanel(EmuApplication *app) : BindingPanel(app) @@ -48,6 +49,13 @@ ControllerPanel::ControllerPanel(EmuApplication *app) editToolButton->setMenu(&edit_menu); editToolButton->setPopupMode(QToolButton::InstantPopup); + QString iconset = QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark ? ":/icons/whiteicons/" : ":/icons/blackicons/"; + const char *icons[] = { + "up", "down", "left", "right", "a", "b", "x", "y", "l", "r", "start", "select", "a", "b", "x", "y", "l", "r" + }; + for (int i = 0; i < 18; i++) + tableWidget_controller->verticalHeaderItem(i)->setIcon(QIcon(iconset + icons[i] + ".svg")); + recreateAutoAssignMenu(); onJoypadsChanged([&]{ recreateAutoAssignMenu(); }); } diff --git a/qt/src/EmuMainWindow.cpp b/qt/src/EmuMainWindow.cpp index d0edde0d..a2b8d322 100644 --- a/qt/src/EmuMainWindow.cpp +++ b/qt/src/EmuMainWindow.cpp @@ -300,6 +300,8 @@ void EmuMainWindow::createWidgets() // Options Menu auto options_menu = new QMenu(tr("&Options")); + + std::array setting_panels = { tr("&General..."), tr("&Display..."), tr("&Sound..."), @@ -307,17 +309,21 @@ void EmuMainWindow::createWidgets() tr("&Controllers..."), tr("Shortcu&ts..."), tr("&Files...") }; - const char *setting_icons[] = { ":/icons/blackicons/settings.svg", - ":/icons/blackicons/display.svg", - ":/icons/blackicons/sound.svg", - ":/icons/blackicons/emulation.svg", - ":/icons/blackicons/joypad.svg", - ":/icons/blackicons/keyboard.svg", - ":/icons/blackicons/folders.svg" }; + QString iconset = + QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark + ? ":/icons/whiteicons/" + : ":/icons/blackicons/"; + const char *setting_icons[] = { "settings.svg", + "display.svg", + "sound.svg", + "emulation.svg", + "joypad.svg", + "keyboard.svg", + "folders.svg" }; for (int i = 0; i < setting_panels.size(); i++) { - auto action = options_menu->addAction(QIcon(setting_icons[i]), setting_panels[i]); + auto action = options_menu->addAction(QIcon(iconset + setting_icons[i]), setting_panels[i]); QObject::connect(action, &QAction::triggered, [&, i] { if (!g_emu_settings_window) g_emu_settings_window = new EmuSettingsWindow(this, app); @@ -326,7 +332,7 @@ void EmuMainWindow::createWidgets() } options_menu->addSeparator(); - auto shader_settings_item = new QAction(QIcon(":/icons/blackicons/shader.svg"), tr("S&hader Settings...")); + auto shader_settings_item = new QAction(QIcon(iconset + "shader.svg"), tr("S&hader Settings...")); QObject::connect(shader_settings_item, &QAction::triggered, [&] { if (canvas) canvas->showParametersDialog(); diff --git a/qt/src/EmuSettingsWindow.cpp b/qt/src/EmuSettingsWindow.cpp index 5af7e259..9b822336 100644 --- a/qt/src/EmuSettingsWindow.cpp +++ b/qt/src/EmuSettingsWindow.cpp @@ -3,6 +3,7 @@ #include "EmuConfig.hpp" #include +#include #include EmuSettingsWindow::EmuSettingsWindow(QWidget *parent, EmuApplication *app_) @@ -45,6 +46,19 @@ EmuSettingsWindow::EmuSettingsWindow(QWidget *parent, EmuApplication *app_) stackedWidget->setCurrentIndex(panelList->currentRow()); }); + QString iconset = ":/icons/whiteicons/"; + if (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Light) + iconset = ":/icons/blackicons/"; + auto icon = [iconset](QString name) -> QIcon { return QIcon(iconset + name); }; + + panelList->item(0)->setIcon(icon("settings.svg")); + panelList->item(1)->setIcon(icon("display.svg")); + panelList->item(2)->setIcon(icon("sound.svg")); + panelList->item(3)->setIcon(icon("emulation.svg")); + panelList->item(4)->setIcon(icon("joypad.svg")); + panelList->item(5)->setIcon(icon("keyboard.svg")); + panelList->item(6)->setIcon(icon("folders.svg")); + connect(defaultsButton, &QPushButton::clicked, [&](bool) { auto section = stackedWidget->currentIndex(); bool restart_needed = app->config->setDefaults(stackedWidget->currentIndex()); diff --git a/qt/src/main.cpp b/qt/src/main.cpp index 13ef65e7..4717ee95 100644 --- a/qt/src/main.cpp +++ b/qt/src/main.cpp @@ -26,6 +26,7 @@ int main(int argc, char *argv[]) emu.qtapp = std::make_unique(argc, argv); QGuiApplication::setDesktopFileName("snes9x-gtk"); + //emu.qtapp->setStyle("fusion"); #ifndef _WIN32 auto quit_handler = [](int) { QApplication::quit(); }; diff --git a/qt/src/resources/snes9x.qrc b/qt/src/resources/snes9x.qrc index 399f8db2..267d5359 100644 --- a/qt/src/resources/snes9x.qrc +++ b/qt/src/resources/snes9x.qrc @@ -1,5 +1,26 @@ + whiteicons/a.svg + whiteicons/b.svg + whiteicons/display.svg + whiteicons/down.svg + whiteicons/emulation.svg + whiteicons/folders.svg + whiteicons/joypad.svg + whiteicons/key.svg + whiteicons/keyboard.svg + whiteicons/l.svg + whiteicons/left.svg + whiteicons/r.svg + whiteicons/right.svg + whiteicons/select.svg + whiteicons/settings.svg + whiteicons/shader.svg + whiteicons/sound.svg + whiteicons/start.svg + whiteicons/up.svg + whiteicons/x.svg + whiteicons/y.svg snes9x.svg blackicons/settings.svg blackicons/folders.svg diff --git a/qt/src/resources/whiteicons/a.svg b/qt/src/resources/whiteicons/a.svg new file mode 100644 index 00000000..16423d68 --- /dev/null +++ b/qt/src/resources/whiteicons/a.svg @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + diff --git a/qt/src/resources/whiteicons/b.svg b/qt/src/resources/whiteicons/b.svg new file mode 100644 index 00000000..42037a10 --- /dev/null +++ b/qt/src/resources/whiteicons/b.svg @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + diff --git a/qt/src/resources/whiteicons/display.svg b/qt/src/resources/whiteicons/display.svg new file mode 100644 index 00000000..1f02013c --- /dev/null +++ b/qt/src/resources/whiteicons/display.svg @@ -0,0 +1 @@ + diff --git a/qt/src/resources/whiteicons/down.svg b/qt/src/resources/whiteicons/down.svg new file mode 100644 index 00000000..d4f5b3cc --- /dev/null +++ b/qt/src/resources/whiteicons/down.svg @@ -0,0 +1,62 @@ + + + + + + + + + + + + + diff --git a/qt/src/resources/whiteicons/emulation.svg b/qt/src/resources/whiteicons/emulation.svg new file mode 100644 index 00000000..14b0989b --- /dev/null +++ b/qt/src/resources/whiteicons/emulation.svg @@ -0,0 +1 @@ + diff --git a/qt/src/resources/whiteicons/folders.svg b/qt/src/resources/whiteicons/folders.svg new file mode 100644 index 00000000..936439c9 --- /dev/null +++ b/qt/src/resources/whiteicons/folders.svg @@ -0,0 +1 @@ + diff --git a/qt/src/resources/whiteicons/joypad.svg b/qt/src/resources/whiteicons/joypad.svg new file mode 100644 index 00000000..97b288d8 --- /dev/null +++ b/qt/src/resources/whiteicons/joypad.svg @@ -0,0 +1,47 @@ + + + + + + + + diff --git a/qt/src/resources/whiteicons/key.svg b/qt/src/resources/whiteicons/key.svg new file mode 100644 index 00000000..7beb8158 --- /dev/null +++ b/qt/src/resources/whiteicons/key.svg @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + diff --git a/qt/src/resources/whiteicons/keyboard.svg b/qt/src/resources/whiteicons/keyboard.svg new file mode 100644 index 00000000..3c63bb69 --- /dev/null +++ b/qt/src/resources/whiteicons/keyboard.svg @@ -0,0 +1 @@ + diff --git a/qt/src/resources/whiteicons/l.svg b/qt/src/resources/whiteicons/l.svg new file mode 100644 index 00000000..ceb424c9 --- /dev/null +++ b/qt/src/resources/whiteicons/l.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + diff --git a/qt/src/resources/whiteicons/left.svg b/qt/src/resources/whiteicons/left.svg new file mode 100644 index 00000000..a2191880 --- /dev/null +++ b/qt/src/resources/whiteicons/left.svg @@ -0,0 +1,63 @@ + + + + + + + + + + + + + diff --git a/qt/src/resources/whiteicons/r.svg b/qt/src/resources/whiteicons/r.svg new file mode 100644 index 00000000..ea0b5695 --- /dev/null +++ b/qt/src/resources/whiteicons/r.svg @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + diff --git a/qt/src/resources/whiteicons/right.svg b/qt/src/resources/whiteicons/right.svg new file mode 100644 index 00000000..725f50dd --- /dev/null +++ b/qt/src/resources/whiteicons/right.svg @@ -0,0 +1,63 @@ + + + + + + + + + + + + + diff --git a/qt/src/resources/whiteicons/select.svg b/qt/src/resources/whiteicons/select.svg new file mode 100644 index 00000000..cb604c7f --- /dev/null +++ b/qt/src/resources/whiteicons/select.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + + diff --git a/qt/src/resources/whiteicons/settings.svg b/qt/src/resources/whiteicons/settings.svg new file mode 100644 index 00000000..00f89c2f --- /dev/null +++ b/qt/src/resources/whiteicons/settings.svg @@ -0,0 +1 @@ + diff --git a/qt/src/resources/whiteicons/shader.svg b/qt/src/resources/whiteicons/shader.svg new file mode 100644 index 00000000..33de7660 --- /dev/null +++ b/qt/src/resources/whiteicons/shader.svg @@ -0,0 +1 @@ + diff --git a/qt/src/resources/whiteicons/sound.svg b/qt/src/resources/whiteicons/sound.svg new file mode 100644 index 00000000..1c707f5f --- /dev/null +++ b/qt/src/resources/whiteicons/sound.svg @@ -0,0 +1 @@ + diff --git a/qt/src/resources/whiteicons/start.svg b/qt/src/resources/whiteicons/start.svg new file mode 100644 index 00000000..552f76f2 --- /dev/null +++ b/qt/src/resources/whiteicons/start.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + + diff --git a/qt/src/resources/whiteicons/up.svg b/qt/src/resources/whiteicons/up.svg new file mode 100644 index 00000000..aee521d4 --- /dev/null +++ b/qt/src/resources/whiteicons/up.svg @@ -0,0 +1,62 @@ + + + + + + + + + + + + + diff --git a/qt/src/resources/whiteicons/x.svg b/qt/src/resources/whiteicons/x.svg new file mode 100644 index 00000000..0e9bf26f --- /dev/null +++ b/qt/src/resources/whiteicons/x.svg @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + diff --git a/qt/src/resources/whiteicons/y.svg b/qt/src/resources/whiteicons/y.svg new file mode 100644 index 00000000..e2e3155b --- /dev/null +++ b/qt/src/resources/whiteicons/y.svg @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + +