diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/General/hotkey/hotkeymanager_win.cpp | 17 | ||||
| -rw-r--r-- | src/plugins/General/hotkey/hotkeymanager_x11.cpp | 17 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/actionmanager.cpp | 4 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/actionmanager.h | 4 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/mainwindow.cpp | 11 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/mainwindow.h | 2 | ||||
| -rw-r--r-- | src/qmmp/soundcore.cpp | 10 | ||||
| -rw-r--r-- | src/qmmp/soundcore.h | 4 |
8 files changed, 39 insertions, 30 deletions
diff --git a/src/plugins/General/hotkey/hotkeymanager_win.cpp b/src/plugins/General/hotkey/hotkeymanager_win.cpp index 1acec3910..ea0b95870 100644 --- a/src/plugins/General/hotkey/hotkeymanager_win.cpp +++ b/src/plugins/General/hotkey/hotkeymanager_win.cpp @@ -130,21 +130,10 @@ public: UiHelper::instance()->toggleVisibility();
break;
case Hotkey::VOLUME_UP:
+ core->changeVolume(+5);
+ break;
case Hotkey::VOLUME_DOWN:
- {
- 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(m_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);
- }
+ core->changeVolume(-5);
break;
case Hotkey::FORWARD:
core->seek(core->elapsed() + 5000);
diff --git a/src/plugins/General/hotkey/hotkeymanager_x11.cpp b/src/plugins/General/hotkey/hotkeymanager_x11.cpp index 241b2ea64..0b90c6c13 100644 --- a/src/plugins/General/hotkey/hotkeymanager_x11.cpp +++ b/src/plugins/General/hotkey/hotkeymanager_x11.cpp @@ -178,21 +178,10 @@ bool HotkeyManager::eventFilter(QObject* o, QEvent* e) UiHelper::instance()->toggleVisibility(); break; case Hotkey::VOLUME_UP: + core->changeVolume(+5); + break; case Hotkey::VOLUME_DOWN: - { - 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); - } + core->changeVolume(-5); break; case Hotkey::FORWARD: core->seek(core->elapsed() + 5000); diff --git a/src/plugins/Ui/skinned/actionmanager.cpp b/src/plugins/Ui/skinned/actionmanager.cpp index 6461e65c5..1425879aa 100644 --- a/src/plugins/Ui/skinned/actionmanager.cpp +++ b/src/plugins/Ui/skinned/actionmanager.cpp @@ -56,6 +56,10 @@ ActionManager::ActionManager(QObject *parent) : m_actions[WM_ALLWAYS_ON_TOP] = createAction2(tr("Always on Top"), "always_on_top", ""); m_actions[WM_STICKY] = createAction2(tr("Put on All Workspaces"), "sticky", ""); m_actions[WM_DOUBLE_SIZE] = createAction2(tr("Double Size"), "double_size", tr("Meta+D")); + //volume + m_actions[VOL_ENC] = createAction(tr("Volume &+"), "vol_enc", tr("0")); + m_actions[VOL_DEC] = createAction(tr("Volume &-"), "vol_dec", tr("9")); + m_actions[VOL_MUTE] = createAction2(tr("&Mute"), "vol_mute", tr("M")); //playlist m_actions[PL_ADD_FILE] = createAction(tr("&Add File"), "add_file", tr("F"), "audio-x-generic"); m_actions[PL_ADD_DIRECTORY] = createAction(tr("&Add Directory"), "add_dir", tr("D"), "folder"); diff --git a/src/plugins/Ui/skinned/actionmanager.h b/src/plugins/Ui/skinned/actionmanager.h index 00b99e3e9..a1f5d891d 100644 --- a/src/plugins/Ui/skinned/actionmanager.h +++ b/src/plugins/Ui/skinned/actionmanager.h @@ -65,6 +65,10 @@ public: WM_STICKY, WM_DOUBLE_SIZE, + VOL_ENC, + VOL_DEC, + VOL_MUTE, + PL_ADD_FILE, PL_ADD_DIRECTORY, PL_ADD_URL, diff --git a/src/plugins/Ui/skinned/mainwindow.cpp b/src/plugins/Ui/skinned/mainwindow.cpp index 0fe9f6522..d09a5e44f 100644 --- a/src/plugins/Ui/skinned/mainwindow.cpp +++ b/src/plugins/Ui/skinned/mainwindow.cpp @@ -402,9 +402,20 @@ void MainWindow::createActions() connect(m_pl_manager, SIGNAL(shuffleChanged(bool)), ACTION(ActionManager::SHUFFLE), SLOT(setChecked(bool))); + QMenu *audioMenu = m_mainMenu->addMenu(tr("Audio")); + QSignalMapper *mapper = new QSignalMapper(this); + mapper->setMapping(ACTION(ActionManager::VOL_ENC), 5); + mapper->setMapping(ACTION(ActionManager::VOL_DEC), -5); + connect(mapper, SIGNAL(mapped(int)), m_core, SLOT(changeVolume(int))); + audioMenu->addAction(SET_ACTION(ActionManager::VOL_ENC, mapper, SLOT(map()))); + audioMenu->addAction(SET_ACTION(ActionManager::VOL_DEC, mapper, SLOT(map()))); + audioMenu->addAction(SET_ACTION(ActionManager::VOL_MUTE, m_core, SLOT(setMuted(bool)))); + connect(m_core, SIGNAL(mutedChanged(bool)), ACTION(ActionManager::VOL_MUTE), SLOT(setChecked(bool))); + m_visMenu = new VisualMenu(this); m_mainMenu->addMenu(m_visMenu); m_mainMenu->addMenu(m_uiHelper->createMenu(UiHelper::TOOLS_MENU, tr("Tools"), this)); + m_mainMenu->addSeparator(); m_mainMenu->addAction(SET_ACTION(ActionManager::SETTINGS, this, SLOT(showSettings()))); m_mainMenu->addSeparator(); diff --git a/src/plugins/Ui/skinned/mainwindow.h b/src/plugins/Ui/skinned/mainwindow.h index 7f3bb5953..c04ed697b 100644 --- a/src/plugins/Ui/skinned/mainwindow.h +++ b/src/plugins/Ui/skinned/mainwindow.h @@ -99,8 +99,6 @@ private: MainDisplay *m_display; PlayList *m_playlist; PlayListManager *m_pl_manager; - QPointer <PlayListModel> m_model; - int m_preamp; EqWidget *m_equalizer; MainVisual *m_vis; bool m_update; diff --git a/src/qmmp/soundcore.cpp b/src/qmmp/soundcore.cpp index d57143441..85837588a 100644 --- a/src/qmmp/soundcore.cpp +++ b/src/qmmp/soundcore.cpp @@ -168,6 +168,16 @@ void SoundCore::setMuted(bool mute) } } +void SoundCore::changeVolume(int delta) +{ + int left = leftVolume(); + int right = rightVolume(); + int volume = qMax(left, right); + int balance = volume > 0 ? (right - left)*100/volume : 0; + volume = delta > 0 ? qMin(100, volume + 5) : qMax(0, volume - 5); + setVolume(volume-qMax(balance,0)*volume/100, volume+qMin(balance,0)*volume/100); +} + int SoundCore::leftVolume() { return m_volumeControl->left(); diff --git a/src/qmmp/soundcore.h b/src/qmmp/soundcore.h index d693c2b0c..8bd41062b 100644 --- a/src/qmmp/soundcore.h +++ b/src/qmmp/soundcore.h @@ -135,6 +135,10 @@ public slots: */ void setMuted(bool mute); /*! + * Changes volume by \b delta percent + */ + void changeVolume(int delta); + /*! * This function plays file or stream with the given path \p source. * Returns \b true if playback has been started successful or source is not a local file, * otherwise returns \b false. Useful for invalid files skipping. |
