1 /* packet_format_group_box.cpp
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
10 #include "packet_format_group_box.h"
11 #include <ui_packet_format_group_box.h>
13 #include <epan/print.h>
16 #include <QStyleOption>
18 PacketFormatGroupBox::PacketFormatGroupBox(QWidget
*parent
) :
20 pf_ui_(new Ui::PacketFormatGroupBox
)
22 pf_ui_
->setupUi(this);
25 QStyleOption style_opt
;
26 int cb_label_offset
= pf_ui_
->detailsCheckBox
->style()->subElementRect(QStyle::SE_CheckBoxContents
, &style_opt
).left();
28 // Indent the checkbox under the "Packet summary" checkbox
29 pf_ui_
->includeColumnHeadingsCheckBox
->setStyleSheet(QString(
31 " padding-left: %1px;"
33 ).arg(cb_label_offset
));
35 // Indent the radio buttons under the "Packet details" checkbox
36 pf_ui_
->allCollapsedButton
->setStyleSheet(QString(
38 " padding-left: %1px;"
40 ).arg(cb_label_offset
));
41 pf_ui_
->asDisplayedButton
->setStyleSheet(QString(
43 " padding-left: %1px;"
45 ).arg(cb_label_offset
));
46 pf_ui_
->allExpandedButton
->setStyleSheet(QString(
48 " padding-left: %1px;"
50 ).arg(cb_label_offset
));
52 // Indent the checkbox under the "Bytes" checkbox
53 pf_ui_
->includeDataSourcesCheckBox
->setStyleSheet(QString(
55 " padding-left: %1px;"
57 ).arg(cb_label_offset
));
60 PacketFormatGroupBox::~PacketFormatGroupBox()
65 bool PacketFormatGroupBox::summaryEnabled()
67 return pf_ui_
->summaryCheckBox
->isChecked();
70 bool PacketFormatGroupBox::detailsEnabled()
72 return pf_ui_
->detailsCheckBox
->isChecked();
75 bool PacketFormatGroupBox::bytesEnabled()
77 return pf_ui_
->bytesCheckBox
->isChecked();
80 bool PacketFormatGroupBox::includeColumnHeadingsEnabled()
82 return pf_ui_
->includeColumnHeadingsCheckBox
->isChecked();
85 bool PacketFormatGroupBox::allCollapsedEnabled()
87 return pf_ui_
->allCollapsedButton
->isChecked();
90 bool PacketFormatGroupBox::asDisplayedEnabled()
92 return pf_ui_
->asDisplayedButton
->isChecked();
95 bool PacketFormatGroupBox::allExpandedEnabled()
97 return pf_ui_
->allExpandedButton
->isChecked();
100 uint
PacketFormatGroupBox::getHexdumpOptions()
102 return pf_ui_
->includeDataSourcesCheckBox
->isChecked() ? HEXDUMP_SOURCE_MULTI
: HEXDUMP_SOURCE_PRIMARY
;
105 void PacketFormatGroupBox::on_summaryCheckBox_toggled(bool checked
)
107 pf_ui_
->includeColumnHeadingsCheckBox
->setEnabled(checked
);
108 emit
formatChanged();
111 void PacketFormatGroupBox::on_detailsCheckBox_toggled(bool checked
)
113 pf_ui_
->allCollapsedButton
->setEnabled(checked
);
114 pf_ui_
->asDisplayedButton
->setEnabled(checked
);
115 pf_ui_
->allExpandedButton
->setEnabled(checked
);
116 emit
formatChanged();
119 void PacketFormatGroupBox::on_bytesCheckBox_toggled(bool checked
)
121 pf_ui_
->includeDataSourcesCheckBox
->setEnabled(checked
);
122 emit
formatChanged();
125 void PacketFormatGroupBox::on_includeColumnHeadingsCheckBox_toggled(bool)
127 emit
formatChanged();
130 void PacketFormatGroupBox::on_allCollapsedButton_toggled(bool checked
)
132 if (checked
) emit
formatChanged();
135 void PacketFormatGroupBox::on_asDisplayedButton_toggled(bool checked
)
137 if (checked
) emit
formatChanged();
140 void PacketFormatGroupBox::on_allExpandedButton_toggled(bool checked
)
142 if (checked
) emit
formatChanged();
145 void PacketFormatGroupBox::on_includeDataSourcesCheckBox_toggled(bool)
147 emit
formatChanged();