Qt Frames: Use ButtonBox instead of buttons
In these frames the Ok and Close buttons are implemented as standalone buttons. This leads to the scenario, that they break plattform-ui preferences on the one hand, as well as not being the same order throughout. This patch replaces all Ok/Close buttons with the Qt button box, which handles the plattform-ui internally, and additionally allways enforces the same order. Change-Id: If62b90016b222322f60c0962da04c8277589a57f Reviewed-on: https://code.wireshark.org/review/12335 Reviewed-by: Roland Knall <rknall@gmail.com> Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
96bf82ced0
commit
b932ee8f13
|
@ -33,6 +33,8 @@
|
|||
#include "address_editor_frame.h"
|
||||
#include <ui_address_editor_frame.h>
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
#include "qt_ui_utils.h"
|
||||
|
||||
// To do:
|
||||
|
@ -60,12 +62,12 @@ AddressEditorFrame::~AddressEditorFrame()
|
|||
void AddressEditorFrame::editAddresses(CaptureFile &cf, int column)
|
||||
{
|
||||
if (!cf.capFile()->current_frame) {
|
||||
on_cancelButton_clicked();
|
||||
on_buttonBox_rejected();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cf_read_record(cf.capFile(), cf.capFile()->current_frame)) {
|
||||
on_cancelButton_clicked();
|
||||
on_buttonBox_rejected();
|
||||
return; // error reading the frame
|
||||
}
|
||||
|
||||
|
@ -107,13 +109,13 @@ void AddressEditorFrame::updateWidgets()
|
|||
ok_enable = true;
|
||||
}
|
||||
|
||||
ui->okButton->setEnabled(ok_enable);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok_enable);
|
||||
}
|
||||
|
||||
void AddressEditorFrame::on_nameResolutionPreferencesToolButton_clicked()
|
||||
{
|
||||
static const QString module_name = "nameres";
|
||||
on_cancelButton_clicked();
|
||||
on_buttonBox_rejected();
|
||||
emit showNameResolutionPreferences(module_name);
|
||||
}
|
||||
|
||||
|
@ -129,12 +131,12 @@ void AddressEditorFrame::on_nameLineEdit_textEdited(const QString &)
|
|||
|
||||
void AddressEditorFrame::on_nameLineEdit_returnPressed()
|
||||
{
|
||||
if (ui->okButton->isEnabled()) {
|
||||
on_okButton_clicked();
|
||||
if (ui->buttonBox->button(QDialogButtonBox::Ok)->isEnabled()) {
|
||||
on_buttonBox_accepted();
|
||||
}
|
||||
}
|
||||
|
||||
void AddressEditorFrame::on_okButton_clicked()
|
||||
void AddressEditorFrame::on_buttonBox_accepted()
|
||||
{
|
||||
if (ui->addressComboBox->count() < 1 || ui->nameLineEdit->text().isEmpty()) {
|
||||
return;
|
||||
|
@ -144,14 +146,14 @@ void AddressEditorFrame::on_okButton_clicked()
|
|||
if (!add_ip_name_from_string(addr.toUtf8().constData(), name.toUtf8().constData())) {
|
||||
QString error_msg = tr("Can't assign %1 to %2").arg(name).arg(addr);
|
||||
emit editAddressStatus(error_msg);
|
||||
ui->okButton->setEnabled(false);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
on_cancelButton_clicked();
|
||||
on_buttonBox_rejected();
|
||||
emit redissectPackets();
|
||||
}
|
||||
|
||||
void AddressEditorFrame::on_cancelButton_clicked()
|
||||
void AddressEditorFrame::on_buttonBox_rejected()
|
||||
{
|
||||
ui->addressComboBox->clear();
|
||||
ui->nameLineEdit->clear();
|
||||
|
|
|
@ -54,8 +54,8 @@ private slots:
|
|||
void on_addressComboBox_currentIndexChanged(const QString &);
|
||||
void on_nameLineEdit_textEdited(const QString &);
|
||||
void on_nameLineEdit_returnPressed();
|
||||
void on_okButton_clicked();
|
||||
void on_cancelButton_clicked();
|
||||
void on_buttonBox_accepted();
|
||||
void on_buttonBox_rejected();
|
||||
|
||||
private:
|
||||
Ui::AddressEditorFrame *ui;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>833</width>
|
||||
<height>28</height>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -19,7 +19,7 @@
|
|||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,3,0,0,0,0,1,0,0,0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,3,0,0,0,0,1,0,0">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
@ -106,16 +106,15 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="okButton">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>27</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "column_editor_frame.h"
|
||||
#include <ui_column_editor_frame.h>
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QComboBox>
|
||||
|
||||
ColumnEditorFrame::ColumnEditorFrame(QWidget *parent) :
|
||||
|
@ -76,7 +77,7 @@ void ColumnEditorFrame::setFields(int index)
|
|||
ui->occurrenceLineEdit->clear();
|
||||
ui->occurrenceLineEdit->setSyntaxState(SyntaxLineEdit::Empty);
|
||||
}
|
||||
ui->okButton->setEnabled(ok);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
|
||||
}
|
||||
|
||||
void ColumnEditorFrame::editColumn(int column)
|
||||
|
@ -107,7 +108,7 @@ void ColumnEditorFrame::on_fieldNameLineEdit_textEdited(const QString &field)
|
|||
((ui->typeComboBox->currentIndex() == COL_CUSTOM) &&
|
||||
(ui->occurrenceLineEdit->syntaxState() == SyntaxLineEdit::Empty)))
|
||||
ok = false;
|
||||
ui->okButton->setEnabled(ok);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
|
||||
|
||||
saved_field_ = field;
|
||||
}
|
||||
|
@ -125,18 +126,18 @@ void ColumnEditorFrame::on_occurrenceLineEdit_textEdited(const QString &occurren
|
|||
((ui->typeComboBox->currentIndex() == COL_CUSTOM) &&
|
||||
(ui->occurrenceLineEdit->syntaxState() == SyntaxLineEdit::Empty)))
|
||||
ok = false;
|
||||
ui->okButton->setEnabled(ok);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
|
||||
|
||||
saved_occurrence_ = occurrence;
|
||||
}
|
||||
|
||||
void ColumnEditorFrame::on_cancelButton_clicked()
|
||||
void ColumnEditorFrame::on_buttonBox_rejected()
|
||||
{
|
||||
cur_column_ = -1;
|
||||
animatedHide();
|
||||
}
|
||||
|
||||
void ColumnEditorFrame::on_okButton_clicked()
|
||||
void ColumnEditorFrame::on_buttonBox_accepted()
|
||||
{
|
||||
QByteArray col_str;
|
||||
if (cur_column_ >= 0) {
|
||||
|
@ -155,7 +156,8 @@ void ColumnEditorFrame::on_okButton_clicked()
|
|||
}
|
||||
emit columnEdited();
|
||||
}
|
||||
on_cancelButton_clicked();
|
||||
|
||||
on_buttonBox_rejected();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -44,8 +44,8 @@ private slots:
|
|||
void on_typeComboBox_activated(int index);
|
||||
void on_fieldNameLineEdit_textEdited(const QString &field);
|
||||
void on_occurrenceLineEdit_textEdited(const QString &occurrence);
|
||||
void on_cancelButton_clicked();
|
||||
void on_okButton_clicked();
|
||||
void on_buttonBox_rejected();
|
||||
void on_buttonBox_accepted();
|
||||
|
||||
private:
|
||||
Ui::ColumnEditorFrame *ui;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1018</width>
|
||||
<height>30</height>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -19,7 +19,7 @@
|
|||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,0,0,0,0,0,0,0,0,2,0,0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,0,0,0,0,0,0,0,0,2,0">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
@ -119,16 +119,15 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>27</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="okButton">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include <epan/filter_expressions.h>
|
||||
#include <ui/preference_utils.h>
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
// To do:
|
||||
// - Add the ability to edit current expressions.
|
||||
|
||||
|
@ -43,7 +45,7 @@ FilterExpressionFrame::~FilterExpressionFrame()
|
|||
void FilterExpressionFrame::addExpression(const QString filter_text)
|
||||
{
|
||||
if (isVisible()) {
|
||||
on_cancelButton_clicked();
|
||||
on_buttonBox_rejected();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -67,12 +69,12 @@ void FilterExpressionFrame::updateWidgets()
|
|||
ok_enable = true;
|
||||
}
|
||||
|
||||
ui->okButton->setEnabled(ok_enable);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok_enable);
|
||||
}
|
||||
|
||||
void FilterExpressionFrame::on_filterExpressionPreferencesToolButton_clicked()
|
||||
{
|
||||
on_cancelButton_clicked();
|
||||
on_buttonBox_rejected();
|
||||
emit showPreferencesDialog(PreferencesDialog::ppFilterExpressions);
|
||||
}
|
||||
|
||||
|
@ -81,19 +83,19 @@ void FilterExpressionFrame::on_labelLineEdit_textChanged(const QString)
|
|||
updateWidgets();
|
||||
}
|
||||
|
||||
void FilterExpressionFrame::on_okButton_clicked()
|
||||
void FilterExpressionFrame::on_buttonBox_accepted()
|
||||
{
|
||||
QByteArray label_ba = ui->labelLineEdit->text().toUtf8();
|
||||
QByteArray expr_ba = ui->displayFilterLineEdit->text().toUtf8();
|
||||
|
||||
filter_expression_new(label_ba.constData(), expr_ba.constData(), TRUE);
|
||||
|
||||
on_cancelButton_clicked();
|
||||
on_buttonBox_rejected();
|
||||
emit filterExpressionsChanged();
|
||||
prefs_main_write();
|
||||
}
|
||||
|
||||
void FilterExpressionFrame::on_cancelButton_clicked()
|
||||
void FilterExpressionFrame::on_buttonBox_rejected()
|
||||
{
|
||||
ui->labelLineEdit->clear();
|
||||
ui->displayFilterLineEdit->clear();
|
||||
|
|
|
@ -53,8 +53,8 @@ private slots:
|
|||
void updateWidgets();
|
||||
void on_filterExpressionPreferencesToolButton_clicked();
|
||||
void on_labelLineEdit_textChanged(const QString);
|
||||
void on_okButton_clicked();
|
||||
void on_cancelButton_clicked();
|
||||
void on_buttonBox_accepted();
|
||||
void on_buttonBox_rejected();
|
||||
};
|
||||
|
||||
#endif // FILTER_EXPRESSION_FRAME_H
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>745</width>
|
||||
<height>22</height>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -19,7 +19,7 @@
|
|||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,0,0,0,1,0,0,0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,0,0,0,1,0,0">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
@ -119,16 +119,15 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="okButton">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>27</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
|
||||
#include "wireshark_application.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
// Qt::escape
|
||||
#include <QTextDocument>
|
||||
|
@ -128,7 +130,7 @@ void PreferenceEditorFrame::uintLineEditTextEdited(const QString &new_str)
|
|||
if (new_str.isEmpty()) {
|
||||
new_uint_ = pref_->stashed_val.uint;
|
||||
ui->preferenceLineEdit->setSyntaxState(SyntaxLineEdit::Empty);
|
||||
ui->okButton->setEnabled(true);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -141,7 +143,7 @@ void PreferenceEditorFrame::uintLineEditTextEdited(const QString &new_str)
|
|||
new_uint_ = pref_->stashed_val.uint;
|
||||
ui->preferenceLineEdit->setSyntaxState(SyntaxLineEdit::Invalid);
|
||||
}
|
||||
ui->okButton->setEnabled(ok);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
|
||||
}
|
||||
|
||||
void PreferenceEditorFrame::stringLineEditTextEdited(const QString &new_str)
|
||||
|
@ -170,7 +172,7 @@ void PreferenceEditorFrame::rangeLineEditTextEdited(const QString &new_str)
|
|||
|
||||
void PreferenceEditorFrame::on_modulePreferencesToolButton_clicked()
|
||||
{
|
||||
on_cancelButton_clicked();
|
||||
on_buttonBox_rejected();
|
||||
if (module_) {
|
||||
QString module_name = module_->name;
|
||||
emit showProtocolPreferences(module_name);
|
||||
|
@ -179,12 +181,12 @@ void PreferenceEditorFrame::on_modulePreferencesToolButton_clicked()
|
|||
|
||||
void PreferenceEditorFrame::on_preferenceLineEdit_returnPressed()
|
||||
{
|
||||
if (ui->okButton->isEnabled()) {
|
||||
on_okButton_clicked();
|
||||
if (ui->buttonBox->button(QDialogButtonBox::Ok)->isEnabled()) {
|
||||
on_buttonBox_accepted();
|
||||
}
|
||||
}
|
||||
|
||||
void PreferenceEditorFrame::on_okButton_clicked()
|
||||
void PreferenceEditorFrame::on_buttonBox_accepted()
|
||||
{
|
||||
bool apply = false;
|
||||
switch(pref_->type) {
|
||||
|
@ -219,7 +221,7 @@ void PreferenceEditorFrame::on_okButton_clicked()
|
|||
prefs_main_write();
|
||||
}
|
||||
}
|
||||
on_cancelButton_clicked();
|
||||
on_buttonBox_rejected();
|
||||
// Emit signals once UI is hidden
|
||||
if (apply) {
|
||||
wsApp->emitAppSignal(WiresharkApplication::PacketDissectionChanged);
|
||||
|
@ -227,7 +229,7 @@ void PreferenceEditorFrame::on_okButton_clicked()
|
|||
}
|
||||
}
|
||||
|
||||
void PreferenceEditorFrame::on_cancelButton_clicked()
|
||||
void PreferenceEditorFrame::on_buttonBox_rejected()
|
||||
{
|
||||
pref_ = NULL;
|
||||
module_ = NULL;
|
||||
|
|
|
@ -54,8 +54,8 @@ private slots:
|
|||
|
||||
void on_modulePreferencesToolButton_clicked();
|
||||
void on_preferenceLineEdit_returnPressed();
|
||||
void on_okButton_clicked();
|
||||
void on_cancelButton_clicked();
|
||||
void on_buttonBox_accepted();
|
||||
void on_buttonBox_rejected();
|
||||
|
||||
private:
|
||||
Ui::PreferenceEditorFrame *ui;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>458</width>
|
||||
<height>22</height>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -19,7 +19,7 @@
|
|||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,0,0,0,0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,0,0,0">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
@ -77,16 +77,15 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="okButton">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>27</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in New Issue