GUI: Togglable graphics settings buttons in status bar

This commit is contained in:
CJBok 2020-01-28 23:59:30 +01:00
parent c457e47297
commit 4bc4fdf5ff
7 changed files with 172 additions and 22 deletions

View File

@ -10,6 +10,6 @@
<file alias="256x256/plus_folder.png">icons/256x256/plus_folder.png</file> <file alias="256x256/plus_folder.png">icons/256x256/plus_folder.png</file>
</qresource> </qresource>
<qresource prefix="colorful"> <qresource prefix="colorful">
<file>style.qss</file> <file alias="style.qss">../default/style.qss</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -1,4 +0,0 @@
/*
This file is intentionally left blank.
We do not want to apply any stylesheet for colorful, only icons.
*/

View File

@ -1,25 +1,18 @@
<RCC> <RCC>
<qresource prefix="icons/default"> <qresource prefix="icons/default">
<file alias="index.theme">icons/index.theme</file> <file alias="index.theme">icons/index.theme</file>
<file alias="16x16/checked.png">icons/16x16/checked.png</file> <file alias="16x16/checked.png">icons/16x16/checked.png</file>
<file alias="16x16/failed.png">icons/16x16/failed.png</file> <file alias="16x16/failed.png">icons/16x16/failed.png</file>
<file alias="16x16/lock.png">icons/16x16/lock.png</file> <file alias="16x16/lock.png">icons/16x16/lock.png</file>
<file alias="48x48/bad_folder.png">icons/48x48/bad_folder.png</file> <file alias="48x48/bad_folder.png">icons/48x48/bad_folder.png</file>
<file alias="48x48/chip.png">icons/48x48/chip.png</file> <file alias="48x48/chip.png">icons/48x48/chip.png</file>
<file alias="48x48/folder.png">icons/48x48/folder.png</file> <file alias="48x48/folder.png">icons/48x48/folder.png</file>
<file alias="48x48/plus.png">icons/48x48/plus.png</file> <file alias="48x48/plus.png">icons/48x48/plus.png</file>
<file alias="48x48/sd_card.png">icons/48x48/sd_card.png</file> <file alias="48x48/sd_card.png">icons/48x48/sd_card.png</file>
<file alias="256x256/yuzu.png">icons/256x256/yuzu.png</file> <file alias="256x256/yuzu.png">icons/256x256/yuzu.png</file>
<file alias="256x256/plus_folder.png">icons/256x256/plus_folder.png</file> <file alias="256x256/plus_folder.png">icons/256x256/plus_folder.png</file>
</qresource> </qresource>
<qresource prefix="default">
<file>style.qss</file>
</qresource>
</RCC> </RCC>

35
dist/qt_themes/default/style.qss vendored Normal file
View File

@ -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;
}

View File

@ -1236,3 +1236,41 @@ QToolButton:disabled,
QPlainTextEdit:disabled { QPlainTextEdit:disabled {
background-color: #2b2e31; 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;
}

View File

@ -454,11 +454,10 @@ void GMainWindow::InitializeWidgets() {
// Create status bar // Create status bar
message_label = new QLabel(); message_label = new QLabel();
// Configured separately for left alignment // Configured separately for left alignment
message_label->setVisible(false);
message_label->setFrameStyle(QFrame::NoFrame); message_label->setFrameStyle(QFrame::NoFrame);
message_label->setContentsMargins(4, 0, 4, 0); message_label->setContentsMargins(4, 0, 4, 0);
message_label->setAlignment(Qt::AlignLeft); message_label->setAlignment(Qt::AlignLeft);
statusBar()->addPermanentWidget(message_label, 1); statusBar()->addPermanentWidget(message_label, 01);
emu_speed_label = new QLabel(); emu_speed_label = new QLabel();
emu_speed_label->setToolTip( emu_speed_label->setToolTip(
@ -476,8 +475,73 @@ void GMainWindow::InitializeWidgets() {
label->setVisible(false); label->setVisible(false);
label->setFrameStyle(QFrame::NoFrame); label->setFrameStyle(QFrame::NoFrame);
label->setContentsMargins(4, 0, 4, 0); 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); statusBar()->setVisible(true);
setStyleSheet(QStringLiteral("QStatusBar::item{border: none;}")); setStyleSheet(QStringLiteral("QStatusBar::item{border: none;}"));
} }
@ -640,6 +704,7 @@ void GMainWindow::InitializeHotkeys() {
Settings::values.use_docked_mode = !Settings::values.use_docked_mode; Settings::values.use_docked_mode = !Settings::values.use_docked_mode;
OnDockedModeChanged(!Settings::values.use_docked_mode, OnDockedModeChanged(!Settings::values.use_docked_mode,
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(); game_list_placeholder->hide();
} }
status_bar_update_timer.start(2000); 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(); const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID();
@ -1065,10 +1132,13 @@ void GMainWindow::ShutdownGame() {
// Disable status bar updates // Disable status bar updates
status_bar_update_timer.stop(); status_bar_update_timer.stop();
message_label->setVisible(false);
emu_speed_label->setVisible(false); emu_speed_label->setVisible(false);
game_fps_label->setVisible(false); game_fps_label->setVisible(false);
emu_frametime_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; emulation_running = false;
@ -1836,6 +1906,13 @@ void GMainWindow::OnConfigure() {
} }
config->Save(); 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() { void GMainWindow::OnLoadAmiibo() {
@ -2028,7 +2105,6 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det
if (emu_thread) { if (emu_thread) {
emu_thread->SetRunning(true); emu_thread->SetRunning(true);
message_label->setText(status_message); message_label->setText(status_message);
message_label->setVisible(true);
} }
} }
} }
@ -2290,8 +2366,16 @@ void GMainWindow::UpdateUITheme() {
QStringList theme_paths(default_theme_paths); QStringList theme_paths(default_theme_paths);
if (is_default_theme || current_theme.isEmpty()) { if (is_default_theme || current_theme.isEmpty()) {
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({}); qApp->setStyleSheet({});
setStyleSheet({}); setStyleSheet({});
}
theme_paths.append(default_icons); theme_paths.append(default_icons);
QIcon::setThemeName(default_icons); QIcon::setThemeName(default_icons);
} else { } else {

View File

@ -27,6 +27,7 @@ class LoadingScreen;
class MicroProfileDialog; class MicroProfileDialog;
class ProfilerWidget; class ProfilerWidget;
class QLabel; class QLabel;
class QPushButton;
class WaitTreeWidget; class WaitTreeWidget;
enum class GameListOpenTarget; enum class GameListOpenTarget;
class GameListPlaceholder; class GameListPlaceholder;
@ -229,6 +230,9 @@ private:
QLabel* emu_speed_label = nullptr; QLabel* emu_speed_label = nullptr;
QLabel* game_fps_label = nullptr; QLabel* game_fps_label = nullptr;
QLabel* emu_frametime_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; QTimer status_bar_update_timer;
std::unique_ptr<Config> config; std::unique_ptr<Config> config;