summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/yuzu/main.cpp105
-rw-r--r--src/yuzu/main.h9
2 files changed, 90 insertions, 24 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 571eacf9f..b85541619 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -957,6 +957,38 @@ void GMainWindow::InitializeWidgets() {
957 tas_label->setFocusPolicy(Qt::NoFocus); 957 tas_label->setFocusPolicy(Qt::NoFocus);
958 statusBar()->insertPermanentWidget(0, tas_label); 958 statusBar()->insertPermanentWidget(0, tas_label);
959 959
960 volume_popup = new QWidget(this);
961 volume_popup->setWindowFlags(Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::Popup);
962 volume_popup->setLayout(new QVBoxLayout());
963 volume_popup->setMinimumWidth(200);
964
965 volume_slider = new QSlider(Qt::Horizontal);
966 volume_slider->setObjectName(QStringLiteral("volume_slider"));
967 volume_slider->setMaximum(200);
968 volume_slider->setPageStep(5);
969 connect(volume_slider, &QSlider::valueChanged, this, [this](int percentage) {
970 Settings::values.audio_muted = false;
971 const auto volume = static_cast<u8>(percentage);
972 Settings::values.volume.SetValue(volume);
973 UpdateVolumeUI();
974 });
975 volume_popup->layout()->addWidget(volume_slider);
976
977 volume_button = new QPushButton();
978 volume_button->setObjectName(QStringLiteral("TogglableStatusBarButton"));
979 volume_button->setFocusPolicy(Qt::NoFocus);
980 volume_button->setCheckable(true);
981 UpdateVolumeUI();
982 connect(volume_button, &QPushButton::clicked, this, [&] {
983 UpdateVolumeUI();
984 volume_popup->setVisible(!volume_popup->isVisible());
985 QRect rect = volume_button->geometry();
986 QPoint bottomLeft = statusBar()->mapToGlobal(rect.topLeft());
987 bottomLeft.setY(bottomLeft.y() - volume_popup->geometry().height());
988 volume_popup->setGeometry(QRect(bottomLeft, QSize(rect.width(), rect.height())));
989 });
990 statusBar()->insertPermanentWidget(0, volume_button);
991
960 // setup AA button 992 // setup AA button
961 aa_status_button = new QPushButton(); 993 aa_status_button = new QPushButton();
962 aa_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton")); 994 aa_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton"));
@@ -1124,30 +1156,9 @@ void GMainWindow::InitializeHotkeys() {
1124 &GMainWindow::OnToggleAdaptingFilter); 1156 &GMainWindow::OnToggleAdaptingFilter);
1125 connect_shortcut(QStringLiteral("Change Docked Mode"), &GMainWindow::OnToggleDockedMode); 1157 connect_shortcut(QStringLiteral("Change Docked Mode"), &GMainWindow::OnToggleDockedMode);
1126 connect_shortcut(QStringLiteral("Change GPU Accuracy"), &GMainWindow::OnToggleGpuAccuracy); 1158 connect_shortcut(QStringLiteral("Change GPU Accuracy"), &GMainWindow::OnToggleGpuAccuracy);
1127 connect_shortcut(QStringLiteral("Audio Mute/Unmute"), 1159 connect_shortcut(QStringLiteral("Audio Mute/Unmute"), &GMainWindow::OnMute);
1128 [] { Settings::values.audio_muted = !Settings::values.audio_muted; }); 1160 connect_shortcut(QStringLiteral("Audio Volume Down"), &GMainWindow::OnDecreaseVolume);
1129 connect_shortcut(QStringLiteral("Audio Volume Down"), [] { 1161 connect_shortcut(QStringLiteral("Audio Volume Up"), &GMainWindow::OnIncreaseVolume);
1130 const auto current_volume = static_cast<s32>(Settings::values.volume.GetValue());
1131 int step = 5;
1132 if (current_volume <= 30) {
1133 step = 2;
1134 }
1135 if (current_volume <= 6) {
1136 step = 1;
1137 }
1138 Settings::values.volume.SetValue(std::max(current_volume - step, 0));
1139 });
1140 connect_shortcut(QStringLiteral("Audio Volume Up"), [] {
1141 const auto current_volume = static_cast<s32>(Settings::values.volume.GetValue());
1142 int step = 5;
1143 if (current_volume < 30) {
1144 step = 2;
1145 }
1146 if (current_volume < 6) {
1147 step = 1;
1148 }
1149 Settings::values.volume.SetValue(current_volume + step);
1150 });
1151 connect_shortcut(QStringLiteral("Toggle Framerate Limit"), [] { 1162 connect_shortcut(QStringLiteral("Toggle Framerate Limit"), [] {
1152 Settings::values.use_speed_limit.SetValue(!Settings::values.use_speed_limit.GetValue()); 1163 Settings::values.use_speed_limit.SetValue(!Settings::values.use_speed_limit.GetValue());
1153 }); 1164 });
@@ -3462,6 +3473,39 @@ void GMainWindow::OnToggleGpuAccuracy() {
3462 UpdateGPUAccuracyButton(); 3473 UpdateGPUAccuracyButton();
3463} 3474}
3464 3475
3476void GMainWindow::OnMute() {
3477 Settings::values.audio_muted = !Settings::values.audio_muted;
3478 UpdateVolumeUI();
3479}
3480
3481void GMainWindow::OnDecreaseVolume() {
3482 Settings::values.audio_muted = false;
3483 const auto current_volume = static_cast<s32>(Settings::values.volume.GetValue());
3484 int step = 5;
3485 if (current_volume <= 30) {
3486 step = 2;
3487 }
3488 if (current_volume <= 6) {
3489 step = 1;
3490 }
3491 Settings::values.volume.SetValue(std::max(current_volume - step, 0));
3492 UpdateVolumeUI();
3493}
3494
3495void GMainWindow::OnIncreaseVolume() {
3496 Settings::values.audio_muted = false;
3497 const auto current_volume = static_cast<s32>(Settings::values.volume.GetValue());
3498 int step = 5;
3499 if (current_volume < 30) {
3500 step = 2;
3501 }
3502 if (current_volume < 6) {
3503 step = 1;
3504 }
3505 Settings::values.volume.SetValue(current_volume + step);
3506 UpdateVolumeUI();
3507}
3508
3465void GMainWindow::OnToggleAdaptingFilter() { 3509void GMainWindow::OnToggleAdaptingFilter() {
3466 auto filter = Settings::values.scaling_filter.GetValue(); 3510 auto filter = Settings::values.scaling_filter.GetValue();
3467 if (filter == Settings::ScalingFilter::LastFilter) { 3511 if (filter == Settings::ScalingFilter::LastFilter) {
@@ -3924,6 +3968,18 @@ void GMainWindow::UpdateAAText() {
3924 } 3968 }
3925} 3969}
3926 3970
3971void GMainWindow::UpdateVolumeUI() {
3972 const auto volume_value = static_cast<int>(Settings::values.volume.GetValue());
3973 volume_slider->setValue(volume_value);
3974 if (Settings::values.audio_muted) {
3975 volume_button->setChecked(false);
3976 volume_button->setText(tr("VOLUME: MUTE", "Volume percentage (e.g. 50%)"));
3977 } else {
3978 volume_button->setChecked(true);
3979 volume_button->setText(tr("VOLUME: %1%", "Volume percentage (e.g. 50%)").arg(volume_value));
3980 }
3981}
3982
3927void GMainWindow::UpdateStatusButtons() { 3983void GMainWindow::UpdateStatusButtons() {
3928 renderer_status_button->setChecked(Settings::values.renderer_backend.GetValue() == 3984 renderer_status_button->setChecked(Settings::values.renderer_backend.GetValue() ==
3929 Settings::RendererBackend::Vulkan); 3985 Settings::RendererBackend::Vulkan);
@@ -3932,6 +3988,7 @@ void GMainWindow::UpdateStatusButtons() {
3932 UpdateDockedButton(); 3988 UpdateDockedButton();
3933 UpdateFilterText(); 3989 UpdateFilterText();
3934 UpdateAAText(); 3990 UpdateAAText();
3991 UpdateVolumeUI();
3935} 3992}
3936 3993
3937void GMainWindow::UpdateUISettings() { 3994void GMainWindow::UpdateUISettings() {
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index 0f61abc7a..a23b373a5 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -37,6 +37,8 @@ class QLabel;
37class MultiplayerState; 37class MultiplayerState;
38class QPushButton; 38class QPushButton;
39class QProgressDialog; 39class QProgressDialog;
40class QSlider;
41class QHBoxLayout;
40class WaitTreeWidget; 42class WaitTreeWidget;
41enum class GameListOpenTarget; 43enum class GameListOpenTarget;
42enum class GameListRemoveTarget; 44enum class GameListRemoveTarget;
@@ -312,6 +314,9 @@ private slots:
312 void OnMenuRecentFile(); 314 void OnMenuRecentFile();
313 void OnConfigure(); 315 void OnConfigure();
314 void OnConfigureTas(); 316 void OnConfigureTas();
317 void OnDecreaseVolume();
318 void OnIncreaseVolume();
319 void OnMute();
315 void OnTasStartStop(); 320 void OnTasStartStop();
316 void OnTasRecord(); 321 void OnTasRecord();
317 void OnTasReset(); 322 void OnTasReset();
@@ -364,6 +369,7 @@ private:
364 void UpdateAPIText(); 369 void UpdateAPIText();
365 void UpdateFilterText(); 370 void UpdateFilterText();
366 void UpdateAAText(); 371 void UpdateAAText();
372 void UpdateVolumeUI();
367 void UpdateStatusBar(); 373 void UpdateStatusBar();
368 void UpdateGPUAccuracyButton(); 374 void UpdateGPUAccuracyButton();
369 void UpdateStatusButtons(); 375 void UpdateStatusButtons();
@@ -412,6 +418,9 @@ private:
412 QPushButton* dock_status_button = nullptr; 418 QPushButton* dock_status_button = nullptr;
413 QPushButton* filter_status_button = nullptr; 419 QPushButton* filter_status_button = nullptr;
414 QPushButton* aa_status_button = nullptr; 420 QPushButton* aa_status_button = nullptr;
421 QPushButton* volume_button = nullptr;
422 QWidget* volume_popup = nullptr;
423 QSlider* volume_slider = nullptr;
415 QTimer status_bar_update_timer; 424 QTimer status_bar_update_timer;
416 425
417 std::unique_ptr<Config> config; 426 std::unique_ptr<Config> config;