diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-08-07 21:58:00 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-08-07 21:58:00 +0000 |
| commit | 31b71619fe8e73ad571c710a3b0b874540fccef0 (patch) | |
| tree | 915ef21e8682f456326dec80ad7031aa73befefc /src/plugins/General | |
| parent | 7649c8c957d15a0a53ff78ed93f0413729101fb8 (diff) | |
| download | qmmp-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')
13 files changed, 127 insertions, 4 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(); } diff --git a/src/plugins/General/hotkey/hotkeymanager.h b/src/plugins/General/hotkey/hotkeymanager.h index 0db01b79e..d892a78ce 100644 --- a/src/plugins/General/hotkey/hotkeymanager.h +++ b/src/plugins/General/hotkey/hotkeymanager.h @@ -42,7 +42,9 @@ public: PLAY_PAUSE, NEXT, PREVIOUS, - SHOW_HIDE + SHOW_HIDE, + VOLUME_UP, + VOLUME_DOWN }; Hotkey() diff --git a/src/plugins/General/hotkey/settingsdialog.cpp b/src/plugins/General/hotkey/settingsdialog.cpp index 2aca48de7..18a77f5a6 100644 --- a/src/plugins/General/hotkey/settingsdialog.cpp +++ b/src/plugins/General/hotkey/settingsdialog.cpp @@ -38,7 +38,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) ui.tableWidget->verticalHeader()->setResizeMode(QHeaderView::Fixed); ui.tableWidget->verticalHeader()->hide(); ui.tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch); - ui.tableWidget->setRowCount (7); + ui.tableWidget->setRowCount (9); ui.tableWidget->setItem(0,0, new QTableWidgetItem(tr("Play"))); ui.tableWidget->setItem(1,0, new QTableWidgetItem(tr("Stop"))); ui.tableWidget->setItem(2,0, new QTableWidgetItem(tr("Pause"))); @@ -46,10 +46,12 @@ SettingsDialog::SettingsDialog(QWidget *parent) ui.tableWidget->setItem(4,0, new QTableWidgetItem(tr("Next"))); ui.tableWidget->setItem(5,0, new QTableWidgetItem(tr("Previous"))); ui.tableWidget->setItem(6,0, new QTableWidgetItem(tr("Show/Hide"))); + ui.tableWidget->setItem(7,0, new QTableWidgetItem(tr("Volume +"))); + ui.tableWidget->setItem(8,0, new QTableWidgetItem(tr("Volume -"))); QSettings settings(Qmmp::configFile(), QSettings::IniFormat); 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) { Hotkey *hotkey = new Hotkey; hotkey->action = i; diff --git a/src/plugins/General/hotkey/translations/hotkey_plugin_cs.ts b/src/plugins/General/hotkey/translations/hotkey_plugin_cs.ts index 442da69ab..3f07c00b1 100644 --- a/src/plugins/General/hotkey/translations/hotkey_plugin_cs.ts +++ b/src/plugins/General/hotkey/translations/hotkey_plugin_cs.ts @@ -85,6 +85,16 @@ <translation>Zobrazit/Skrýt</translation> </message> <message> + <location filename="../settingsdialog.cpp" line="49"/> + <source>Volume +</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../settingsdialog.cpp" line="50"/> + <source>Volume -</source> + <translation type="unfinished"></translation> + </message> + <message> <location filename="../settingsdialog.ui" line="14"/> <source>Global Hotkey Plugin Settings</source> <translation>Nastavení modulu klávesových zkratek</translation> diff --git a/src/plugins/General/hotkey/translations/hotkey_plugin_de.ts b/src/plugins/General/hotkey/translations/hotkey_plugin_de.ts index 5c4d7ee2a..e525c99b6 100644 --- a/src/plugins/General/hotkey/translations/hotkey_plugin_de.ts +++ b/src/plugins/General/hotkey/translations/hotkey_plugin_de.ts @@ -85,6 +85,16 @@ <translation>Ein-/Ausblenden</translation> </message> <message> + <location filename="../settingsdialog.cpp" line="49"/> + <source>Volume +</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../settingsdialog.cpp" line="50"/> + <source>Volume -</source> + <translation type="unfinished"></translation> + </message> + <message> <location filename="../settingsdialog.ui" line="14"/> <source>Global Hotkey Plugin Settings</source> <translation type="unfinished">Einstellungen Global-Hotkey-Modul</translation> diff --git a/src/plugins/General/hotkey/translations/hotkey_plugin_it.ts b/src/plugins/General/hotkey/translations/hotkey_plugin_it.ts index 8c3cf852b..3de33e402 100644 --- a/src/plugins/General/hotkey/translations/hotkey_plugin_it.ts +++ b/src/plugins/General/hotkey/translations/hotkey_plugin_it.ts @@ -85,6 +85,16 @@ <translation>Mostra/nascondi</translation> </message> <message> + <location filename="../settingsdialog.cpp" line="49"/> + <source>Volume +</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../settingsdialog.cpp" line="50"/> + <source>Volume -</source> + <translation type="unfinished"></translation> + </message> + <message> <location filename="../settingsdialog.ui" line="14"/> <source>Global Hotkey Plugin Settings</source> <translation>Impostazioni modulo scorciatoie globali</translation> diff --git a/src/plugins/General/hotkey/translations/hotkey_plugin_lt.ts b/src/plugins/General/hotkey/translations/hotkey_plugin_lt.ts index b88b871a8..4554c69c6 100644 --- a/src/plugins/General/hotkey/translations/hotkey_plugin_lt.ts +++ b/src/plugins/General/hotkey/translations/hotkey_plugin_lt.ts @@ -85,6 +85,16 @@ <translation>Rodyti/Slėpti</translation> </message> <message> + <location filename="../settingsdialog.cpp" line="49"/> + <source>Volume +</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../settingsdialog.cpp" line="50"/> + <source>Volume -</source> + <translation type="unfinished"></translation> + </message> + <message> <location filename="../settingsdialog.ui" line="14"/> <source>Global Hotkey Plugin Settings</source> <translation>Global Hotkey nustatymai</translation> diff --git a/src/plugins/General/hotkey/translations/hotkey_plugin_pl.ts b/src/plugins/General/hotkey/translations/hotkey_plugin_pl.ts index 235a7521f..8f405f756 100644 --- a/src/plugins/General/hotkey/translations/hotkey_plugin_pl.ts +++ b/src/plugins/General/hotkey/translations/hotkey_plugin_pl.ts @@ -85,6 +85,16 @@ <translation>Pokaż/Ukryj</translation> </message> <message> + <location filename="../settingsdialog.cpp" line="49"/> + <source>Volume +</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../settingsdialog.cpp" line="50"/> + <source>Volume -</source> + <translation type="unfinished"></translation> + </message> + <message> <location filename="../settingsdialog.ui" line="14"/> <source>Global Hotkey Plugin Settings</source> <translation>Globalne ustawienia wtyczki Klawiszów Skrótowych</translation> diff --git a/src/plugins/General/hotkey/translations/hotkey_plugin_ru.ts b/src/plugins/General/hotkey/translations/hotkey_plugin_ru.ts index aa477077b..be84f2811 100644 --- a/src/plugins/General/hotkey/translations/hotkey_plugin_ru.ts +++ b/src/plugins/General/hotkey/translations/hotkey_plugin_ru.ts @@ -85,6 +85,16 @@ <translation>Показать/Скрыть</translation> </message> <message> + <location filename="../settingsdialog.cpp" line="49"/> + <source>Volume +</source> + <translation>Громкость +</translation> + </message> + <message> + <location filename="../settingsdialog.cpp" line="50"/> + <source>Volume -</source> + <translation>Громкость -</translation> + </message> + <message> <location filename="../settingsdialog.ui" line="14"/> <source>Global Hotkey Plugin Settings</source> <translation>Настройки модуля глобальных клавиш</translation> diff --git a/src/plugins/General/hotkey/translations/hotkey_plugin_tr.ts b/src/plugins/General/hotkey/translations/hotkey_plugin_tr.ts index 3e8c4c95f..9c36d964f 100644 --- a/src/plugins/General/hotkey/translations/hotkey_plugin_tr.ts +++ b/src/plugins/General/hotkey/translations/hotkey_plugin_tr.ts @@ -85,6 +85,16 @@ <translation>Göster/Gizle</translation> </message> <message> + <location filename="../settingsdialog.cpp" line="49"/> + <source>Volume +</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../settingsdialog.cpp" line="50"/> + <source>Volume -</source> + <translation type="unfinished"></translation> + </message> + <message> <location filename="../settingsdialog.ui" line="14"/> <source>Global Hotkey Plugin Settings</source> <translation>Genel Kısayol Eklentisi Ayarları</translation> diff --git a/src/plugins/General/hotkey/translations/hotkey_plugin_uk_UA.ts b/src/plugins/General/hotkey/translations/hotkey_plugin_uk_UA.ts index 2bc3cdb74..88d16fdfa 100644 --- a/src/plugins/General/hotkey/translations/hotkey_plugin_uk_UA.ts +++ b/src/plugins/General/hotkey/translations/hotkey_plugin_uk_UA.ts @@ -85,6 +85,16 @@ <translation>Показати/Сховати</translation> </message> <message> + <location filename="../settingsdialog.cpp" line="49"/> + <source>Volume +</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../settingsdialog.cpp" line="50"/> + <source>Volume -</source> + <translation type="unfinished"></translation> + </message> + <message> <location filename="../settingsdialog.ui" line="14"/> <source>Global Hotkey Plugin Settings</source> <translation>Налаштування модуля глобальних клавіш</translation> diff --git a/src/plugins/General/hotkey/translations/hotkey_plugin_zh_CN.ts b/src/plugins/General/hotkey/translations/hotkey_plugin_zh_CN.ts index c9b8b6ee4..d152c2d11 100644 --- a/src/plugins/General/hotkey/translations/hotkey_plugin_zh_CN.ts +++ b/src/plugins/General/hotkey/translations/hotkey_plugin_zh_CN.ts @@ -85,6 +85,16 @@ <translation>显示/隐藏</translation> </message> <message> + <location filename="../settingsdialog.cpp" line="49"/> + <source>Volume +</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../settingsdialog.cpp" line="50"/> + <source>Volume -</source> + <translation type="unfinished"></translation> + </message> + <message> <location filename="../settingsdialog.ui" line="14"/> <source>Global Hotkey Plugin Settings</source> <translation>全局快捷键设置</translation> diff --git a/src/plugins/General/hotkey/translations/hotkey_plugin_zh_TW.ts b/src/plugins/General/hotkey/translations/hotkey_plugin_zh_TW.ts index 51bc27b8e..acaeaa620 100644 --- a/src/plugins/General/hotkey/translations/hotkey_plugin_zh_TW.ts +++ b/src/plugins/General/hotkey/translations/hotkey_plugin_zh_TW.ts @@ -85,6 +85,16 @@ <translation>察看/隱藏</translation> </message> <message> + <location filename="../settingsdialog.cpp" line="49"/> + <source>Volume +</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../settingsdialog.cpp" line="50"/> + <source>Volume -</source> + <translation type="unfinished"></translation> + </message> + <message> <location filename="../settingsdialog.ui" line="14"/> <source>Global Hotkey Plugin Settings</source> <translation>全局熱鍵插件設置</translation> |
