From e0617e0660c042afbbab3fdc3c5c6dd5b1cf07ce Mon Sep 17 00:00:00 2001 From: Mikkel Krautz Date: Tue, 27 May 2008 22:57:10 +0000 Subject: [PATCH] Implement volume shortcuts (for feature request #1954994: volume keybind) git-svn-id: https://mumble.svn.sourceforge.net/svnroot/mumble/trunk@1162 05730e5d-ab1b-0410-a4ac-84af385074fa --- src/mumble/AudioOutput.ui | 2 +- src/mumble/MainWindow.cpp | 22 ++++++++++++++++++++++ src/mumble/MainWindow.h | 5 +++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/mumble/AudioOutput.ui b/src/mumble/AudioOutput.ui index a440084cf..850500235 100644 --- a/src/mumble/AudioOutput.ui +++ b/src/mumble/AudioOutput.ui @@ -167,7 +167,7 @@ <b>This adjusts the volume of incoming speech.</b><br />Note that this can only be used to decrease the volume. No amplification is possible. - 10 + 0 100 diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index 76443f4fe..63aea0328 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -197,6 +197,12 @@ void MainWindow::createActions() { gsMinimal=new GlobalShortcut(this, idx++, tr("Toggle Minimal", "Global Shortcut")); gsMinimal->setObjectName(QLatin1String("ToggleMinimal")); + gsVolumeUp=new GlobalShortcut(this, idx++, tr("Volume Up (+10%)", "Global Shortcut")); + gsVolumeUp->setObjectName(QLatin1String("VolumeUp")); + + gsVolumeDown=new GlobalShortcut(this, idx++, tr("Volume Down (-10%)", "Global Shortcut")); + gsVolumeDown->setObjectName(QLatin1String("VolumeDown")); + qstiIcon = new QSystemTrayIcon(qiIcon, this); qstiIcon->setToolTip(tr("Mumble")); qstiIcon->setObjectName(QLatin1String("Icon")); @@ -1028,6 +1034,22 @@ void MainWindow::on_CenterPos_triggered(bool down) { } } +void MainWindow::on_VolumeUp_triggered(bool down) { + if (down) { + float v = floorf(g.s.fVolume * 10.0); + if (v < 10.0) + g.s.fVolume = ++v / 10.0; + } +} + +void MainWindow::on_VolumeDown_triggered(bool down) { + if (down) { + float v = ceilf(g.s.fVolume * 10.0); + if (v > 0.0) + g.s.fVolume = --v / 10.0; + } +} + void MainWindow::pushLink(bool down) { if (down) { g.iAltSpeak++; diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h index 10b6464c3..ab5c2653d 100644 --- a/src/mumble/MainWindow.h +++ b/src/mumble/MainWindow.h @@ -78,8 +78,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin GlobalShortcut *gsPushTalk, *gsResetAudio, *gsMuteSelf, *gsDeafSelf; GlobalShortcut *gsUnlink, *gsCenterPos, *gsPushMute, *gsMetaChannel, *gsToggleOverlay; - GlobalShortcut *gsAltTalk; - GlobalShortcut *gsMinimal; + GlobalShortcut *gsAltTalk, *gsMinimal, *gsVolumeUp, *gsVolumeDown; LogTitleBar *ltbDockTitle; ACLEditor *aclEdit; @@ -146,6 +145,8 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin void on_PushToMute_triggered(bool); void on_AltPushToTalk_triggered(bool); void on_CenterPos_triggered(bool); + void on_VolumeUp_triggered(bool); + void on_VolumeDown_triggered(bool); void on_Reconnect_timeout(); void on_Icon_activated(QSystemTrayIcon::ActivationReason); void serverConnected();