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

List:       kde-panel-devel
Subject:    Re: Review Request 115431: Fix the numbers cut off problem in digital clock applet
From:       "Yichao Zhou" <broken.zhou () gmail ! com>
Date:       2014-02-04 3:58:33
Message-ID: 20140204035833.4979.40949 () probe ! kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


> On Feb. 3, 2014, 9:32 a.m., Sebastian Kügler wrote:
> > plasma/generic/applets/digital-clock/clock.cpp, line 714
> > <https://git.reviewboard.kde.org/r/115431/diff/3/?file=241362#file241362line714>
> > 
> > This seems overly complex to me. In other such places, we happily use "M".
> > 
> > Do you still see the issue if you just use "M" here?
> 
> Yichao Zhou wrote:
> I'm not quite understood.  Do you mean that we should change everything to M?  For \
> example, "06:00 PM Saturday" to "MMMMMMMMMMMMMMMMM"?  I think that will be overly \
> wide. 
> Sebastian Kügler wrote:
> Well, the number of characters should be the timeformat's numer, but it makes sense \
> to use the same letter for all of them, because we don't want these metrics to \
> change when the time changes, this will make the clock jump whenever the time \
> changes, and possibly even the panel (since the clock's applet size depends on the \
> size of the rendered text). (An issue, I've just fixed not long ago in Plasma \
> Next.)

I think it is more reasonable to change from
"06:00 PM Saturday" to
"00:00 MM Mmmmmmmm", rather than
"MMMMMMMMMMMMMMMMM".

Because some fonts's "M"s are almost twice as wide as "0"s and ":"s.  Using only "M" \
will make the "fakeWidth" be twice as much as the "realWidth".  I think this will \
make it a little ugly.  So I choose to use the second string.

In order to let these metrics not to change when the time changes TOTALLY, I think \
this is very hard:  You need to first use a fakeString to calculate the width and the \
positions of each character and then manually draw each character on each precomputed \
position (because the font may not be a monospace font).  I think using "M" here \
cannot fix this issue (the result is same).


- Yichao


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/115431/#review48795
-----------------------------------------------------------


On Feb. 2, 2014, 12:31 p.m., Yichao Zhou wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/115431/
> -----------------------------------------------------------
> 
> (Updated Feb. 2, 2014, 12:31 p.m.)
> 
> 
> Review request for Plasma.
> 
> 
> Bugs: 228902
> http://bugs.kde.org/show_bug.cgi?id=228902
> 
> 
> Repository: kde-workspace
> 
> 
> Description
> -------
> 
> For bug, see
> https://bugs.launchpad.net/ubuntu/+source/kde-workspace/+bug/1052059 and
> https://bugs.kde.org/show_bug.cgi?id=228902
> 
> The problem is that in original code, it always uses 23:59 to calculate the width \
> of the text.  However, in some font, AM is wider than PM, and 0 is wider than 2 and \
> 5.  That causes some fonts been cropped. 
> 
> Diffs
> -----
> 
> plasma/generic/applets/digital-clock/clock.cpp f26e328 
> 
> Diff: https://git.reviewboard.kde.org/r/115431/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Yichao Zhou
> 
> 


[Attachment #5 (text/html)]

<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;">  <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://git.reviewboard.kde.org/r/115431/">https://git.reviewboard.kde.org/r/115431/</a>
  </td>
    </tr>
   </table>
   <br />










<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;">  <p style="margin-top: 0;">On February 3rd, 2014, 9:32 a.m. UTC, <b>Sebastian \
Kügler</b> wrote:</p>  <blockquote style="margin-left: 1em; border-left: 2px solid \
#d0d0d0; padding-left: 10px;">  



<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;">  <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;">  <a \
href="https://git.reviewboard.kde.org/r/115431/diff/3/?file=241362#file241362line714" \
style="color: black; font-weight: bold; text-decoration: \
underline;">plasma/generic/applets/digital-clock/clock.cpp</a>  <span \
style="font-weight: normal;">

     (Diff revision 3)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">void \
Clock::expandFontToMax(QFont &amp;font, const QString &amp;text)</pre></td>

  </tr>
 </tbody>



 
 

 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th>  <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>  <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">714</font></th>  <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span \
class="n">QString</span> <span class="n">myText</span> <span class="o">=</span> <span \
class="n">text</span><span class="p">;</span></pre></td>  </tr>

 </tbody>

</table>

  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This seems overly \
complex to me. In other such places, we happily use &quot;M&quot;.

Do you still see the issue if you just use &quot;M&quot; here?</pre>
 </blockquote>



 <p>On February 3rd, 2014, 11:34 a.m. UTC, <b>Yichao Zhou</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;">  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I&#39;m not quite \
understood.  Do you mean that we should change everything to M?  For example, \
&quot;06:00 PM Saturday&quot; to &quot;MMMMMMMMMMMMMMMMM&quot;?  I think that will be \
overly wide.</pre>  </blockquote>





 <p>On February 3rd, 2014, 11:47 a.m. UTC, <b>Sebastian Kügler</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;">  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Well, the number of \
characters should be the timeformat&#39;s numer, but it makes sense to use the same \
letter for all of them, because we don&#39;t want these metrics to change when the \
time changes, this will make the clock jump whenever the time changes, and possibly \
even the panel (since the clock&#39;s applet size depends on the size of the rendered \
text). (An issue, I&#39;ve just fixed not long ago in Plasma Next.)</pre>  \
</blockquote>







</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I think it \
is more reasonable to change from &quot;06:00 PM Saturday&quot; to
&quot;00:00 MM Mmmmmmmm&quot;, rather than
&quot;MMMMMMMMMMMMMMMMM&quot;.

Because some fonts&#39;s &quot;M&quot;s are almost twice as wide as &quot;0&quot;s \
and &quot;:&quot;s.  Using only &quot;M&quot; will make the &quot;fakeWidth&quot; be \
twice as much as the &quot;realWidth&quot;.  I think this will make it a little ugly. \
So I choose to use the second string.

In order to let these metrics not to change when the time changes TOTALLY, I think \
this is very hard:  You need to first use a fakeString to calculate the width and the \
positions of each character and then manually draw each character on each precomputed \
position (because the font may not be a monospace font).  I think using &quot;M&quot; \
here cannot fix this issue (the result is same).</pre> <br />




<p>- Yichao</p>


<br />
<p>On February 2nd, 2014, 12:31 p.m. UTC, Yichao Zhou wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('https://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;">  <tr>
  <td>

<div>Review request for Plasma.</div>
<div>By Yichao Zhou.</div>


<p style="color: grey;"><i>Updated Feb. 2, 2014, 12:31 p.m.</i></p>







<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="http://bugs.kde.org/show_bug.cgi?id=228902">228902</a>


</div>



<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kde-workspace
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" \
style="border: 1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">For bug, see \
https://bugs.launchpad.net/ubuntu/+source/kde-workspace/+bug/1052059 and \
https://bugs.kde.org/show_bug.cgi?id=228902

The problem is that in original code, it always uses 23:59 to calculate the width of \
the text.  However, in some font, AM is wider than PM, and 0 is wider than 2 and 5.  \
That causes some fonts been cropped.</pre>  </td>
 </tr>
</table>



<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>plasma/generic/applets/digital-clock/clock.cpp <span style="color: \
grey">(f26e328)</span></li>

</ul>

<p><a href="https://git.reviewboard.kde.org/r/115431/diff/" style="margin-left: \
3em;">View Diff</a></p>







  </td>
 </tr>
</table>








  </div>
 </body>
</html>



_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


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

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