FusionStyle: re-add icons for dockwidget titlebar

Re-add the icon for dockwidget titlebars as png images in different
resolutions to avoid a blurry icon on high-dpi displays. Also add the
source svg.

Task-number: QTBUG-118122
Task-number: QTBUG-118643
Change-Id: I24f710e3c7390762c7079c0e153f015475347591
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Christian Ehrlicher 2023-11-01 12:12:26 +01:00
parent 9e1210752f
commit acdef6669f
24 changed files with 328 additions and 0 deletions

View File

@ -327,6 +327,36 @@ qt_internal_add_resource(Widgets "qstyle1"
${qstyle1_resource_files}
)
set(qstyle_resource_fusion_files
"styles/images/fusion_closedock-10.png"
"styles/images/fusion_closedock-16.png"
"styles/images/fusion_closedock-20.png"
"styles/images/fusion_closedock-32.png"
"styles/images/fusion_closedock-48.png"
"styles/images/fusion_closedock-64.png"
"styles/images/fusion_normalizedockup_10.png"
"styles/images/fusion_normalizedockup-16.png"
"styles/images/fusion_normalizedockup_20.png"
"styles/images/fusion_normalizedockup-32.png"
"styles/images/fusion_normalizedockup_48.png"
"styles/images/fusion_normalizedockup_64.png"
"styles/images/fusion_titlebar-min-10.png"
"styles/images/fusion_titlebar-min-16.png"
"styles/images/fusion_titlebar-min-20.png"
"styles/images/fusion_titlebar-min-32.png"
"styles/images/fusion_titlebar-min-48.png"
"styles/images/fusion_titlebar-min-64.png"
)
qt_internal_add_resource(Widgets "qstyle_fusion"
PREFIX
"/qt-project.org/styles/fusionstyle"
BASE
"styles"
FILES
${qstyle_resource_fusion_files}
)
if(QT_FEATURE_reduce_relocations AND UNIX AND GCC)
target_link_options(Widgets PRIVATE
"LINKER:--dynamic-list=${CMAKE_CURRENT_LIST_DIR}/QtWidgets.dynlist")

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 869 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

View File

@ -0,0 +1,93 @@
<?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"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
width="8px"
height="8px"
viewBox="0 0 8 8"
style="enable-background:new 0 0 8 8;"
xml:space="preserve"
sodipodi:docname="fusion_closedock.svg"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
inkscape:export-filename="/home/chehrlic/kde/qt.src/qtbase/src/widgets/styles/images/fusion_closedock-64.png"
inkscape:export-xdpi="768"
inkscape:export-ydpi="768"><metadata
id="metadata120"><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><defs
id="defs118">
</defs><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="918"
id="namedview116"
showgrid="false"
inkscape:zoom="63.727999"
inkscape:cx="5.1718865"
inkscape:cy="4.7238684"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1"
inkscape:document-rotation="0" />
<style
type="text/css"
id="style101">
.st0{fill:none;}
.st1{fill:#353637;}
</style>
<g
id="g105">
<rect
class="st0"
width="8"
height="8"
id="rect103"
x="0"
y="0" />
</g>
<g
id="g981"><rect
x="5.1188383"
y="-2.9975181"
transform="rotate(45.000001)"
class="st1"
width="1.0760319"
height="5.9950356"
id="rect107"
style="stroke-width:0.768594;fill:#6c6a67;fill-opacity:1" /><rect
x="-0.53801638"
y="-8.6545134"
transform="rotate(135)"
class="st1"
width="1.0760319"
height="5.9950356"
id="rect109"
style="stroke-width:0.768594;fill:#6c6a67;fill-opacity:1" /><rect
style="fill:none;stroke:#6c6a67;stroke-width:0.469731;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect151"
width="6.5302691"
height="6.5302691"
x="0.73486549"
y="0.73486549" /></g></svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

View File

@ -0,0 +1,84 @@
<?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"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
width="8px"
height="8px"
viewBox="0 0 8 8"
style="enable-background:new 0 0 8 8;"
xml:space="preserve"
sodipodi:docname="fusion_normalizedockup.svg"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
inkscape:export-filename="/home/chehrlic/kde/qt.src/qtbase/src/widgets/styles/images/fusion_normalizedockup_64.png"
inkscape:export-xdpi="768"
inkscape:export-ydpi="768"><metadata
id="metadata120"><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><defs
id="defs118">
</defs><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="918"
id="namedview116"
showgrid="false"
inkscape:zoom="63.727999"
inkscape:cx="3.979318"
inkscape:cy="4.7238684"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1"
inkscape:document-rotation="0" />
<style
type="text/css"
id="style101">
.st0{fill:none;}
.st1{fill:#353637;}
</style>
<g
id="g105">
<rect
class="st0"
width="8"
height="8"
id="rect103"
x="0"
y="0" />
</g>
<rect
style="fill:none;stroke:#6c6a67;stroke-width:0.469731;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect151"
width="6.5302691"
height="6.5302691"
x="0.73486549"
y="0.73486549" /><g
id="g1123"
transform="matrix(0.85891433,0,0,0.86643038,0.5610817,0.55019701)"><path
id="rect151-3-6"
style="fill:none;stroke:#6c6a67;stroke-width:0.5;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.6347656,1.6347656 v 1 h 2.7304688 v 2.7304688 h 1 V 1.6347656 Z" /><path
style="fill:none;fill-opacity:1;stroke:#6c6a67;stroke-width:0.5;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 1.634209,2.6342089 H 5.3657907 V 6.3657906 H 1.634209 Z"
id="rect151-3" /></g></svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 749 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 887 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View File

@ -0,0 +1,75 @@
<?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"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
width="8px"
height="8px"
viewBox="0 0 8 8"
style="enable-background:new 0 0 8 8;"
xml:space="preserve"
sodipodi:docname="fusion_titlebar-min.svg"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
inkscape:export-filename="/home/chehrlic/kde/qt.src/qtbase/src/widgets/styles/images/fusion_titlebar-min-64.png"
inkscape:export-xdpi="768"
inkscape:export-ydpi="768"><metadata
id="metadata120"><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></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs118">
</defs><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="918"
id="namedview116"
showgrid="false"
inkscape:zoom="45.0625"
inkscape:cx="-0.80217757"
inkscape:cy="6.6858335"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1" />
<style
type="text/css"
id="style101">
.st0{fill:none;}
.st1{fill:#353637;}
</style>
<g
id="g105">
<rect
class="st0"
width="8"
height="8"
id="rect103"
x="0"
y="0" />
</g>
<rect
style="fill:#6c6a67;fill-opacity:1;stroke:none;stroke-width:0.529435;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1157"
width="5.5"
height="1.5"
x="1"
y="5.5" /></svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -3632,12 +3632,50 @@ QRect QFusionStyle::subElementRect(SubElement sr, const QStyleOption *opt, const
return r;
}
/*!
\reimp
*/
QIcon QFusionStyle::iconFromTheme(StandardPixmap standardIcon) const
{
QIcon icon;
#if QT_CONFIG(imageformat_png)
auto addIconFiles = [](QStringView prefix, QIcon &icon)
{
const auto fullPrefix = QStringLiteral(":/qt-project.org/styles/fusionstyle/images/") + prefix;
static constexpr auto dockTitleIconSizes = {10, 16, 20, 32, 48, 64};
for (int size : dockTitleIconSizes)
icon.addFile(fullPrefix + QString::number(size) + QStringLiteral(".png"),
QSize(size, size));
};
switch (standardIcon) {
case SP_TitleBarNormalButton:
addIconFiles(u"fusion_normalizedockup-", icon);
break;
case SP_TitleBarMinButton:
addIconFiles(u"fusion_titlebar-min-", icon);
break;
case SP_TitleBarCloseButton:
case SP_DockWidgetCloseButton:
addIconFiles(u"fusion_closedock-", icon);
break;
default:
break;
}
#else // imageformat_png
Q_UNUSED(standardIcon);
#endif // imageformat_png
return icon;
}
/*!
\reimp
*/
QIcon QFusionStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option,
const QWidget *widget) const
{
const auto icon = iconFromTheme(standardIcon);
if (!icon.availableSizes().isEmpty())
return icon;
return QCommonStyle::standardIcon(standardIcon, option, widget);
}
@ -3647,6 +3685,13 @@ QIcon QFusionStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption
QPixmap QFusionStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
const QWidget *widget) const
{
auto getDevicePixelRatio = [](const QWidget *widget)
{
return widget ? widget->devicePixelRatio() : qApp->devicePixelRatio();
};
const auto icon = iconFromTheme(standardPixmap);
if (!icon.availableSizes().isEmpty())
return icon.pixmap(QSize(16, 16), getDevicePixelRatio(widget));
return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
}

View File

@ -54,6 +54,7 @@ public:
int styleHint(StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr,
QStyleHintReturn *returnData = nullptr) const override;
QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const override;
QIcon iconFromTheme(StandardPixmap standardIcon) const;
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = nullptr,
const QWidget *widget = nullptr) const override;
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,