diff options
| author | João Barbosa <[email protected]> | 2018-07-30 22:44:18 +0100 |
|---|---|---|
| committer | João Barbosa <[email protected]> | 2018-07-30 23:13:04 +0100 |
| commit | f7a553177d4b969956bc04a0140fce34958971f5 (patch) | |
| tree | de2c0d6c3b527d1c0eda8fbbf2af7cff902f6ffd /src | |
| parent | Merge #13786: refactor: Avoid locking tx pool cs thrice (diff) | |
| download | discoin-f7a553177d4b969956bc04a0140fce34958971f5.tar.xz discoin-f7a553177d4b969956bc04a0140fce34958971f5.zip | |
gui: Add GUIUtil::ItemDelegate with keyEscapePressed signal
Diffstat (limited to 'src')
| -rw-r--r-- | src/qt/guiutil.cpp | 11 | ||||
| -rw-r--r-- | src/qt/guiutil.h | 13 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 9dde2c392..955f5cdfe 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -49,6 +49,7 @@ #include <QDoubleValidator> #include <QFileDialog> #include <QFont> +#include <QKeyEvent> #include <QLineEdit> #include <QSettings> #include <QTextDocument> // for Qt::mightBeRichText @@ -927,4 +928,14 @@ void ClickableProgressBar::mouseReleaseEvent(QMouseEvent *event) Q_EMIT clicked(event->pos()); } +bool ItemDelegate::eventFilter(QObject *object, QEvent *event) +{ + if (event->type() == QEvent::KeyPress) { + if (static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape) { + Q_EMIT keyEscapePressed(); + } + } + return QItemDelegate::eventFilter(object, event); +} + } // namespace GUIUtil diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 6aa65369f..5b32f03aa 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -10,6 +10,7 @@ #include <QEvent> #include <QHeaderView> +#include <QItemDelegate> #include <QMessageBox> #include <QObject> #include <QProgressBar> @@ -232,6 +233,18 @@ namespace GUIUtil typedef ClickableProgressBar ProgressBar; + class ItemDelegate : public QItemDelegate + { + Q_OBJECT + public: + ItemDelegate(QObject* parent) : QItemDelegate(parent) {} + + Q_SIGNALS: + void keyEscapePressed(); + + private: + bool eventFilter(QObject *object, QEvent *event); + }; } // namespace GUIUtil #endif // BITCOIN_QT_GUIUTIL_H |