[prev in list] [next in list] [prev in thread] [next in thread] 

List:       amarok-devel
Subject:    [UI] [Patch] Volume "dial"...
From:       Thomas =?iso-8859-1?q?L=FCbking?= <thomas.luebking () web ! de>
Date:       2010-08-09 0:26:03
Message-ID: 201008090226.03741.thomas.luebking () web ! de
[Download RAW message or body]

I've rethought a couple of things (even after the other thread)

Of course there (imo) good reasons for such approach, but i'll explain them 
later - first you should try out (best w/o reading the code - i promise, it 
contains very few trojans ;-) and check for usability.

a) "do i get it"
b) "can i handle it"

Otherwise it's visually a "bit rough on the corners", ie. could need two more 
icons to finegrain/stress state representation and maybe some nice animations 
=)
also i don't like the invocation of un/mute strings (since they can be 
horribly long as verbs in some langs) ... and the tooltip on value changes 
(using the dial!) sometimes works and sometimes not .. due to the wonders of 
tooltip land =\

ok: that's enough info for the moment.

Cheers
Thomas

ps: patch size defers from default_theme_clean.svg update, sorry :(

["volume_usability.diff" (text/x-patch)]

diff --git a/src/images/default-theme-clean.svg b/src/images/default-theme-clean.svg
index 6bad334..80ada8d 100644
--- a/src/images/default-theme-clean.svg
+++ b/src/images/default-theme-clean.svg
@@ -30,18 +30,20 @@
      objecttolerance="10"
      inkscape:pageopacity="0.0"
      inkscape:pageshadow="2"
-     inkscape:zoom="1.4142136"
-     inkscape:cx="2035.649"
-     inkscape:cy="223.19126"
+     inkscape:zoom="0.7071068"
+     inkscape:cx="2335.6462"
+     inkscape:cy="215.32329"
      inkscape:document-units="px"
-     inkscape:current-layer="PLAYpause"
+     inkscape:current-layer="AutoSlide"
      showgrid="true"
      inkscape:window-width="1204"
      inkscape:window-height="922"
-     inkscape:window-x="180"
-     inkscape:window-y="154"
+     inkscape:window-x="69"
+     inkscape:window-y="63"
      inkscape:window-maximized="0"
-     inkscape:snap-global="true">
+     inkscape:snap-global="true"
+     showguides="true"
+     inkscape:guide-bbox="true">
     <inkscape:grid
        type="xygrid"
        id="grid11130"
@@ -6148,6 +6150,370 @@
        fx="-49.43668"
        fy="182.12218"
        r="77.579712" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3199"
+       id="linearGradient6396"
+       gradientUnits="userSpaceOnUse"
+       x1="-51.71981"
+       y1="118.87298"
+       x2="-51.71981"
+       y2="277.07474" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3358"
+       id="linearGradient6398"
+       gradientUnits="userSpaceOnUse"
+       x1="-88.878075"
+       y1="277.73642"
+       x2="-88.878075"
+       y2="117.91134" />
+    <radialGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3209"
+       id="radialGradient6400"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(1,1.0196079,-0.9635052,0.9823971,173.19254,69.463585)"
 +       cx="-49.43668"
+       cy="182.12218"
+       fx="-49.43668"
+       fy="182.12218"
+       r="77.579712" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3358"
+       id="linearGradient6402"
+       gradientUnits="userSpaceOnUse"
+       x1="-61.127529"
+       y1="278.12927"
+       x2="-61.127529"
+       y2="117.4472" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6404"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0,-3.4516455,2.6740186,0,1593.9619,979.07216)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6406"
+       gradientUnits="userSpaceOnUse"
+       x1="1633.0101"
+       y1="937.82581"
+       x2="1633.0101"
+       y2="1012.8258" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3199"
+       id="linearGradient6422"
+       gradientUnits="userSpaceOnUse"
+       x1="-51.71981"
+       y1="118.87298"
+       x2="-51.71981"
+       y2="277.07474" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3358"
+       id="linearGradient6424"
+       gradientUnits="userSpaceOnUse"
+       x1="-88.878075"
+       y1="277.73642"
+       x2="-88.878075"
+       y2="117.91134" />
+    <radialGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3209"
+       id="radialGradient6426"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(1,1.0196079,-0.9635052,0.9823971,173.19254,69.463585)"
 +       cx="-49.43668"
+       cy="182.12218"
+       fx="-49.43668"
+       fy="182.12218"
+       r="77.579712" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3358"
+       id="linearGradient6428"
+       gradientUnits="userSpaceOnUse"
+       x1="-61.127529"
+       y1="278.12927"
+       x2="-61.127529"
+       y2="117.4472" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6430"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0,-3.4516455,2.6740186,0,1430.4619,982.29137)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6432"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0,-3.4516455,2.6740186,0,1430.4619,982.29137)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6434"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0,-3.4516455,2.6740186,0,1430.4619,982.29137)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6436"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0,-3.4516455,2.6740186,0,1430.4619,982.29137)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6443"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(3.4516455,0,0,2.6740186,1462.3405,960.92001)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6445"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(3.4516455,0,0,2.6740186,1462.3405,960.92001)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6447"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(3.4516455,0,0,2.6740186,1462.3405,960.92001)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6487"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(3.4516455,0,0,2.6740186,1462.3405,960.92001)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6489"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(3.4516455,0,0,2.6740186,1462.3405,960.92001)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6491"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(3.4516455,0,0,2.6740186,1462.3405,960.92001)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6494"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0,-3.4516455,2.6740186,0,1432.8852,1004.2914)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6497"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0,-3.4516455,2.6740186,0,1432.8852,1004.2914)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6500"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0,-3.4516455,2.6740186,0,1432.8852,1004.2914)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6502"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(3.4516455,0,0,2.6740186,1462.3405,960.92001)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6504"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(3.4516455,0,0,2.6740186,1462.3405,960.92001)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6506"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(3.4516455,0,0,2.6740186,1462.3405,960.92001)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6509"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0,-3.4516455,2.6740186,0,1432.8852,958.2914)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6512"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0,-3.4516455,2.6740186,0,1432.8852,958.2914)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient6515"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0,-3.4516455,2.6740186,0,1432.8852,958.2914)"
+       x1="11.66507"
+       y1="10.737893"
+       x2="-8.9148693"
+       y2="10.737893" />
+    <inkscape:perspective
+       id="perspective6533"
+       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+       inkscape:vp_z="1 : 0.5 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="0 : 0.5 : 1"
+       sodipodi:type="inkscape:persp3d" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient7344"
+       x1="1093.1143"
+       y1="462.74231"
+       x2="1173.0101"
+       y2="462.74231"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient7346"
+       x1="1093.1351"
+       y1="462.74231"
+       x2="1173.031"
+       y2="462.74231"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient7348"
+       x1="1093.1143"
+       y1="462.74231"
+       x2="1173.0101"
+       y2="462.74231"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient7350"
+       x1="1093.1351"
+       y1="462.74231"
+       x2="1173.031"
+       y2="462.74231"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient7352"
+       gradientUnits="userSpaceOnUse"
+       x1="1137.2234"
+       y1="527.10291"
+       x2="1137.2234"
+       y2="399.10287" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient7354"
+       gradientUnits="userSpaceOnUse"
+       x1="1125.6223"
+       y1="530.01074"
+       x2="1125.6223"
+       y2="398.56216" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient7356"
+       gradientUnits="userSpaceOnUse"
+       x1="1128.366"
+       y1="396.59918"
+       x2="1128.366"
+       y2="530.08887" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3223"
+       id="linearGradient7358"
+       gradientUnits="userSpaceOnUse"
+       x1="1123.0961"
+       y1="403.64401"
+       x2="1123.0961"
+       y2="526.47443" />
   </defs>
   <metadata
      id="metadata6835">
@@ -11416,7 +11782,7 @@
       <path
          id="path4206"
          d="M 1442.0045,955.7389 C 1436.5538,956.00105 1414.087,973.54764 \
1414.1314,977.99569 C 1414.1788,982.74027 1440.1277,1001.4991 1443.2872,999.07376 C \
1446.4468,996.64849 1446.0435,958.26622 1442.8365,955.94691 C 1442.6361,955.80195 \
                1442.3679,955.72143 1442.0045,955.73891 L 1442.0045,955.7389 z"
-         style="fill:url(#linearGradient4222);fill-opacity:1;stroke:#000000;stroke-width:1;stroke-opacity:0.62745098" \
/> +         style="fill:url(#linearGradient4222);fill-opacity:1;stroke:#000000;stroke \
-width:1;stroke-opacity:0.62745097999999999;stroke-miterlimit:4;stroke-dasharray:none" \
/>  <path
          id="path4208"
          d="M 1449.2848,963.71251 L 1449.2848,967.97666 C 1454.607,967.96577 \
1458.9463,972.22285 1458.9572,977.545 C 1458.9681,982.86718 1454.711,987.20646 \
1449.3888,987.21735 C 1449.3739,987.21738 1449.2997,987.21739 1449.2848,987.21735 L \
1449.2848,991.3775 C 1449.3061,991.37754 1449.3675,991.37754 1449.3888,991.37749 C \
1457.012,991.3619 1463.2023,985.1681 1463.1867,977.545 C 1463.1711,969.92191 \
1456.908,963.69692 1449.2848,963.71252 L 1449.2848,963.71251 z" @@ -11915,5 +12281,65 \
@@  <title
          id="title4557">progress_slider_played_left</title>
     </path>
+    <g
+       id="AutoSlide"
+       transform="translate(3.72532,-99.645394)">
+      <path
+         sodipodi:type="arc"
+         style="fill:url(#linearGradient6422);fill-opacity:1;stroke:url(#linearGradient6424);stroke-width:1.23364747"
 +         id="path6410"
+         sodipodi:cx="-51.71981"
+         sodipodi:cy="197.97386"
+         sodipodi:rx="77.579712"
+         sodipodi:ry="79.100883"
+         d="m 25.859901,197.97386 c 0,43.68621 -34.7336197,79.10089 \
-77.579711,79.10089 -42.846092,0 -77.57971,-35.41468 -77.57971,-79.10089 0,-43.68621 \
34.733618,-79.10088 77.57971,-79.10088 42.8460913,0 77.579711,35.41467 \
77.579711,79.10088 z" +         \
transform="matrix(0.8185128,0,0,0.8027723,1491.8435,818.61708)" /> +      <path
+         transform="matrix(0.6638333,0,0,0.6510673,1483.8435,848.65071)"
+         d="m 25.859901,197.97386 a 77.579712,79.100883 0 1 1 -155.159421,0 \
77.579712,79.100883 0 1 1 155.159421,0 z" +         sodipodi:ry="79.100883"
+         sodipodi:rx="77.579712"
+         sodipodi:cy="197.97386"
+         sodipodi:cx="-51.71981"
+         id="path6412"
+         style="opacity:0.86000001;fill:url(#radialGradient6426);fill-opacity:1;stroke:url(#linearGradient6428);stroke-width:1.52109921"
 +         sodipodi:type="arc" />
+      <g
+         transform="matrix(0,0.1877443,-0.3671875,0,1619.4234,797.32219)"
+         style="fill:url(#linearGradient7350);fill-opacity:1;stroke:#000000;stroke-wi \
dth:3.80866408;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:0.62745098;stroke-dasharray:none"
 +         id="g6517">
+        <path
+           id="path6519"
+           d="m 1093.1351,398.74231 c 8.878,21.33303 17.7539,42.66697 26.632,64 \
-8.8781,21.33303 -17.754,42.66697 -26.632,64 26.6329,-21.33206 53.2629,-42.66794 \
79.8959,-64 -26.633,-21.33206 -53.263,-42.66794 -79.8959,-64 z" +           \
style="fill:url(#linearGradient7356);fill-opacity:1;stroke:#000000;stroke-width:3.8086 \
6408;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:0.62745098;stroke-dasharray:none" \
/> +      </g>
+      <g
+         id="g6521"
+         style="fill:url(#linearGradient7344);fill-opacity:1;stroke:#000000;stroke-wi \
dth:2.51910543;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:0.62745098;stroke-dasharray:none"
 +         transform="matrix(0,-0.2849938,-0.55293225,0,1705.3753,1263.7039)">
+        <path
+           style="fill:url(#linearGradient7352);fill-opacity:1;stroke:#000000;stroke- \
width:3.14888167;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:0.62745098;stroke-dasharray:none"
 +           d="m 1093.1143,398.74231 c 8.878,21.33303 17.7538,42.66697 26.6319,64 \
-8.8781,21.33303 -17.7539,42.66697 -26.6319,64 26.6328,-21.33206 53.2629,-42.66794 \
79.8958,-64 -26.6329,-21.33206 -53.263,-42.66794 -79.8958,-64 z" +           \
id="path6523" /> +      </g>
+      <g
+         transform="matrix(0,-0.18774454,-0.3671875,0,1619.4234,1167.3237)"
+         style="fill:url(#linearGradient7348);fill-opacity:1;stroke:#000000;stroke-wi \
dth:3.8086617;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:0.62745098;stroke-dasharray:none"
 +         id="g6556">
+        <path
+           id="path6558"
+           d="m 1093.1143,398.74231 c 8.878,21.33303 17.7538,42.66697 26.6319,64 \
-8.8781,21.33303 -17.7539,42.66697 -26.6319,64 26.6328,-21.33206 53.2629,-42.66794 \
79.8958,-64 -26.6329,-21.33206 -53.263,-42.66794 -79.8958,-64 z" +           \
style="fill:url(#linearGradient7354);fill-opacity:1;stroke:#000000;stroke-width:3.8086 \
617;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:0.62745098;stroke-dasharray:none" \
/> +      </g>
+      <g
+         id="g6560"
+         style="fill:url(#linearGradient7346);fill-opacity:1;stroke:#000000;stroke-wi \
dth:6.42157269;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:0.62745098;stroke-dasharray:none"
 +         transform="matrix(0,0.10013029,-0.2421875,0,1561.5806,908.01527)">
+        <path
+           style="fill:url(#linearGradient7358);fill-opacity:1;stroke:#000000;stroke- \
width:6.42157269;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:0.62745098;stroke-dasharray:none"
 +           d="m 1093.1351,398.74231 c 8.878,21.33303 17.7539,42.66697 26.632,64 \
-8.8781,21.33303 -17.754,42.66697 -26.632,64 26.6329,-21.33206 53.2629,-42.66794 \
79.8959,-64 -26.633,-21.33206 -53.263,-42.66794 -79.8959,-64 z" +           \
id="path6562" /> +      </g>
+    </g>
   </g>
 </svg>
diff --git a/src/widgets/VolumeDial.cpp b/src/widgets/VolumeDial.cpp
index 4447921..4507d88 100644
--- a/src/widgets/VolumeDial.cpp
+++ b/src/widgets/VolumeDial.cpp
@@ -38,6 +38,8 @@ VolumeDial::VolumeDial( QWidget *parent ) : QDial( parent )
 {
     m_anim.step = 0;
     m_anim.timer = 0;
+    m_autoSlide.timer = 0;
+    m_softUp.timer = 0;
     setMouseTracking( true );
 
     connect ( this, SIGNAL( valueChanged(int) ), SLOT( valueChangedSlot(int) ) );
@@ -110,14 +112,81 @@ static bool onRing( const QRect &r, const QPoint &p )
     return sqrt(dx*dx + dy*dy) > r.width()/4;
 }
 
+static int clamp( int v, int min, int max )
+{
+    if (v > max) return max;
+    if (v < min) return min;
+    return v;
+}
+
 void VolumeDial::mouseMoveEvent( QMouseEvent *me )
 {
     if ( me->buttons() == Qt::NoButton )
         setCursor( onRing( rect(), me->pos() ) ? Qt::PointingHandCursor : \
                Qt::ArrowCursor );
-    else if ( m_isClick )
+    else if ( m_isClick || m_autoSlide.timer )
+    {
         me->accept();
+        if ( !m_autoSlide.timer )
+        {
+            QPoint dragDist = me->pos() - m_autoSlide.startPos;
+            dragDist.rx() = qAbs( dragDist.x() );
+            dragDist.ry() = qAbs( dragDist.y() );
+
+            if ( dragDist.x() > 7 && dragDist.x() > 3*dragDist.y()/2 )
+            {
+                m_autoSlide.direction = Qt::Horizontal;
+                m_autoSlide.timer = startTimer( 80 );
+            }
+            else if ( dragDist.y() > 7 && dragDist.y() > 3*dragDist.x()/2 )
+            {
+                m_autoSlide.direction = Qt::Vertical;
+                m_autoSlide.timer = startTimer( 80 );
+            }
+            if ( m_autoSlide.timer )
+                update(); // changed - redisplay the dial
+        }
+        if ( m_autoSlide.timer )
+        {
+            int exc;
+            if ( m_autoSlide.direction == Qt::Horizontal )
+            {
+                const int max = 2*width()/3;
+                exc = clamp( me->pos().x() - width()/2, -max, max );
+                m_autoSlide.delta = 2*exc*exc/width(); // e^2/(w/2)
+            }
+            else
+            {
+                const int max = 2*height()/3;
+                exc = clamp( me->pos().y() - height()/2, -max, max );
+                m_autoSlide.delta = -2*exc*exc/height(); // e^2/(h/2)
+            }
+            if ( !m_autoSlide.delta )
+            {
+                if ( m_autoSlide.direction == Qt::Horizontal )
+                    setValue( value() + me->pos().x() - m_autoSlide.lastPos.x() );
+                else
+                    setValue( value() - me->pos().y() + m_autoSlide.lastPos.y() );
+            }
+            else if ( exc < 0 )
+                m_autoSlide.delta = -m_autoSlide.delta; // ^2 kills sign...
+        }
+    }
+    else if ( m_softUp.timer )
+    {
+        QPoint d = m_softUp.startPos - me->pos();
+        if ( d.manhattanLength() > 6 )
+        {   // directly jump to the position and stop fading in due to user request
+            killTimer( m_softUp.timer );
+            m_softUp.timer = m_softUp.delta = 0;
+            m_formerValue = m_softUp.target;
+            blockSignals( false );
+            setValue( m_softUp.target );
+            blockSignals( true );
+        }
+    }
     else
-        QDial::mouseMoveEvent( me );
+        QDial::mouseMoveEvent( me ); // still support radial movement
+    m_autoSlide.lastPos = me->pos();
 }
 
 void VolumeDial::mousePressEvent( QMouseEvent *me )
@@ -128,20 +197,39 @@ void VolumeDial::mousePressEvent( QMouseEvent *me )
         return;
     }
 
+    // check whether the outer dial was hit for radial usage
     m_isClick = !onRing( rect(), me->pos() );
 
+    // for value changes caused by mouseevent we'll only let our adjusted value \
changes be emitted +    // see ::sliderChange()
+    m_formerValue = value();
+    blockSignals( true );
+
     if ( m_isClick )
+    {
+        if ( m_autoSlide.timer ) // should not happen, but ensure to prevent \
multiple infinite timers on lousy event dispatchers .. not naming any OS here ;-P +   \
{ +            killTimer( m_autoSlide.timer );
+            m_autoSlide.timer = 0;
+        }
+        m_autoSlide.startPos = m_autoSlide.lastPos = me->pos();
+        m_autoSlide.delta = 0;
         update(); // hide the ring
+    }
     else
     {
         setCursor( Qt::PointingHandCursor ); // hint dragging
-        QDial::mousePressEvent( me ); // this will directly jump to the proper \
position +        setSliderDown( true );
+        m_softUp.startPos = me->pos();
+        m_softUp.delta = 1;
+        if ( m_softUp.timer )
+        {
+            killTimer( m_softUp.timer );
+            m_softUp.timer = 0;
+        }
+        m_autoSlide.direction = (Qt::Orientation)-1;
+        QDial::mouseMoveEvent( me ); // this will cause or guarded sliderChange()
     }
-
-    // for value changes caused by mouseevent we'll only let our adjusted value \
                changes be emitted
-    // see ::sliderChange()
-    m_formerValue = value();
-    blockSignals( true );
 }
 
 void VolumeDial::mouseReleaseEvent( QMouseEvent *me )
@@ -153,7 +241,19 @@ void VolumeDial::mouseReleaseEvent( QMouseEvent *me )
     setCursor( Qt::ArrowCursor );
     setSliderDown( false );
 
-    if ( m_isClick )
+    m_softUp.delta = 0; // cleanup
+    if ( m_softUp.timer )
+    {
+        killTimer( m_softUp.timer );
+        m_softUp.timer = 0;
+    }
+    else if ( m_autoSlide.timer ) // ELSE cleanup
+    {
+        killTimer( m_autoSlide.timer );
+        m_autoSlide.timer = 0;
+        m_autoSlide.delta = 0;
+    }
+    else if ( m_isClick ) // ELSE!
     {
         m_isClick = !onRing( rect(), me->pos() );
         if ( m_isClick )
@@ -161,20 +261,44 @@ void VolumeDial::mouseReleaseEvent( QMouseEvent *me )
     }
 
     m_isClick = false;
+    update(); // show other icon again
 }
 
 void VolumeDial::paintEvent( QPaintEvent * )
 {
     QPainter p( this );
-    int icon = m_muted ? 0 : 3;
-    if ( icon && value() < 66 )
-        icon = value() < 33 ? 1 : 2;
+    int icon;
+    if ( m_autoSlide.timer || m_isClick )
+        icon = 4;
+    else
+    {
+        icon = m_muted ? 0 : 3;
+        if ( icon && value() < 66 )
+            icon = value() < 33 ? 1 : 2;
+    }
     p.drawPixmap( 0,0, m_icon[ icon ] );
-    if ( !m_isClick )
+    if ( m_autoSlide.timer || !m_isClick )
     {
         p.setPen( QPen( m_sliderGradient, 3, Qt::SolidLine, Qt::RoundCap ) );
         p.setRenderHint( QPainter::Antialiasing );
         p.drawArc( rect().adjusted(4,4,-4,-4), -110*16, - value()*320*16 / \
(maximum() - minimum()) ); +        if ( m_autoSlide.timer )
+        {
+            p.setPen( Qt::black ); // NOT GOOD - this should be more flexible... \
(but the def. icons are white inside) +            p.setFont( font() );
+            p.drawText( rect().adjusted( 0, QFontMetrics(font()).xHeight()/2, 0, 0 \
), Qt::AlignCenter, QString("%1%").arg(value()) ); +        }
+    }
+    else if ( m_isClick )
+    {
+        p.setPen( Qt::black ); // NOT GOOD - this should be more flexible... (but \
the def. icons are white inside) +        QString text = m_muted ? i18n( "Unmute" ) : \
i18n( "Mute" ); +        QFont fnt;
+        fnt.setBold(true);
+        if ( fnt.pointSize() != -1 ) // asian fonts are all crap :-(
+            fnt.setPointSize( 2*fnt.pointSize()*width() / ( \
3*QFontMetrics(fnt).boundingRect( text ).width() ) ); +        p.setFont( fnt );
+        p.drawText( rect().adjusted( 0, QFontMetrics(fnt).xHeight()/2, 0, 0 ), \
Qt::AlignCenter, text );  }
     p.end();
 }
@@ -193,6 +317,12 @@ void VolumeDial::resizeEvent( QResizeEvent *re )
 
     if( re->size() != re->oldSize() )
     {
+        QFont fnt;
+        fnt.setBold(true);
+        if ( fnt.pointSize() != -1 ) // asian fonts are all crap :-(
+            fnt.setPointSize( 2*fnt.pointSize()*width() / ( \
3*QFontMetrics(fnt).boundingRect( "333%" ).width() ) ); +        setFont( fnt );
+        
         renderIcons();
         m_sliderGradient = QPixmap( size() );
         updateSliderGradient();
@@ -206,9 +336,10 @@ void VolumeDial::renderIcons()
     m_icon[1] = The::svgHandler()->renderSvg( "Volume_low", width(), height(), \
                "Volume_low", true );
     m_icon[2] = The::svgHandler()->renderSvg( "Volume_mid", width(), height(), \
                "Volume_mid", true );
     m_icon[3] = The::svgHandler()->renderSvg( "Volume",     width(), height(), \
                "Volume",     true );
-    if( layoutDirection() == Qt::RightToLeft )
+    m_icon[4] = The::svgHandler()->renderSvg( "AutoSlide",  width(), height(), \
"AutoSlide",  true ); +    if ( layoutDirection() == Qt::RightToLeft )
     {
-        for ( int i = 0; i < 4; ++i )
+        for ( int i = 0; i < 5; ++i )
             m_icon[i] = QPixmap::fromImage( m_icon[i].toImage().mirrored( true, \
false ) );  }
 }
@@ -232,22 +363,49 @@ void VolumeDial::stopFade()
 
 void VolumeDial::timerEvent( QTimerEvent *te )
 {
-    if ( te->timerId() != m_anim.timer )
+    if ( te->timerId() == m_autoSlide.timer )
+    {
+        int nv = clamp( value() + m_autoSlide.delta, minimum(), maximum() );
+        if ( nv != value() )
+            setValue( nv );
         return;
-    if ( underMouse() ) // fade in
+    }
+
+    if ( te->timerId() == m_softUp.timer )
     {
-        m_anim.step += 2;
-        if ( m_anim.step > 5 )
-            stopFade();
+        int nv = clamp( value() + m_softUp.delta, minimum(), m_softUp.target );
+        if ( nv != value() )
+        {
+            blockSignals( false );
+            setValue( nv );
+            blockSignals( true );
+            m_softUp.delta *= 1.6;
+        }
+        else // done
+        {
+            killTimer( m_softUp.timer );
+            m_softUp.timer = m_softUp.delta = 0;
+        }
+        return;
     }
-    else // fade out
+
+    if ( te->timerId() == m_anim.timer )
     {
-        --m_anim.step;
-        if ( m_anim.step < 1 )
-            stopFade();
+        if ( underMouse() ) // fade in
+        {
+            m_anim.step += 2;
+            if ( m_anim.step > 5 )
+                stopFade();
+        }
+        else // fade out
+        {
+            --m_anim.step;
+            if ( m_anim.step < 1 )
+                stopFade();
+        }
+        updateSliderGradient();
+        repaint();
     }
-    updateSliderGradient();
-    repaint();
 }
 
 void VolumeDial::updateSliderGradient()
@@ -312,9 +470,37 @@ QSize VolumeDial::sizeHint() const
 
 void VolumeDial::sliderChange( SliderChange change )
 {
+    if ( m_autoSlide.timer )
+    {
+        blockSignals( false );
+        emit sliderMoved( value() );
+        emit valueChanged( value() );
+        blockSignals( true );
+        return;
+    }
+
     if ( change == SliderValueChange && isSliderDown() && signalsBlocked() )
     {
         int d = value() - m_formerValue;
+        
+        if ( m_softUp.delta && !m_softUp.timer )
+        {
+            if ( d > 10 )
+            {
+                m_softUp.target = value();
+                setValue( m_formerValue );
+                m_softUp.timer = startTimer( 50 );
+            }
+            else
+            {
+                blockSignals( false );
+                emit sliderMoved( value() );
+                emit valueChanged( value() );
+                blockSignals( true );
+                QDial::sliderChange(change);
+            }
+            return;  // this is an initial volUp attempt - no real action at all
+        }
         if ( d && d < 33 && d > -33 ) // don't allow real "jumps" > 1/3
         {
             if ( d > 5 ) // ease movement
@@ -329,6 +515,8 @@ void VolumeDial::sliderChange( SliderChange change )
         }
         if ( d )
             setValue( m_formerValue );
+        const QPoint tooltipPosition = mapToGlobal( rect().translated( 7, -22 \
).bottomLeft() ); +        QToolTip::showText( tooltipPosition, toolTip() );
     }
     QDial::sliderChange(change);
 }
diff --git a/src/widgets/VolumeDial.h b/src/widgets/VolumeDial.h
index f706cf2..2b4473a 100644
--- a/src/widgets/VolumeDial.h
+++ b/src/widgets/VolumeDial.h
@@ -70,7 +70,7 @@ private slots:
     void valueChangedSlot( int );
 
 private:
-    QPixmap m_icon[4];
+    QPixmap m_icon[5];
     QPixmap m_sliderGradient;
     int m_formerValue;
     QList<QWidget*> m_wheelProxies;
@@ -79,6 +79,17 @@ private:
         int step;
         int timer;
     } m_anim;
+    struct
+    {
+        Qt::Orientation direction;
+        QPoint startPos, lastPos;
+        int timer, delta;
+    } m_autoSlide;
+    struct
+    {
+        QPoint startPos;
+        int timer, delta, target;
+    } m_softUp;
     bool m_isClick, m_isDown, m_muted;
     QColor m_highlightColor;
 };



_______________________________________________
Amarok-devel mailing list
Amarok-devel@kde.org
https://mail.kde.org/mailman/listinfo/amarok-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic