diff options
author | Gerald Combs <gerald@wireshark.org> | 2019-06-13 10:25:19 -0700 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2019-06-13 18:02:50 +0000 |
commit | b94047c606a53f405ea24ca5bf5161a74da7d4b9 (patch) | |
tree | 0c1b8091e8533adccb1d92331434f472cef725ba | |
parent | f41e1d22f0d9b9deb7f7f8dc9e3f81f45faae11a (diff) |
Qt: Add support for template icons.
Add support for ".template" icons, which are masked against the current
WindowText color. Convert the edit-find icons to templates.
Reload our icon(s) when we receive a QEvent::PaletteChange in MainWindow
and in StockIconToolButton.
Clean our SVGs.
To do:
- Convert other black or mostly black icons to templates.
- Handle QEvent::PaletteChange in more places.
Ping-Bug: 15511
Change-Id: I1ce78d92e769861dc38d86a3def5116fb869e2bf
Reviewed-on: https://code.wireshark.org/review/33571
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>
19 files changed, 268 insertions, 253 deletions
diff --git a/image/stock_icons.qrc b/image/stock_icons.qrc index 577a03b024..45d8f22d6b 100644 --- a/image/stock_icons.qrc +++ b/image/stock_icons.qrc @@ -57,8 +57,8 @@ <file>stock_icons/14x14/x-filter-matching-bookmark.active@2x.png</file> <file>stock_icons/14x14/x-filter-matching-bookmark.selected.png</file> <file>stock_icons/14x14/x-filter-matching-bookmark.selected@2x.png</file> - <file>stock_icons/16x16/edit-find.png</file> - <file>stock_icons/16x16/edit-find@2x.png</file> + <file>stock_icons/16x16/edit-find.template.png</file> + <file>stock_icons/16x16/edit-find.template@2x.png</file> <file>stock_icons/16x16/go-first.png</file> <file>stock_icons/16x16/go-first@2x.png</file> <file>stock_icons/16x16/go-jump.png</file> @@ -103,8 +103,8 @@ <file>stock_icons/24x14/x-filter-apply.active@2x.png</file> <file>stock_icons/24x14/x-filter-apply.selected.png</file> <file>stock_icons/24x14/x-filter-apply.selected@2x.png</file> - <file>stock_icons/24x24/edit-find.png</file> - <file>stock_icons/24x24/edit-find@2x.png</file> + <file>stock_icons/24x24/edit-find.template.png</file> + <file>stock_icons/24x24/edit-find.template@2x.png</file> <file>stock_icons/24x24/go-first.png</file> <file>stock_icons/24x24/go-first@2x.png</file> <file>stock_icons/24x24/go-jump.png</file> diff --git a/image/stock_icons/16x16/edit-find.png b/image/stock_icons/16x16/edit-find.png Binary files differdeleted file mode 100644 index 5ea11cf618..0000000000 --- a/image/stock_icons/16x16/edit-find.png +++ /dev/null diff --git a/image/stock_icons/16x16/edit-find.svg b/image/stock_icons/16x16/edit-find.svg deleted file mode 100644 index e16f162aa9..0000000000 --- a/image/stock_icons/16x16/edit-find.svg +++ /dev/null @@ -1,120 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> - -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="16" - height="16" - id="svg2" - version="1.1" - inkscape:version="0.48.2 r9819" - sodipodi:docname="edit-find.svg" - inkscape:export-filename="edit-find.png" - inkscape:export-xdpi="90" - inkscape:export-ydpi="90"> - <defs - id="defs4"> - <inkscape:perspective - sodipodi:type="inkscape:persp3d" - inkscape:vp_x="0 : 526.18109 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_z="744.09448 : 526.18109 : 1" - inkscape:persp3d-origin="372.04724 : 350.78739 : 1" - id="perspective10" /> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="32.125" - inkscape:cx="8" - inkscape:cy="8" - inkscape:document-units="px" - inkscape:current-layer="layer1" - showgrid="true" - inkscape:window-width="931" - inkscape:window-height="683" - inkscape:window-x="80" - inkscape:window-y="784" - inkscape:window-maximized="0"> - <inkscape:grid - type="xygrid" - id="grid2983" - empspacing="4" - visible="true" - enabled="true" - snapvisiblegridlinesonly="true" /> - </sodipodi:namedview> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1" - transform="translate(0,-1036.3622)"> - <g - id="g3763" - transform="matrix(0.50914019,-0.29395223,0.29395223,0.50914019,-301.43501,516.71748)"> - <g - transform="translate(-10,2)" - id="g3759"> - <rect - style="fill:#2e3436;fill-opacity:1;stroke:#2e3436;stroke-width:1.7009567;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" - id="rect2987" - width="3" - height="9" - x="16.5" - y="1042.3622" - rx="1.7009567" - ry="1.7009567" /> - <path - style="fill:none;stroke:#2e3436;stroke-width:3.4019134;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" - d="m 18,1030.3622 c 0,13 0,13 0,13" - id="path3757" - inkscape:connector-curvature="0" /> - </g> - <path - transform="matrix(1.3,0,0,1.4444444,-1.1,1026.4733)" - d="M 12,6.5 C 12,8.9852814 9.7614237,11 7,11 4.2385763,11 2,8.9852814 2,6.5 2,4.0147186 4.2385763,2 7,2 c 2.7614237,0 5,2.0147186 5,4.5 z" - sodipodi:ry="4.5" - sodipodi:rx="5" - sodipodi:cy="6.5" - sodipodi:cx="7" - id="path2985" - style="fill:#eeeeec;fill-opacity:1;stroke:#2e3436;stroke-width:1.24128401;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" - sodipodi:type="arc" /> - </g> - <path - sodipodi:type="arc" - style="fill:none;stroke:#2e3436;stroke-width:1.26713073;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" - id="path3769" - sodipodi:cx="11" - sodipodi:cy="8" - sodipodi:rx="2.9472158" - sodipodi:ry="2.9472158" - d="M 8.2358567,6.9774576 A 2.9472158,2.9472158 0 0 1 11.758699,5.1521137" - transform="matrix(0.78918459,0,0,0.78918459,-1.4346112,1035.5437)" - sodipodi:start="3.4959119" - sodipodi:end="4.9727497" - sodipodi:open="true" /> - </g> -</svg> diff --git a/image/stock_icons/16x16/edit-find.template.png b/image/stock_icons/16x16/edit-find.template.png Binary files differnew file mode 100644 index 0000000000..7eee37c2f2 --- /dev/null +++ b/image/stock_icons/16x16/edit-find.template.png diff --git a/image/stock_icons/16x16/edit-find.template.svg b/image/stock_icons/16x16/edit-find.template.svg new file mode 100644 index 0000000000..bd4071be3b --- /dev/null +++ b/image/stock_icons/16x16/edit-find.template.svg @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + height="16" + width="16" + version="1.1" + id="svg9548" + sodipodi:docname="edit-find.template.svg" + inkscape:version="0.92.2 5c3e80d, 2017-08-06"> + <metadata + id="metadata9554"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs9552" /> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1035" + inkscape:window-height="735" + id="namedview9550" + showgrid="false" + inkscape:zoom="29.0625" + inkscape:cx="8" + inkscape:cy="8" + inkscape:window-x="541" + inkscape:window-y="121" + inkscape:window-maximized="0" + inkscape:current-layer="svg9548" /> + <radialGradient + id="a" + cx="3.776183" + cy="8.476432" + gradientTransform="matrix(0.8502024,0.49086459,-0.49086459,0.8502024,4.567725,-0.470796)" + gradientUnits="userSpaceOnUse" + r="4.321379"> + <stop + offset="0" + stop-opacity=".121569" + id="stop9531" /> + <stop + offset="1" + stop-opacity=".309645" + id="stop9535" + style="stop-color:#000000;stop-opacity:0.24705882" /> + </radialGradient> + <rect + style="fill:#0c0000;stroke:#000000;stroke-linecap:round;stroke-opacity:1;fill-opacity:1" + id="rect9538" + y="13.242122" + x="2.593333" + width="1.763713" + transform="rotate(-30)" + rx="1" + height="5.2911401" /> + <path + inkscape:connector-curvature="0" + style="fill:none;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + id="path9540" + d="M 5.0650002,4.688002 A 2.3258973,2.3258973 0 0 1 7.845173,3.2474687" /> + <path + inkscape:connector-curvature="0" + style="fill:none;stroke:#000000;stroke-width:2;stroke-opacity:1" + id="path9542" + d="m 9.2089838,9 c 0.715675,1.2396 0.715675,1.2396 0.715675,1.2396" /> + <circle + style="fill:url(#a);stroke:#000000;stroke-linecap:round;stroke-opacity:1" + id="circle9544" + transform="rotate(-30)" + r="3.8213789" + cy="8.2449293" + cx="3.47523" /> +</svg> diff --git a/image/stock_icons/16x16/edit-find.template@2x.png b/image/stock_icons/16x16/edit-find.template@2x.png Binary files differnew file mode 100644 index 0000000000..5c4f21f180 --- /dev/null +++ b/image/stock_icons/16x16/edit-find.template@2x.png diff --git a/image/stock_icons/16x16/edit-find@2x.png b/image/stock_icons/16x16/edit-find@2x.png Binary files differdeleted file mode 100644 index ae4d818bb0..0000000000 --- a/image/stock_icons/16x16/edit-find@2x.png +++ /dev/null diff --git a/image/stock_icons/24x24/edit-find.png b/image/stock_icons/24x24/edit-find.png Binary files differdeleted file mode 100644 index f739ea9880..0000000000 --- a/image/stock_icons/24x24/edit-find.png +++ /dev/null diff --git a/image/stock_icons/24x24/edit-find.svg b/image/stock_icons/24x24/edit-find.svg deleted file mode 100644 index 67497daabe..0000000000 --- a/image/stock_icons/24x24/edit-find.svg +++ /dev/null @@ -1,120 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> - -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="24" - height="24" - id="svg2" - version="1.1" - inkscape:version="0.48.2 r9819" - sodipodi:docname="edit-find.svg" - inkscape:export-filename="edit-find.png" - inkscape:export-xdpi="90" - inkscape:export-ydpi="90"> - <defs - id="defs4"> - <inkscape:perspective - sodipodi:type="inkscape:persp3d" - inkscape:vp_x="0 : 526.18109 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_z="744.09448 : 526.18109 : 1" - inkscape:persp3d-origin="372.04724 : 350.78739 : 1" - id="perspective10" /> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="21.416667" - inkscape:cx="11.182879" - inkscape:cy="12" - inkscape:document-units="px" - inkscape:current-layer="layer1" - showgrid="true" - inkscape:window-width="931" - inkscape:window-height="683" - inkscape:window-x="285" - inkscape:window-y="790" - inkscape:window-maximized="0"> - <inkscape:grid - type="xygrid" - id="grid2983" - empspacing="4" - visible="true" - enabled="true" - snapvisiblegridlinesonly="true" /> - </sodipodi:namedview> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1" - transform="translate(0,-1028.3622)"> - <g - id="g3763" - transform="matrix(0.82446641,-0.47637689,0.47600591,0.82510896,-489.17862,185.1767)"> - <g - transform="translate(-10,2)" - id="g3759"> - <rect - style="fill:#2e3436;fill-opacity:1;stroke:#2e3436;stroke-width:1.04999804;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" - id="rect2987" - width="3" - height="9" - x="16.5" - y="1042.3622" - rx="1.0504072" - ry="1.0495892" /> - <path - style="fill:none;stroke:#2e3436;stroke-width:2.09999609;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" - d="m 18,1030.3622 c 0,13 0,13 0,13" - id="path3757" - inkscape:connector-curvature="0" /> - </g> - <path - transform="matrix(1.3,0,0,1.4444444,-1.1,1026.4733)" - d="M 12,6.5 C 12,8.9852814 9.7614237,11 7,11 4.2385763,11 2,8.9852814 2,6.5 2,4.0147186 4.2385763,2 7,2 c 2.7614237,0 5,2.0147186 5,4.5 z" - sodipodi:ry="4.5" - sodipodi:rx="5" - sodipodi:cy="6.5" - sodipodi:cx="7" - id="path2985" - style="fill:#eeeeec;fill-opacity:1;stroke:#2e3436;stroke-width:0.7662428;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" - sodipodi:type="arc" /> - </g> - <path - sodipodi:type="arc" - style="fill:none;stroke:#2e3436;stroke-width:0.78219789;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" - id="path3769" - sodipodi:cx="11" - sodipodi:cy="8" - sodipodi:rx="2.9472158" - sodipodi:ry="2.9472158" - d="M 8.2358567,6.9774576 A 2.9472158,2.9472158 0 0 1 11.758699,5.1521137" - transform="matrix(1.277951,0,0,1.2789469,-3.7024834,1025.3339)" - sodipodi:start="3.4959119" - sodipodi:end="4.9727497" - sodipodi:open="true" /> - </g> -</svg> diff --git a/image/stock_icons/24x24/edit-find.template.png b/image/stock_icons/24x24/edit-find.template.png Binary files differnew file mode 100644 index 0000000000..58c9468ec1 --- /dev/null +++ b/image/stock_icons/24x24/edit-find.template.png diff --git a/image/stock_icons/24x24/edit-find.template.svg b/image/stock_icons/24x24/edit-find.template.svg new file mode 100644 index 0000000000..f669b6b4df --- /dev/null +++ b/image/stock_icons/24x24/edit-find.template.svg @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + height="24" + width="24" + version="1.1" + id="svg9523" + sodipodi:docname="edit-find.template.svg" + inkscape:version="0.92.2 5c3e80d, 2017-08-06"> + <metadata + id="metadata9529"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs9527" /> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1190" + inkscape:window-height="824" + id="namedview9525" + showgrid="false" + inkscape:zoom="27.40821" + inkscape:cx="8.4426718" + inkscape:cy="12" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="svg9523" /> + <radialGradient + id="a" + cx="5.516279" + cy="12.297983" + gradientTransform="matrix(0.86592771,0.5001384,-0.50031865,0.86556467,6.666019,-1.018595)" + gradientUnits="userSpaceOnUse" + r="6.689283"> + <stop + offset="0" + stop-opacity=".121569" + id="stop9504" /> + <stop + offset="1" + stop-opacity=".309804" + id="stop9508" + style="stop-color:#000000;stop-opacity:0.24705882" /> + </radialGradient> + <rect + style="fill:#000001;stroke:#000000;stroke-linecap:round" + id="rect9511" + y="20.016092" + x="3.812156" + width="2.8565919" + transform="matrix(0.86585665,-0.50029218,0.49970789,0.86619399,0,0)" + ry="0.99980497" + rx="1.000195" + height="8.5731153" /> + <path + style="fill:none;stroke:#000000;stroke-width:2" + inkscape:connector-curvature="0" + id="path9513" + d="m 13.528935,13 c 2.916666,5 2.916666,5 2.916666,5" /> + <ellipse + cx="5.2404718" + cy="11.919237" + rx="6.1892829" + ry="6.1916938" + transform="matrix(0.86585664,-0.50029219,0.49970789,0.86619399,0,0)" + id="ellipse9515" + style="fill:url(#a);stroke:#000000;stroke-linecap:round" /> + <path + d="M 6.8225383,5.8954978 A 3.7663974,3.7693325 0 0 1 11.324558,3.5609798" + id="path9517" + inkscape:connector-curvature="0" + style="fill:none;stroke:#000000;stroke-linecap:round;stroke-linejoin:round" /> +</svg> diff --git a/image/stock_icons/24x24/edit-find.template@2x.png b/image/stock_icons/24x24/edit-find.template@2x.png Binary files differnew file mode 100644 index 0000000000..a100f18fab --- /dev/null +++ b/image/stock_icons/24x24/edit-find.template@2x.png diff --git a/image/stock_icons/24x24/edit-find@2x.png b/image/stock_icons/24x24/edit-find@2x.png Binary files differdeleted file mode 100644 index 98ae655ffa..0000000000 --- a/image/stock_icons/24x24/edit-find@2x.png +++ /dev/null diff --git a/image/stock_icons/svg-to-png.sh b/image/stock_icons/svg-to-png.sh index 3fb8ab87e1..d989d0073c 100755 --- a/image/stock_icons/svg-to-png.sh +++ b/image/stock_icons/svg-to-png.sh @@ -13,6 +13,8 @@ COMMON_ARGS="--export-area-page" +SVGCLEANER=$( type -p svgcleaner ) + set_source_svgs() { local out_icon=$1 case $out_icon in @@ -34,7 +36,7 @@ set_source_svgs() { } ICONS=" - edit-find + edit-find.template go-first go-jump go-last @@ -74,10 +76,14 @@ ICONS=" zoom-out " +if [ -n "$@" ] ; then + ICONS="$@" +fi + QRC_FILES="" # 12x12 -for SIZE in 14x14 16x16 24x14 24x14 ; do +for SIZE in 14x14 16x16 24x14 24x24 ; do WIDTH=${SIZE/x*/} HEIGHT=${SIZE/*x/} SIZE_DIR=${SIZE} @@ -91,6 +97,13 @@ for SIZE in 14x14 16x16 24x14 24x14 ; do cd $SIZE_DIR || exit 1 for ICON in $ICONS ; do + echo "Converting $ICON" + if [ -n "$SVGCLEANER" ] ; then + mv "$ICON.svg" "$ICON.dirty.svg" + $SVGCLEANER "$ICON.dirty.svg" "$ICON.svg" + rm "$ICON.dirty.svg" + fi + set_source_svgs "$ICON" if [ ! -f ${ONE_X_SVG} ] ; then @@ -105,15 +118,16 @@ for SIZE in 14x14 16x16 24x14 24x14 ; do # shellcheck disable=SC2086 inkscape $COMMON_ARGS $ONE_X_ARGS \ --file="$PWD/$ONE_X_SVG" --export-png="$PWD/$ONE_X_PNG" || exit 1 + QRC_FILES="${QRC_FILES} ${SIZE_DIR}/${ONE_X_PNG}" fi if [ $TWO_X_SVG -nt "$TWO_X_PNG" ] ; then # shellcheck disable=SC2086 inkscape $COMMON_ARGS $TWO_X_ARGS \ --file="$PWD/$TWO_X_SVG" --export-png="$PWD/$TWO_X_PNG" || exit 1 + QRC_FILES="${QRC_FILES} ${SIZE_DIR}/${TWO_X_PNG}" fi - QRC_FILES="${QRC_FILES} ${SIZE_DIR}/${ONE_X_PNG} ${SIZE_DIR}/${TWO_X_PNG}" done cd .. diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 9ff8d0965e..6a532dec09 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -877,6 +877,19 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event) { return QMainWindow::eventFilter(obj, event); } +bool MainWindow::event(QEvent *event) +{ + switch (event->type()) { + case QEvent::PaletteChange: + initMainToolbarIcons(); + break; + default: + break; + + } + return QMainWindow::event(event); +} + void MainWindow::keyPressEvent(QKeyEvent *event) { // Explicitly focus on the display filter combo. diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index 26559a645f..cba3ced572 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -133,6 +133,7 @@ public: protected: virtual bool eventFilter(QObject *obj, QEvent *event); + virtual bool event(QEvent *event); virtual void keyPressEvent(QKeyEvent *event); virtual void closeEvent(QCloseEvent *event); virtual void dragEnterEvent(QDragEnterEvent *event); diff --git a/ui/qt/utils/stock_icon.cpp b/ui/qt/utils/stock_icon.cpp index 014a625fbd..c623326943 100644 --- a/ui/qt/utils/stock_icon.cpp +++ b/ui/qt/utils/stock_icon.cpp @@ -29,7 +29,8 @@ // http://msdn.microsoft.com/en-us/library/ms246582.aspx // To do: -// - 32x32, 48x48, 64x64, and unscaled (.svg) icons +// - Respond to dark mode changes via QEvent::PaletteChange. +// - 32x32, 48x48, 64x64, and unscaled (.svg) icons. // - Indent find & go actions when those panes are open. // - Replace or remove: // WIRESHARK_STOCK_CAPTURE_FILTER x-capture-filter @@ -75,7 +76,39 @@ StockIcon::StockIcon(const QString icon_name) : // Is this one of our locally sourced, cage-free, organic icons? QStringList types = QStringList() << "14x14" << "16x16" << "24x14" << "24x24"; + QList<QPalette::ColorGroup> color_groups = QList<QPalette::ColorGroup>() + << QPalette::Disabled + << QPalette::Active + << QPalette::Inactive + << QPalette::Normal; foreach (QString type, types) { + // First, check for a template (mask) icon + // Templates should be monochrome as described at + // https://developer.apple.com/design/human-interface-guidelines/macos/icons-and-images/custom-icons/ + // Transparency is supported. + QString icon_path_template = path_pfx_ + QString("%1/%2.template.png").arg(type).arg(icon_name); + if (QFile::exists(icon_path_template)) { + QIcon mask_icon = QIcon(); + mask_icon.addFile(icon_path_template); + + foreach(QSize sz, mask_icon.availableSizes()) { + QPixmap mask_pm = mask_icon.pixmap(sz); + foreach (QPalette::ColorGroup cg, color_groups) { + QImage mode_img(sz, QImage::Format_ARGB32); + mode_img.setDevicePixelRatio(mask_pm.devicePixelRatioF()); + QPainter painter(&mode_img); + QBrush br(wsApp->palette().color(cg, QPalette::WindowText)); + painter.fillRect(0, 0, sz.width(), sz.height(), br); + painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); + painter.drawPixmap(0, 0, mask_pm); + addPixmap(QPixmap::fromImage(mode_img)); + } + } + + continue; + } + + // Regular full-color icons QString icon_path = path_pfx_ + QString("%1/%2.png").arg(type).arg(icon_name); if (QFile::exists(icon_path)) { addFile(icon_path); diff --git a/ui/qt/widgets/stock_icon_tool_button.cpp b/ui/qt/widgets/stock_icon_tool_button.cpp index 11a373a57e..3db550ce78 100644 --- a/ui/qt/widgets/stock_icon_tool_button.cpp +++ b/ui/qt/widgets/stock_icon_tool_button.cpp @@ -28,9 +28,7 @@ StockIconToolButton::StockIconToolButton(QWidget * parent, QString stock_icon_na QToolButton(parent), leave_timer_(0) { - if (!stock_icon_name.isEmpty()) { - setStockIcon(stock_icon_name); - } + setStockIcon(stock_icon_name); } void StockIconToolButton::setIconMode(QIcon::Mode mode) @@ -47,7 +45,13 @@ void StockIconToolButton::setIconMode(QIcon::Mode mode) void StockIconToolButton::setStockIcon(QString icon_name) { - base_icon_ = StockIcon(icon_name); + if (!icon_name.isEmpty()) { + icon_name_ = icon_name; + } + if (icon_name_.isEmpty()) { + return; + } + base_icon_ = StockIcon(icon_name_); setIconMode(); } @@ -91,6 +95,9 @@ bool StockIconToolButton::event(QEvent *event) } break; } + case QEvent::PaletteChange: + setStockIcon(); + break; default: break; } diff --git a/ui/qt/widgets/stock_icon_tool_button.h b/ui/qt/widgets/stock_icon_tool_button.h index 793e7fd2ea..7fc0e2f0b8 100644 --- a/ui/qt/widgets/stock_icon_tool_button.h +++ b/ui/qt/widgets/stock_icon_tool_button.h @@ -19,13 +19,14 @@ public: explicit StockIconToolButton(QWidget * parent = 0, QString stock_icon_name = QString()); void setIconMode(QIcon::Mode mode = QIcon::Normal); - void setStockIcon(QString icon_name); + void setStockIcon(QString icon_name = QString()); protected: virtual bool event(QEvent *event); private: QIcon base_icon_; + QString icon_name_; int leave_timer_; static const int leave_interval_ = 500; // ms }; |