From 5c9ebfa943d3276169d7724f85e98984f35dbcaa Mon Sep 17 00:00:00 2001 From: GrossTrevor Date: Sun, 4 Feb 2024 12:12:32 -0500 Subject: [PATCH] FEAT(client): Toggle positional audio shortcut Added new global shortcut that toggles the state of positional audio Fixes #6133 --- src/mumble/GlobalShortcutTypes.h | 2 ++ src/mumble/MainWindow.cpp | 17 +++++++++++++++++ src/mumble/MainWindow.h | 3 +++ 3 files changed, 22 insertions(+) diff --git a/src/mumble/GlobalShortcutTypes.h b/src/mumble/GlobalShortcutTypes.h index c04eb3ae1..67b03d9f2 100644 --- a/src/mumble/GlobalShortcutTypes.h +++ b/src/mumble/GlobalShortcutTypes.h @@ -57,6 +57,7 @@ enum Type { HelpAbout, HelpAboutQt, HelpVersionCheck, + TogglePositionalAudio, }; // A few assertions meant to catch, if anyone inserts a new value in-between instead of appending @@ -65,6 +66,7 @@ static_assert(PushToTalk == 1, "You may only append to the end of the enum!"); static_assert(ToggleMinimalView == 9, "You may only append to the end of the enum!"); static_assert(ToggleSearch == 22, "You may only append to the end of the enum!"); static_assert(HelpVersionCheck == 43, "You may only append to the end of the enum!"); +static_assert(TogglePositionalAudio == 44, "You may only append to the end of the enum!"); } // namespace GlobalShortcutType #endif // MUMBLE_MUMBLE_GLOBALSHORTCUTTYPES_H_ diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index 4c0f5e2ee..5a327c915 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -412,6 +412,11 @@ void MainWindow::createActions() { gsHelpVersionCheck->setObjectName(QLatin1String("gsHelpVersionCheck")); gsHelpVersionCheck->qsWhatsThis = tr("This will check if mumble is up to date"); + gsTogglePositionalAudio = new GlobalShortcut(this, GlobalShortcutType::TogglePositionalAudio, + tr("Toggle positional audio", "Global Shortcut")); + gsTogglePositionalAudio->setObjectName("gsTogglePositionalAudio"); + gsTogglePositionalAudio->qsWhatsThis = tr("This will toggle positional audio on/off"); + #ifndef Q_OS_MAC qstiIcon->show(); #endif @@ -3386,6 +3391,14 @@ void MainWindow::on_gsHelpVersionCheck_triggered(bool down, QVariant) { versionCheck(); } +void MainWindow::on_gsTogglePositionalAudio_triggered(bool down, QVariant) { + if (!down) { + return; + } + + enablePositionalAudio(!Global::get().s.bPositionalAudio); +} + void MainWindow::whisperReleased(QVariant scdata) { if (Global::get().iPushToTalk <= 0) @@ -4188,6 +4201,10 @@ void MainWindow::versionCheck() { new VersionCheck(false, this); } +void MainWindow::enablePositionalAudio(bool enable) { + Global::get().s.bPositionalAudio = enable; +} + void MainWindow::on_muteCuePopup_triggered() { if (Global::get().s.muteCueShown || Global::get().inConfigUI) { return; diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h index d3592f671..e8c848d58 100644 --- a/src/mumble/MainWindow.h +++ b/src/mumble/MainWindow.h @@ -108,6 +108,7 @@ public: GlobalShortcut *gsConfigDialog, *gsAudioWizard, *gsConfigCert; GlobalShortcut *gsAudioTTS; GlobalShortcut *gsHelpAbout, *gsHelpAboutQt, *gsHelpVersionCheck; + GlobalShortcut *gsTogglePositionalAudio; DockTitleBar *dtbLogDockTitle, *dtbChatDockTitle; @@ -342,6 +343,7 @@ public slots: void on_gsHelpAbout_triggered(bool, QVariant); void on_gsHelpAboutQt_triggered(bool, QVariant); void on_gsHelpVersionCheck_triggered(bool, QVariant); + void on_gsTogglePositionalAudio_triggered(bool, QVariant); void on_Reconnect_timeout(); void on_Icon_activated(QSystemTrayIcon::ActivationReason); @@ -437,6 +439,7 @@ public: void openAboutDialog(); void openAboutQtDialog(); void versionCheck(); + void enablePositionalAudio(bool enable); }; #endif