Update behavior of chat window close button

Use a stylesheet to suppress highlighting of the background when
pressing the button down.  Instead, it will change the image.

Unfortunately I wasn't able to find a way to do this without requiring
an extra image, or by doing it through the icon system.  The different
icon states didn't seem to take effect for button presses, and using
opacity in the stylesheet doesn't work yet for `QPushButton`s.
This commit is contained in:
Ryan Huffman 2014-04-10 12:19:27 -07:00
parent 37f9f47488
commit de475ee46c
3 changed files with 100 additions and 10 deletions

View file

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:sketch="http://www.bohemiancoding.com/sketch/ns"
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="44px"
height="44px"
viewBox="0 0 44 44"
version="1.1"
id="svg3085"
inkscape:version="0.48.2 r9819"
sodipodi:docname="close_hover.svg">
<metadata
id="metadata3099">
<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>Slice 1</dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="814"
inkscape:window-height="783"
id="namedview3097"
showgrid="false"
inkscape:zoom="10.727273"
inkscape:cx="14.784087"
inkscape:cy="19.379049"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="Page-1" />
<title
id="title3087">Slice 1</title>
<description
id="description3089">Created with Sketch (http://www.bohemiancoding.com/sketch)</description>
<defs
id="defs3091" />
<g
id="Page-1"
sketch:type="MSPage"
stroke-width="1"
stroke="none"
fill-rule="evenodd"
fill="none">
<g
id="close"
sketch:type="MSLayerGroup"
fill="#CCCCCC">
<path
d="M0.286382588,32.6200761 L32.6200759,0.286382745 C33.0019275,-0.0954590326 33.6210173,-0.0954590326 34.0028688,0.286382745 L43.380667,9.66418097 C43.7625088,10.0460227 43.7625088,10.6651125 43.380667,11.0469543 L43.380667,11.0469543 L11.0469639,43.3806574 C10.6651221,43.7624992 10.0460226,43.7624992 9.66418081,43.3806574 L0.286382588,34.0028592 C-0.0954591894,33.6210076 -0.0954591894,33.0019179 0.286382588,32.6200761 L0.286382588,32.6200761 L0.286382588,32.6200761 Z"
id="path16"
sketch:type="MSShapeGroup"
style="fill:#e6e6e6" />
<path
d="M32.6200759,43.3806574 L0.286382588,11.0469543 C-0.0954591894,10.6651125 -0.0954591894,10.0460227 0.286382588,9.66418097 L9.66418081,0.286382745 C10.0460226,-0.0954590326 10.6651221,-0.0954590326 11.0469639,0.286382745 L43.380667,32.6200761 C43.7625088,33.0019179 43.7625088,33.6210076 43.380667,34.0028592 L34.0028688,43.3806574 C33.6210173,43.7624992 33.0019275,43.7624992 32.6200759,43.3806574 L32.6200759,43.3806574 Z"
id="path18"
sketch:type="MSShapeGroup"
style="fill:#e6e6e6" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3 KiB

View file

@ -1,8 +1,9 @@
<RCC>
<qresource prefix="/">
<file>images/close.svg</file>
<file>images/kill-script.svg</file>
<file>images/reload.svg</file>
<file>images/stop.svg</file>
</qresource>
<qresource prefix="/">
<file>images/close_down.svg</file>
<file>images/close.svg</file>
<file>images/kill-script.svg</file>
<file>images/reload.svg</file>
<file>images/stop.svg</file>
</qresource>
</RCC>

View file

@ -96,13 +96,23 @@
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="styleSheet">
<string notr="true">QPushButton {
background-color: rgba( 0, 0, 0, 0% );
border: none;
image: url(:images/close.svg)
}
QPushButton:pressed {
background-color: rgba( 0, 0, 0, 0% );
border: none;
image: url(:images/close_down.svg)
}</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/resources.qrc">
<normaloff>:/images/close.svg</normaloff>:/images/close.svg</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>