Skip to content

Commit

Permalink
FEAT(client): Toggle positional audio shortcut
Browse files Browse the repository at this point in the history
Added new global shortcut that toggles the state of positional audio

Fixes mumble-voip#6133
  • Loading branch information
GrossTrevor committed Feb 4, 2024
1 parent c4b5858 commit 71d7bcf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mumble/GlobalShortcutTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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_
17 changes: 17 additions & 0 deletions src/mumble/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(QLatin1String("gsTogglePositionalAudio"));
gsTogglePositionalAudio->qsWhatsThis = tr("This will turn on/off positional audio");

#ifndef Q_OS_MAC
qstiIcon->show();
#endif
Expand Down Expand Up @@ -3350,6 +3355,14 @@ void MainWindow::on_gsHelpVersionCheck_triggered(bool down, QVariant) {
versionCheck();
}

void MainWindow::on_gsTogglePositionalAudio_triggered(bool down, QVariant) {
if (!down) {
return;
}

togglePositionalAudio(!Global::get().s.bPositionalAudio);
}


void MainWindow::whisperReleased(QVariant scdata) {
if (Global::get().iPushToTalk <= 0)
Expand Down Expand Up @@ -4152,6 +4165,10 @@ void MainWindow::versionCheck() {
new VersionCheck(false, this);
}

void MainWindow::togglePositionalAudio(const bool &newState) {
Global::get().s.bPositionalAudio = newState;
}

void MainWindow::on_muteCuePopup_triggered() {
if (Global::get().s.muteCueShown || Global::get().inConfigUI) {
return;
Expand Down
3 changes: 3 additions & 0 deletions src/mumble/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindow {
GlobalShortcut *gsConfigDialog, *gsAudioWizard, *gsConfigCert;
GlobalShortcut *gsAudioTTS;
GlobalShortcut *gsHelpAbout, *gsHelpAboutQt, *gsHelpVersionCheck;
GlobalShortcut *gsTogglePositionalAudio;

DockTitleBar *dtbLogDockTitle, *dtbChatDockTitle;

Expand Down Expand Up @@ -336,6 +337,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);
Expand Down Expand Up @@ -431,6 +433,7 @@ public slots:
void openAboutDialog();
void openAboutQtDialog();
void versionCheck();
void togglePositionalAudio(const bool &newState);
};

#endif

0 comments on commit 71d7bcf

Please sign in to comment.