summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorRoland Knall <roland.knall@br-automation.com>2017-01-24 17:34:07 +0100
committerRoland Knall <rknall@gmail.com>2017-02-24 08:12:46 +0000
commit321386e9f49d88b64f48868c6e4079b2073547a1 (patch)
treed30943f392b322b6dd7e1245f7efc3915051ab55 /ui
parentbd9afdddfe45b4c9c6e966df7264d12cdfd85f42 (diff)
downloadwireshark-321386e9f49d88b64f48868c6e4079b2073547a1.tar.gz
PluginIF: AdditionalToolbar
Creates an interface for plugins and other parts of the code, to add a new toolbar to the system and have various widget types interact with this toolbar. All toolbars added via this interface, will be added to an additional submenu called "Additional Toolbars" within Wireshark. Also a demo plugin is being provided, demonstrating various features of the toolbar, including updating the gui elements. It also demonstrates how to update toolbar items. Change-Id: I8d0351224b3d7f4b90220d58970b51695551d7e3 Reviewed-on: https://code.wireshark.org/review/19803 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/CMakeLists.txt4
-rw-r--r--ui/qt/Makefile.am4
-rw-r--r--ui/qt/additional_toolbar.cpp537
-rw-r--r--ui/qt/additional_toolbar.h101
-rw-r--r--ui/qt/apply_line_edit.cpp181
-rw-r--r--ui/qt/apply_line_edit.h82
-rw-r--r--ui/qt/main_window.cpp133
-rw-r--r--ui/qt/main_window.h5
-rw-r--r--ui/qt/main_window.ui6
-rw-r--r--ui/qt/main_window_slots.cpp70
-rw-r--r--ui/recent.c14
-rw-r--r--ui/recent.h1
12 files changed, 1129 insertions, 9 deletions
diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt
index 2eb0b43beb..f70606e1a4 100644
--- a/ui/qt/CMakeLists.txt
+++ b/ui/qt/CMakeLists.txt
@@ -27,6 +27,7 @@ set(WIRESHARK_QT_HEADERS
about_dialog.h
accordion_frame.h
address_editor_frame.h
+ apply_line_edit.h
bluetooth_att_server_attributes_dialog.h
bluetooth_device_dialog.h
bluetooth_devices_dialog.h
@@ -84,6 +85,7 @@ set(WIRESHARK_QT_HEADERS
gsm_map_summary_dialog.h
iax2_analysis_dialog.h
import_text_dialog.h
+ additional_toolbar.h
interface_tree_model.h
interface_tree_cache_model.h
interface_sort_filter_model.h
@@ -198,6 +200,7 @@ set(WIRESHARK_QT_SRC
about_dialog.cpp
accordion_frame.cpp
address_editor_frame.cpp
+ apply_line_edit.cpp
bluetooth_att_server_attributes_dialog.cpp
bluetooth_device_dialog.cpp
bluetooth_devices_dialog.cpp
@@ -250,6 +253,7 @@ set(WIRESHARK_QT_SRC
geometry_state_dialog.cpp
iax2_analysis_dialog.cpp
import_text_dialog.cpp
+ additional_toolbar.cpp
interface_tree_model.cpp
interface_tree_cache_model.cpp
interface_sort_filter_model.cpp
diff --git a/ui/qt/Makefile.am b/ui/qt/Makefile.am
index b199e7ff3d..eb1d77e7a4 100644
--- a/ui/qt/Makefile.am
+++ b/ui/qt/Makefile.am
@@ -156,6 +156,7 @@ MOC_HDRS = \
about_dialog.h \
accordion_frame.h \
address_editor_frame.h \
+ apply_line_edit.h \
bluetooth_att_server_attributes_dialog.h \
bluetooth_device_dialog.h \
bluetooth_devices_dialog.h \
@@ -212,6 +213,7 @@ MOC_HDRS = \
iax2_analysis_dialog.h \
import_text_dialog.h \
interface_frame.h \
+ additional_toolbar.h \
interface_tree_model.h \
interface_tree_cache_model.h \
interface_sort_filter_model.h \
@@ -439,6 +441,7 @@ WIRESHARK_QT_SRC = \
about_dialog.cpp \
accordion_frame.cpp \
address_editor_frame.cpp \
+ apply_line_edit.cpp \
bluetooth_att_server_attributes_dialog.cpp \
bluetooth_device_dialog.cpp \
bluetooth_devices_dialog.cpp \
@@ -492,6 +495,7 @@ WIRESHARK_QT_SRC = \
iax2_analysis_dialog.cpp \
import_text_dialog.cpp \
interface_frame.cpp \
+ additional_toolbar.cpp \
interface_tree_model.cpp \
interface_tree_cache_model.cpp \
interface_sort_filter_model.cpp \
diff --git a/ui/qt/additional_toolbar.cpp b/ui/qt/additional_toolbar.cpp
new file mode 100644
index 0000000000..5192fb5312
--- /dev/null
+++ b/ui/qt/additional_toolbar.cpp
@@ -0,0 +1,537 @@
+/* additional_toolbar.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 <additional_toolbar.h>
+#include <config.h>
+
+#include <glib.h>
+
+#include <ui/qt/apply_line_edit.h>
+#include <ui/qt/qt_ui_utils.h>
+#include <ui/qt/variant_pointer.h>
+#include <ui/qt/wireshark_application.h>
+
+#include <QLabel>
+#include <QLineEdit>
+#include <QHBoxLayout>
+#include <QComboBox>
+#include <QWidget>
+#include <QCheckBox>
+#include <QPushButton>
+#include <QStandardItem>
+#include <QStandardItemModel>
+#include <QLayoutItem>
+
+const char * AdditionalToolbarWidgetAction::propertyName = "additional_toolbar_item";
+
+AdditionalToolBar::AdditionalToolBar(ext_toolbar_t * exttoolbar, QWidget * parent)
+: QToolBar(parent),
+ toolbar(exttoolbar)
+{ }
+
+AdditionalToolBar::~AdditionalToolBar()
+{ }
+
+AdditionalToolBar * AdditionalToolBar::create(QWidget * parent, ext_toolbar_t * toolbar)
+{
+ if ( g_list_length( toolbar->children ) == 0 )
+ return NULL;
+
+ AdditionalToolBar * result = new AdditionalToolBar(toolbar, parent);
+ result->setMovable(false);
+ result->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ result->layout()->setMargin(0);
+ result->layout()->setSpacing(4);
+
+ GList * walker = toolbar->children;
+ bool spacerNeeded = true;
+
+ while ( walker && walker->data )
+ {
+ ext_toolbar_t * item = (ext_toolbar_t *)walker->data;
+ if ( item->type == EXT_TOOLBAR_ITEM )
+ {
+ if ( item->item_type == EXT_TOOLBAR_STRING )
+ spacerNeeded = false;
+
+ QAction * newAction = new AdditionalToolbarWidgetAction(item, result);
+ if ( newAction )
+ {
+ result->addAction(newAction);
+ /* Necessary, because enable state is resetted upon adding the action */
+ result->actions()[result->actions().count() - 1]->setEnabled(!item->capture_only);
+ }
+ }
+
+ walker = g_list_next ( walker );
+ }
+
+ if ( result->children().count() == 0 )
+ return NULL;
+
+ if ( spacerNeeded )
+ {
+ QWidget * empty = new QWidget();
+ empty->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
+ result->addWidget(empty);
+
+ }
+
+ return result;
+}
+
+QString AdditionalToolBar::menuName()
+{
+ return (toolbar && toolbar->name) ? QString(toolbar->name) : QString();
+}
+
+AdditionalToolbarWidgetAction::AdditionalToolbarWidgetAction(QObject * parent)
+: QWidgetAction(parent),
+ toolbar_item(0)
+{ }
+
+AdditionalToolbarWidgetAction::AdditionalToolbarWidgetAction(ext_toolbar_t * item, QObject * parent)
+: QWidgetAction(parent),
+ toolbar_item(item)
+{
+ connect(wsApp, SIGNAL(captureActive(int)), this, SLOT(captureActive(int)));
+}
+
+AdditionalToolbarWidgetAction::AdditionalToolbarWidgetAction(const AdditionalToolbarWidgetAction & copy_object)
+: QWidgetAction(copy_object.parent()),
+ toolbar_item(copy_object.toolbar_item)
+{
+ connect(wsApp, SIGNAL(captureActive(int)), this, SLOT(captureActive(int)));
+}
+
+
+void AdditionalToolbarWidgetAction::captureActive(int activeCaptures)
+{
+ if ( toolbar_item && toolbar_item->capture_only )
+ {
+ setEnabled(activeCaptures != 0);
+ }
+}
+
+/* Exists, so a default deconstructor does not call delete on toolbar_item */
+AdditionalToolbarWidgetAction::~AdditionalToolbarWidgetAction() { }
+
+QWidget * AdditionalToolbarWidgetAction::createWidget(QWidget * parent)
+{
+ QWidget * barItem = 0;
+
+ if ( toolbar_item->type != EXT_TOOLBAR_ITEM )
+ return barItem;
+
+ switch ( toolbar_item->item_type )
+ {
+ case EXT_TOOLBAR_BUTTON:
+ barItem = createButton(toolbar_item, parent);
+ break;
+ case EXT_TOOLBAR_BOOLEAN:
+ barItem = createBoolean(toolbar_item, parent);
+ break;
+ case EXT_TOOLBAR_STRING:
+ barItem = createTextEditor(toolbar_item, parent);
+ break;
+ case EXT_TOOLBAR_SELECTOR:
+ barItem = createSelector(toolbar_item, parent);
+ break;
+ }
+
+ if ( ! barItem )
+ return 0;
+
+ barItem->setToolTip(toolbar_item->tooltip);
+ barItem->setProperty(propertyName, VariantPointer<ext_toolbar_t>::asQVariant(toolbar_item));
+
+#ifdef Q_OS_MAC
+ barItem->setAttribute(Qt::WA_MacSmallSize, true);
+#endif
+
+ return barItem;
+}
+
+static void
+toolbar_button_cb(gpointer item, gpointer item_data, gpointer user_data)
+{
+ if ( ! item || ! item_data || ! user_data )
+ return;
+
+ QPushButton * widget = (QPushButton *)(item_data);
+ ext_toolbar_update_t * update_entry = (ext_toolbar_update_t *)user_data;
+
+ if ( widget && update_entry->type == EXT_TOOLBAR_UPDATE_VALUE )
+ widget->setText((gchar *)update_entry->user_data);
+}
+
+QWidget * AdditionalToolbarWidgetAction::createButton(ext_toolbar_t * item, QWidget * parent)
+{
+ if ( ! item || item->type != EXT_TOOLBAR_ITEM || item->item_type != EXT_TOOLBAR_BUTTON )
+ return 0;
+
+ QString defValue = item->defvalue;
+
+ QPushButton * button = new QPushButton(item->name, parent);
+ button->setText(item->name);
+ connect(button, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
+
+ ext_toolbar_register_update_cb(item, (ext_toolbar_action_cb)&toolbar_button_cb, (void *)button);
+
+ return button;
+}
+
+static void
+toolbar_boolean_cb(gpointer item, gpointer item_data, gpointer user_data)
+{
+ if ( ! item || ! item_data || ! user_data )
+ return;
+
+ QCheckBox * widget = (QCheckBox *)(item_data);
+ ext_toolbar_update_t * update_entry = (ext_toolbar_update_t *)user_data;
+
+ if ( widget && update_entry->type == EXT_TOOLBAR_UPDATE_VALUE )
+ {
+ bool oldState = false;
+ if ( update_entry->silent )
+ oldState = widget->blockSignals(true);
+
+ widget->setCheckState(GPOINTER_TO_INT(update_entry->user_data) == 1 ? Qt::Checked : Qt::Unchecked);
+
+ if ( update_entry->silent )
+ widget->blockSignals(oldState);
+ }
+}
+
+QWidget * AdditionalToolbarWidgetAction::createBoolean(ext_toolbar_t * item, QWidget * parent)
+{
+ if ( ! item || item->type != EXT_TOOLBAR_ITEM || item->item_type != EXT_TOOLBAR_BOOLEAN )
+ return 0;
+
+ QString defValue = toolbar_item->defvalue;
+
+ QCheckBox * checkbox = new QCheckBox(item->name, parent);
+ checkbox->setText(item->name);
+ setCheckable(true);
+ checkbox->setCheckState(defValue.compare("true", Qt::CaseInsensitive) == 0 ? Qt::Checked : Qt::Unchecked);
+ connect(checkbox, SIGNAL(stateChanged(int)), this, SLOT(onCheckBoxChecked(int)));
+
+ ext_toolbar_register_update_cb(item, (ext_toolbar_action_cb)&toolbar_boolean_cb, (void *)checkbox);
+
+ return checkbox;
+}
+
+QWidget * AdditionalToolbarWidgetAction::createLabelFrame(ext_toolbar_t * item, QWidget * parent)
+{
+ if ( ! item )
+ return new QWidget();
+
+ QWidget * frame = new QWidget(parent);
+
+ QHBoxLayout * frameLayout = new QHBoxLayout(frame);
+ frameLayout->setMargin(0);
+ frameLayout->setSpacing(0);
+
+ QLabel * strLabel = new QLabel(item->name, frame);
+ strLabel->setToolTip(item->tooltip);
+
+#ifdef Q_OS_MAC
+ frame->setAttribute(Qt::WA_MacSmallSize, true);
+ strLabel->setAttribute(Qt::WA_MacSmallSize, true);
+#endif
+
+ frameLayout->addWidget(strLabel);
+
+ frame->setLayout(frameLayout);
+
+ return frame;
+}
+
+static void
+toolbar_string_cb(gpointer item, gpointer item_data, gpointer user_data)
+{
+ if ( ! item || ! item_data || ! user_data )
+ return;
+
+ ApplyLineEdit * edit = (ApplyLineEdit *)(item_data);
+ ext_toolbar_update_t * update_entry = (ext_toolbar_update_t *)user_data;
+
+ if ( edit && update_entry->type == EXT_TOOLBAR_UPDATE_VALUE )
+ {
+ bool oldState = false;
+ if ( update_entry->silent )
+ oldState = edit->blockSignals(true);
+
+ edit->setText((gchar *)update_entry->user_data);
+
+ if ( update_entry->silent )
+ edit->blockSignals(oldState);
+ }
+}
+
+QWidget * AdditionalToolbarWidgetAction::createTextEditor(ext_toolbar_t * item, QWidget * parent)
+{
+ if ( ! item || item->type != EXT_TOOLBAR_ITEM || item->item_type != EXT_TOOLBAR_STRING )
+ return 0;
+
+ QWidget * frame = createLabelFrame(toolbar_item, parent);
+
+ ApplyLineEdit * strEdit = new ApplyLineEdit(toolbar_item->defvalue, frame);
+ strEdit->setToolTip(toolbar_item->tooltip);
+ strEdit->setRegEx(toolbar_item->regex);
+ strEdit->setEmptyAllowed(toolbar_item->is_required);
+ strEdit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
+
+#ifdef Q_OS_MAC
+ strEdit->setAttribute(Qt::WA_MacSmallSize, true);
+#endif
+
+ frame->layout()->addWidget(strEdit);
+
+ connect(strEdit, SIGNAL(textApplied()), this, SLOT(sendTextToCallback()));
+
+ ext_toolbar_register_update_cb(item, (ext_toolbar_action_cb)&toolbar_string_cb, (void *)strEdit);
+
+ return frame;
+}
+
+static void
+toolbar_selector_cb(gpointer item, gpointer item_data, gpointer user_data)
+{
+ if ( ! item || ! item_data || ! user_data )
+ return;
+
+ QComboBox * comboBox = (QComboBox *)(item_data);
+ ext_toolbar_update_t * update_entry = (ext_toolbar_update_t *)user_data;
+
+ bool oldState = false;
+
+ if ( update_entry->silent )
+ oldState = comboBox->blockSignals(true);
+
+ if ( update_entry->type == EXT_TOOLBAR_UPDATE_VALUE )
+ {
+ QString data = QString((gchar *)update_entry->user_data);
+ bool conv_ok = false;
+
+ int dataValue = data.toInt(&conv_ok, 10);
+ if ( conv_ok && dataValue >= 0 && comboBox->model()->rowCount() < dataValue )
+ comboBox->setCurrentIndex(dataValue);
+ else
+ comboBox->setCurrentText(data);
+ }
+ else if ( update_entry->type == EXT_TOOLBAR_UPDATE_DATA )
+ {
+ QStandardItemModel * sourceModel = (QStandardItemModel *)comboBox->model();
+
+ GList * walker = (GList *)update_entry->user_data;
+ if ( g_list_length(walker) == 0 )
+ return;
+
+ sourceModel->clear();
+
+ while ( walker && walker->data )
+ {
+ ext_toolbar_value_t * listvalue = (ext_toolbar_value_t *)walker->data;
+
+ QStandardItem * si = new QStandardItem(listvalue->display);
+ si->setData(VariantPointer<ext_toolbar_value_t>::asQVariant(listvalue), Qt::UserRole);
+ sourceModel->appendRow(si);
+
+ walker = g_list_next(walker);
+ }
+ }
+ else if ( update_entry->type == EXT_TOOLBAR_UPDATE_DATABYINDEX )
+ {
+ QStandardItemModel * sourceModel = (QStandardItemModel *)comboBox->model();
+
+ if ( ! update_entry->user_data || ! update_entry->data_index )
+ return;
+
+ gchar * idx = (gchar *)update_entry->data_index;
+ gchar * display = (gchar *)update_entry->user_data;
+
+ for ( int i = 0; i < sourceModel->rowCount(); i++ )
+ {
+ QStandardItem * item = sourceModel->item(i, 0);
+ ext_toolbar_value_t * entry = VariantPointer<ext_toolbar_value_t>::asPtr(item->data(Qt::UserRole));
+ if ( entry && g_strcmp0( entry->value, idx) == 0 )
+ {
+ item->setText(display);
+ break;
+ }
+ }
+ }
+
+ if ( update_entry->silent )
+ comboBox->blockSignals(oldState);
+
+}
+
+QWidget * AdditionalToolbarWidgetAction::createSelector(ext_toolbar_t * item, QWidget * parent)
+{
+ if ( ! item || item->type != EXT_TOOLBAR_ITEM || item->item_type != EXT_TOOLBAR_SELECTOR )
+ return 0;
+
+ if ( g_list_length(item->values) == 0 )
+ return 0;
+
+ QWidget * frame = createLabelFrame(item, parent);
+
+ QComboBox * myBox = new QComboBox(parent);
+ myBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
+
+ QStandardItemModel * sourceModel = new QStandardItemModel();
+
+ GList * walker = item->values;
+ int selIndex = 0;
+ while ( walker && walker->data )
+ {
+ ext_toolbar_value_t * listvalue = (ext_toolbar_value_t *)walker->data;
+
+ QStandardItem * si = new QStandardItem(listvalue->display);
+ si->setData(VariantPointer<ext_toolbar_value_t>::asQVariant(listvalue), Qt::UserRole);
+ sourceModel->appendRow(si);
+
+ if ( listvalue->is_default )
+ selIndex = sourceModel->rowCount();
+
+ walker = g_list_next(walker);
+ }
+
+ myBox->setModel(sourceModel);
+ myBox->setCurrentIndex(selIndex);
+
+#ifdef Q_OS_MAC
+ myBox->setAttribute(Qt::WA_MacSmallSize, true);
+#endif
+
+ frame->layout()->addWidget(myBox);
+
+ connect(myBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onSelectionInWidgetChanged(int)));
+
+ ext_toolbar_register_update_cb(item, (ext_toolbar_action_cb)&toolbar_selector_cb, (void *)myBox);
+
+ return frame;
+}
+
+ext_toolbar_t * AdditionalToolbarWidgetAction::extractToolbarItemFromObject(QObject * object)
+{
+ QWidget * widget = dynamic_cast<QWidget *>(object);
+ if ( ! widget )
+ return 0;
+
+ QVariant propValue = widget->property(propertyName);
+
+ /* If property is invalid, look if our parent has this property */
+ if ( ! propValue.isValid() )
+ {
+ QWidget * frame = dynamic_cast<QWidget *>(widget->parent());
+ if ( ! frame )
+ return 0;
+
+ propValue = frame->property(propertyName);
+ }
+
+ if ( ! propValue.isValid() )
+ return 0;
+
+ return VariantPointer<ext_toolbar_t>::asPtr(propValue);
+}
+
+void AdditionalToolbarWidgetAction::onButtonClicked()
+{
+ ext_toolbar_t * item = extractToolbarItemFromObject(sender());
+ if ( ! item )
+ return;
+
+ item->callback(item, 0, item->user_data);
+}
+
+void AdditionalToolbarWidgetAction::onCheckBoxChecked(int checkState)
+{
+ ext_toolbar_t * item = extractToolbarItemFromObject(sender());
+ if ( ! item )
+ return;
+
+ gboolean value = checkState == Qt::Checked ? true : false;
+
+ item->callback(item, &value, item->user_data);
+}
+
+void AdditionalToolbarWidgetAction::sendTextToCallback()
+{
+ ext_toolbar_t * item = extractToolbarItemFromObject(sender());
+ if ( ! item )
+ return;
+
+ if (item->item_type != EXT_TOOLBAR_STRING )
+ return;
+
+ ApplyLineEdit * editor = dynamic_cast<ApplyLineEdit *>(sender());
+ if ( ! editor )
+ {
+ /* Called from button, searching for acompanying line edit */
+ QWidget * parent = dynamic_cast<QWidget *>(sender()->parent());
+ if ( parent )
+ {
+ QList<ApplyLineEdit *> children = parent->findChildren<ApplyLineEdit *>();
+ if ( children.count() >= 0 )
+ editor = children.at(0);
+ }
+ }
+
+ if ( editor )
+ item->callback(item, qstring_strdup(editor->text()), item->user_data);
+}
+
+void AdditionalToolbarWidgetAction::onSelectionInWidgetChanged(int idx)
+{
+ QComboBox * editor = dynamic_cast<QComboBox *>(sender());
+ ext_toolbar_t * item = extractToolbarItemFromObject(editor);
+ if ( ! item || item->item_type != EXT_TOOLBAR_SELECTOR )
+ return;
+
+ QStandardItemModel * sourceModel = (QStandardItemModel *) editor->model();
+ if ( sourceModel->rowCount() <= idx )
+ return;
+
+ QModelIndex mdIdx = sourceModel->index(idx, 0);
+ QVariant dataSet = sourceModel->data(mdIdx, Qt::UserRole);
+ if ( dataSet.isValid() )
+ {
+ ext_toolbar_value_t * value_entry = VariantPointer<ext_toolbar_value_t>::asPtr(dataSet);
+ item->callback(item, value_entry, item->user_data);
+ }
+}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/ui/qt/additional_toolbar.h b/ui/qt/additional_toolbar.h
new file mode 100644
index 0000000000..b5b274945e
--- /dev/null
+++ b/ui/qt/additional_toolbar.h
@@ -0,0 +1,101 @@
+/* additional_toolbar.h
+ *
+ * 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.
+ */
+
+#ifndef UI_QT_ADDITIONAL_TOOLBAR_H_
+#define UI_QT_ADDITIONAL_TOOLBAR_H_
+
+#include <epan/plugin_if.h>
+
+#include <QToolBar>
+#include <QWidgetAction>
+
+/* Class for all display widgets.
+ *
+ * Inherits QWidgetAction, otherwise the extension popup might not work for the toolbar
+ */
+class AdditionalToolbarWidgetAction: public QWidgetAction
+{
+ Q_OBJECT
+
+public:
+
+ AdditionalToolbarWidgetAction(QObject * parent = 0);
+ AdditionalToolbarWidgetAction(ext_toolbar_t * item, QObject * parent = 0);
+ AdditionalToolbarWidgetAction(const AdditionalToolbarWidgetAction & copy_object);
+ ~AdditionalToolbarWidgetAction();
+
+protected:
+ virtual QWidget * createWidget(QWidget * parent);
+
+ static const char * propertyName;
+
+private:
+
+ ext_toolbar_t * toolbar_item;
+
+ QWidget * createButton(ext_toolbar_t * item, QWidget * parent);
+ QWidget * createBoolean(ext_toolbar_t * item, QWidget * parent);
+ QWidget * createTextEditor(ext_toolbar_t * item, QWidget * parent);
+ QWidget * createSelector(ext_toolbar_t * item, QWidget * parent);
+
+ QWidget * createLabelFrame(ext_toolbar_t * item, QWidget * parent);
+
+ ext_toolbar_t * extractToolbarItemFromObject(QObject *);
+
+private slots:
+ void onButtonClicked();
+ void onCheckBoxChecked(int);
+ void sendTextToCallback();
+ void onSelectionInWidgetChanged(int idx);
+
+ void captureActive(int);
+};
+
+class AdditionalToolBar: public QToolBar
+{
+ Q_OBJECT
+
+public:
+ AdditionalToolBar(ext_toolbar_t * toolbar, QWidget * parent = 0);
+ virtual ~AdditionalToolBar();
+
+ static AdditionalToolBar * create(QWidget * parent, ext_toolbar_t * toolbar);
+
+ QString menuName();
+
+private:
+ ext_toolbar_t * toolbar;
+};
+
+#endif /* UI_QT_ADDITIONAL_TOOLBAR_H_ */
+
+/*
+ * 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:
+ */
diff --git a/ui/qt/apply_line_edit.cpp b/ui/qt/apply_line_edit.cpp
new file mode 100644
index 0000000000..2e2acc7454
--- /dev/null
+++ b/ui/qt/apply_line_edit.cpp
@@ -0,0 +1,181 @@
+/* apply_lineedit.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 <ui/qt/apply_line_edit.h>
+
+#include <epan/prefs.h>
+
+#include <ui/qt/color_utils.h>
+
+#include <QRegExp>
+#include <QRegExpValidator>
+#include <QStyle>
+
+ApplyLineEdit::ApplyLineEdit(QString linePlaceholderText, QWidget * parent)
+: QLineEdit(parent),
+ applyButton(0)
+{
+ emptyAllowed_ = false;
+ regex_ = QString();
+
+ applyButton = new StockIconToolButton(parent, "x-filter-apply");
+ applyButton->setCursor(Qt::ArrowCursor);
+ applyButton->setEnabled(false);
+ applyButton->setToolTip(tr("Apply changes"));
+ applyButton->setIconSize(QSize(24, 14));
+ applyButton->setMaximumWidth(30);
+ applyButton->setStyleSheet(
+ "QToolButton {"
+ " border: none;"
+ " background: transparent;" // Disables platform style on Windows.
+ " padding: 0 0 0 0;"
+ "}"
+ );
+
+#ifdef Q_OS_MAC
+ setAttribute(Qt::WA_MacSmallSize, true);
+ applyButton->setAttribute(Qt::WA_MacSmallSize, true);
+#endif
+
+ setPlaceholderText(linePlaceholderText);
+
+ connect(this, SIGNAL(textEdited(const QString&)), this, SLOT(onTextEdited(const QString&)));
+ connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&)));
+
+ connect(this, SIGNAL(returnPressed()), this, SLOT(onSubmitContent()));
+ connect(applyButton, SIGNAL(clicked()), this, SLOT(onSubmitContent()));
+
+ handleValidation(QString(linePlaceholderText));
+
+ setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
+}
+
+ApplyLineEdit::~ApplyLineEdit() {}
+
+void ApplyLineEdit::setRegEx(QString regex)
+{
+ regex_ = regex;
+}
+
+QString ApplyLineEdit::regex()
+{
+ return regex_;
+}
+
+void ApplyLineEdit::setEmptyAllowed(bool emptyAllowed)
+{
+ emptyAllowed_ = emptyAllowed;
+}
+
+bool ApplyLineEdit::emptyAllowed()
+{
+ return emptyAllowed_;
+}
+
+bool ApplyLineEdit::isValidText(QString & text, bool ignoreEmptyCheck)
+{
+ if ( text.length() == 0 )
+ {
+ if ( ! ignoreEmptyCheck && ! emptyAllowed_ )
+ return false;
+ else if ( ignoreEmptyCheck )
+ return true;
+ }
+
+ if ( regex_.length() > 0 )
+ {
+ QRegExp rx ( regex_ );
+ QRegExpValidator v(rx, 0);
+
+ int pos = 0;
+ if ( ! rx.isValid() || v.validate(text, pos) != QValidator::Acceptable )
+ return false;
+ }
+
+ return true;
+}
+
+void ApplyLineEdit::onTextEdited(const QString & text)
+{
+ QString newText = QString(text);
+ applyButton->setEnabled(isValidText(newText));
+ handleValidation(newText);
+}
+
+void ApplyLineEdit::onTextChanged(const QString & text)
+{
+ handleValidation(QString(text));
+}
+
+void ApplyLineEdit::handleValidation(QString newText)
+{
+ int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
+
+ QString style_sheet = QString(
+ "ApplyLineEdit {"
+ " padding-left: %1px;"
+ " padding-right: %2px;"
+ " background-color: %3;"
+ "}"
+ )
+ .arg(frameWidth + 1)
+ .arg(applyButton->sizeHint().width() + frameWidth)
+ .arg(isValidText(newText, true) ? QString("") : ColorUtils::fromColorT(prefs.gui_text_invalid).name());
+
+ setStyleSheet(style_sheet);
+}
+
+void ApplyLineEdit::resizeEvent(QResizeEvent *)
+{
+ int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
+ QSize apsz = applyButton->sizeHint();
+
+ applyButton->move((contentsRect().right() + pos().x()) - ( frameWidth + apsz.width() ) - 2,
+ contentsRect().top() + pos().y());
+
+ applyButton->setMinimumHeight(height());
+ applyButton->setMaximumHeight(height());
+}
+
+void ApplyLineEdit::onSubmitContent()
+{
+ QString data = text();
+ if ( ! isValidText(data) )
+ return;
+
+ /* Freeze apply button to signal the text has been sent. Will be unfreezed, if the text in the textbox changes again */
+ applyButton->setEnabled(false);
+
+ emit textApplied();
+}
+
+/*
+ * 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:
+ */
diff --git a/ui/qt/apply_line_edit.h b/ui/qt/apply_line_edit.h
new file mode 100644
index 0000000000..d26b514f68
--- /dev/null
+++ b/ui/qt/apply_line_edit.h
@@ -0,0 +1,82 @@
+/* apply_lineedit.h
+ *
+ * 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.
+ */
+
+#ifndef UI_QT_APPLY_LINE_EDIT_H_
+#define UI_QT_APPLY_LINE_EDIT_H_
+
+#include <QLineEdit>
+#include <QString>
+
+#include <ui/qt/stock_icon_tool_button.h>
+
+class ApplyLineEdit : public QLineEdit
+{
+ Q_OBJECT
+
+public:
+ explicit ApplyLineEdit(QString linePlaceholderText, QWidget *parent = 0);
+ ~ApplyLineEdit();
+
+ Q_PROPERTY(QString regex READ regex WRITE setRegEx);
+ Q_PROPERTY(bool emptyAllowed READ emptyAllowed WRITE setEmptyAllowed);
+
+ QString regex();
+ void setRegEx(QString);
+
+ bool emptyAllowed();
+ void setEmptyAllowed(bool);
+
+signals:
+ void textApplied();
+
+protected:
+ void resizeEvent(QResizeEvent *);
+
+private:
+
+ QString regex_;
+ bool emptyAllowed_;
+
+ StockIconToolButton *applyButton;
+
+ bool isValidText(QString &, bool ignoreEmptyCheck = false);
+ void handleValidation(QString newText);
+
+private slots:
+ void onTextEdited(const QString &);
+ void onTextChanged(const QString &);
+ void onSubmitContent();
+};
+
+#endif /* UI_QT_APPLY_LINE_EDIT_H_ */
+
+/*
+ * 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:
+ */
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 45479df68d..6573a7c6f6 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -69,6 +69,9 @@
#include "wireless_frame.h"
#include "wireshark_application.h"
+#include "additional_toolbar.h"
+#include "variant_pointer.h"
+
#include "qt_ui_utils.h"
#include <QAction>
@@ -193,6 +196,18 @@ static void plugin_if_mainwindow_get_ws_info(gconstpointer user_data)
#endif /* HAVE_LIBPCAP */
+static void plugin_if_mainwindow_update_toolbars(gconstpointer user_data)
+{
+ if (!gbl_cur_main_window_ || ! user_data)
+ return;
+
+ GHashTable * data_set = (GHashTable *)user_data;
+ if (g_hash_table_lookup_extended(data_set, "toolbar_name", NULL, NULL)) {
+ QString toolbarName((const char *)g_hash_table_lookup(data_set, "toolbar_name"));
+ gbl_cur_main_window_->removeAdditionalToolbar(toolbarName);
+ }
+}
+
gpointer
simple_dialog(ESD_TYPE_E type, gint btn_mask, const gchar *msg_format, ...)
{
@@ -350,7 +365,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(wsApp, SIGNAL(appInitialized()), this, SLOT(initViewColorizeMenu()));
connect(wsApp, SIGNAL(appInitialized()), this, SLOT(addStatsPluginsToMenu()));
connect(wsApp, SIGNAL(appInitialized()), this, SLOT(addDynamicMenus()));
- connect(wsApp, SIGNAL(appInitialized()), this, SLOT(addExternalMenus()));
+ connect(wsApp, SIGNAL(appInitialized()), this, SLOT(addPluginIFStructures()));
connect(wsApp, SIGNAL(appInitialized()), this, SLOT(initConversationMenus()));
connect(wsApp, SIGNAL(appInitialized()), this, SLOT(initExportObjectsMenus()));
@@ -722,6 +737,7 @@ MainWindow::MainWindow(QWidget *parent) :
#ifdef HAVE_LIBPCAP
plugin_if_register_gui_cb(PLUGIN_IF_GET_WS_INFO, plugin_if_mainwindow_get_ws_info);
#endif
+ plugin_if_register_gui_cb(PLUGIN_IF_REMOVE_TOOLBAR, plugin_if_mainwindow_update_toolbars);
main_ui_->mainStack->setCurrentWidget(main_welcome_);
}
@@ -742,7 +758,17 @@ QMenu *MainWindow::createPopupMenu()
menu->addAction(main_ui_->actionViewMainToolbar);
menu->addAction(main_ui_->actionViewFilterToolbar);
menu->addAction(main_ui_->actionViewWirelessToolbar);
+
+ if ( ! main_ui_->actionViewAdditionalToolbars->actions().isEmpty() )
+ {
+ QMenu * subMenu = menu->addMenu(main_ui_->actionViewAdditionalToolbars->title());
+ foreach ( QAction * action, main_ui_->actionViewAdditionalToolbars->actions() )
+ subMenu->addAction(action);
+
+ }
+
menu->addAction(main_ui_->actionViewStatusBar);
+
menu->addSeparator();
menu->addAction(main_ui_->actionViewPacketList);
menu->addAction(main_ui_->actionViewPacketDetails);
@@ -1845,6 +1871,9 @@ void MainWindow::initShowHideMainWidgets()
showHideMainWidgets(shmwa);
}
+ /* Initially hide the additional toolbars menus */
+ main_ui_->actionViewAdditionalToolbars->menuAction()->setVisible(false);
+
connect(show_hide_actions_, SIGNAL(triggered(QAction*)), this, SLOT(showHideMainWidgets(QAction*)));
}
@@ -2554,16 +2583,13 @@ QMenu * MainWindow::searchSubMenu(QString objectName)
return 0;
}
-void MainWindow::addExternalMenus()
+void MainWindow::addPluginIFStructures()
{
- QMenu * subMenu = NULL;
- GList * user_menu = NULL;
- ext_menu_t * menu = NULL;
-
- user_menu = ext_menubar_get_entries();
+ GList * user_menu = ext_menubar_get_entries();
while (user_menu && user_menu->data) {
- menu = (ext_menu_t *) user_menu->data;
+ QMenu * subMenu = NULL;
+ ext_menu_t * menu = (ext_menu_t *) user_menu->data;
/* On this level only menu items should exist. Not doing an assert here,
* as it could be an honest mistake */
@@ -2589,8 +2615,99 @@ void MainWindow::addExternalMenus()
/* Iterate Loop */
user_menu = g_list_next (user_menu);
}
+
+ int cntToolbars = 0;
+
+ QMenu * tbMenu = main_ui_->actionViewAdditionalToolbars;
+ GList * if_toolbars = ext_toolbar_get_entries();
+ while ( if_toolbars && if_toolbars->data ) {
+
+ ext_toolbar_t * toolbar = (ext_toolbar_t*) if_toolbars->data;
+
+ if ( toolbar->type != EXT_TOOLBAR_BAR) {
+ if_toolbars = g_list_next ( if_toolbars );
+ continue;
+ }
+
+ bool visible = g_list_find_custom(recent.gui_additional_toolbars, toolbar->name, (GCompareFunc) strcmp) ? true : false;
+
+ AdditionalToolBar * ifToolBar = AdditionalToolBar::create(this, toolbar);
+ ifToolBar->setVisible(visible);
+
+ if ( ifToolBar )
+ {
+
+ QAction * iftbAction = new QAction(QString(toolbar->name), this);
+ iftbAction->setToolTip(toolbar->tooltip);
+ iftbAction->setEnabled(true);
+ iftbAction->setCheckable(true);
+ iftbAction->setChecked(visible);
+ iftbAction->setToolTip(tr("Show or hide the toolbar"));
+ iftbAction->setData(VariantPointer<ext_toolbar_t>::asQVariant(toolbar));
+
+ QAction * before = 0;
+
+ foreach ( QAction * action, tbMenu->actions() )
+ {
+ /* Ensure we add the menu entries in sorted order */
+ if ( action->text().compare(toolbar->name, Qt::CaseInsensitive) > 0 )
+ {
+ before = action;
+ break;
+ }
+ }
+
+ tbMenu->insertAction(before, iftbAction);
+
+ addToolBar(Qt::TopToolBarArea, ifToolBar);
+ insertToolBarBreak(ifToolBar);
+
+ if ( show_hide_actions_ )
+ show_hide_actions_->addAction(iftbAction);
+
+ cntToolbars++;
+ }
+
+ if_toolbars = g_list_next ( if_toolbars );
+ }
+
+ if ( cntToolbars )
+ tbMenu->menuAction()->setVisible(true);
+
}
+void MainWindow::removeAdditionalToolbar(QString toolbarName)
+{
+ if ( toolbarName.length() == 0 )
+ return;
+
+ QList<QToolBar *> toolbars = findChildren<QToolBar *>();
+ foreach(QToolBar * tb, toolbars) {
+ AdditionalToolBar * ifToolBar = dynamic_cast<AdditionalToolBar *>(tb);
+
+ if ( ifToolBar && ifToolBar->menuName().compare(toolbarName) ) {
+
+ GList *entry = g_list_find_custom(recent.gui_additional_toolbars, ifToolBar->menuName().toStdString().c_str(), (GCompareFunc) strcmp);
+ if (entry) {
+ recent.gui_additional_toolbars = g_list_remove(recent.gui_additional_toolbars, entry->data);
+ }
+ QList<QAction *> actions = main_ui_->actionViewAdditionalToolbars->actions();
+ foreach(QAction * action, actions) {
+ ext_toolbar_t * item = VariantPointer<ext_toolbar_t>::asPtr(action->data());
+ if ( item && ifToolBar->menuName().compare(item->name) ) {
+ if ( show_hide_actions_ )
+ show_hide_actions_->removeAction(action);
+ main_ui_->actionViewAdditionalToolbars->removeAction(action);
+ }
+ }
+
+ break;
+ }
+ }
+
+}
+
+
/*
* Editor modelines
*
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index eb96f3e03f..aeb3a18052 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -98,6 +98,8 @@ public:
void gotoFrame(int packet_num);
CaptureFile *captureFile() { return &capture_file_; }
+ void removeAdditionalToolbar(QString toolbarName);
+
protected:
virtual bool eventFilter(QObject *obj, QEvent *event);
virtual void keyPressEvent(QKeyEvent *event);
@@ -334,8 +336,9 @@ private slots:
void addStatsPluginsToMenu();
void addDynamicMenus();
void reloadDynamicMenus();
- void addExternalMenus();
+ void addPluginIFStructures();
QMenu * searchSubMenu(QString objectName);
+ void activatePluginIFToolbar(bool);
void startInterfaceCapture(bool valid, const QString capture_filter);
diff --git a/ui/qt/main_window.ui b/ui/qt/main_window.ui
index 14569e72cf..0d66379c9f 100644
--- a/ui/qt/main_window.ui
+++ b/ui/qt/main_window.ui
@@ -335,9 +335,15 @@
<addaction name="actionViewInternalsDissectorTables"/>
<addaction name="actionViewInternalsSupportedProtocols"/>
</widget>
+ <widget class="QMenu" name="actionViewAdditionalToolbars">
+ <property name="title">
+ <string>Additional Toolbars</string>
+ </property>
+ </widget>
<addaction name="actionViewMainToolbar"/>
<addaction name="actionViewFilterToolbar"/>
<addaction name="actionViewWirelessToolbar"/>
+ <addaction name="actionViewAdditionalToolbars" />
<addaction name="actionViewStatusBar"/>
<addaction name="separator"/>
<addaction name="actionViewFullScreen"/>
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 48be263011..0a578fd706 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -55,6 +55,7 @@
#include "epan/epan_dissect.h"
#include "epan/filter_expressions.h"
#include "epan/prefs.h"
+#include "epan/plugin_if.h"
#include "epan/uat.h"
#include "epan/value_string.h"
@@ -119,6 +120,7 @@
#include "gsm_map_summary_dialog.h"
#include "iax2_analysis_dialog.h"
#include "io_graph_dialog.h"
+#include <additional_toolbar.h>
#include "lbm_stream_dialog.h"
#include "lbm_uimflow_dialog.h"
#include "lbm_lbtrm_transport_dialog.h"
@@ -483,6 +485,18 @@ void MainWindow::layoutToolbars()
main_ui_->displayFilterToolBar->setVisible(recent.filter_toolbar_show);
main_ui_->wirelessToolBar->setVisible(recent.wireless_toolbar_show);
main_ui_->statusBar->setVisible(recent.statusbar_show);
+
+ QList<QToolBar *> toolbars = findChildren<QToolBar *>();
+ foreach (QToolBar * bar, toolbars ) {
+ AdditionalToolBar * iftoolbar = dynamic_cast<AdditionalToolBar *>(bar);
+ if ( iftoolbar ) {
+ bool visible = false;
+ if ( g_list_find_custom(recent.gui_additional_toolbars, iftoolbar->menuName().toUtf8().constData(), (GCompareFunc) strcmp) )
+ visible = true;
+
+ iftoolbar->setVisible(visible);
+ }
+ }
}
void MainWindow::updatePreferenceActions()
@@ -509,6 +523,15 @@ void MainWindow::updateRecentActions()
main_ui_->actionViewPacketDetails->setChecked(recent.tree_view_show && prefs_has_layout_pane_content(layout_pane_content_pdetails));
main_ui_->actionViewPacketBytes->setChecked(recent.byte_view_show && prefs_has_layout_pane_content(layout_pane_content_pbytes));
+ foreach ( QAction * action, main_ui_->actionViewAdditionalToolbars->actions() ) {
+ ext_toolbar_t * toolbar = VariantPointer<ext_toolbar_t>::asPtr(action->data());
+ bool checked = false;
+ if ( toolbar && g_list_find_custom(recent.gui_additional_toolbars, toolbar->name, (GCompareFunc) strcmp) )
+ checked = true;
+
+ action->setChecked( checked );
+ }
+
foreach (QAction* tda, td_actions.keys()) {
if (recent.gui_time_format == td_actions[tda]) {
tda->setChecked(true);
@@ -2223,6 +2246,25 @@ void MainWindow::showHideMainWidgets(QAction *action)
} else if (widget == byte_view_tab_) {
recent.byte_view_show = show;
main_ui_->actionViewPacketBytes->setChecked(show);
+ } else {
+ ext_toolbar_t * toolbar = VariantPointer<ext_toolbar_t>::asPtr(action->data());
+ if (toolbar) {
+ GList *entry = g_list_find_custom(recent.gui_additional_toolbars, toolbar->name, (GCompareFunc) strcmp);
+ if (show && !entry) {
+ recent.gui_additional_toolbars = g_list_append(recent.gui_additional_toolbars, g_strdup(toolbar->name));
+ } else if (!show && entry) {
+ recent.gui_additional_toolbars = g_list_remove(recent.gui_additional_toolbars, entry->data);
+ }
+ action->setChecked(show);
+
+ QList<QToolBar *> toolbars = findChildren<QToolBar *>();
+ foreach (QToolBar * bar, toolbars ) {
+ AdditionalToolBar * iftoolbar = dynamic_cast<AdditionalToolBar *>(bar);
+ if ( iftoolbar && iftoolbar->menuName().compare(toolbar->name) == 0 ) {
+ iftoolbar->setVisible(show);
+ }
+ }
+ }
}
if (widget) {
@@ -3898,6 +3940,34 @@ void MainWindow::on_actionViewFullScreen_triggered(bool checked)
}
}
+void MainWindow::activatePluginIFToolbar(bool)
+{
+ QAction * sendingAction = dynamic_cast<QAction *>(sender());
+ if ( ! sendingAction || ! sendingAction->data().isValid() )
+ return;
+
+ ext_toolbar_t * toolbar = VariantPointer<ext_toolbar_t>::asPtr(sendingAction->data());
+
+ QList<QToolBar *> toolbars = findChildren<QToolBar *>();
+ foreach (QToolBar * bar, toolbars )
+ {
+ AdditionalToolBar * iftoolbar = dynamic_cast<AdditionalToolBar *>(bar);
+ if ( iftoolbar && iftoolbar->menuName().compare(toolbar->name) == 0 )
+ {
+ if ( iftoolbar->isVisible() )
+ {
+ iftoolbar->setVisible(false);
+ sendingAction->setChecked(true);
+ }
+ else
+ {
+ iftoolbar->setVisible(true);
+ sendingAction->setChecked(true);
+ }
+ }
+ }
+}
+
#ifdef _MSC_VER
#pragma warning(pop)
#endif
diff --git a/ui/recent.c b/ui/recent.c
index aaad91b0ad..d1894e0ed8 100644
--- a/ui/recent.c
+++ b/ui/recent.c
@@ -73,6 +73,7 @@
#define RECENT_GUI_ENDPOINT_TABS "gui.endpoint_tabs"
#define RECENT_GUI_RLC_PDUS_FROM_MAC_FRAMES "gui.rlc_pdus_from_mac_frames"
#define RECENT_GUI_CUSTOM_COLORS "gui.custom_colors"
+#define RECENT_GUI_TOOLBAR_SHOW "gui.additional_toolbar_show"
#define RECENT_GUI_GEOMETRY "gui.geom."
@@ -858,6 +859,12 @@ write_profile_recent(void)
fprintf(rf, RECENT_GUI_FILEOPEN_REMEMBERED_DIR ": %s\n", get_last_open_dir());
}
+ fprintf(rf, "\n# Additional Toolbars shown\n");
+ fprintf(rf, "# List of additional toolbars to show.\n");
+ string_list = join_string_list(recent.gui_additional_toolbars);
+ fprintf(rf, RECENT_GUI_TOOLBAR_SHOW ": %s\n", string_list);
+ g_free(string_list);
+
fclose(rf);
/* XXX - catch I/O errors (e.g. "ran out of disk space") and return
@@ -1111,6 +1118,8 @@ read_set_recent_pair_static(gchar *key, const gchar *value,
g_free (recent.gui_fileopen_remembered_dir);
}
recent.gui_fileopen_remembered_dir = g_strdup(value);
+ } else if (strcmp(key, RECENT_GUI_TOOLBAR_SHOW) == 0) {
+ recent.gui_additional_toolbars = prefs_get_string_list(value);
}
return PREFS_SET_OK;
@@ -1279,6 +1288,11 @@ recent_read_profile_static(char **rf_path_return, int *rf_errno_return)
recent.gui_fileopen_remembered_dir = NULL;
}
+ if (recent.gui_additional_toolbars) {
+ g_list_free_full (recent.gui_additional_toolbars, g_free);
+ recent.gui_additional_toolbars = NULL;
+ }
+
/* Construct the pathname of the user's profile recent file. */
rf_path = get_persconffile_path(RECENT_FILE_NAME, TRUE);
diff --git a/ui/recent.h b/ui/recent.h
index bce8214b85..2f33302b9b 100644
--- a/ui/recent.h
+++ b/ui/recent.h
@@ -110,6 +110,7 @@ typedef struct recent_settings_tag {
gchar *gui_fileopen_remembered_dir; /* folder of last capture loaded in File Open dialog */
gboolean gui_rlc_use_pdus_from_mac;
GList *custom_colors;
+ GList *gui_additional_toolbars;
} recent_settings_t;
/** Global recent settings. */