diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2020-08-12 21:03:34 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2020-08-12 21:03:34 +0000 |
| commit | 7ef8d11baeaf1847ba7f1df5d858f8cffea9300d (patch) | |
| tree | a741fb49db8834efd4b46d760b89082547eb2a9d /src/plugins/General/hotkey | |
| parent | 6f301f5880f7efce76ed46e7b502830642b87370 (diff) | |
| download | qmmp-7ef8d11baeaf1847ba7f1df5d858f8cffea9300d.tar.gz qmmp-7ef8d11baeaf1847ba7f1df5d858f8cffea9300d.tar.bz2 qmmp-7ef8d11baeaf1847ba7f1df5d858f8cffea9300d.zip | |
coding style fixes
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9470 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General/hotkey')
| -rw-r--r-- | src/plugins/General/hotkey/hotkeymanager_win.cpp | 31 | ||||
| -rw-r--r-- | src/plugins/General/hotkey/settingsdialog.cpp | 17 |
2 files changed, 21 insertions, 27 deletions
diff --git a/src/plugins/General/hotkey/hotkeymanager_win.cpp b/src/plugins/General/hotkey/hotkeymanager_win.cpp index 8e28f116a..f806f7995 100644 --- a/src/plugins/General/hotkey/hotkeymanager_win.cpp +++ b/src/plugins/General/hotkey/hotkeymanager_win.cpp @@ -76,21 +76,22 @@ quint32 Hotkey::defaultKey() quint32 Hotkey::defaultKey(int act)
{
//default key bindings
- QMap<int, quint32> keyMap;
- keyMap[PLAY] = 0;
- keyMap[STOP] = VK_MEDIA_STOP;
- keyMap[PAUSE] = 0;
- keyMap[PLAY_PAUSE] = VK_MEDIA_PLAY_PAUSE;
- keyMap[NEXT] = VK_MEDIA_NEXT_TRACK;
- keyMap[PREVIOUS] = VK_MEDIA_PREV_TRACK;
- keyMap[SHOW_HIDE] = 0;
- keyMap[VOLUME_UP] = VK_VOLUME_UP;
- keyMap[VOLUME_DOWN] = VK_VOLUME_DOWN;
- keyMap[FORWARD] = 0;
- keyMap[REWIND] = 0;
- keyMap[JUMP_TO_TRACK] = 0;
- keyMap[VOLUME_MUTE] = VK_VOLUME_MUTE;
- return keyMap[act];
+ static const QMap<int, quint32> defaultKeys = {
+ { PLAY, 0 },
+ { STOP, VK_MEDIA_STOP },
+ { PAUSE, 0 },
+ { PLAY_PAUSE, VK_MEDIA_PLAY_PAUSE },
+ { NEXT, VK_MEDIA_NEXT_TRACK },
+ { PREVIOUS, VK_MEDIA_PREV_TRACK },
+ { SHOW_HIDE, 0 },
+ { VOLUME_UP, VK_VOLUME_UP },
+ { VOLUME_DOWN, VK_VOLUME_DOWN },
+ { FORWARD, 0 },
+ { REWIND, 0 },
+ { JUMP_TO_TRACK, 0 },
+ { VOLUME_MUTE, VK_VOLUME_MUTE },
+ };
+ return defaultKeys[act];
}
HotkeyManager::HotkeyManager(QObject *parent) : QObject(parent)
diff --git a/src/plugins/General/hotkey/settingsdialog.cpp b/src/plugins/General/hotkey/settingsdialog.cpp index 1255790e2..89ec737e8 100644 --- a/src/plugins/General/hotkey/settingsdialog.cpp +++ b/src/plugins/General/hotkey/settingsdialog.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009-2015 by Ilya Kotov * + * Copyright (C) 2009-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -22,6 +22,7 @@ #include <QHeaderView> #include <QMessageBox> #include <qmmp/qmmp.h> +#include <algorithm> #include "hotkeydialog.h" #include "settingsdialog.h" @@ -63,7 +64,6 @@ SettingsDialog::SettingsDialog(QWidget *parent) settings.endGroup(); } - SettingsDialog::~SettingsDialog() { while (!m_hotkeys.isEmpty()) @@ -86,18 +86,11 @@ void SettingsDialog::accept() void SettingsDialog::on_tableWidget_itemDoubleClicked (QTableWidgetItem *item) { - Hotkey *key = nullptr; - for(Hotkey *k : m_hotkeys) - { - if (k->action == item->type()) - { - key = k; - break; - } - } - if (!key) + auto it = std::find_if(m_hotkeys.cbegin(), m_hotkeys.cend(), [item](Hotkey *k) { return k->action == item->type(); }); + if(it == m_hotkeys.cend()) return; + Hotkey *key = *it; HotkeyDialog *dialog = new HotkeyDialog(key->key, key->mod, this); if (item->type() >= QTableWidgetItem::UserType && dialog->exec() == QDialog::Accepted) |
