strawberry-audio-player-win.../src/globalshortcuts/globalshortcutsmanager.h

106 lines
2.6 KiB
C
Raw Normal View History

2018-02-27 18:06:05 +01:00
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018, Jonas Kvinge <jonas@jkvinge.net>
2018-02-27 18:06:05 +01:00
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
2018-08-09 18:39:44 +02:00
*
2018-02-27 18:06:05 +01:00
*/
2021-01-26 19:13:29 +01:00
#ifndef GLOBALSHORTCUTSMANAGER_H
#define GLOBALSHORTCUTSMANAGER_H
2018-02-27 18:06:05 +01:00
#include "config.h"
#include <functional>
#include <QObject>
#include <QWidget>
2018-02-27 18:06:05 +01:00
#include <QMap>
#include <QString>
#include <QKeySequence>
2018-02-27 18:06:05 +01:00
#include <QSettings>
2020-02-09 02:29:35 +01:00
class QShortcut;
class QAction;
2021-01-26 19:13:29 +01:00
class GlobalShortcutsBackend;
2018-02-27 18:06:05 +01:00
2021-01-26 19:13:29 +01:00
class GlobalShortcutsManager : public QWidget {
2018-02-27 18:06:05 +01:00
Q_OBJECT
public:
2021-01-26 19:13:29 +01:00
explicit GlobalShortcutsManager(QWidget *parent = nullptr);
2018-02-27 18:06:05 +01:00
struct Shortcut {
QString id;
QKeySequence default_key;
QAction *action;
QShortcut *shortcut;
};
QMap<QString, Shortcut> shortcuts() const { return shortcuts_; }
bool IsGsdAvailable() const;
2020-10-31 02:08:19 +01:00
bool IsKdeAvailable() const;
bool IsX11Available() const;
2018-02-27 18:06:05 +01:00
bool IsMacAccessibilityEnabled() const;
public slots:
void ReloadSettings();
void ShowMacAccessibilityDialog();
void Unregister();
void Register();
signals:
2018-02-27 18:06:05 +01:00
void Play();
void Pause();
void PlayPause();
void Stop();
void StopAfter();
void Next();
void Previous();
void IncVolume();
void DecVolume();
void Mute();
void SeekForward();
void SeekBackward();
void ShowHide();
void ShowOSD();
void TogglePrettyOSD();
void CycleShuffleMode();
void CycleRepeatMode();
void RemoveCurrentSong();
void ToggleScrobbling();
2019-06-12 00:38:52 +02:00
void Love();
2018-02-27 18:06:05 +01:00
private:
void AddShortcut(const QString &id, const QString &name, std::function<void()> signal, const QKeySequence &default_key = QKeySequence(0));
2018-02-27 18:06:05 +01:00
Shortcut AddShortcut(const QString &id, const QString &name, const QKeySequence &default_key);
private:
2021-01-26 19:13:29 +01:00
GlobalShortcutsBackend *gsd_backend_;
GlobalShortcutsBackend *kde_backend_;
GlobalShortcutsBackend *system_backend_;
2018-02-27 18:06:05 +01:00
QMap<QString, Shortcut> shortcuts_;
QSettings settings_;
bool use_gsd_;
2020-10-31 02:08:19 +01:00
bool use_kde_;
bool use_x11_;
2018-02-27 18:06:05 +01:00
};
2021-01-26 19:13:29 +01:00
#endif // GLOBALSHORTCUTSMANAGER_H