aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/widgets
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2019-06-16 11:07:13 -0700
committerAnders Broman <a.broman58@gmail.com>2019-06-17 00:46:21 +0000
commit178e7ce9a533ba9e5e152c9f7bc08f5ba8f25f0b (patch)
tree2b668ea6426fd35b212c14d951f5b11f6fe2b3a7 /ui/qt/widgets
parentc6bed352540a8859c3820ad38de52ae7bf27cbe6 (diff)
Qt: Filter expression toolbar dark mode updates.
Move plus-8.png to stock_icons/8x8 and rename it list-add.template.png which conforms to the Freedesktop icon naming specifications and makes it a template icon. Update our style sheet when we recive a QEvent::PaletteChange. Ping-Bug: 15511 Change-Id: I4b8ddcb4eb64f11faec21d5df4a3fd7fdc5cf488 Reviewed-on: https://code.wireshark.org/review/33626 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>
Diffstat (limited to 'ui/qt/widgets')
-rw-r--r--ui/qt/widgets/filter_expression_toolbar.cpp42
-rw-r--r--ui/qt/widgets/filter_expression_toolbar.h4
2 files changed, 34 insertions, 12 deletions
diff --git a/ui/qt/widgets/filter_expression_toolbar.cpp b/ui/qt/widgets/filter_expression_toolbar.cpp
index 42036f23c6..cc56e46c87 100644
--- a/ui/qt/widgets/filter_expression_toolbar.cpp
+++ b/ui/qt/widgets/filter_expression_toolbar.cpp
@@ -34,18 +34,7 @@ struct filter_expression_data
FilterExpressionToolBar::FilterExpressionToolBar(QWidget * parent) :
DragDropToolBar(parent)
{
- // Try to draw 1-pixel-wide separator lines from the button label
- // ascent to its baseline.
- int sep_margin = (fontMetrics().height() * 0.5) - 1;
- QColor sep_color = ColorUtils::alphaBlend(palette().text(), palette().base(), 0.3);
- setStyleSheet(QString(
- "QToolBar { background: none; border: none; spacing: 1px; }"
- "QFrame {"
- " min-width: 1px; max-width: 1px;"
- " margin: %1px 0 %2px 0; padding: 0;"
- " background-color: %3;"
- "}"
- ).arg(sep_margin).arg(sep_margin - 1).arg(sep_color.name()));
+ updateStyleSheet();
setContextMenuPolicy(Qt::CustomContextMenu);
@@ -60,6 +49,19 @@ FilterExpressionToolBar::FilterExpressionToolBar(QWidget * parent) :
}
+bool FilterExpressionToolBar::event(QEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::PaletteChange:
+ updateStyleSheet();
+ break;
+ default:
+ break;
+
+ }
+ return DragDropToolBar::event(event);
+}
+
void FilterExpressionToolBar::onCustomMenuHandler(const QPoint& pos)
{
QAction * filterAction = actionAt(pos);
@@ -200,6 +202,22 @@ void FilterExpressionToolBar::toolBarShowPreferences()
emit filterPreferences();
}
+void FilterExpressionToolBar::updateStyleSheet()
+{
+ // Try to draw 1-pixel-wide separator lines from the button label
+ // ascent to its baseline.
+ int sep_margin = (fontMetrics().height() * 0.5) - 1;
+ QColor sep_color = ColorUtils::alphaBlend(palette().text(), palette().base(), 0.3);
+ setStyleSheet(QString(
+ "QToolBar { background: none; border: none; spacing: 1px; }"
+ "QFrame {"
+ " min-width: 1px; max-width: 1px;"
+ " margin: %1px 0 %2px 0; padding: 0;"
+ " background-color: %3;"
+ "}"
+ ).arg(sep_margin).arg(sep_margin - 1).arg(sep_color.name()));
+}
+
int FilterExpressionToolBar::uatRowIndexForFilter(QString label, QString expression)
{
int result = -1;
diff --git a/ui/qt/widgets/filter_expression_toolbar.h b/ui/qt/widgets/filter_expression_toolbar.h
index af4956c770..5601825549 100644
--- a/ui/qt/widgets/filter_expression_toolbar.h
+++ b/ui/qt/widgets/filter_expression_toolbar.h
@@ -20,6 +20,9 @@ class FilterExpressionToolBar : public DragDropToolBar
public:
explicit FilterExpressionToolBar(QWidget * parent = Q_NULLPTR);
+protected:
+ virtual bool event(QEvent *event);
+
public slots:
void filterExpressionsChanged();
@@ -41,6 +44,7 @@ private slots:
void toolBarShowPreferences();
private:
+ void updateStyleSheet();
int uatRowIndexForFilter(QString label, QString expression);
static gboolean filter_expression_add_action(const void *key, void *value, void *user_data);