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

List:       kde-commits
Subject:    playground/base/plasma/applets/train-clock
From:       Sebastian Kügler <sebas () kde ! nl>
Date:       2007-12-23 4:03:07
Message-ID: 1198382587.568359.18360.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 751874 by sebas:

* Add colon between minutes and hours
* Make vertical spacing variable
* 



 M  +31 -17    clock.cpp  
 M  +8 -8      train-clock.svg  


--- trunk/playground/base/plasma/applets/train-clock/clock.cpp #751873:751874
@@ -102,8 +102,8 @@
         return;
     }
 
-    setContentSize(QSize(120, 60));
-    setMinimumContentSize(QSizeF(80, 44));
+    setContentSize(QSize(150, 60));
+    setMinimumContentSize(QSizeF(100, 44));
     dataEngine("time")->connectSource(m_timezone, this, 6000, \
Plasma::AlignToMinute);  }
 
@@ -291,12 +291,17 @@
 {
     int offset = 0;
     const int margin = 4;
+    if (digitNumber == 0) {
+        //return margin;
+    }
 
     offset += (elWidth+m_horizontalSpacing) * digitNumber; // Add space taken by \
                digit
-    offset += (int)(( contentSize().width()-(elWidth*4 + \
m_horizontalSpacing*6-margin*2)) /2); // Align to center +    //offset += (int)(( \
contentSize().width()-(elWidth*4 + m_horizontalSpacing*6-margin*2)) /2); // Align to \
center +    offset += (int)(( contentSize().width()-(elWidth*4 + \
m_horizontalSpacing*4 + elWidth/1.7 - margin*2)) /2); // Align to center  
-    if (digitNumber >= 2) { // There's a gap between hours and minutes...
-        offset += m_horizontalSpacing*6;
+    if (digitNumber > 2) { // There's a smaller gap between hours and minutes ...
+        offset -= elWidth;
+        offset += (int)(elWidth/1.7);
     }
     return offset;
 }
@@ -332,6 +337,7 @@
         QString dateString;
 
         if (m_showDate || m_showTimezone) {
+            kDebug() << "Show Date or Timezone";
             QFontMetrics fm(p->font());
 
             int littlerHeight = qRound(timeRect.height() - (fm.height() + margin*2 + \
textMargin)); @@ -363,24 +369,24 @@
             }
 
             p->drawText(dateRect, dateString,
-                        QTextOption (Qt::AlignHCenter));
+                        QTextOption (Qt::AlignRight));
         }
 
         // Find the largest possible size fitting in the remaining space
         // Aspect ratio for the whole digiclock
 
         // Get the aspect ratio from the svg
-        m_theme->resize(timeRect.width(), timeRect.height());
+        //m_theme->resize(timeRect.width(), timeRect.height());
 
 
         // In the svg the elements are 141*41, so using this aspect ratio (not an \
                overly clean approach, but works ;-) )
-        int aspectRatio = 131/41;
+        //int aspectRatio = 131/41;
 
         int maxHeight = qMin((int)(contentSize().height()), timeRect.height());
-        int maxWidth = \
/*qMin((int)(*/contentSize().width()-(margin*2)/*),(int)(timeRect.width()-(margin*2)))*/;
 +        int maxWidth = (int)(contentSize().width()-(margin*2));
 
-        kDebug() << "mw1:" << contentSize().width()-(margin*2) << "mw2:" << \
                timeRect.width()-(margin*2);
-        kDebug() << "mh1:" << contentSize().height() << "mh2:" << timeRect.height();
+        //kDebug() << "mw1:" << contentSize().width()-(margin*2) << "mw2:" << \
timeRect.width()-(margin*2); +        //kDebug() << "mh1:" << contentSize().height() \
<< "mh2:" << timeRect.height();  
         if (maxHeight*3 > maxWidth) {
             maxHeight =(int)(maxWidth/3);
@@ -396,25 +402,28 @@
             timeRect.setWidth((int)(((timeRect.height()-m_verticalSpacing)/2) \
*1.4*4+(6*m_horizontalSpacing)));  } // small enough now.
 
-        kDebug() << "Contents rect is:" << contentsRect;
+        //kDebug() << "Contents rect is:" << contentsRect;
         // Conditionally paint panel Background
         if (formFactor() == Plasma::Horizontal) {
             m_theme->paint(p, contentsRect, "panel-bg");
         }
 
-//         m_theme->resize(timeRect.width(), timeRect.height());
+        m_theme->resize(timeRect.width(), timeRect.height());
 
-        int elHeight = qRound(( timeRect.height() - m_verticalSpacing - margin*2) / \
2.0); +        int elHeight = qRound(( timeRect.height() - m_verticalSpacing - \
                margin) / 2.0);
         int elWidth = qRound(elHeight*1.4); // Needs to be in line with the graphics
 
+        m_verticalSpacing = elHeight/11; // From the SVG,the horizontal space is \
1/11 of the height  m_horizontalSpacing = qMin(4, qRound(elWidth/10));
-        kDebug() << "elHeight::" << elHeight;
+        //kDebug() << "elHeight::" << elHeight;
 
         // enforce natural aspect ratio for elements
         QSize elSize = m_defaultElementSize;
         elSize.scale(elWidth, elHeight, Qt::KeepAspectRatio);
         elWidth = elSize.width();
         elHeight = elSize.height();
+        // colon is 42 wide, digits 72
+        int colonWidth = (int)(elWidth/1.7);
 
         // set left offset of clock elements so as to horizontally center the time \
display  int leftOffset = getOffsetForDigit(0, elWidth);
@@ -438,13 +447,18 @@
         m_theme->paint(p, QRectF(leftOffset, upperElementTop, elWidth, elHeight), \
                'e'+timeString[1]+"-p1");
         m_theme->paint(p, QRectF(leftOffset, bottomElementTop, elWidth, elHeight), \
'e'+timeString[1]+"-p2");  
+        // colon
+        leftOffset = getOffsetForDigit(2, elWidth);
+        m_theme->paint(p, QRectF(leftOffset, upperElementTop, colonWidth, elHeight), \
"colon-top"); +        m_theme->paint(p, QRectF(leftOffset, bottomElementTop, \
colonWidth, elHeight), "colon-bottom"); +
         // 10-minutes-digit
-        leftOffset = getOffsetForDigit(2, elWidth);
+        leftOffset = getOffsetForDigit(3, elWidth);
         m_theme->paint(p, QRectF(leftOffset, upperElementTop, elWidth, elHeight), \
                'e'+timeString[3]+"-p1");
         m_theme->paint(p, QRectF(leftOffset, bottomElementTop, elWidth, elHeight), \
'e'+timeString[3]+"-p2");  
         // 1-minute-digit
-        leftOffset = getOffsetForDigit(3, elWidth);
+        leftOffset = getOffsetForDigit(4, elWidth);
         m_theme->paint(p, QRectF(leftOffset, upperElementTop, elWidth, elHeight), \
                'e'+timeString[4]+"-p1");
         m_theme->paint(p, QRectF(leftOffset, bottomElementTop, elWidth, elHeight), \
'e'+timeString[4]+"-p2");  
--- trunk/playground/base/plasma/applets/train-clock/train-clock.svg #751873:751874
@@ -16,7 +16,7 @@
    sodipodi:version="0.32"
    inkscape:version="0.45.1"
    version="1.0"
-   sodipodi:docbase="/home/me/kde4/src/base/plasma/applets/train-clock"
+   sodipodi:docbase="/home/sebas/dev/KDE/playground-base/plasma/applets/train-clock"
    sodipodi:docname="train-clock.svg"
    inkscape:output_extension="org.inkscape.output.svg.inkscape"
    inkscape:export-filename="/home/pinheiro/Documents/pics/estilo/plasma/basetext2part.png"
 @@ -31,7 +31,7 @@
      inkscape:pageshadow="2"
      inkscape:zoom="2.8284271"
      inkscape:cx="176.76685"
-     inkscape:cy="103.40692"
+     inkscape:cy="168.60357"
      inkscape:current-layer="layer1"
      showgrid="true"
      inkscape:document-units="px"
@@ -40,8 +40,8 @@
      height="130px"
      inkscape:window-width="1219"
      inkscape:window-height="734"
-     inkscape:window-x="53"
-     inkscape:window-y="0"
+     inkscape:window-x="456"
+     inkscape:window-y="80"
      showguides="true"
      inkscape:guide-bbox="true"
      gridtolerance="7"
@@ -966,7 +966,7 @@
        d="M -290.74346,229.3805 C -290.74346,229.90272 -290.82209,230.3641 \
-290.97934,230.76466 C -291.1366,231.16226 -291.35172,231.49606 -291.62469,231.76606 \
C -291.89767,232.0331 -292.22108,232.23635 -292.59493,232.37581 C \
-292.96583,232.51229 -293.36639,232.58054 -293.79662,232.58054 L -296.14212,232.58054 \
L -296.14212,226.30954 L -294.06811,226.30954 C -293.58447,226.30955 \
-293.1394,226.37037 -292.73291,226.49202 C -292.32345,226.61071 -291.97185,226.79615 \
-291.6781,227.04835 C -291.38436,227.2976 -291.15589,227.61508 -290.99269,228.0008 C \
-290.82654,228.38652 -290.74346,228.84643 -290.74346,229.3805 M -291.59798,229.3805 C \
-291.59799,228.95621 -291.65882,228.59422 -291.78046,228.29454 C -291.90212,227.9919 \
-292.07273,227.74415 -292.29229,227.55128 C -292.51186,227.35842 -292.77445,227.21748 \
-293.08006,227.12846 C -293.38567,227.03649 -293.72096,226.9905 -294.08591,226.99049 \
L -295.29204,226.99049 L -295.29204,231.89958 L -293.89453,231.89958 C \
                -293.56518,231.89958 -293
 .26106,231.84618 -292.98214,231.73936 C -292.70027,231.63254 -292.45697,231.4738 \
-292.25223,231.26314 C -292.04751,231.05247 -291.88728,230.78988 -291.77156,230.47537 \
C -291.65585,230.16086 -291.59799,229.7959 -291.59798,229.3805 M -289.07445,230.34185 \
C -289.07446,230.59406 -289.04924,230.82697 -288.99879,231.0406 C \
-288.94539,231.25127 -288.86527,231.43375 -288.75846,231.58804 C -288.64868,231.73936 \
-288.50922,231.85804 -288.34009,231.94409 C -288.17097,232.02717 -287.96772,232.06871 \
-287.73035,232.06871 C -287.3832,232.06871 -287.10578,231.99898 -286.89808,231.85953 \
C -286.68741,231.72007 -286.54499,231.54353 -286.47081,231.3299 L \
-285.76761,231.53018 C -285.81805,231.6637 -285.88926,231.7987 -285.98124,231.93519 C \
-286.07026,232.06871 -286.19042,232.19036 -286.34174,232.30014 C -286.49307,232.40696 \
-286.68296,232.49597 -286.91143,232.56718 C -287.13693,232.63543 -287.40991,232.66955 \
-287.73035,232.66955 C -288.44246,232.66955 -288.98544,232.4574 -289.3593,232.0331 C \
                -289
 .73019,231.60881 -289.91563,230.9783 -289.91563,230.14157 C -289.91563,229.69057 \
-289.85926,229.3093 -289.74651,228.99775 C -289.63376,228.68324 -289.47947,228.42806 \
-289.28364,228.23223 C -289.08781,228.03641 -288.85934,227.89547 -288.59823,227.80942 \
C -288.33713,227.72041 -288.05822,227.6759 -287.76151,227.6759 C -287.35798,227.6759 \
-287.02121,227.74118 -286.7512,227.87173 C -286.47823,228.00228 -286.26015,228.18328 \
-286.09696,228.41471 C -285.9308,228.64318 -285.8136,228.91319 -285.74535,229.22473 C \
-285.67415,229.53628 -285.63854,229.87305 -285.63854,230.23503 L -285.63854,230.34185 \
L -289.07445,230.34185 M -286.46636,229.72766 C -286.51087,229.22028 \
-286.63994,228.85088 -286.85357,228.61944 C -287.06721,228.38504 -287.3743,228.26784 \
-287.77486,228.26784 C -287.90838,228.26784 -288.04932,228.29009 -288.19767,228.3346 \
C -288.34306,228.37614 -288.47807,228.4518 -288.60268,228.56158 C -288.7273,228.67137 \
-288.83264,228.82121 -288.91868,229.0111 C -289.00473,229.19803 -289.0  \
5369,229.43688 -289.06555,229.72766 L -286.46636,229.72766 M -284.00514,230.15047 C \
-284.00514,230.42641 -283.98586,230.6801 -283.94728,230.91153 C -283.90574,231.14297 \
-283.8375,231.34325 -283.74255,231.51237 C -283.6476,231.67853 -283.52299,231.8076 \
-283.36869,231.89958 C -283.21144,231.99156 -283.01858,232.03755 -282.79011,232.03755 \
C -282.50527,232.03755 -282.2679,231.96041 -282.078,231.80612 C -281.88514,231.65183 \
-281.76646,231.41446 -281.72195,231.09401 L -280.91192,231.14742 C \
-280.93863,231.34622 -280.99649,231.5376 -281.0855,231.72156 C -281.17452,231.90552 \
-281.29617,232.06723 -281.45046,232.20668 C -281.60178,232.34613 -281.78723,232.45888 \
-282.00679,232.54493 C -282.22636,232.62801 -282.48005,232.66955 -282.76785,232.66955 \
C -283.14468,232.66955 -283.46513,232.60576 -283.7292,232.47817 C \
-283.99327,232.35058 -284.20839,232.17553 -284.37455,231.95299 C -284.53774,231.72749 \
-284.65642,231.46342 -284.7306,231.16077 C -284.80478,230.85516 -284.84187,230.52433 \
-284.8  4187,230.16827 C -284.84187,229.84486 -284.81516,229.56002 \
-284.76175,229.31374 C -284.70835,229.06451 -284.63417,228.84791 -284.53922,228.66395 \
C -284.44131,228.47702 -284.32707,228.32125 -284.19652,228.19663 C \
-284.06597,228.06904 -283.92503,227.96816 -283.77371,227.89398 C -283.61942,227.81684 \
-283.45771,227.76195 -283.28858,227.72931 C -283.11946,227.6937 -282.94885,227.6759 \
-282.77676,227.6759 C -282.50675,227.6759 -282.26641,227.71299 -282.05575,227.78716 C \
-281.84508,227.86135 -281.66409,227.96371 -281.51276,228.09426 C -281.35848,228.22185 \
-281.23386,228.37317 -281.13891,228.54823 C -281.04396,228.72329 -280.9772,228.9117 \
-280.93863,229.11346 L -281.762,229.17577 C -281.80355,228.90874 -281.90888,228.69659 \
-282.078,228.53933 C -282.24713,228.38207 -282.48746,228.30345 -282.79901,228.30344 C \
-283.02748,228.30345 -283.21886,228.34202 -283.37314,228.41916 C -283.52447,228.49334 \
-283.6476,228.60757 -283.74255,228.76186 C -283.8375,228.91319 -283.90574,229.10457 \
-283.9472  8,229.336 C -283.98586,229.56744 -284.00514,229.83893 \
-284.00514,230.15047"  \
style="font-size:9.11497307px;font-style:normal;font-weight:normal;fill:#d7d7d7;fill-o \
pacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Liberation \
Sans" />  <g
-       id="g3207"
+       id="colon-top"
        style="stroke:none"
        transform="matrix(1,0,0,0.9907072,0,0.4744142)">
       <g
@@ -983,7 +983,7 @@
       </g>
       <path
          transform="translate(-484.66288,-12.38055)"
-         d="M -23.5,50.94873 A 4,4 0 1 1 -31.5,50.94873 A 4,4 0 1 1 -23.5,50.94873 \
z" +         d="M -23.5 50.94873 A 4 4 0 1 1  -31.5,50.94873 A 4 4 0 1 1  -23.5 \
50.94873 z"  sodipodi:ry="4"
          sodipodi:rx="4"
          sodipodi:cy="50.94873"
@@ -993,7 +993,7 @@
          sodipodi:type="arc" />
     </g>
     <g
-       id="g3212"
+       id="colon-bottom"
        transform="matrix(1,0,0,1.0311312,0,-2.13929)">
       <g
          transform="matrix(0.5775876,0,0,1,-239.9009,0)"
@@ -1014,7 +1014,7 @@
          sodipodi:cy="50.94873"
          sodipodi:rx="4"
          sodipodi:ry="4"
-         d="M -23.5,50.94873 A 4,4 0 1 1 -31.5,50.94873 A 4,4 0 1 1 -23.5,50.94873 \
z" +         d="M -23.5 50.94873 A 4 4 0 1 1  -31.5,50.94873 A 4 4 0 1 1  -23.5 \
50.94873 z"  transform="translate(-484.66288,8.99445)" />
     </g>
     <g


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

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