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>
This commit is contained in:
parent
939ea8c8ed
commit
59fce46d01
|
@ -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
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue