@@ -21,11 +21,14 @@
|
||||
#include "keysequenceeditor.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QKeyEvent>
|
||||
|
||||
namespace olive {
|
||||
|
||||
#define super QKeySequenceEdit
|
||||
|
||||
KeySequenceEditor::KeySequenceEditor(QWidget* parent, QAction* a)
|
||||
: QKeySequenceEdit(parent), action(a) {
|
||||
: super(parent), action(a) {
|
||||
setKeySequence(action->shortcut());
|
||||
}
|
||||
|
||||
@@ -49,4 +52,26 @@ QString KeySequenceEditor::export_shortcut() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void KeySequenceEditor::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
if (e->key() == Qt::Key_Backspace) {
|
||||
clear();
|
||||
} else if (e->key() == Qt::Key_Escape) {
|
||||
e->ignore();
|
||||
} else{
|
||||
super::keyPressEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
void KeySequenceEditor::keyReleaseEvent(QKeyEvent *e)
|
||||
{
|
||||
if (e->key() == Qt::Key_Backspace) {
|
||||
// Do nothing
|
||||
} else if (e->key() == Qt::Key_Escape) {
|
||||
e->ignore();
|
||||
} else {
|
||||
super::keyReleaseEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -94,6 +94,12 @@ public:
|
||||
* because a default shortcut does not need to be saved to a file.
|
||||
*/
|
||||
QString export_shortcut();
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent *e) override;
|
||||
|
||||
virtual void keyReleaseEvent(QKeyEvent *e) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Internal reference to the linked QAction
|
||||
|
||||
Reference in New Issue
Block a user