aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorRoland Knall <roland.knall@br-automation.com>2015-12-01 15:41:44 +0100
committerGerald Combs <gerald@wireshark.org>2015-12-01 23:33:57 +0000
commitb932ee8f136ffeb3e78ce0f03e08df81fd18d9d4 (patch)
tree2826b2e104b2894ae3a47c840cc1f3efce2d5420 /ui
parent96bf82ced0b58c7a4c2a6c300efeebe4f05c0ff4 (diff)
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>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/address_editor_frame.cpp22
-rw-r--r--ui/qt/address_editor_frame.h4
-rw-r--r--ui/qt/address_editor_frame.ui21
-rw-r--r--ui/qt/column_editor_frame.cpp14
-rw-r--r--ui/qt/column_editor_frame.h4
-rw-r--r--ui/qt/column_editor_frame.ui21
-rw-r--r--ui/qt/filter_expression_frame.cpp14
-rw-r--r--ui/qt/filter_expression_frame.h4
-rw-r--r--ui/qt/filter_expression_frame.ui21
-rw-r--r--ui/qt/preference_editor_frame.cpp18
-rw-r--r--ui/qt/preference_editor_frame.h4
-rw-r--r--ui/qt/preference_editor_frame.ui21
12 files changed, 86 insertions, 82 deletions
diff --git a/ui/qt/address_editor_frame.cpp b/ui/qt/address_editor_frame.cpp
index 670aec6fc5..0ed5246ad1 100644
--- a/ui/qt/address_editor_frame.cpp
+++ b/ui/qt/address_editor_frame.cpp
@@ -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();
diff --git a/ui/qt/address_editor_frame.h b/ui/qt/address_editor_frame.h
index 92b3463e4c..0bec30b4b9 100644
--- a/ui/qt/address_editor_frame.h
+++ b/ui/qt/address_editor_frame.h
@@ -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;
diff --git a/ui/qt/address_editor_frame.ui b/ui/qt/address_editor_frame.ui
index 5b16198fab..9a4fd8a1e7 100644
--- a/ui/qt/address_editor_frame.ui
+++ b/ui/qt/address_editor_frame.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>
diff --git a/ui/qt/column_editor_frame.cpp b/ui/qt/column_editor_frame.cpp
index d23071042f..2e3ca3dc16 100644
--- a/ui/qt/column_editor_frame.cpp
+++ b/ui/qt/column_editor_frame.cpp
@@ -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();
}
/*
diff --git a/ui/qt/column_editor_frame.h b/ui/qt/column_editor_frame.h
index b35200dcad..f7e019bad5 100644
--- a/ui/qt/column_editor_frame.h
+++ b/ui/qt/column_editor_frame.h
@@ -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;
diff --git a/ui/qt/column_editor_frame.ui b/ui/qt/column_editor_frame.ui
index 97d06bf9cd..cbf3812c3d 100644
--- a/ui/qt/column_editor_frame.ui
+++ b/ui/qt/column_editor_frame.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>
diff --git a/ui/qt/filter_expression_frame.cpp b/ui/qt/filter_expression_frame.cpp
index ce99fe0fcd..c876a85c66 100644
--- a/ui/qt/filter_expression_frame.cpp
+++ b/ui/qt/filter_expression_frame.cpp
@@ -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();
diff --git a/ui/qt/filter_expression_frame.h b/ui/qt/filter_expression_frame.h
index 3e289919f5..ad3119d23b 100644
--- a/ui/qt/filter_expression_frame.h
+++ b/ui/qt/filter_expression_frame.h
@@ -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
diff --git a/ui/qt/filter_expression_frame.ui b/ui/qt/filter_expression_frame.ui
index 7a2a33f67d..96ab542b91 100644
--- a/ui/qt/filter_expression_frame.ui
+++ b/ui/qt/filter_expression_frame.ui
@@ -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>
diff --git a/ui/qt/preference_editor_frame.cpp b/ui/qt/preference_editor_frame.cpp
index e942359997..6b193e36c0 100644
--- a/ui/qt/preference_editor_frame.cpp
+++ b/ui/qt/preference_editor_frame.cpp
@@ -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;
diff --git a/ui/qt/preference_editor_frame.h b/ui/qt/preference_editor_frame.h
index d652572828..4969a9bf2c 100644
--- a/ui/qt/preference_editor_frame.h
+++ b/ui/qt/preference_editor_frame.h
@@ -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;
diff --git a/ui/qt/preference_editor_frame.ui b/ui/qt/preference_editor_frame.ui
index dc740984f5..0b7ac881cd 100644
--- a/ui/qt/preference_editor_frame.ui
+++ b/ui/qt/preference_editor_frame.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>