From e1fc60ddaecaa914e384ae8bc9bf46cca0096df2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stig=20Bj=C3=B8rlykke?= Date: Tue, 9 Oct 2018 11:46:00 +0200 Subject: [PATCH] Qt: Add back pathLabel in some dialogs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add the pathLabel for Coloring Rules, Decode As, Display Filters and Capture Filter. Put the absolute file path into the pathLabel if the file exists. This aligns with UAT dialogs and frames. Change-Id: I72bd06e31bab220de0a0ef8df99df9a4daed667c Reviewed-on: https://code.wireshark.org/review/30089 Petri-Dish: Stig Bjørlykke Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/color_filters.c | 6 +++--- epan/color_filters.h | 2 ++ ui/filter_files.c | 15 --------------- ui/filter_files.h | 15 +++++++++++++++ ui/qt/coloring_rules_dialog.cpp | 20 +++++++++++++++++++- ui/qt/coloring_rules_dialog.ui | 26 +++++++++++++++++++++++++- ui/qt/decode_as_dialog.cpp | 19 +++++++++++++++++++ ui/qt/decode_as_dialog.ui | 21 ++++++++++++++++++++- ui/qt/filter_dialog.cpp | 20 ++++++++++++++++++++ ui/qt/filter_dialog.ui | 21 ++++++++++++++++++++- 10 files changed, 143 insertions(+), 22 deletions(-) diff --git a/epan/color_filters.c b/epan/color_filters.c index 4d3bd098f7..1283f94e5e 100644 --- a/epan/color_filters.c +++ b/epan/color_filters.c @@ -287,7 +287,7 @@ color_filters_get(gchar** err_msg, color_filter_add_cb_func add_cb) * Get the path for the file that would have their filters, and * try to open it. */ - path = get_persconffile_path("colorfilters", TRUE); + path = get_persconffile_path(COLORFILTERS_FILE_NAME, TRUE); if ((f = ws_fopen(path, "r")) == NULL) { if (errno != ENOENT) { /* Error trying to open the file; give up. */ @@ -687,7 +687,7 @@ color_filters_read_globals(gpointer user_data, gchar** err_msg, color_filter_add * Get the path for the file that would have the global filters, and * try to open it. */ - path = get_datafile_path("colorfilters"); + path = get_datafile_path(COLORFILTERS_FILE_NAME); if ((f = ws_fopen(path, "r")) == NULL) { if (errno != ENOENT) { /* Error trying to open the file; give up. */ @@ -804,7 +804,7 @@ color_filters_write(GSList *cfl, gchar** err_msg) return FALSE; } - path = get_persconffile_path("colorfilters", TRUE); + path = get_persconffile_path(COLORFILTERS_FILE_NAME, TRUE); if ((f = ws_fopen(path, "w+")) == NULL) { *err_msg = g_strdup_printf("Could not open\n%s\nfor writing: %s.", path, g_strerror(errno)); diff --git a/epan/color_filters.h b/epan/color_filters.h index 7cfc910e26..00b05df994 100644 --- a/epan/color_filters.h +++ b/epan/color_filters.h @@ -20,6 +20,8 @@ extern "C" { struct epan_dissect; +#define COLORFILTERS_FILE_NAME "colorfilters" + #define CONVERSATION_COLOR_PREFIX "___conversation_color_filter___" /** @file * Color filters. diff --git a/ui/filter_files.c b/ui/filter_files.c index 487f5c1e5f..971f9c3959 100644 --- a/ui/filter_files.c +++ b/ui/filter_files.c @@ -22,21 +22,6 @@ #include "ui/filter_files.h" -/* - * Old filter file name. - */ -#define FILTER_FILE_NAME "filters" - -/* - * Capture filter file name. - */ -#define CFILTER_FILE_NAME "cfilters" - -/* - * Display filter file name. - */ -#define DFILTER_FILE_NAME "dfilters" - /* * List of capture filters - saved. */ diff --git a/ui/filter_files.h b/ui/filter_files.h index 3891a919a3..88ad6378a5 100644 --- a/ui/filter_files.h +++ b/ui/filter_files.h @@ -15,6 +15,21 @@ extern "C" { #endif /* __cplusplus */ +/* + * Old filter file name. + */ +#define FILTER_FILE_NAME "filters" + +/* + * Capture filter file name. + */ +#define CFILTER_FILE_NAME "cfilters" + +/* + * Display filter file name. + */ +#define DFILTER_FILE_NAME "dfilters" + /* * Filter lists. */ diff --git a/ui/qt/coloring_rules_dialog.cpp b/ui/qt/coloring_rules_dialog.cpp index 4d4ea5653f..3358a9250a 100644 --- a/ui/qt/coloring_rules_dialog.cpp +++ b/ui/qt/coloring_rules_dialog.cpp @@ -20,12 +20,14 @@ #include "wsutil/filesystem.h" #include "wireshark_application.h" +#include "ui/qt/utils/qt_ui_utils.h" #include "ui/qt/widgets/copy_from_profile_menu.h" #include "ui/qt/widgets/wireshark_file_dialog.h" #include #include #include +#include /* * @file Coloring Rules dialog @@ -58,6 +60,14 @@ ColoringRulesDialog::ColoringRulesDialog(QWidget *parent, QString add_filter) : ui->coloringRulesTreeView->resizeColumnToContents(i); } +#ifdef Q_OS_MAC + ui->newToolButton->setAttribute(Qt::WA_MacSmallSize, true); + ui->deleteToolButton->setAttribute(Qt::WA_MacSmallSize, true); + ui->copyToolButton->setAttribute(Qt::WA_MacSmallSize, true); + ui->clearToolButton->setAttribute(Qt::WA_MacSmallSize, true); + ui->pathLabel->setAttribute(Qt::WA_MacSmallSize, true); +#endif + connect(ui->coloringRulesTreeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(colorRuleSelectionChanged(const QItemSelection &, const QItemSelection &))); connect(&colorRuleDelegate_, SIGNAL(invalidField(const QModelIndex&, const QString&)), @@ -75,12 +85,20 @@ ColoringRulesDialog::ColoringRulesDialog(QWidget *parent, QString add_filter) : export_button_->setToolTip(tr("Save filters in a file.")); QPushButton *copy_button = ui->buttonBox->addButton(tr("Copy from"), QDialogButtonBox::ActionRole); - copy_from_menu_ = new CopyFromProfileMenu("colorfilters"); + copy_from_menu_ = new CopyFromProfileMenu(COLORFILTERS_FILE_NAME); copy_button->setMenu(copy_from_menu_); copy_button->setToolTip(tr("Copy coloring rules from another profile.")); copy_button->setEnabled(copy_from_menu_->haveProfiles()); connect(copy_from_menu_, SIGNAL(triggered(QAction *)), this, SLOT(copyFromProfile(QAction *))); + QString abs_path = gchar_free_to_qstring(get_persconffile_path(COLORFILTERS_FILE_NAME, TRUE)); + if (file_exists(abs_path.toUtf8().constData())) { + ui->pathLabel->setText(abs_path); + ui->pathLabel->setUrl(QUrl::fromLocalFile(abs_path).toString()); + ui->pathLabel->setToolTip(tr("Open ") + COLORFILTERS_FILE_NAME); + ui->pathLabel->setEnabled(true); + } + if (!add_filter.isEmpty()) { colorRuleModel_.addColor(false, add_filter, palette().color(QPalette::Text), palette().color(QPalette::Base)); diff --git a/ui/qt/coloring_rules_dialog.ui b/ui/qt/coloring_rules_dialog.ui index 894381f7b7..2922793a08 100644 --- a/ui/qt/coloring_rules_dialog.ui +++ b/ui/qt/coloring_rules_dialog.ui @@ -56,7 +56,7 @@ - + @@ -189,6 +189,25 @@ + + + + + 1 + 0 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + @@ -209,6 +228,11 @@ QTreeView
widgets/tabnav_tree_view.h
+ + ElidedLabel + QLabel +
widgets/elided_label.h
+
diff --git a/ui/qt/decode_as_dialog.cpp b/ui/qt/decode_as_dialog.cpp index 0c78e389bd..d7a6d68c0a 100644 --- a/ui/qt/decode_as_dialog.cpp +++ b/ui/qt/decode_as_dialog.cpp @@ -15,6 +15,7 @@ #include "ui/decode_as_utils.h" #include "ui/simple_dialog.h" +#include "wsutil/filesystem.h" #include #include @@ -26,6 +27,8 @@ #include #include #include +#include + #include // To do: @@ -46,8 +49,24 @@ DecodeAsDialog::DecodeAsDialog(QWidget *parent, capture_file *cf, bool create_ne ui->decodeAsTreeView->setModel(model_); ui->decodeAsTreeView->setItemDelegate(delegate_); +#ifdef Q_OS_MAC + ui->newToolButton->setAttribute(Qt::WA_MacSmallSize, true); + ui->deleteToolButton->setAttribute(Qt::WA_MacSmallSize, true); + ui->copyToolButton->setAttribute(Qt::WA_MacSmallSize, true); + ui->clearToolButton->setAttribute(Qt::WA_MacSmallSize, true); + ui->pathLabel->setAttribute(Qt::WA_MacSmallSize, true); +#endif + setWindowTitle(wsApp->windowTitleString(tr("Decode As" UTF8_HORIZONTAL_ELLIPSIS))); + QString abs_path = gchar_free_to_qstring(get_persconffile_path(DECODE_AS_ENTRIES_FILE_NAME, TRUE)); + if (file_exists(abs_path.toUtf8().constData())) { + ui->pathLabel->setText(abs_path); + ui->pathLabel->setUrl(QUrl::fromLocalFile(abs_path).toString()); + ui->pathLabel->setToolTip(tr("Open ") + DECODE_AS_ENTRIES_FILE_NAME); + ui->pathLabel->setEnabled(true); + } + fillTable(); connect(model_, SIGNAL(modelReset()), this, SLOT(modelRowsReset())); diff --git a/ui/qt/decode_as_dialog.ui b/ui/qt/decode_as_dialog.ui index 9981b0f177..6db0a61cc4 100644 --- a/ui/qt/decode_as_dialog.ui +++ b/ui/qt/decode_as_dialog.ui @@ -19,7 +19,7 @@
- + @@ -89,6 +89,25 @@ + + + + + 1 + 0 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + diff --git a/ui/qt/filter_dialog.cpp b/ui/qt/filter_dialog.cpp index cfcb4f020f..cc9a06f541 100644 --- a/ui/qt/filter_dialog.cpp +++ b/ui/qt/filter_dialog.cpp @@ -22,7 +22,9 @@ #include #include +#include +#include #include //#include "capture_filter_syntax_worker.h" #include @@ -51,13 +53,22 @@ FilterDialog::FilterDialog(QWidget *parent, FilterType filter_type, const QStrin if (parent) loadGeometry(parent->width() * 2 / 3, parent->height() * 2 / 3); setWindowIcon(wsApp->normalIcon()); +#ifdef Q_OS_MAC + ui->newToolButton->setAttribute(Qt::WA_MacSmallSize, true); + ui->deleteToolButton->setAttribute(Qt::WA_MacSmallSize, true); + ui->copyToolButton->setAttribute(Qt::WA_MacSmallSize, true); + ui->pathLabel->setAttribute(Qt::WA_MacSmallSize, true); +#endif + ui->filterTreeWidget->setDragEnabled(true); ui->filterTreeWidget->viewport()->setAcceptDrops(true); ui->filterTreeWidget->setDropIndicatorShown(true); ui->filterTreeWidget->setDragDropMode(QAbstractItemView::InternalMove); + const gchar * filename = NULL; if (filter_type == CaptureFilter) { setWindowTitle(wsApp->windowTitleString(tr("Capture Filters"))); + filename = CFILTER_FILE_NAME; // QThread *syntax_thread = new QThread; // syntax_worker_ = new CaptureFilterSyntaxWorker; @@ -70,6 +81,15 @@ FilterDialog::FilterDialog(QWidget *parent, FilterType filter_type, const QStrin // syntax_thread->start(); } else { setWindowTitle(wsApp->windowTitleString(tr("Display Filters"))); + filename = DFILTER_FILE_NAME; + } + + QString abs_path = gchar_free_to_qstring(get_persconffile_path(filename, TRUE)); + if (file_exists(abs_path.toUtf8().constData())) { + ui->pathLabel->setText(abs_path); + ui->pathLabel->setUrl(QUrl::fromLocalFile(abs_path).toString()); + ui->pathLabel->setToolTip(tr("Open ") + filename); + ui->pathLabel->setEnabled(true); } ui->filterTreeWidget->setItemDelegateForColumn(filter_col_, filter_tree_delegate_); diff --git a/ui/qt/filter_dialog.ui b/ui/qt/filter_dialog.ui index 1d6db2dc23..87d2b7dd95 100644 --- a/ui/qt/filter_dialog.ui +++ b/ui/qt/filter_dialog.ui @@ -41,7 +41,7 @@ - + @@ -100,6 +100,25 @@ + + + + + 1 + 0 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -- 2.34.1