mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-04 21:27:31 +01:00
Code cleanups
This commit is contained in:
parent
93acd26444
commit
473b4839d9
@ -57,8 +57,8 @@ class Song;
|
||||
class SystemTrayIcon;
|
||||
class TaskManager;
|
||||
class TranscodeDialog;
|
||||
class WiimotedevShortcuts;
|
||||
class VisualisationContainer;
|
||||
class WiimotedevShortcuts;
|
||||
class Ui_MainWindow;
|
||||
|
||||
class QSortFilterProxyModel;
|
||||
@ -212,7 +212,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WIIMOTEDEV
|
||||
WiimotedevShortcuts *wiimotedev_shortcuts_;
|
||||
WiimotedevShortcuts* wiimotedev_shortcuts_;
|
||||
#endif
|
||||
|
||||
QMenu* playlist_menu_;
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
const char* WiimotedevShortcuts::kSettingsGroup = "Wiimotedev";
|
||||
|
||||
WiimotedevShortcuts::WiimotedevShortcuts(Player *player, QObject *parent)
|
||||
WiimotedevShortcuts::WiimotedevShortcuts(Player* player, QObject* parent)
|
||||
:QObject(parent),
|
||||
player_(player),
|
||||
wiimotedev_iface_(NULL),
|
||||
@ -63,18 +63,20 @@ void WiimotedevShortcuts::SetEnabled(bool enabled)
|
||||
void WiimotedevShortcuts::ReloadSettings() {
|
||||
settings_.sync();
|
||||
quint64 value;
|
||||
if (value = settings_.value(QString::fromUtf8("next_track"), quint64(WIIMOTE_BTN_RIGHT)).toInt()) actions_[PlayerNextTrack] = value;
|
||||
if (value = settings_.value(QString::fromUtf8("previous_track"), quint64(WIIMOTE_BTN_LEFT)).toInt()) actions_[PlayerPreviousTrack] = value;
|
||||
if (value = settings_.value(QString::fromUtf8("play"), quint64(0)).toInt()) actions_[PlayerPlay] = value;
|
||||
if (value = settings_.value(QString::fromUtf8("stop"), quint64(0)).toInt()) actions_[PlayerStop] = value;
|
||||
if (value = settings_.value(QString::fromUtf8("inc_volume"), quint64(WIIMOTE_BTN_PLUS)).toInt()) actions_[PlayerIncVolume] = value;
|
||||
if (value = settings_.value(QString::fromUtf8("dec_volume"), quint64(WIIMOTE_BTN_MINUS)).toInt()) actions_[PlayerDecVolume] = value;
|
||||
if (value = settings_.value(QString::fromUtf8("mute"), quint64(0)).toInt()) actions_[PlayerMute] = value;
|
||||
if (value = settings_.value(QString::fromUtf8("pause"), quint64(0)).toInt()) actions_[PlayerPause] = value;
|
||||
if (value = settings_.value(QString::fromUtf8("togglepause"), quint64(WIIMOTE_BTN_1)).toInt()) actions_[PlayerTogglePause] = value;
|
||||
if (value = settings_.value(QString::fromUtf8("seek_backward"), quint64(WIIMOTE_BTN_UP)).toInt()) actions_[PlayerSeekBackward] = value;
|
||||
if (value = settings_.value(QString::fromUtf8("seek_forward"), quint64(WIIMOTE_BTN_DOWN)).toInt()) actions_[PlayerSeekForward] = value;
|
||||
if (value = settings_.value(QString::fromUtf8("show_osd"), quint64(WIIMOTE_BTN_2)).toInt()) actions_[PlayerShowOSD] = value;
|
||||
if (value = settings_.value("next_track", WIIMOTE_BTN_RIGHT).toULongLong()) actions_[value] = PlayerNextTrack;
|
||||
if (value = settings_.value("previous_track", WIIMOTE_BTN_LEFT).toULongLong()) actions_[value] = PlayerPreviousTrack;
|
||||
if (value = settings_.value("next_track", WIIMOTE_BTN_SHIFT_RIGHT).toULongLong()) actions_[value] = PlayerNextTrack;
|
||||
if (value = settings_.value("previous_track", WIIMOTE_BTN_SHIFT_LEFT).toULongLong()) actions_[value] = PlayerPreviousTrack;
|
||||
if (value = settings_.value("play", 0).toULongLong()) actions_[value] = PlayerPlay;
|
||||
if (value = settings_.value("stop", 0).toULongLong()) actions_[value] = PlayerStop;
|
||||
if (value = settings_.value("inc_volume", WIIMOTE_BTN_PLUS).toULongLong()) actions_[value] = PlayerIncVolume;
|
||||
if (value = settings_.value("dec_volume", WIIMOTE_BTN_MINUS).toULongLong()) actions_[value] = PlayerDecVolume;
|
||||
if (value = settings_.value("mute", 0).toULongLong()) actions_[value] = PlayerMute;
|
||||
if (value = settings_.value("pause", 0).toULongLong()) actions_[value] = PlayerPause;
|
||||
if (value = settings_.value("togglepause", WIIMOTE_BTN_1).toULongLong()) actions_[value] = PlayerTogglePause;
|
||||
if (value = settings_.value("seek_backward", WIIMOTE_BTN_UP).toULongLong()) actions_[value] = PlayerSeekBackward;
|
||||
if (value = settings_.value("seek_forward", WIIMOTE_BTN_DOWN).toULongLong()) actions_[value] = PlayerSeekForward;
|
||||
if (value = settings_.value("show_osd", WIIMOTE_BTN_2).toULongLong()) actions_[value] = PlayerShowOSD;
|
||||
|
||||
SetEnabled(settings_.value(QString::fromUtf8("enabled"), quint64(true)).toBool());
|
||||
}
|
||||
@ -104,12 +106,12 @@ void WiimotedevShortcuts::DbusWiimoteGeneralButtons(quint32 id, quint64 value) {
|
||||
|
||||
if (wiimotedev_buttons_ == buttons) return;
|
||||
|
||||
QMapIterator< quint32, quint64> actions(actions_);
|
||||
QMapIterator<quint64, quint32> actions(actions_);
|
||||
|
||||
while (actions.hasNext()) {
|
||||
actions.next();
|
||||
if (actions.value() == 0) continue;
|
||||
if ((actions.value() & buttons) == actions.value()) EmitRequest(actions.key());
|
||||
if (actions.key() == 0) continue;
|
||||
if ((actions.key() & buttons) == actions.key()) EmitRequest(actions.value());
|
||||
}
|
||||
|
||||
wiimotedev_buttons_ = buttons;
|
||||
|
@ -14,8 +14,8 @@
|
||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SHORTCUTS_H
|
||||
#define SHORTCUTS_H
|
||||
#ifndef WIIMOTEDEV_SHORTCUTS_H
|
||||
#define WIIMOTEDEV_SHORTCUTS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
@ -29,13 +29,13 @@ class WiimotedevShortcuts :public QObject {
|
||||
public:
|
||||
static const char* kSettingsGroup;
|
||||
|
||||
WiimotedevShortcuts(Player *player = 0, QObject *parent = 0);
|
||||
WiimotedevShortcuts(Player* player = 0, QObject* parent = 0);
|
||||
|
||||
public slots:
|
||||
void ReloadSettings();
|
||||
void SetEnabled(bool enabled);
|
||||
|
||||
private Q_SLOTS:
|
||||
private slots:
|
||||
void DbusWiimoteGeneralButtons(quint32 id, quint64 value);
|
||||
|
||||
private:
|
||||
@ -47,7 +47,7 @@ private:
|
||||
QSettings settings_;
|
||||
|
||||
private:
|
||||
enum action {
|
||||
enum Action {
|
||||
PlayerNextTrack,
|
||||
PlayerPreviousTrack,
|
||||
PlayerPlay,
|
||||
@ -63,7 +63,7 @@ private:
|
||||
PlayerShowOSD
|
||||
};
|
||||
|
||||
QMap < quint32, quint64> actions_;
|
||||
QMap <quint64, quint32> actions_;
|
||||
|
||||
signals:
|
||||
void Next();
|
||||
@ -82,4 +82,4 @@ signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // SHORTCUTS_H
|
||||
#endif // WIIMOTEDEV_SHORTCUTS_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user