aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General/hotkey/hotkeymanager.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2009-08-07 21:58:00 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2009-08-07 21:58:00 +0000
commit31b71619fe8e73ad571c710a3b0b874540fccef0 (patch)
tree915ef21e8682f456326dec80ad7031aa73befefc /src/plugins/General/hotkey/hotkeymanager.cpp
parent7649c8c957d15a0a53ff78ed93f0413729101fb8 (diff)
downloadqmmp-31b71619fe8e73ad571c710a3b0b874540fccef0.tar.gz
qmmp-31b71619fe8e73ad571c710a3b0b874540fccef0.tar.bz2
qmmp-31b71619fe8e73ad571c710a3b0b874540fccef0.zip
hotkey plugin: added volume control
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1118 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General/hotkey/hotkeymanager.cpp')
-rw-r--r--src/plugins/General/hotkey/hotkeymanager.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/plugins/General/hotkey/hotkeymanager.cpp b/src/plugins/General/hotkey/hotkeymanager.cpp
index 5a78c910a..712c7871c 100644
--- a/src/plugins/General/hotkey/hotkeymanager.cpp
+++ b/src/plugins/General/hotkey/hotkeymanager.cpp
@@ -63,6 +63,8 @@ quint32 Hotkey::defaultKey(int act)
keyMap[NEXT] = XF86XK_AudioNext;
keyMap[PREVIOUS] = XF86XK_AudioPrev;
keyMap[SHOW_HIDE] = 0;
+ keyMap[VOLUME_UP] = XF86XK_AudioRaiseVolume;
+ keyMap[VOLUME_DOWN] = XF86XK_AudioLowerVolume;
return keyMap[act];
}
@@ -72,7 +74,7 @@ HotkeyManager::HotkeyManager(QObject *parent) : General(parent)
WId rootWindow = QX11Info::appRootWindow();
QSettings settings(Qmmp::configFile(), QSettings::IniFormat); //load settings
settings.beginGroup("Hotkey");
- for (int i = Hotkey::PLAY, j = 0; i <= Hotkey::SHOW_HIDE; ++i, ++j)
+ for (int i = Hotkey::PLAY, j = 0; i <= Hotkey::VOLUME_DOWN; ++i, ++j)
{
quint32 key = settings.value(QString("key_%1").arg(i), Hotkey::defaultKey(i)).toUInt();
quint32 mod = settings.value(QString("modifiers_%1").arg(i), 0).toUInt();
@@ -158,6 +160,23 @@ bool HotkeyManager::eventFilter(QObject* o, QEvent* e)
break;
case Hotkey::SHOW_HIDE:
toggleVisibility();
+ break;
+ case Hotkey::VOLUME_UP:
+ case Hotkey::VOLUME_DOWN:
+ SoundCore *core = SoundCore::instance();
+ int volume = qMax(core->leftVolume(), core->rightVolume());
+ int balance = 0;
+ int left = core->leftVolume();
+ int right = core->rightVolume();
+ if (left || right)
+ balance = (right - left)*100/volume;
+ if(hotkey->action == Hotkey::VOLUME_UP)
+ volume = qMin (100, volume + 5);
+ else
+ volume = qMax (0, volume - 5);
+ core->setVolume(volume-qMax(balance,0)*volume/100,
+ volume+qMin(balance,0)*volume/100);
+ break;
}
qApp->processEvents();
}