aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/preference_editor_frame.cpp
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2017-09-18 19:20:50 +0200
committerAnders Broman <a.broman58@gmail.com>2017-09-19 06:41:06 +0000
commit59fce46d01582e0d2ffd3a606fdd8b50c713f6a1 (patch)
tree67e54d3b90d82604592e6771bdbd913770aff823 /ui/qt/preference_editor_frame.cpp
parent939ea8c8ed2b96b2959a1c9869ac5fe6237808f9 (diff)
Qt: Add key events to accept and reject changes in PreferenceEditorFrame
Change-Id: I4a9c4b80b0438cd33c38b274a24a3b1b5db46cb8 Reviewed-on: https://code.wireshark.org/review/23605 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/preference_editor_frame.cpp')
-rw-r--r--ui/qt/preference_editor_frame.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/ui/qt/preference_editor_frame.cpp b/ui/qt/preference_editor_frame.cpp
index 1b40adf1df..267aee7d05 100644
--- a/ui/qt/preference_editor_frame.cpp
+++ b/ui/qt/preference_editor_frame.cpp
@@ -39,6 +39,7 @@
#include "wireshark_application.h"
#include <QPushButton>
+#include <QKeyEvent>
// To do:
// - Handle PREF_SAVE_FILENAME, PREF_OPEN_FILENAME and PREF_DIRNAME.
@@ -239,6 +240,21 @@ void PreferenceEditorFrame::on_buttonBox_rejected()
animatedHide();
}
+void PreferenceEditorFrame::keyPressEvent(QKeyEvent *event)
+{
+ if (event->modifiers() == Qt::NoModifier) {
+ if (event->key() == Qt::Key_Escape) {
+ on_buttonBox_rejected();
+ } else if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
+ if (ui->buttonBox->button(QDialogButtonBox::Ok)->isEnabled()) {
+ on_buttonBox_accepted();
+ } else if (ui->preferenceLineEdit->syntaxState() == SyntaxLineEdit::Invalid) {
+ emit pushFilterSyntaxStatus(tr("Invalid value."));
+ }
+ }
+ }
+}
+
/*
* Editor modelines
*