From 4bc4fdf5ff69e8a8eeb7e62635c50ea4c84eb952 Mon Sep 17 00:00:00 2001 From: CJBok Date: Tue, 28 Jan 2020 23:59:30 +0100 Subject: [PATCH 1/3] GUI: Togglable graphics settings buttons in status bar --- dist/qt_themes/colorful/style.qrc | 2 +- dist/qt_themes/colorful/style.qss | 4 -- dist/qt_themes/default/default.qrc | 13 +--- dist/qt_themes/default/style.qss | 35 +++++++++++ dist/qt_themes/qdarkstyle/style.qss | 38 +++++++++++ src/yuzu/main.cpp | 98 ++++++++++++++++++++++++++--- src/yuzu/main.h | 4 ++ 7 files changed, 172 insertions(+), 22 deletions(-) delete mode 100644 dist/qt_themes/colorful/style.qss create mode 100644 dist/qt_themes/default/style.qss diff --git a/dist/qt_themes/colorful/style.qrc b/dist/qt_themes/colorful/style.qrc index af2f3fd561..36735519a5 100644 --- a/dist/qt_themes/colorful/style.qrc +++ b/dist/qt_themes/colorful/style.qrc @@ -10,6 +10,6 @@ icons/256x256/plus_folder.png - style.qss + ../default/style.qss diff --git a/dist/qt_themes/colorful/style.qss b/dist/qt_themes/colorful/style.qss deleted file mode 100644 index 413fc81da7..0000000000 --- a/dist/qt_themes/colorful/style.qss +++ /dev/null @@ -1,4 +0,0 @@ -/* - This file is intentionally left blank. - We do not want to apply any stylesheet for colorful, only icons. -*/ diff --git a/dist/qt_themes/default/default.qrc b/dist/qt_themes/default/default.qrc index d1a0ee1bea..c51fdb26cc 100644 --- a/dist/qt_themes/default/default.qrc +++ b/dist/qt_themes/default/default.qrc @@ -1,25 +1,18 @@ icons/index.theme - icons/16x16/checked.png - icons/16x16/failed.png - icons/16x16/lock.png - icons/48x48/bad_folder.png - icons/48x48/chip.png - icons/48x48/folder.png - icons/48x48/plus.png - icons/48x48/sd_card.png - icons/256x256/yuzu.png - icons/256x256/plus_folder.png + + style.qss + diff --git a/dist/qt_themes/default/style.qss b/dist/qt_themes/default/style.qss new file mode 100644 index 0000000000..6b5953e385 --- /dev/null +++ b/dist/qt_themes/default/style.qss @@ -0,0 +1,35 @@ +QPushButton#TogglableStatusBarButton { + color: #959595; + border: 1px solid transparent; + background-color: transparent; + padding: 0px 3px 0px 3px; + text-align: center; +} + +QPushButton#TogglableStatusBarButton:checked { + color: #000000; +} + +QPushButton#TogglableStatusBarButton:hover { + border: 1px solid #76797C; +} + +QPushButton#RendererStatusBarButton { + color: #656565; + border: 1px solid transparent; + background-color: transparent; + padding: 0px 3px 0px 3px; + text-align: center; +} + +QPushButton#RendererStatusBarButton:hover { + border: 1px solid #76797C; +} + +QPushButton#RendererStatusBarButton:checked { + color: #e85c00; +} + +QPushButton#RendererStatusBarButton:!checked{ + color: #0066ff; +} diff --git a/dist/qt_themes/qdarkstyle/style.qss b/dist/qt_themes/qdarkstyle/style.qss index 9814b06ddc..7d088a7197 100644 --- a/dist/qt_themes/qdarkstyle/style.qss +++ b/dist/qt_themes/qdarkstyle/style.qss @@ -1236,3 +1236,41 @@ QToolButton:disabled, QPlainTextEdit:disabled { background-color: #2b2e31; } + +QPushButton#TogglableStatusBarButton { + min-width: 0px; + color: #656565; + border: 1px solid transparent; + background-color: transparent; + padding: 0px 3px 0px 3px; + text-align: center; +} + +QPushButton#TogglableStatusBarButton:checked { + color: #ffffff; +} + +QPushButton#TogglableStatusBarButton:hover { + border: 1px solid #76797C; +} + +QPushButton#RendererStatusBarButton { + min-width: 0px; + color: #656565; + border: 1px solid transparent; + background-color: transparent; + padding: 0px 3px 0px 3px; + text-align: center; +} + +QPushButton#RendererStatusBarButton:hover { + border: 1px solid #76797C; +} + +QPushButton#RendererStatusBarButton:checked { + color: #e85c00; +} + +QPushButton#RendererStatusBarButton:!checked{ + color: #00ccdd; +} \ No newline at end of file diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index b5dd3e0d60..135adde06d 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -454,11 +454,10 @@ void GMainWindow::InitializeWidgets() { // Create status bar message_label = new QLabel(); // Configured separately for left alignment - message_label->setVisible(false); message_label->setFrameStyle(QFrame::NoFrame); message_label->setContentsMargins(4, 0, 4, 0); message_label->setAlignment(Qt::AlignLeft); - statusBar()->addPermanentWidget(message_label, 1); + statusBar()->addPermanentWidget(message_label, 01); emu_speed_label = new QLabel(); emu_speed_label->setToolTip( @@ -476,8 +475,73 @@ void GMainWindow::InitializeWidgets() { label->setVisible(false); label->setFrameStyle(QFrame::NoFrame); label->setContentsMargins(4, 0, 4, 0); - statusBar()->addPermanentWidget(label, 0); + statusBar()->addPermanentWidget(label); } + + // Setup Dock button + dock_status_button = new QPushButton(); + dock_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton")); + dock_status_button->setFocusPolicy(Qt::NoFocus); + connect(dock_status_button, &QPushButton::clicked, [&] { + Settings::values.use_docked_mode = !Settings::values.use_docked_mode; + dock_status_button->setChecked(Settings::values.use_docked_mode); + OnDockedModeChanged(!Settings::values.use_docked_mode, Settings::values.use_docked_mode); + }); + dock_status_button->setText(tr("DOCK")); + dock_status_button->setCheckable(true); + dock_status_button->setChecked(Settings::values.use_docked_mode); + statusBar()->insertPermanentWidget(0, dock_status_button); + + // Setup ASync button + async_status_button = new QPushButton(); + async_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton")); + async_status_button->setFocusPolicy(Qt::NoFocus); + connect(async_status_button, &QPushButton::clicked, [&] { + if (emulation_running) { + return; + } + Settings::values.use_asynchronous_gpu_emulation = + !Settings::values.use_asynchronous_gpu_emulation; + async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation); + Settings::Apply(); + }); + async_status_button->setText(tr("ASYNC")); + async_status_button->setCheckable(true); + async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation); + statusBar()->insertPermanentWidget(0, async_status_button); + + // Setup Renderer API button + renderer_status_button = new QPushButton(); + renderer_status_button->setObjectName(QStringLiteral("RendererStatusBarButton")); + renderer_status_button->setCheckable(true); + renderer_status_button->setFocusPolicy(Qt::NoFocus); + connect(renderer_status_button, &QPushButton::toggled, [=](bool checked) { + renderer_status_button->setText(checked ? tr("VULKAN") : tr("OPENGL")); + }); + renderer_status_button->toggle(); + +#ifndef HAS_VULKAN + renderer_status_button->setChecked(false); + renderer_status_button->setCheckable(false); + renderer_status_button->setDisabled(true); +#else + renderer_status_button->setChecked(Settings::values.renderer_backend == + Settings::RendererBackend::Vulkan); + connect(renderer_status_button, &QPushButton::clicked, [=] { + if (emulation_running) { + return; + } + if (renderer_status_button->isChecked()) { + Settings::values.renderer_backend = Settings::RendererBackend::Vulkan; + } else { + Settings::values.renderer_backend = Settings::RendererBackend::OpenGL; + } + + Settings::Apply(); + }); +#endif // HAS_VULKAN + statusBar()->insertPermanentWidget(0, renderer_status_button); + statusBar()->setVisible(true); setStyleSheet(QStringLiteral("QStatusBar::item{border: none;}")); } @@ -640,6 +704,7 @@ void GMainWindow::InitializeHotkeys() { Settings::values.use_docked_mode = !Settings::values.use_docked_mode; OnDockedModeChanged(!Settings::values.use_docked_mode, Settings::values.use_docked_mode); + dock_status_button->setChecked(Settings::values.use_docked_mode); }); } @@ -1000,6 +1065,8 @@ void GMainWindow::BootGame(const QString& filename) { game_list_placeholder->hide(); } status_bar_update_timer.start(2000); + async_status_button->setDisabled(true); + renderer_status_button->setDisabled(true); const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID(); @@ -1065,10 +1132,13 @@ void GMainWindow::ShutdownGame() { // Disable status bar updates status_bar_update_timer.stop(); - message_label->setVisible(false); emu_speed_label->setVisible(false); game_fps_label->setVisible(false); emu_frametime_label->setVisible(false); + async_status_button->setEnabled(true); +#ifdef HAS_VULKAN + renderer_status_button->setEnabled(true); +#endif emulation_running = false; @@ -1836,6 +1906,13 @@ void GMainWindow::OnConfigure() { } config->Save(); + + dock_status_button->setChecked(Settings::values.use_docked_mode); + async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation); +#ifdef HAS_VULKAN + renderer_status_button->setChecked( + Settings::values.renderer_backend == Settings::RendererBackend::Vulkan ? true : false); +#endif } void GMainWindow::OnLoadAmiibo() { @@ -2028,7 +2105,6 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det if (emu_thread) { emu_thread->SetRunning(true); message_label->setText(status_message); - message_label->setVisible(true); } } } @@ -2290,8 +2366,16 @@ void GMainWindow::UpdateUITheme() { QStringList theme_paths(default_theme_paths); if (is_default_theme || current_theme.isEmpty()) { - qApp->setStyleSheet({}); - setStyleSheet({}); + const QString theme_uri(QStringLiteral(":default/style.qss")); + QFile f(theme_uri); + if (f.open(QFile::ReadOnly | QFile::Text)) { + QTextStream ts(&f); + qApp->setStyleSheet(ts.readAll()); + setStyleSheet(ts.readAll()); + } else { + qApp->setStyleSheet({}); + setStyleSheet({}); + } theme_paths.append(default_icons); QIcon::setThemeName(default_icons); } else { diff --git a/src/yuzu/main.h b/src/yuzu/main.h index a56f9a981f..537c7d5edd 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -27,6 +27,7 @@ class LoadingScreen; class MicroProfileDialog; class ProfilerWidget; class QLabel; +class QPushButton; class WaitTreeWidget; enum class GameListOpenTarget; class GameListPlaceholder; @@ -229,6 +230,9 @@ private: QLabel* emu_speed_label = nullptr; QLabel* game_fps_label = nullptr; QLabel* emu_frametime_label = nullptr; + QPushButton* async_status_button = nullptr; + QPushButton* renderer_status_button = nullptr; + QPushButton* dock_status_button = nullptr; QTimer status_bar_update_timer; std::unique_ptr config; From 6e87111f91ebfe1a0b9f544fd0b5d7d7262b8fe9 Mon Sep 17 00:00:00 2001 From: CJBok Date: Wed, 29 Jan 2020 00:02:28 +0100 Subject: [PATCH 2/3] minor corrections --- src/yuzu/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 135adde06d..a32de5ea3f 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -457,7 +457,7 @@ void GMainWindow::InitializeWidgets() { message_label->setFrameStyle(QFrame::NoFrame); message_label->setContentsMargins(4, 0, 4, 0); message_label->setAlignment(Qt::AlignLeft); - statusBar()->addPermanentWidget(message_label, 01); + statusBar()->addPermanentWidget(message_label, 1); emu_speed_label = new QLabel(); emu_speed_label->setToolTip( @@ -1911,7 +1911,7 @@ void GMainWindow::OnConfigure() { async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation); #ifdef HAS_VULKAN renderer_status_button->setChecked( - Settings::values.renderer_backend == Settings::RendererBackend::Vulkan ? true : false); + Settings::values.renderer_backend == Settings::RendererBackend::Vulkan); #endif } From 8d6b4e836cfb0652ce8455bae812cba7c9ff514d Mon Sep 17 00:00:00 2001 From: CJBok Date: Wed, 29 Jan 2020 05:43:55 +0100 Subject: [PATCH 3/3] clang --- src/yuzu/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index a32de5ea3f..666c9b7d55 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1910,8 +1910,8 @@ void GMainWindow::OnConfigure() { dock_status_button->setChecked(Settings::values.use_docked_mode); async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation); #ifdef HAS_VULKAN - renderer_status_button->setChecked( - Settings::values.renderer_backend == Settings::RendererBackend::Vulkan); + renderer_status_button->setChecked(Settings::values.renderer_backend == + Settings::RendererBackend::Vulkan); #endif }