2013-01-21 05:29:14 +00:00
|
|
|
/* layout_preferences_frame.cpp
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "layout_preferences_frame.h"
|
2015-06-25 16:17:03 +00:00
|
|
|
#include <ui_layout_preferences_frame.h>
|
2013-01-21 05:29:14 +00:00
|
|
|
|
|
|
|
#include <QAbstractButton>
|
|
|
|
#include <QToolButton>
|
|
|
|
#include <QRadioButton>
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <epan/prefs-int.h>
|
|
|
|
|
|
|
|
LayoutPreferencesFrame::LayoutPreferencesFrame(QWidget *parent) :
|
|
|
|
QFrame(parent),
|
|
|
|
ui(new Ui::LayoutPreferencesFrame)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
pref_layout_type_ = prefFromPrefPtr(&prefs.gui_layout_type);
|
|
|
|
pref_layout_content_1_ = prefFromPrefPtr(&prefs.gui_layout_content_1);
|
|
|
|
pref_layout_content_2_ = prefFromPrefPtr(&prefs.gui_layout_content_2);
|
|
|
|
pref_layout_content_3_ = prefFromPrefPtr(&prefs.gui_layout_content_3);
|
|
|
|
|
2013-01-22 18:27:18 +00:00
|
|
|
QString image_pad_ss = "QToolButton { padding: 0.3em; }";
|
|
|
|
ui->layout1ToolButton->setStyleSheet(image_pad_ss);
|
|
|
|
ui->layout2ToolButton->setStyleSheet(image_pad_ss);
|
|
|
|
ui->layout3ToolButton->setStyleSheet(image_pad_ss);
|
|
|
|
ui->layout4ToolButton->setStyleSheet(image_pad_ss);
|
|
|
|
ui->layout5ToolButton->setStyleSheet(image_pad_ss);
|
|
|
|
ui->layout6ToolButton->setStyleSheet(image_pad_ss);
|
2015-02-18 12:30:06 +00:00
|
|
|
|
2017-07-27 21:10:42 +00:00
|
|
|
QStyleOption style_opt;
|
|
|
|
QString indent_ss = QString(
|
|
|
|
"QCheckBox {"
|
|
|
|
" margin-left: %1px;"
|
|
|
|
"}"
|
|
|
|
).arg(ui->packetListSeparatorCheckBox->style()->subElementRect(QStyle::SE_CheckBoxContents, &style_opt).left());
|
2017-11-28 13:36:09 +00:00
|
|
|
ui->packetListSeparatorCheckBox->setStyleSheet(indent_ss);
|
2017-07-27 21:10:42 +00:00
|
|
|
ui->statusBarShowSelectedPacketCheckBox->setStyleSheet(indent_ss);
|
|
|
|
ui->statusBarShowFileLoadTimeCheckBox->setStyleSheet(indent_ss);
|
|
|
|
|
2015-02-18 12:30:06 +00:00
|
|
|
pref_packet_list_separator_ = prefFromPrefPtr(&prefs.gui_qt_packet_list_separator);
|
2017-01-07 13:52:23 +00:00
|
|
|
ui->packetListSeparatorCheckBox->setChecked(prefs_get_bool_value(pref_packet_list_separator_, pref_stashed));
|
2017-07-26 21:18:07 +00:00
|
|
|
|
|
|
|
pref_show_selected_packet_ = prefFromPrefPtr(&prefs.gui_qt_show_selected_packet);
|
|
|
|
ui->statusBarShowSelectedPacketCheckBox->setChecked(prefs_get_bool_value(pref_show_selected_packet_, pref_stashed));
|
2017-07-27 21:10:42 +00:00
|
|
|
|
|
|
|
pref_show_file_load_time_ = prefFromPrefPtr(&prefs.gui_qt_show_file_load_time);
|
|
|
|
ui->statusBarShowFileLoadTimeCheckBox->setChecked(prefs_get_bool_value(pref_show_file_load_time_, pref_stashed));
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LayoutPreferencesFrame::~LayoutPreferencesFrame()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2015-07-07 21:47:20 +00:00
|
|
|
void LayoutPreferencesFrame::showEvent(QShowEvent *)
|
2013-01-21 05:29:14 +00:00
|
|
|
{
|
|
|
|
updateWidgets();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::updateWidgets()
|
|
|
|
{
|
2017-01-07 13:52:23 +00:00
|
|
|
switch (prefs_get_uint_value_real(pref_layout_type_, pref_stashed)) {
|
2013-01-21 05:29:14 +00:00
|
|
|
case layout_type_5:
|
|
|
|
ui->layout5ToolButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
case layout_type_2:
|
|
|
|
ui->layout2ToolButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
case layout_type_1:
|
|
|
|
ui->layout1ToolButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
case layout_type_4:
|
|
|
|
ui->layout4ToolButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
case layout_type_3:
|
|
|
|
ui->layout3ToolButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
case layout_type_6:
|
|
|
|
ui->layout6ToolButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
switch (prefs_get_enum_value(pref_layout_content_1_, pref_stashed)) {
|
2013-01-21 05:29:14 +00:00
|
|
|
case layout_pane_content_plist:
|
|
|
|
ui->pane1PacketListRadioButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
case layout_pane_content_pdetails:
|
|
|
|
ui->pane1PacketDetailsRadioButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
case layout_pane_content_pbytes:
|
|
|
|
ui->pane1PacketBytesRadioButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
case layout_pane_content_none:
|
|
|
|
ui->pane1NoneRadioButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
switch (prefs_get_enum_value(pref_layout_content_2_, pref_stashed)) {
|
2013-01-21 05:29:14 +00:00
|
|
|
case layout_pane_content_plist:
|
|
|
|
ui->pane2PacketListRadioButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
case layout_pane_content_pdetails:
|
|
|
|
ui->pane2PacketDetailsRadioButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
case layout_pane_content_pbytes:
|
|
|
|
ui->pane2PacketBytesRadioButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
case layout_pane_content_none:
|
|
|
|
ui->pane2NoneRadioButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
switch (prefs_get_enum_value(pref_layout_content_3_, pref_stashed)) {
|
2013-01-21 05:29:14 +00:00
|
|
|
case layout_pane_content_plist:
|
|
|
|
ui->pane3PacketListRadioButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
case layout_pane_content_pdetails:
|
|
|
|
ui->pane3PacketDetailsRadioButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
case layout_pane_content_pbytes:
|
|
|
|
ui->pane3PacketBytesRadioButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
case layout_pane_content_none:
|
|
|
|
ui->pane3NoneRadioButton->setChecked(true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_layout5ToolButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_uint_value(pref_layout_type_, layout_type_5, pref_stashed);
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_layout2ToolButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_uint_value(pref_layout_type_, layout_type_2, pref_stashed);
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_layout1ToolButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_uint_value(pref_layout_type_, layout_type_1, pref_stashed);
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_layout4ToolButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_uint_value(pref_layout_type_, layout_type_4, pref_stashed);
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_layout3ToolButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_uint_value(pref_layout_type_, layout_type_3, pref_stashed);
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_layout6ToolButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_uint_value(pref_layout_type_, layout_type_6, pref_stashed);
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_pane1PacketListRadioButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_enum_value(pref_layout_content_1_, layout_pane_content_plist, pref_stashed);
|
2013-01-22 18:27:18 +00:00
|
|
|
if (ui->pane2PacketListRadioButton->isChecked())
|
|
|
|
ui->pane2NoneRadioButton->click();
|
|
|
|
if (ui->pane3PacketListRadioButton->isChecked())
|
|
|
|
ui->pane3NoneRadioButton->click();
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_pane1PacketDetailsRadioButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_enum_value(pref_layout_content_1_, layout_pane_content_pdetails, pref_stashed);
|
2013-01-22 18:27:18 +00:00
|
|
|
if (ui->pane2PacketDetailsRadioButton->isChecked())
|
|
|
|
ui->pane2NoneRadioButton->click();
|
|
|
|
if (ui->pane3PacketDetailsRadioButton->isChecked())
|
|
|
|
ui->pane3NoneRadioButton->click();
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_pane1PacketBytesRadioButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_enum_value(pref_layout_content_1_, layout_pane_content_pbytes, pref_stashed);
|
2013-01-22 18:27:18 +00:00
|
|
|
if (ui->pane2PacketBytesRadioButton->isChecked())
|
|
|
|
ui->pane2NoneRadioButton->click();
|
|
|
|
if (ui->pane3PacketBytesRadioButton->isChecked())
|
|
|
|
ui->pane3NoneRadioButton->click();
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_pane1NoneRadioButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_enum_value(pref_layout_content_1_, layout_pane_content_none, pref_stashed);
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_pane2PacketListRadioButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_enum_value(pref_layout_content_2_, layout_pane_content_plist, pref_stashed);
|
2013-01-22 18:27:18 +00:00
|
|
|
if (ui->pane1PacketListRadioButton->isChecked())
|
|
|
|
ui->pane1NoneRadioButton->click();
|
|
|
|
if (ui->pane3PacketListRadioButton->isChecked())
|
|
|
|
ui->pane3NoneRadioButton->click();
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_pane2PacketDetailsRadioButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_enum_value(pref_layout_content_2_, layout_pane_content_pdetails, pref_stashed);
|
2013-01-22 18:27:18 +00:00
|
|
|
if (ui->pane1PacketDetailsRadioButton->isChecked())
|
|
|
|
ui->pane1NoneRadioButton->click();
|
|
|
|
if (ui->pane3PacketDetailsRadioButton->isChecked())
|
|
|
|
ui->pane3NoneRadioButton->click();
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_pane2PacketBytesRadioButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_enum_value(pref_layout_content_2_, layout_pane_content_pbytes, pref_stashed);
|
2013-01-22 18:27:18 +00:00
|
|
|
if (ui->pane1PacketBytesRadioButton->isChecked())
|
|
|
|
ui->pane1NoneRadioButton->click();
|
|
|
|
if (ui->pane3PacketBytesRadioButton->isChecked())
|
|
|
|
ui->pane3NoneRadioButton->click();
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_pane2NoneRadioButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_enum_value(pref_layout_content_2_, layout_pane_content_none, pref_stashed);
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_pane3PacketListRadioButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_enum_value(pref_layout_content_3_, layout_pane_content_plist, pref_stashed);
|
2013-01-22 18:27:18 +00:00
|
|
|
if (ui->pane1PacketListRadioButton->isChecked())
|
|
|
|
ui->pane1NoneRadioButton->click();
|
|
|
|
if (ui->pane2PacketListRadioButton->isChecked())
|
|
|
|
ui->pane2NoneRadioButton->click();
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_pane3PacketDetailsRadioButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_enum_value(pref_layout_content_3_, layout_pane_content_pdetails, pref_stashed);
|
2013-01-22 18:27:18 +00:00
|
|
|
if (ui->pane1PacketDetailsRadioButton->isChecked())
|
|
|
|
ui->pane1NoneRadioButton->click();
|
|
|
|
if (ui->pane2PacketDetailsRadioButton->isChecked())
|
|
|
|
ui->pane2NoneRadioButton->click();
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_pane3PacketBytesRadioButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_enum_value(pref_layout_content_3_, layout_pane_content_pbytes, pref_stashed);
|
2013-01-22 18:27:18 +00:00
|
|
|
if (ui->pane1PacketBytesRadioButton->isChecked())
|
|
|
|
ui->pane1NoneRadioButton->click();
|
|
|
|
if (ui->pane2PacketBytesRadioButton->isChecked())
|
|
|
|
ui->pane2NoneRadioButton->click();
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_pane3NoneRadioButton_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_enum_value(pref_layout_content_3_, layout_pane_content_none, pref_stashed);
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
2015-07-07 21:47:20 +00:00
|
|
|
void LayoutPreferencesFrame::on_restoreButtonBox_clicked(QAbstractButton *)
|
2013-01-21 05:29:14 +00:00
|
|
|
{
|
2017-01-07 13:52:23 +00:00
|
|
|
reset_stashed_pref(pref_layout_type_);
|
|
|
|
reset_stashed_pref(pref_layout_content_1_);
|
2013-01-22 18:27:18 +00:00
|
|
|
updateWidgets();
|
2017-01-07 13:52:23 +00:00
|
|
|
reset_stashed_pref(pref_layout_content_2_);
|
2013-01-22 18:27:18 +00:00
|
|
|
updateWidgets();
|
2017-01-07 13:52:23 +00:00
|
|
|
reset_stashed_pref(pref_layout_content_3_);
|
2013-01-21 05:29:14 +00:00
|
|
|
updateWidgets();
|
2015-02-18 12:30:06 +00:00
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
ui->packetListSeparatorCheckBox->setChecked(prefs_get_bool_value(pref_packet_list_separator_, pref_default));
|
2017-07-26 21:18:07 +00:00
|
|
|
ui->statusBarShowSelectedPacketCheckBox->setChecked(prefs_get_bool_value(pref_show_selected_packet_, pref_default));
|
2017-07-27 21:10:42 +00:00
|
|
|
ui->statusBarShowFileLoadTimeCheckBox->setChecked(prefs_get_bool_value(pref_show_file_load_time_, pref_default));
|
2015-02-18 12:30:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutPreferencesFrame::on_packetListSeparatorCheckBox_toggled(bool checked)
|
|
|
|
{
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_bool_value(pref_packet_list_separator_, (gboolean) checked, pref_stashed);
|
2013-01-21 05:29:14 +00:00
|
|
|
}
|
|
|
|
|
2017-07-26 21:18:07 +00:00
|
|
|
void LayoutPreferencesFrame::on_statusBarShowSelectedPacketCheckBox_toggled(bool checked)
|
|
|
|
{
|
|
|
|
prefs_set_bool_value(pref_show_selected_packet_, (gboolean) checked, pref_stashed);
|
|
|
|
}
|
|
|
|
|
2017-07-27 21:10:42 +00:00
|
|
|
void LayoutPreferencesFrame::on_statusBarShowFileLoadTimeCheckBox_toggled(bool checked)
|
|
|
|
{
|
|
|
|
prefs_set_bool_value(pref_show_file_load_time_, (gboolean) checked, pref_stashed);
|
|
|
|
}
|
|
|
|
|
2013-01-21 05:29:14 +00:00
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|