aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2018-01-29 14:40:45 -0800
committerAnders Broman <a.broman58@gmail.com>2018-01-31 04:55:37 +0000
commitf5a8711ef195d1bc538a05a4602ee9388da81561 (patch)
tree0cd9af2e6a8bef7b4189cf5bf9aba3bec3ec08e0
parent47e1798762478ae19354297e5a95d46487cafd42 (diff)
Qt: About dialog updates.
Open lua scripts when double-clicked. Behavior depends on your system configuration. Add tooltips accordingly. Let Qt wrap the "Wireshark" tab information. Set column widths by eyeballing their contents. Elide the Folders and Plugins strings in the middle. Fixup placeholder text capitalization. Draw links using the palette link color. Change-Id: Ic141eae05541480ec1e254c55fd81728d04713d9 Reviewed-on: https://code.wireshark.org/review/25510 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--epan/wslua/init_wslua.c20
-rw-r--r--epan/wslua/init_wslua.h15
-rw-r--r--ui/qt/about_dialog.cpp96
-rw-r--r--ui/qt/about_dialog.h2
-rw-r--r--ui/qt/about_dialog.ui10
-rw-r--r--ui/qt/models/astringlist_list_model.cpp20
-rw-r--r--ui/qt/models/astringlist_list_model.h5
-rw-r--r--ui/qt/models/url_link_delegate.cpp12
-rw-r--r--ui/qt/models/url_link_delegate.h1
9 files changed, 88 insertions, 93 deletions
diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c
index 59a374b935..9369972486 100644
--- a/epan/wslua/init_wslua.c
+++ b/epan/wslua/init_wslua.c
@@ -9,19 +9,7 @@
* 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.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include "config.h"
@@ -726,7 +714,7 @@ void wslua_plugins_get_descriptions(wslua_plugin_description_callback callback,
for (lua_plug = wslua_plugin_list; lua_plug != NULL; lua_plug = lua_plug->next)
{
- callback(lua_plug->name, lua_plug->version, "lua script",
+ callback(lua_plug->name, lua_plug->version, wslua_plugin_type_name(),
lua_plug->filename, user_data);
}
}
@@ -745,6 +733,10 @@ wslua_plugins_dump_all(void)
wslua_plugins_get_descriptions(print_wslua_plugin_description, NULL);
}
+const char *wslua_plugin_type_name(void) {
+ return "lua script";
+}
+
static ei_register_info* ws_lua_ei = NULL;
static int ws_lua_ei_len = 0;
diff --git a/epan/wslua/init_wslua.h b/epan/wslua/init_wslua.h
index 1c6d9624ea..9504379eaa 100644
--- a/epan/wslua/init_wslua.h
+++ b/epan/wslua/init_wslua.h
@@ -5,19 +5,7 @@
* 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.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __INIT_WSLUA_H__
@@ -38,6 +26,7 @@ typedef void (*wslua_plugin_description_callback)(const char *, const char *,
void *);
WS_DLL_PUBLIC void wslua_plugins_get_descriptions(wslua_plugin_description_callback callback, void *user_data);
WS_DLL_PUBLIC void wslua_plugins_dump_all(void);
+WS_DLL_PUBLIC const char *wslua_plugin_type_name(void);
#ifdef __cplusplus
}
diff --git a/ui/qt/about_dialog.cpp b/ui/qt/about_dialog.cpp
index d022afcc09..5d5dc5c49b 100644
--- a/ui/qt/about_dialog.cpp
+++ b/ui/qt/about_dialog.cpp
@@ -15,6 +15,9 @@
#include "wireshark_application.h"
#include <wsutil/filesystem.h>
+#include <QDesktopServices>
+#include <QUrl>
+
#ifdef HAVE_LIBSMI
#include <epan/oids.h>
#endif
@@ -144,8 +147,14 @@ PluginListModel::PluginListModel(QObject * parent) : AStringListListModel(parent
typeNames_ << QString("");
foreach(QStringList row, plugin_data)
{
- typeNames_ << row.at(2);
- appendRow(row);
+ QString type_name = row.at(2);
+ QString tooltip;
+ typeNames_ << type_name;
+
+ if (type_name == wslua_plugin_type_name()) {
+ tooltip = tr("Double-click to edit");
+ }
+ appendRow(row, tooltip);
}
typeNames_.sort();
@@ -274,9 +283,11 @@ AboutDialog::AboutDialog(QWidget *parent) :
QFile f_license;
QString message;
- GString *comp_info_str = get_compiled_version_info(get_wireshark_qt_compiled_info,
- get_gui_compiled_info);
- GString *runtime_info_str = get_runtime_version_info(get_wireshark_runtime_info);
+ QString vcs_version_info_str = get_ws_vcs_version_info();
+ QString copyright_info_str = get_copyright_info();
+ QString comp_info_str = gstring_free_to_qbytearray(get_compiled_version_info(get_wireshark_qt_compiled_info,
+ get_gui_compiled_info));
+ QString runtime_info_str = gstring_free_to_qbytearray(get_runtime_version_info(get_wireshark_runtime_info));
AuthorListModel * authorModel = new AuthorListModel(this);
@@ -298,20 +309,16 @@ AboutDialog::AboutDialog(QWidget *parent) :
/* Wireshark tab */
/* Construct the message string */
- message = QString(
- "Version %1\n"
- "\n"
- "%2"
- "\n"
- "%3"
- "\n"
- "%4"
- "\n"
- "Wireshark is Open Source Software released under the GNU General Public License.\n"
- "\n"
- "Check the man page and http://www.wireshark.org for more information.")
- .arg(get_ws_vcs_version_info(), get_copyright_info(), comp_info_str->str, runtime_info_str->str);
-
+ message = "<p>Version " + vcs_version_info_str.toHtmlEscaped() + "</p>\n\n";
+ message += "<p>" + copyright_info_str.toHtmlEscaped() + "</p>\n\n";
+ message += "<p>" + comp_info_str.toHtmlEscaped() + "</p>\n\n";
+ message += "<p>" + runtime_info_str.toHtmlEscaped() + "</p>\n\n";
+ message += "<p>Wireshark is Open Source Software released under the GNU General Public License.</p>\n\n";
+ message += "<p>Check the man page and http://www.wireshark.org for more information.</p>\n\n";
+
+ ui->label_wireshark->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
+ ui->label_wireshark->setTextFormat(Qt::RichText);
+ ui->label_wireshark->setWordWrap(true);
ui->label_wireshark->setTextInteractionFlags(Qt::TextSelectableByMouse);
ui->label_wireshark->setText(message);
@@ -333,6 +340,7 @@ AboutDialog::AboutDialog(QWidget *parent) :
ui->tblFolders->setRootIsDecorated(false);
ui->tblFolders->setItemDelegateForColumn(1, new UrlLinkDelegate(this));
ui->tblFolders->setContextMenuPolicy(Qt::CustomContextMenu);
+ ui->tblFolders->setTextElideMode(Qt::ElideMiddle);
connect(ui->tblFolders, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(handleCopyMenu(QPoint)));
connect(ui->searchFolders, SIGNAL(textChanged(QString)), folderProxyModel, SLOT(setFilter(QString)));
connect(ui->tblFolders, SIGNAL(clicked(QModelIndex)), this, SLOT(urlClicked(QModelIndex)));
@@ -352,6 +360,7 @@ AboutDialog::AboutDialog(QWidget *parent) :
ui->tblPlugins->setRootIsDecorated(false);
ui->cmbType->addItems(pluginModel->typeNames());
ui->tblPlugins->setContextMenuPolicy(Qt::CustomContextMenu);
+ ui->tblPlugins->setTextElideMode(Qt::ElideMiddle);
connect(ui->tblPlugins, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(handleCopyMenu(QPoint)));
connect(ui->searchPlugins, SIGNAL(textChanged(QString)), pluginFilterModel, SLOT(setFilter(QString)));
connect(ui->cmbType, SIGNAL(currentIndexChanged(QString)), pluginTypeModel, SLOT(setFilter(QString)));
@@ -396,31 +405,33 @@ AboutDialog::~AboutDialog()
void AboutDialog::showEvent(QShowEvent * event)
{
- QList<QWidget *> pages;
-
- // Authors, Folders & Shortcuts: Equal-sized columns.
- pages << ui->tab_authors << ui->tab_folders << ui->tab_shortcuts;
-
- foreach ( QWidget * tabPage, pages )
- {
- QList<QTreeView *> childs = tabPage->findChildren<QTreeView*>();
- if ( childs.count() == 0 )
- continue;
+ int one_em = fontMetrics().height();
- QTreeView * tree = childs.at(0);
+ // Authors: Names slightly narrower than emails.
+ QAbstractItemModel *model = ui->tblAuthors->model();
+ int column_count = model->columnCount();
+ ui->tblAuthors->setColumnWidth(0, (ui->tblAuthors->parentWidget()->width() / column_count) - one_em);
- int columnCount = tree->model()->columnCount();
- for ( int cnt = 0; cnt < columnCount; cnt++ )
- tree->setColumnWidth(cnt, tabPage->width() / columnCount);
- tree->header()->setStretchLastSection(true);
- }
+ // Folders: First and last to contents.
+ ui->tblFolders->resizeColumnToContents(0);
+ ui->tblFolders->resizeColumnToContents(2);
+ ui->tblFolders->setColumnWidth(1, ui->tblFolders->parentWidget()->width() -
+ (ui->tblFolders->columnWidth(0) + ui->tblFolders->columnWidth(2)));
- // Plugins: Content-sized columns
- QAbstractItemModel *model = ui->tblPlugins->model();
+ // Plugins: All but the last to contents.
+ model = ui->tblPlugins->model();
for (int col = 0; model && col < model->columnCount() - 1; col++) {
ui->tblPlugins->resizeColumnToContents(col);
}
+ // Shortcuts: Set widths manually.
+ model = ui->tblShortcuts->model();
+ // Contents + 2 em-widths
+ ui->tblShortcuts->resizeColumnToContents(0);
+ ui->tblShortcuts->setColumnWidth(0, ui->tblShortcuts->columnWidth(0) + (one_em * 2));
+ ui->tblShortcuts->setColumnWidth(1, one_em * 12);
+ ui->tblShortcuts->resizeColumnToContents(2);
+
QDialog::showEvent(event);
}
@@ -532,6 +543,17 @@ void AboutDialog::copyActionTriggered(bool copyRow)
clipBoard->setText(clipdata);
}
+void AboutDialog::on_tblPlugins_doubleClicked(const QModelIndex &index)
+{
+ const int row = index.row();
+ const int type_col = 2;
+ const int path_col = 3;
+ const QAbstractItemModel *model = index.model();
+ if (model->index(row, type_col).data().toString() == wslua_plugin_type_name()) {
+ QDesktopServices::openUrl(QUrl::fromLocalFile(model->index(row, path_col).data().toString()));
+ }
+}
+
/*
* Editor modelines
*
diff --git a/ui/qt/about_dialog.h b/ui/qt/about_dialog.h
index 7bb458f30e..1c4fe0c662 100644
--- a/ui/qt/about_dialog.h
+++ b/ui/qt/about_dialog.h
@@ -97,7 +97,7 @@ private slots:
void handleCopyMenu(QPoint);
void copyActionTriggered(bool row = false);
void copyRowActionTriggered();
-
+ void on_tblPlugins_doubleClicked(const QModelIndex &index);
};
#endif // ABOUT_DIALOG_H
diff --git a/ui/qt/about_dialog.ui b/ui/qt/about_dialog.ui
index fade8f3e94..527012415f 100644
--- a/ui/qt/about_dialog.ui
+++ b/ui/qt/about_dialog.ui
@@ -82,12 +82,6 @@
<property name="text">
<string/>
</property>
- <property name="scaledContents">
- <bool>true</bool>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
</widget>
</item>
<item>
@@ -190,7 +184,7 @@
<item>
<widget class="QLineEdit" name="searchPlugins">
<property name="placeholderText">
- <string>Search plugins</string>
+ <string>Search Plugins</string>
</property>
</widget>
</item>
@@ -245,7 +239,7 @@
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="textElideMode">
- <enum>Qt::ElideNone</enum>
+ <enum>Qt::ElideRight</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
diff --git a/ui/qt/models/astringlist_list_model.cpp b/ui/qt/models/astringlist_list_model.cpp
index 23955ffb18..6156b44966 100644
--- a/ui/qt/models/astringlist_list_model.cpp
+++ b/ui/qt/models/astringlist_list_model.cpp
@@ -19,16 +19,17 @@ AStringListListModel::AStringListListModel(QObject * parent):
QAbstractTableModel(parent)
{}
-AStringListListModel::~AStringListListModel() { modelData.clear(); }
+AStringListListModel::~AStringListListModel() { display_data_.clear(); }
-void AStringListListModel::appendRow(const QStringList & data, const QModelIndex &parent)
+void AStringListListModel::appendRow(const QStringList & display_strings, const QString & row_tooltip, const QModelIndex &parent)
{
QStringList columns = headerColumns();
- if ( data.count() != columns.count() )
+ if ( display_strings.count() != columns.count() )
return;
emit beginInsertRows(parent, rowCount(), rowCount());
- modelData << data;
+ display_data_ << display_strings;
+ tooltip_data_ << row_tooltip;
emit endInsertRows();
}
@@ -36,7 +37,7 @@ int AStringListListModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
- return modelData.count();
+ return display_data_.count();
}
int AStringListListModel::columnCount(const QModelIndex &parent) const
@@ -66,11 +67,18 @@ QVariant AStringListListModel::data(const QModelIndex &index, int role) const
if ( role == Qt::DisplayRole )
{
- QStringList data = modelData.at(index.row());
+ QStringList data = display_data_.at(index.row());
if ( index.column() < columnCount() )
return QVariant::fromValue(data.at(index.column()));
}
+ else if ( role == Qt::ToolTipRole )
+ {
+ QString tooltip = tooltip_data_.at(index.row());
+ if (!tooltip.isEmpty()) {
+ return tooltip;
+ }
+ }
return QVariant();
}
diff --git a/ui/qt/models/astringlist_list_model.h b/ui/qt/models/astringlist_list_model.h
index a7459cdfe5..ddefe4d8dd 100644
--- a/ui/qt/models/astringlist_list_model.h
+++ b/ui/qt/models/astringlist_list_model.h
@@ -33,12 +33,13 @@ public:
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
protected:
- virtual void appendRow(const QStringList &, const QModelIndex &parent = QModelIndex());
+ virtual void appendRow(const QStringList &, const QString & row_tooltip = QString(), const QModelIndex &parent = QModelIndex());
virtual QStringList headerColumns() const = 0;
private:
- QList<QStringList> modelData;
+ QList<QStringList> display_data_;
+ QStringList tooltip_data_;
};
class AStringListListSortFilterProxyModel : public QSortFilterProxyModel
diff --git a/ui/qt/models/url_link_delegate.cpp b/ui/qt/models/url_link_delegate.cpp
index 503a606100..14d05daac1 100644
--- a/ui/qt/models/url_link_delegate.cpp
+++ b/ui/qt/models/url_link_delegate.cpp
@@ -10,28 +10,18 @@
#include <ui/qt/models/url_link_delegate.h>
-#include <QComboBox>
-#include <QEvent>
-#include <QLineEdit>
#include <QPainter>
-#include <QTextDocument>
-#include <QRect>
-#include <QStyledItemDelegate>
-#include <QStyleOptionViewItem>
-#include <QTextEdit>
UrlLinkDelegate::UrlLinkDelegate(QObject *parent)
: QStyledItemDelegate(parent)
{}
void UrlLinkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
- QStyleOptionViewItem options = option;
- initStyleOption(&options, index);
-
QStyleOptionViewItem opt = option;
initStyleOption(&opt, index);
opt.font.setUnderline(true);
+ opt.palette.setColor(QPalette::Text, opt.palette.link().color());
QStyledItemDelegate::paint(painter, opt, index);
}
diff --git a/ui/qt/models/url_link_delegate.h b/ui/qt/models/url_link_delegate.h
index 9bd0542133..fa1a20bd6c 100644
--- a/ui/qt/models/url_link_delegate.h
+++ b/ui/qt/models/url_link_delegate.h
@@ -13,7 +13,6 @@
#include <config.h>
-#include <QWidget>
#include <QStyledItemDelegate>
#include <QStyleOptionViewItem>
#include <QModelIndex>