diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2017-09-18 19:20:50 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-09-19 06:41:06 +0000 |
commit | 59fce46d01582e0d2ffd3a606fdd8b50c713f6a1 (patch) | |
tree | 67e54d3b90d82604592e6771bdbd913770aff823 /ui | |
parent | 939ea8c8ed2b96b2959a1c9869ac5fe6237808f9 (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')
-rw-r--r-- | ui/qt/main_window.cpp | 2 | ||||
-rw-r--r-- | ui/qt/preference_editor_frame.cpp | 16 | ||||
-rw-r--r-- | ui/qt/preference_editor_frame.h | 4 |
3 files changed, 22 insertions, 0 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 392e308076..115b5c7a7b 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -412,6 +412,8 @@ MainWindow::MainWindow(QWidget *parent) : connect(main_ui_->columnEditorFrame, SIGNAL(pushFilterSyntaxStatus(const QString&)), main_ui_->statusBar, SLOT(pushTemporaryStatus(const QString&))); main_ui_->preferenceEditorFrame->hide(); + connect(main_ui_->preferenceEditorFrame, SIGNAL(pushFilterSyntaxStatus(const QString&)), + main_ui_->statusBar, SLOT(pushTemporaryStatus(const QString&))); main_ui_->filterExpressionFrame->hide(); #ifndef HAVE_LIBPCAP 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 * diff --git a/ui/qt/preference_editor_frame.h b/ui/qt/preference_editor_frame.h index 4969a9bf2c..d765ad1465 100644 --- a/ui/qt/preference_editor_frame.h +++ b/ui/qt/preference_editor_frame.h @@ -45,6 +45,10 @@ public slots: signals: void showProtocolPreferences(const QString module_name); + void pushFilterSyntaxStatus(const QString&); + +protected: + void keyPressEvent(QKeyEvent *event); private slots: // Similar to ModulePreferencesScrollArea |