Add margin hints to toolbar.svg and refactor PC3 ToolBar

There's no need to redefine contentWidth and contentHeight. For controls based on QQC2 Pane, content size is implicit size if not 0, else the implicit size of the top level child item if there is only one.
This commit is contained in:
Noah Davis 2020-10-16 02:31:09 -04:00 committed by Marco Martin
parent 13b0bb8364
commit b3ee36cfbb
2 changed files with 43 additions and 37 deletions

View File

@ -11,17 +11,20 @@ import org.kde.plasma.core 2.0 as PlasmaCore
T.ToolBar {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding)
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding)
contentWidth: contentChildren[0].implicitWidth
contentHeight: contentChildren[0].implicitHeight
leftPadding: background.leftMargin
topPadding: background.topMargin
rightPadding: background.rightMargin
bottomPadding: background.bottomMargin
padding: units.smallSpacing
contentItem: Item { }
background: PlasmaCore.FrameSvgItem {
implicitHeight: 40
implicitHeight: 40 // TODO: Find a good way to sync this with the size of (Button or ToolButton) + padding
imagePath: "widgets/toolbar"
colorGroup: PlasmaCore.ColorScope.colorGroup
enabledBorders: control.position == T.ToolBar.Header ? PlasmaCore.FrameSvgItem.BottomBorder : PlasmaCore.FrameSvgItem.TopBorder

View File

@ -1,23 +1,22 @@
<?xml version="1.0"?>
<!-- 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" id="svg2" sodipodi:version="0.32" inkscape:version="0.48.4 r9939" width="17" height="57" sodipodi:docname="toolbar.svgz" inkscape:output_extension="org.inkscape.output.svgz.inkscape" inkscape:export-filename="/home/pinheiro/Documents/pics/estilo/plasma/wether.png" inkscape:export-xdpi="90" inkscape:export-ydpi="90" version="1.0">
<sodipodi:namedview inkscape:window-height="830" inkscape:window-width="1408" inkscape:pageshadow="2" inkscape:pageopacity="1" guidetolerance="10.0" gridtolerance="10.0" objecttolerance="10.0" borderopacity="1.0" bordercolor="#666666" pagecolor="#b5b5b5" id="base" inkscape:zoom="13.153057" inkscape:cx="34.875467" inkscape:cy="61.853553" inkscape:window-x="264" inkscape:window-y="138" inkscape:current-layer="svg2" showgrid="true" showguides="true" inkscape:guide-bbox="true" inkscape:snap-guide="false" inkscape:snap-bbox="true" inkscape:object-paths="true" inkscape:bbox-nodes="false" inkscape:snap-global="true" inkscape:object-nodes="true" inkscape:window-maximized="0">
<inkscape:grid snapvisiblegridlinesonly="true" empspacing="5" enabled="true" visible="true" id="grid5592" type="xygrid"/>
</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"/>
</cc:Work>
<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="defs5">
<style id="current-color-scheme" type="text/css">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg id="svg2" sodipodi:version="0.32" inkscape:version="1.1-dev (fefa202dbf, 2020-10-11)" width="17" height="57" sodipodi:docname="toolbar.svg" inkscape:output_extension="org.inkscape.output.svgz.inkscape" inkscape:export-filename="/home/pinheiro/Documents/pics/estilo/plasma/wether.png" inkscape:export-xdpi="90" inkscape:export-ydpi="90" version="1.0" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
<sodipodi:namedview inkscape:window-height="830" inkscape:window-width="1408" inkscape:pageshadow="2" inkscape:pageopacity="1" guidetolerance="10.0" gridtolerance="10.0" objecttolerance="10.0" borderopacity="1.0" bordercolor="#666666" pagecolor="#b5b5b5" id="base" inkscape:zoom="13.153057" inkscape:cx="34.875467" inkscape:cy="61.853553" inkscape:window-x="264" inkscape:window-y="138" inkscape:current-layer="svg2" showgrid="true" showguides="true" inkscape:guide-bbox="true" inkscape:snap-guide="false" inkscape:snap-bbox="true" inkscape:object-paths="true" inkscape:bbox-nodes="false" inkscape:snap-global="true" inkscape:object-nodes="true" inkscape:window-maximized="0">
<inkscape:grid snapvisiblegridlinesonly="true" empspacing="5" enabled="true" visible="true" id="grid5592" type="xygrid" />
</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" />
</cc:Work>
<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="defs5">
<style id="current-color-scheme" type="text/css">
.ColorScheme-Text {
color:#31363b;
stop-color:#31363b;
@ -63,15 +62,19 @@
stop-color:#3daee9;
}
</style>
</defs>
<rect style="opacity:1;fill:#4e9a06;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" id="hint-tile-center" width="2.0329318" height="2.077126" x="-2.7400386" y="-1.3405813" rx="0" ry="2.077126"/>
<path inkscape:connector-curvature="0" id="center" d="m 2.9997,6.0000048 0,11.0000002 10.999999,0 0,-11.0000002 -10.999999,0 z" style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" class="ColorScheme-Background" inkscape:label="#normal-center-8"/>
<path inkscape:connector-curvature="0" id="right" d="m 13.9997,6.0000048 0,11.0000002 2,0 c 6.68e-4,-0.0183 0,-0.0344 0,-0.0529 l 0,-10.8942302 c 0,-0.0185 6.68e-4,-0.03453 0,-0.05288 l -2,0 z" style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" class="ColorScheme-Background" inkscape:label="#normal-right-4"/>
<path sodipodi:nodetypes="ccccsscc" inkscape:connector-curvature="0" id="top" d="m 2.9997,3.9999578 0,2.000047 10.999999,0 0,-2.000047 c -0.0041,-6.7e-4 0.0042,0 1e-6,0 l -10.98814,0 c -0.004,0 -0.008,-6.7e-4 -0.0119,0 z" style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" inkscape:label="#plain-top" class="ColorScheme-Background"/>
<path inkscape:connector-curvature="0" id="left" d="m 1,6.0000048 c -6.7e-4,0.01835 0,0.03439 0,0.05288 L 1,16.947115 c 0,0.0185 -6.7e-4,0.0345 0,0.0529 l 2,0 0,-11.0000002 -2,0 z" style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" class="ColorScheme-Background" inkscape:label="#normal-left-0"/>
<path sodipodi:nodetypes="ccccc" inkscape:connector-curvature="0" id="bottom" d="m 2.9997,16.999665 0,2 11,0 0,-1.99966 z" style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" inkscape:label="#plain-bottom" class="ColorScheme-Background"/>
<path style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" d="m 0.999667,3.9999578 0,2.000047 1.999771,0 0,-2.000047 c -7.46e-4,-6.7e-4 7.63e-4,0 0,0 l -1.997614,0 c -7.28e-4,0 -0.0015,-6.7e-4 -0.0022,0 z" id="topleft" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccsscc" inkscape:label="#path3112" class="ColorScheme-Background"/>
<path style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" d="m 13.999707,4.0003028 0,1.999702 1.999771,0 0,-1.999702 c -7.46e-4,-6.7e-4 7.63e-4,0 0,0 l -1.997614,0 c -7.28e-4,0 -0.0015,-6.7e-4 -0.0022,0 z" id="topright" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccsscc" inkscape:label="#path3118" class="ColorScheme-Background"/>
<path sodipodi:nodetypes="ccccsscc" inkscape:connector-curvature="0" id="bottomright" d="m 13.999707,16.999955 0,1.99971 1.999771,0 0,-1.99971 c -7.46e-4,-6.7e-4 7.63e-4,0 0,0 l -1.997614,0 c -7.28e-4,0 -0.0015,-6.7e-4 -0.0022,0 z" style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" inkscape:label="#path3130" class="ColorScheme-Background"/>
<path style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" d="m 0.999707,16.999955 0,1.99971 1.999771,0 0,-1.99971 c -7.46e-4,-6.7e-4 7.63e-4,0 0,0 l -1.997614,0 c -7.28e-4,0 -0.0015,-6.7e-4 -0.0022,0 z" id="bottomleft" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccsscc" inkscape:label="#path3136" class="ColorScheme-Background"/>
</defs>
<rect style="opacity:1;fill:#4e9a06;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" id="hint-tile-center" width="2.0329318" height="2.077126" x="-2.7400386" y="-1.3405813" rx="0" ry="2.077126" />
<path inkscape:connector-curvature="0" id="center" d="m 2.9997,6.0000048 0,11.0000002 10.999999,0 0,-11.0000002 -10.999999,0 z" style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" class="ColorScheme-Background" inkscape:label="#normal-center-8" />
<path inkscape:connector-curvature="0" id="right" d="m 13.9997,6.0000048 0,11.0000002 2,0 c 6.68e-4,-0.0183 0,-0.0344 0,-0.0529 l 0,-10.8942302 c 0,-0.0185 6.68e-4,-0.03453 0,-0.05288 l -2,0 z" style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" class="ColorScheme-Background" inkscape:label="#normal-right-4" />
<path sodipodi:nodetypes="ccccsscc" inkscape:connector-curvature="0" id="top" d="m 2.9997,3.9999578 0,2.000047 10.999999,0 0,-2.000047 c -0.0041,-6.7e-4 0.0042,0 1e-6,0 l -10.98814,0 c -0.004,0 -0.008,-6.7e-4 -0.0119,0 z" style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" inkscape:label="#plain-top" class="ColorScheme-Background" />
<path inkscape:connector-curvature="0" id="left" d="m 1,6.0000048 c -6.7e-4,0.01835 0,0.03439 0,0.05288 L 1,16.947115 c 0,0.0185 -6.7e-4,0.0345 0,0.0529 l 2,0 0,-11.0000002 -2,0 z" style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" class="ColorScheme-Background" inkscape:label="#normal-left-0" />
<path sodipodi:nodetypes="ccccc" inkscape:connector-curvature="0" id="bottom" d="m 2.9997,16.999665 0,2 11,0 0,-1.99966 z" style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" inkscape:label="#plain-bottom" class="ColorScheme-Background" />
<path style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" d="m 0.999667,3.9999578 0,2.000047 1.999771,0 0,-2.000047 c -7.46e-4,-6.7e-4 7.63e-4,0 0,0 l -1.997614,0 c -7.28e-4,0 -0.0015,-6.7e-4 -0.0022,0 z" id="topleft" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccsscc" inkscape:label="#path3112" class="ColorScheme-Background" />
<path style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" d="m 13.999707,4.0003028 0,1.999702 1.999771,0 0,-1.999702 c -7.46e-4,-6.7e-4 7.63e-4,0 0,0 l -1.997614,0 c -7.28e-4,0 -0.0015,-6.7e-4 -0.0022,0 z" id="topright" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccsscc" inkscape:label="#path3118" class="ColorScheme-Background" />
<path sodipodi:nodetypes="ccccsscc" inkscape:connector-curvature="0" id="bottomright" d="m 13.999707,16.999955 0,1.99971 1.999771,0 0,-1.99971 c -7.46e-4,-6.7e-4 7.63e-4,0 0,0 l -1.997614,0 c -7.28e-4,0 -0.0015,-6.7e-4 -0.0022,0 z" style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" inkscape:label="#path3130" class="ColorScheme-Background" />
<path style="opacity:1;fill:currentColor;fill-opacity:1;fill-rule:nonzero;stroke:none" d="m 0.999707,16.999955 0,1.99971 1.999771,0 0,-1.99971 c -7.46e-4,-6.7e-4 7.63e-4,0 0,0 l -1.997614,0 c -7.28e-4,0 -0.0015,-6.7e-4 -0.0022,0 z" id="bottomleft" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccsscc" inkscape:label="#path3136" class="ColorScheme-Background" />
<rect style="fill:#0000ff;fill-rule:evenodd" id="hint-top-margin" width="1" height="2" x="7.5" y="4" />
<rect style="fill:#0000ff;fill-rule:evenodd" id="hint-left-margin" width="2" height="1" x="1" y="10" />
<rect style="fill:#0000ff;fill-rule:evenodd" id="hint-bottom-margin" width="1" height="2" x="7.5" y="17" />
<rect style="fill:#0000ff;fill-rule:evenodd" id="hint-right-margin" width="2" height="1" x="14" y="10" />
</svg>

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB