2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* This file was part of Clementine.
|
|
|
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GLOBALSHORTCUTGRABBER_H
|
|
|
|
#define GLOBALSHORTCUTGRABBER_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QObject>
|
|
|
|
#include <QWidget>
|
2018-02-27 18:06:05 +01:00
|
|
|
#include <QDialog>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QList>
|
|
|
|
#include <QString>
|
|
|
|
#include <QKeySequence>
|
|
|
|
|
|
|
|
class QEvent;
|
|
|
|
class QHideEvent;
|
|
|
|
class QShowEvent;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
class MacMonitorWrapper;
|
|
|
|
class Ui_GlobalShortcutGrabber;
|
|
|
|
|
|
|
|
#ifdef __OBJC__
|
|
|
|
@class NSEvent;
|
|
|
|
#else
|
|
|
|
class NSEvent;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class GlobalShortcutGrabber : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-04-07 16:49:15 +02:00
|
|
|
explicit GlobalShortcutGrabber(QWidget *parent = nullptr);
|
2020-06-15 21:55:05 +02:00
|
|
|
~GlobalShortcutGrabber() override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
QKeySequence GetKey(const QString &name);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
protected:
|
2020-06-15 21:55:05 +02:00
|
|
|
bool event(QEvent *e) override;
|
|
|
|
void showEvent(QShowEvent *e) override;
|
|
|
|
void hideEvent(QHideEvent *e) override;
|
2018-02-27 18:06:05 +01:00
|
|
|
void grabKeyboard();
|
|
|
|
void releaseKeyboard();
|
|
|
|
|
2024-08-12 01:06:15 +02:00
|
|
|
private Q_SLOTS:
|
2019-02-09 12:47:40 +01:00
|
|
|
void Accepted();
|
|
|
|
void Rejected();
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
private:
|
|
|
|
void UpdateText();
|
|
|
|
void SetupMacEventHandler();
|
|
|
|
void TeardownMacEventHandler();
|
|
|
|
bool HandleMacEvent(NSEvent*);
|
|
|
|
|
|
|
|
Ui_GlobalShortcutGrabber *ui_;
|
|
|
|
QKeySequence ret_;
|
|
|
|
|
|
|
|
QList<int> modifier_keys_;
|
|
|
|
|
|
|
|
MacMonitorWrapper *wrapper_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GLOBALSHORTCUTGRABBER_H
|