Qt: Add the ability to show preferences by module name.
Currently unused, but allows feature parity with the GTK+ UI. Change-Id: I33e0bfb434949aabd75ecd2ed36e696731195542 Reviewed-on: https://code.wireshark.org/review/8922 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
6625cf5e52
commit
9fb6ec6c89
|
@ -330,6 +330,7 @@ private slots:
|
|||
void on_actionEditPacketComment_triggered();
|
||||
void on_actionEditConfigurationProfiles_triggered();
|
||||
void showPreferencesDialog(PreferencesDialog::PreferencesPane start_pane = PreferencesDialog::ppAppearance);
|
||||
void showPreferencesDialog(QString module_name);
|
||||
void on_actionEditPreferences_triggered();
|
||||
|
||||
void showHideMainWidgets(QAction *action);
|
||||
|
|
|
@ -1970,8 +1970,23 @@ void MainWindow::on_actionEditConfigurationProfiles_triggered()
|
|||
|
||||
void MainWindow::showPreferencesDialog(PreferencesDialog::PreferencesPane start_pane)
|
||||
{
|
||||
PreferencesDialog pref_dialog(this, start_pane);
|
||||
PreferencesDialog pref_dialog(this);
|
||||
|
||||
pref_dialog.setPane(start_pane);
|
||||
pref_dialog.exec();
|
||||
|
||||
// Emitting PacketDissectionChanged directly from PreferencesDialog
|
||||
// can cause problems. Queue them up and emit them here.
|
||||
foreach (WiresharkApplication::AppSignal app_signal, pref_dialog.appSignals()) {
|
||||
wsApp->emitAppSignal(app_signal);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::showPreferencesDialog(QString module_name)
|
||||
{
|
||||
PreferencesDialog pref_dialog(this);
|
||||
|
||||
pref_dialog.setPane(module_name);
|
||||
pref_dialog.exec();
|
||||
|
||||
// Emitting PacketDissectionChanged directly from PreferencesDialog
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "color.h"
|
||||
|
||||
#include <epan/prefs.h>
|
||||
#include <epan/prefs-int.h>
|
||||
|
||||
#include <QScrollArea>
|
||||
|
||||
|
@ -43,6 +44,7 @@ class ModulePreferencesScrollArea : public QScrollArea
|
|||
public:
|
||||
explicit ModulePreferencesScrollArea(module_t *module, QWidget *parent = 0);
|
||||
~ModulePreferencesScrollArea();
|
||||
const QString name() const { return QString(module_->name); }
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *);
|
||||
|
|
|
@ -195,9 +195,6 @@ module_prefs_show(module_t *module, gpointer ti_ptr)
|
|||
/* Scrolled window */
|
||||
ModulePreferencesScrollArea *mpsa = new ModulePreferencesScrollArea(module);
|
||||
|
||||
// /* Associate this module with the page's frame. */
|
||||
// g_object_set_data(G_OBJECT(frame), E_PAGE_MODULE_KEY, module);
|
||||
|
||||
/* Add the page to the notebook */
|
||||
stacked_widget->addWidget(mpsa);
|
||||
|
||||
|
@ -261,7 +258,7 @@ const int capture_item_ = 1;
|
|||
// We store the saved and current preference values in the "Advanced" tree columns
|
||||
const int pref_ptr_col_ = 0;
|
||||
|
||||
PreferencesDialog::PreferencesDialog(QWidget *parent, PreferencesPane start_pane) :
|
||||
PreferencesDialog::PreferencesDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
pd_ui_(new Ui::PreferencesDialog),
|
||||
cur_line_edit_(NULL),
|
||||
|
@ -301,18 +298,21 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, PreferencesPane start_pane
|
|||
pd_ui_->prefsTree->invisibleRootItem()->child(capture_item_)->setDisabled(disable_capture);
|
||||
|
||||
// PreferencesPane, prefsTree, and stackedWidget must all correspond to each other.
|
||||
// This may not be the best way to go about enforcing that.
|
||||
QTreeWidgetItem *item = pd_ui_->prefsTree->itemAt(0,0);
|
||||
QTreeWidgetItem *start_item = pd_ui_->prefsTree->invisibleRootItem()->child(0);
|
||||
item->setSelected(true);
|
||||
pd_ui_->stackedWidget->setCurrentIndex(0);
|
||||
for (int i = 0; i < pd_ui_->stackedWidget->count() && item; i++) {
|
||||
item->setData(0, Qt::UserRole, qVariantFromValue(pd_ui_->stackedWidget->widget(i)));
|
||||
if (i == start_pane) {
|
||||
start_item = item;
|
||||
}
|
||||
item = pd_ui_->prefsTree->itemBelow(item);
|
||||
}
|
||||
pd_ui_->prefsTree->setCurrentItem(start_item);
|
||||
item = pd_ui_->prefsTree->topLevelItem(0);
|
||||
prefs_pane_to_item_[ppAppearance] = item;
|
||||
prefs_pane_to_item_[ppLayout] = item->child(0);
|
||||
prefs_pane_to_item_[ppColumn] = item->child(1);
|
||||
prefs_pane_to_item_[ppFontAndColor] = item->child(2);
|
||||
prefs_pane_to_item_[ppCapture] = pd_ui_->prefsTree->topLevelItem(1);
|
||||
prefs_pane_to_item_[ppFilterExpressions] = pd_ui_->prefsTree->topLevelItem(2);
|
||||
|
||||
// Printing prefs don't apply here.
|
||||
module_t *print_module = prefs_find_module("print");
|
||||
|
@ -334,6 +334,26 @@ PreferencesDialog::~PreferencesDialog()
|
|||
prefs_modules_foreach_submodules(NULL, module_prefs_clean_stash, NULL);
|
||||
}
|
||||
|
||||
void PreferencesDialog::setPane(PreferencesDialog::PreferencesPane start_pane)
|
||||
{
|
||||
if (prefs_pane_to_item_.contains(start_pane)) {
|
||||
pd_ui_->prefsTree->setCurrentItem(prefs_pane_to_item_[start_pane]);
|
||||
}
|
||||
}
|
||||
|
||||
void PreferencesDialog::setPane(const QString module_name)
|
||||
{
|
||||
QTreeWidgetItemIterator pref_it(pd_ui_->prefsTree);
|
||||
while (*pref_it) {
|
||||
ModulePreferencesScrollArea *mpsa = qobject_cast<ModulePreferencesScrollArea *>((*pref_it)->data(0, Qt::UserRole).value<QWidget *>());
|
||||
if (mpsa && mpsa->name() == module_name) {
|
||||
pd_ui_->prefsTree->setCurrentItem((*pref_it));
|
||||
break;
|
||||
}
|
||||
++pref_it;
|
||||
}
|
||||
}
|
||||
|
||||
void PreferencesDialog::showEvent(QShowEvent *evt)
|
||||
{
|
||||
Q_UNUSED(evt);
|
||||
|
|
|
@ -59,8 +59,11 @@ public:
|
|||
ppFilterExpressions
|
||||
};
|
||||
|
||||
explicit PreferencesDialog(QWidget *parent = 0, PreferencesPane start_pane = ppAppearance);
|
||||
explicit PreferencesDialog(QWidget *parent = 0);
|
||||
~PreferencesDialog();
|
||||
void setPane(PreferencesPane start_pane);
|
||||
void setPane(const QString module_name);
|
||||
|
||||
const QList<WiresharkApplication::AppSignal> appSignals() const { return app_signals_; }
|
||||
|
||||
protected:
|
||||
|
@ -72,6 +75,7 @@ private:
|
|||
void updateItem(QTreeWidgetItem &item);
|
||||
|
||||
Ui::PreferencesDialog *pd_ui_;
|
||||
QHash<PreferencesDialog::PreferencesPane, QTreeWidgetItem *>prefs_pane_to_item_;
|
||||
int cur_pref_type_;
|
||||
QLineEdit *cur_line_edit_;
|
||||
QString saved_string_pref_;
|
||||
|
|
Loading…
Reference in New Issue