Qt: Add back pathLabel in some dialogs
authorStig Bjørlykke <stig@bjorlykke.org>
Tue, 9 Oct 2018 09:46:00 +0000 (11:46 +0200)
committerAnders Broman <a.broman58@gmail.com>
Wed, 10 Oct 2018 04:46:28 +0000 (04:46 +0000)
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 <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
epan/color_filters.c
epan/color_filters.h
ui/filter_files.c
ui/filter_files.h
ui/qt/coloring_rules_dialog.cpp
ui/qt/coloring_rules_dialog.ui
ui/qt/decode_as_dialog.cpp
ui/qt/decode_as_dialog.ui
ui/qt/filter_dialog.cpp
ui/qt/filter_dialog.ui

index 4d3bd098f7ee5eb3e1c05390345af433a6cd226e..1283f94e5ee7fd418560756a74ad41a587d34cc3 100644 (file)
@@ -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));
index 7cfc910e2612931037e7129f877176b23a1f79a3..00b05df994ad8aaeb635422ebb5edee4de974676 100644 (file)
@@ -20,6 +20,8 @@ extern "C" {
 
 struct epan_dissect;
 
+#define COLORFILTERS_FILE_NAME          "colorfilters"
+
 #define CONVERSATION_COLOR_PREFIX       "___conversation_color_filter___"
 /** @file
  *  Color filters.
index 487f5c1e5f02aedbbe453df96a83429a276c334f..971f9c3959bedf6b9bbb3894fe8515155b6750c4 100644 (file)
 
 #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.
  */
index 3891a919a3021d48e43681e7b3e4a590e6e38515..88ad6378a5ed56061415239c9422263a60e16502 100644 (file)
 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.
  */
index 4d4ea5653f6bb22eaee37e35d1635af0af3cbba0..3358a9250a2551d5489a7d006f3004524dafd0fe 100644 (file)
 #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 <QColorDialog>
 #include <QMessageBox>
 #include <QPushButton>
+#include <QUrl>
 
 /*
  * @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));
 
index 894381f7b712052680ce4b9a095306cdcaa96d0d..2922793a089961596dca53a9eeca929e16526358 100644 (file)
@@ -56,7 +56,7 @@
     </widget>
    </item>
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0,0,0,1">
+    <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0,0,0,0,1">
      <item>
       <widget class="QToolButton" name="newToolButton">
        <property name="toolTip">
        </property>
       </spacer>
      </item>
+     <item>
+      <widget class="ElidedLabel" name="pathLabel">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+         <horstretch>1</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+       </property>
+       <property name="openExternalLinks">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
    <item>
    <extends>QTreeView</extends>
    <header>widgets/tabnav_tree_view.h</header>
   </customwidget>
+  <customwidget>
+   <class>ElidedLabel</class>
+   <extends>QLabel</extends>
+   <header>widgets/elided_label.h</header>
+  </customwidget>
  </customwidgets>
  <resources>
   <include location="../../image/stock_icons.qrc"/>
index 0c78e389bd847f627c2ca276dd92441efab8e771..d7a6d68c0a19a6cd06ae4645539169bdfac57579 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "ui/decode_as_utils.h"
 #include "ui/simple_dialog.h"
+#include "wsutil/filesystem.h"
 #include <wsutil/utf8_entities.h>
 
 #include <ui/qt/utils/qt_ui_utils.h>
@@ -26,6 +27,8 @@
 #include <QFont>
 #include <QFontMetrics>
 #include <QLineEdit>
+#include <QUrl>
+
 #include <QDebug>
 
 // 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()));
index 9981b0f177b52c686d24f2f4dd743ed083d3c6d2..6db0a61cc429d3b2788815d712543e0a6591ded3 100644 (file)
@@ -19,7 +19,7 @@
     </widget>
    </item>
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
+    <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0,1">
      <item>
       <widget class="QToolButton" name="newToolButton">
        <property name="toolTip">
        </property>
       </spacer>
      </item>
+     <item>
+      <widget class="ElidedLabel" name="pathLabel">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+         <horstretch>1</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+       </property>
+       <property name="openExternalLinks">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
    <item>
index cfcb4f020f54e151f417afb2233654a34ea8e49a..cc9a06f541212c208779f112e8ad840c4d08c478 100644 (file)
@@ -22,7 +22,9 @@
 
 #include <QMessageBox>
 #include <QThread>
+#include <QUrl>
 
+#include <ui/qt/utils/qt_ui_utils.h>
 #include <ui/qt/widgets/capture_filter_edit.h>
 //#include "capture_filter_syntax_worker.h"
 #include <ui/qt/widgets/display_filter_edit.h>
@@ -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_);
index 1d6db2dc2322ec049f273e838c537037bb60a51d..87d2b7dd95e4a0d93131b9954014fcab65917da2 100644 (file)
@@ -41,7 +41,7 @@
     </widget>
    </item>
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
+    <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,1">
      <item>
       <widget class="QToolButton" name="newToolButton">
        <property name="toolTip">
        </property>
       </spacer>
      </item>
+     <item>
+      <widget class="ElidedLabel" name="pathLabel">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+         <horstretch>1</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+       </property>
+       <property name="openExternalLinks">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
    <item>