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>
This commit is contained in:
Gerald Combs 2019-06-16 11:07:13 -07:00 committed by Anders Broman
parent c6bed35254
commit 178e7ce9a5
9 changed files with 44 additions and 27 deletions

View File

@ -17,8 +17,8 @@ used for troubleshooting, analysis, development and education.
== Whats New
Many user interface improvements have been made. See the “New and Updated
Features” section below for more details.
Many improvements have been made. See the “New and Updated Features”
section below for more details.
// === Bug Fixes
@ -34,6 +34,8 @@ Features” section below for more details.
The following features are new (or have been significantly updated)
since version 3.0.0:
* Dark mode support on macOS and dark theme support on other platforms
has been improved.
* Brotli decompression support in HTTP/HTTP2 (requires the brotli library).
* The build system now checks for a SpeexDSP system library installation. The
bundled Speex resampler code is still provided as a fallback.

View File

@ -41,7 +41,7 @@ image/capture_comment_add.png created from elements in
image/capture_comment_disabled.png accessories-text-editor.svg and
image/capture_comment_update.png paper-sheets.svg
plus-8.png macOS style add / remove icons. Created by Peter Hosey.
list-add.png macOS style add / remove icons. Created by Peter Hosey.
minus-8.png Released under CC-PD.
copy-8.png macOS style copy icon.

View File

@ -5,7 +5,7 @@
</qresource>
<qresource prefix="/stock">
<file>minus-8.png</file>
<file>plus-8.png</file>
<file alias="plus-8.png">stock_icons/8x8/list-add.template.png</file>
<file>copy-8.png</file>
<file>delete_list.png</file>
<file>delete_list@2x.png</file>
@ -15,6 +15,7 @@
<file>arrow_down@2x.png</file>
</qresource>
<qresource prefix="">
<file>stock_icons/8x8/list-add.template.png</file>
<file>stock_icons/14x14/x-capture-comment-update.png</file>
<file>stock_icons/14x14/x-capture-comment-update@2x.png</file>
<file>stock_icons/14x14/x-capture-filter-bookmark.png</file>

View File

Before

Width:  |  Height:  |  Size: 81 B

After

Width:  |  Height:  |  Size: 81 B

View File

@ -2012,6 +2012,8 @@ void MainWindow::initMainToolbarIcons()
main_ui_->actionViewZoomOut->setIcon(StockIcon("zoom-out"));
main_ui_->actionViewNormalSize->setIcon(StockIcon("zoom-original"));
main_ui_->actionViewResizeColumns->setIcon(StockIcon("x-resize-columns"));
main_ui_->actionNewDisplayFilterExpression->setIcon(StockIcon("list-add"));
}
void MainWindow::initShowHideMainWidgets()

View File

@ -2953,16 +2953,6 @@
</property>
</action>
<action name="actionNewDisplayFilterExpression">
<property name="icon">
<iconset resource="../../image/stock_icons.qrc">
<normaloff>:/stock/plus-8.png</normaloff>:/stock/plus-8.png</iconset>
</property>
<property name="text">
<string>Add a filter button</string>
</property>
<property name="iconText">
<string>Expression…</string>
</property>
<property name="toolTip">
<string>Add a display filter button.</string>
</property>

View File

@ -75,7 +75,7 @@ StockIcon::StockIcon(const QString icon_name) :
}
// Is this one of our locally sourced, cage-free, organic icons?
QStringList types = QStringList() << "14x14" << "16x16" << "24x14" << "24x24";
QStringList types = QStringList() << "8x8" << "14x14" << "16x16" << "24x14" << "24x24";
QList<QPalette::ColorGroup> color_groups = QList<QPalette::ColorGroup>()
<< QPalette::Disabled
<< QPalette::Active

View File

@ -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;

View File

@ -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);