2020-11-01 12:35:20 +00:00
|
|
|
#ifndef SHORTCUTSEDITOR_H
|
|
|
|
#define SHORTCUTSEDITOR_H
|
|
|
|
|
2020-11-08 13:36:02 +00:00
|
|
|
#include "shortcut.h"
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
2020-11-01 12:35:20 +00:00
|
|
|
#include <QDialog>
|
|
|
|
#include <QMap>
|
2020-11-08 13:36:02 +00:00
|
|
|
#include <QHash>
|
|
|
|
#include <QAction>
|
2020-11-01 12:35:20 +00:00
|
|
|
|
2020-11-08 13:36:02 +00:00
|
|
|
class QFormLayout;
|
|
|
|
class MultiKeyEdit;
|
2020-11-01 12:35:20 +00:00
|
|
|
class QAbstractButton;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class ShortcutsEditor;
|
|
|
|
}
|
|
|
|
|
2020-11-08 13:36:02 +00:00
|
|
|
class ShortcutsEditor : public QMainWindow
|
2020-11-01 12:35:20 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-11-09 10:50:15 +00:00
|
|
|
explicit ShortcutsEditor(QWidget *parent = nullptr);
|
|
|
|
explicit ShortcutsEditor(const QObjectList &shortcutableObjects, QWidget *parent = nullptr);
|
2020-11-01 12:35:20 +00:00
|
|
|
~ShortcutsEditor();
|
|
|
|
|
2020-11-09 10:50:15 +00:00
|
|
|
void setShortcutableObjects(const QObjectList &shortcutableObjects);
|
|
|
|
|
2020-11-08 13:36:02 +00:00
|
|
|
signals:
|
|
|
|
void shortcutsSaved();
|
|
|
|
|
2020-11-01 12:35:20 +00:00
|
|
|
private:
|
|
|
|
Ui::ShortcutsEditor *ui;
|
2020-11-08 13:36:02 +00:00
|
|
|
QWidget *main_container;
|
|
|
|
QMultiMap<QString, const QObject *> labels_objects;
|
|
|
|
QHash<QString, QFormLayout *> contexts_layouts;
|
|
|
|
QHash<MultiKeyEdit *, const QObject *> multiKeyEdits_objects;
|
|
|
|
|
|
|
|
void parseObjectList(const QObjectList &objectList);
|
|
|
|
QString getLabel(const QObject *object) const;
|
|
|
|
bool stringPropertyIsNotEmpty(const QObject *object, const char *name) const;
|
|
|
|
void populateMainContainer();
|
|
|
|
QString getShortcutContext(const QObject *object) const;
|
|
|
|
void addNewContextGroup(const QString &shortcutContext);
|
|
|
|
void addNewMultiKeyEdit(const QObject *object, const QString &shortcutContext);
|
|
|
|
QList<MultiKeyEdit *> siblings(MultiKeyEdit *multiKeyEdit) const;
|
|
|
|
void promptUserOnDuplicateFound(MultiKeyEdit *current, MultiKeyEdit *sender);
|
|
|
|
void removeKeySequence(const QKeySequence &keySequence, MultiKeyEdit *multiKeyEdit);
|
2020-11-01 12:35:20 +00:00
|
|
|
void saveShortcuts();
|
|
|
|
void resetShortcuts();
|
|
|
|
|
|
|
|
private slots:
|
2020-11-08 13:36:02 +00:00
|
|
|
void checkForDuplicates(const QKeySequence &keySequence);
|
2020-11-01 12:35:20 +00:00
|
|
|
void dialogButtonClicked(QAbstractButton *button);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SHORTCUTSEDITOR_H
|