HACK: 1. try to match RowsetProperties
[wireshark-wip.git] / ui / qt / layout_preferences_frame.cpp
blob3a51c0a558773cc2d7e393ae849217e8bbf27dc2
1 /* layout_preferences_frame.cpp
3 * $Id$
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "layout_preferences_frame.h"
25 #include "ui_layout_preferences_frame.h"
27 #include <QAbstractButton>
28 #include <QToolButton>
29 #include <QRadioButton>
31 #include <QDebug>
32 #include <epan/prefs-int.h>
34 LayoutPreferencesFrame::LayoutPreferencesFrame(QWidget *parent) :
35 QFrame(parent),
36 ui(new Ui::LayoutPreferencesFrame)
38 ui->setupUi(this);
40 pref_layout_type_ = prefFromPrefPtr(&prefs.gui_layout_type);
41 pref_layout_content_1_ = prefFromPrefPtr(&prefs.gui_layout_content_1);
42 pref_layout_content_2_ = prefFromPrefPtr(&prefs.gui_layout_content_2);
43 pref_layout_content_3_ = prefFromPrefPtr(&prefs.gui_layout_content_3);
45 QString image_pad_ss = "QToolButton { padding: 0.3em; }";
46 ui->layout1ToolButton->setStyleSheet(image_pad_ss);
47 ui->layout2ToolButton->setStyleSheet(image_pad_ss);
48 ui->layout3ToolButton->setStyleSheet(image_pad_ss);
49 ui->layout4ToolButton->setStyleSheet(image_pad_ss);
50 ui->layout5ToolButton->setStyleSheet(image_pad_ss);
51 ui->layout6ToolButton->setStyleSheet(image_pad_ss);
54 LayoutPreferencesFrame::~LayoutPreferencesFrame()
56 delete ui;
59 void LayoutPreferencesFrame::showEvent(QShowEvent *evt)
61 Q_UNUSED(evt);
62 updateWidgets();
65 void LayoutPreferencesFrame::updateWidgets()
67 switch (pref_layout_type_->stashed_val.uint) {
68 case layout_type_5:
69 ui->layout5ToolButton->setChecked(true);
70 break;
71 case layout_type_2:
72 ui->layout2ToolButton->setChecked(true);
73 break;
74 case layout_type_1:
75 ui->layout1ToolButton->setChecked(true);
76 break;
77 case layout_type_4:
78 ui->layout4ToolButton->setChecked(true);
79 break;
80 case layout_type_3:
81 ui->layout3ToolButton->setChecked(true);
82 break;
83 case layout_type_6:
84 ui->layout6ToolButton->setChecked(true);
85 break;
88 switch (pref_layout_content_1_->stashed_val.enumval) {
89 case layout_pane_content_plist:
90 ui->pane1PacketListRadioButton->setChecked(true);
91 break;
92 case layout_pane_content_pdetails:
93 ui->pane1PacketDetailsRadioButton->setChecked(true);
94 break;
95 case layout_pane_content_pbytes:
96 ui->pane1PacketBytesRadioButton->setChecked(true);
97 break;
98 case layout_pane_content_none:
99 ui->pane1NoneRadioButton->setChecked(true);
100 break;
103 switch (pref_layout_content_2_->stashed_val.enumval) {
104 case layout_pane_content_plist:
105 ui->pane2PacketListRadioButton->setChecked(true);
106 break;
107 case layout_pane_content_pdetails:
108 ui->pane2PacketDetailsRadioButton->setChecked(true);
109 break;
110 case layout_pane_content_pbytes:
111 ui->pane2PacketBytesRadioButton->setChecked(true);
112 break;
113 case layout_pane_content_none:
114 ui->pane2NoneRadioButton->setChecked(true);
115 break;
118 switch (pref_layout_content_3_->stashed_val.enumval) {
119 case layout_pane_content_plist:
120 ui->pane3PacketListRadioButton->setChecked(true);
121 break;
122 case layout_pane_content_pdetails:
123 ui->pane3PacketDetailsRadioButton->setChecked(true);
124 break;
125 case layout_pane_content_pbytes:
126 ui->pane3PacketBytesRadioButton->setChecked(true);
127 break;
128 case layout_pane_content_none:
129 ui->pane3NoneRadioButton->setChecked(true);
130 break;
134 void LayoutPreferencesFrame::on_layout5ToolButton_toggled(bool checked)
136 if (!checked) return;
137 pref_layout_type_->stashed_val.uint = layout_type_5;
140 void LayoutPreferencesFrame::on_layout2ToolButton_toggled(bool checked)
142 if (!checked) return;
143 pref_layout_type_->stashed_val.uint = layout_type_2;
146 void LayoutPreferencesFrame::on_layout1ToolButton_toggled(bool checked)
148 if (!checked) return;
149 pref_layout_type_->stashed_val.uint = layout_type_1;
152 void LayoutPreferencesFrame::on_layout4ToolButton_toggled(bool checked)
154 if (!checked) return;
155 pref_layout_type_->stashed_val.uint = layout_type_4;
158 void LayoutPreferencesFrame::on_layout3ToolButton_toggled(bool checked)
160 if (!checked) return;
161 pref_layout_type_->stashed_val.uint = layout_type_3;
164 void LayoutPreferencesFrame::on_layout6ToolButton_toggled(bool checked)
166 if (!checked) return;
167 pref_layout_type_->stashed_val.uint = layout_type_6;
170 void LayoutPreferencesFrame::on_pane1PacketListRadioButton_toggled(bool checked)
172 if (!checked) return;
173 pref_layout_content_1_->stashed_val.enumval = layout_pane_content_plist;
174 if (ui->pane2PacketListRadioButton->isChecked())
175 ui->pane2NoneRadioButton->click();
176 if (ui->pane3PacketListRadioButton->isChecked())
177 ui->pane3NoneRadioButton->click();
180 void LayoutPreferencesFrame::on_pane1PacketDetailsRadioButton_toggled(bool checked)
182 if (!checked) return;
183 pref_layout_content_1_->stashed_val.enumval = layout_pane_content_pdetails;
184 if (ui->pane2PacketDetailsRadioButton->isChecked())
185 ui->pane2NoneRadioButton->click();
186 if (ui->pane3PacketDetailsRadioButton->isChecked())
187 ui->pane3NoneRadioButton->click();
190 void LayoutPreferencesFrame::on_pane1PacketBytesRadioButton_toggled(bool checked)
192 if (!checked) return;
193 pref_layout_content_1_->stashed_val.enumval = layout_pane_content_pbytes;
194 if (ui->pane2PacketBytesRadioButton->isChecked())
195 ui->pane2NoneRadioButton->click();
196 if (ui->pane3PacketBytesRadioButton->isChecked())
197 ui->pane3NoneRadioButton->click();
200 void LayoutPreferencesFrame::on_pane1NoneRadioButton_toggled(bool checked)
202 if (!checked) return;
203 pref_layout_content_1_->stashed_val.enumval = layout_pane_content_none;
206 void LayoutPreferencesFrame::on_pane2PacketListRadioButton_toggled(bool checked)
208 if (!checked) return;
209 pref_layout_content_2_->stashed_val.enumval = layout_pane_content_plist;
210 if (ui->pane1PacketListRadioButton->isChecked())
211 ui->pane1NoneRadioButton->click();
212 if (ui->pane3PacketListRadioButton->isChecked())
213 ui->pane3NoneRadioButton->click();
216 void LayoutPreferencesFrame::on_pane2PacketDetailsRadioButton_toggled(bool checked)
218 if (!checked) return;
219 pref_layout_content_2_->stashed_val.enumval = layout_pane_content_pdetails;
220 if (ui->pane1PacketDetailsRadioButton->isChecked())
221 ui->pane1NoneRadioButton->click();
222 if (ui->pane3PacketDetailsRadioButton->isChecked())
223 ui->pane3NoneRadioButton->click();
226 void LayoutPreferencesFrame::on_pane2PacketBytesRadioButton_toggled(bool checked)
228 if (!checked) return;
229 pref_layout_content_2_->stashed_val.enumval = layout_pane_content_pbytes;
230 if (ui->pane1PacketBytesRadioButton->isChecked())
231 ui->pane1NoneRadioButton->click();
232 if (ui->pane3PacketBytesRadioButton->isChecked())
233 ui->pane3NoneRadioButton->click();
236 void LayoutPreferencesFrame::on_pane2NoneRadioButton_toggled(bool checked)
238 if (!checked) return;
239 pref_layout_content_2_->stashed_val.enumval = layout_pane_content_none;
242 void LayoutPreferencesFrame::on_pane3PacketListRadioButton_toggled(bool checked)
244 if (!checked) return;
245 pref_layout_content_3_->stashed_val.enumval = layout_pane_content_plist;
246 if (ui->pane1PacketListRadioButton->isChecked())
247 ui->pane1NoneRadioButton->click();
248 if (ui->pane2PacketListRadioButton->isChecked())
249 ui->pane2NoneRadioButton->click();
252 void LayoutPreferencesFrame::on_pane3PacketDetailsRadioButton_toggled(bool checked)
254 if (!checked) return;
255 pref_layout_content_3_->stashed_val.enumval = layout_pane_content_pdetails;
256 if (ui->pane1PacketDetailsRadioButton->isChecked())
257 ui->pane1NoneRadioButton->click();
258 if (ui->pane2PacketDetailsRadioButton->isChecked())
259 ui->pane2NoneRadioButton->click();
262 void LayoutPreferencesFrame::on_pane3PacketBytesRadioButton_toggled(bool checked)
264 if (!checked) return;
265 pref_layout_content_3_->stashed_val.enumval = layout_pane_content_pbytes;
266 if (ui->pane1PacketBytesRadioButton->isChecked())
267 ui->pane1NoneRadioButton->click();
268 if (ui->pane2PacketBytesRadioButton->isChecked())
269 ui->pane2NoneRadioButton->click();
272 void LayoutPreferencesFrame::on_pane3NoneRadioButton_toggled(bool checked)
274 if (!checked) return;
275 pref_layout_content_3_->stashed_val.enumval = layout_pane_content_none;
279 void LayoutPreferencesFrame::on_restoreButtonBox_clicked(QAbstractButton *button)
281 Q_UNUSED(button);
282 pref_layout_type_->stashed_val.uint = pref_layout_type_->default_val.uint;
283 pref_layout_content_1_->stashed_val.enumval = pref_layout_content_1_->default_val.enumval;
284 updateWidgets();
285 pref_layout_content_2_->stashed_val.enumval = pref_layout_content_2_->default_val.enumval;
286 updateWidgets();
287 pref_layout_content_3_->stashed_val.enumval = pref_layout_content_3_->default_val.enumval;
288 updateWidgets();
292 * Editor modelines
294 * Local Variables:
295 * c-basic-offset: 4
296 * tab-width: 8
297 * indent-tabs-mode: nil
298 * End:
300 * ex: set shiftwidth=4 tabstop=8 expandtab:
301 * :indentSize=4:tabSize=8:noTabs=true: