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

List:       kde-edu-devel
Subject:    D16839: Force black pen when painting unstyled TextLabel
From:       Mikhail Rudenko <noreply () phabricator ! kde ! org>
Date:       2018-11-24 23:09:00
Message-ID: a22a7447e8002caba8cf55b307540080 () localhost ! localdomain
[Download RAW message or body]

[Attachment #2 (text/plain)]

mikhailru added a comment.


  @asemke, thanks for your explanation! I've done some research, and it looks like at \
least 3 issues exist:  
  (1) The first case is when theme == "". This is what happens when no theme has been \
configured via the settings dialog and labplot2rc does not contain "Theme" key in \
[Settings_Worksheet] group, or when labplot2rc does not exist (first run). In this \
case, CartesianPlot does not apply theme to children, including axes labels:  
    //in CartesianPlot::childAdded
    if (!d->theme.isEmpty()) {
            const auto* elem = dynamic_cast<const WorksheetElement*>(child);
    	if (elem) {
    		KConfig config(ThemeHandler::themeFilePath(d->theme), KConfig::SimpleConfig);
    		const_cast<WorksheetElement*>(elem)->loadThemeConfig(config);
    	}
    } else {
    	//no theme is available, apply the default colors for curves only, s.a. \
XYCurve::loadThemeConfig()  
  This results in d->textWrapper.text in TextLabels containing plain text without any \
formatting. I've checked XMLs to verify:  
    <textLabel creation_time="2018-23-11 00:20:41:571" name="x axis 1">
    <comment></comment>
    <geometry x="-10.5833" y="605.444" horizontalPosition="3" verticalPosition="3" \
horizontalAlignment="1" verticalAlignment="1" rotationAngle="0" visible="1"/>  \
<text>x axis 1</text>  <format teXUsed="0" fontFamily="Computer Modern" fontSize="-1" \
fontPointSize="12" fontWeight="50" fontItalic="0" teXFontColor_r="0" \
teXFontColor_g="0" teXFontColor_b="0"/>  </textLabel>
  
  Compare this to the XML obtained with theme != "":
  
    <textLabel creation_time="2018-23-11 00:31:30:976" name="x axis 1">
    <comment />
        <geometry x="-10.5833" y="605.444" horizontalPosition="3" \
verticalPosition="3" horizontalAlignment="1" verticalAlignment="1" rotationAngle="0" \
visible="1" />  <text>
              &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" \
                "http://www.w3.org/TR/REC-html40/strict.dtd"&gt;
              &lt;html&gt;&lt;head&gt;&lt;meta name="qrichtext" content="1" \
/&gt;&lt;style type="text/css"&gt;  p, li { white-space: pre-wrap; }
              &lt;/style&gt;&lt;/head&gt;&lt;body style=" font-family:'Noto Sans'; \
font-size:10pt; font-weight:400; font-style:normal;"&gt;  &lt;p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px;"&gt;&lt;span style=" color:#ffffff; \
background-color:#000000;"&gt;x axis \
1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;  </text>
        <format teXUsed="0" fontFamily="Computer Modern" fontSize="-1" \
fontPointSize="12" fontWeight="50" fontItalic="0" teXFontColor_r="0" \
teXFontColor_g="0" teXFontColor_b="0" />  </textLabel>
  
  This text without formatting is painted with the default color, taken from the Qt \
theme. And this is the case which my original patch addressed.  
  (2) theme == "None". I suppose it's what you were talking about in "On the last \
screenshot...".  In this case theme != "", but ThemeHandler::themeFilePath cannot \
find theme file and returns "", so values hardcoded in KConfigGroup::readEntry calls \
are used. Unfortunately, both [Label]/FontColor (TextLabel.cpp:842) and \
[Worksheet]/BackgroundFirstColor (Worksheet.cpp:96) use Qt::white as default.  
  (3) LabelWidget doesn't look nice with some Qt theme/label colors combination.
  
  What can be done about this? I'm not deeply familiar with the codebase, but I have \
some ideas. If you find them worthwhile, I'll submit patches.  
  (1) I'm not sure whether using labels text without formatting is a supposed mode of \
operation. Maybe we should somehow fallback to "None" (hardcoded) theme instead of \
current behaviour?  
  (2) Swap background/foreground color defaults in TextLabel::loadThemeConfig. This \
one looks harmless.  
  (3) Concerning this one, I can't come up with a solution which doesn't hurt present \
functionality. I'll think a bit more. Btw, does [Label]/BackgroundColor affect plot \
appearance in any way?

REPOSITORY
  R262 LabPlot

REVISION DETAIL
  https://phabricator.kde.org/D16839

To: mikhailru, #labplot
Cc: asemke, cfeck, kde-edu, narvaez, apol


[Attachment #3 (text/html)]

<table><tr><td style="">mikhailru added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: \
right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: \
#F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: \
inline-block; border: 1px solid rgba(71,87,120,.2);" \
href="https://phabricator.kde.org/D16839">View Revision</a></tr></table><br \
/><div><div><p><a href="https://phabricator.kde.org/p/asemke/" style="  border-color: \
#f1f7ff;  color: #19558d;
              background-color: #f1f7ff;
                border: 1px solid transparent;
                border-radius: 3px;
                font-weight: bold;
                padding: 0 4px;">@asemke</a>, thanks for your explanation! I&#039;ve \
done some research, and it looks like at least 3 issues exist:</p>

<p>(1) The first case is when theme == &quot;&quot;. This is what happens when no \
theme has been configured via the settings dialog and labplot2rc does not contain \
&quot;Theme&quot; key in [Settings_Worksheet] group, or when labplot2rc does not \
exist (first run). In this case, CartesianPlot does not apply theme to children, \
including axes labels:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" \
data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px \
&quot;Menlo&quot;, &quot;Consolas&quot;, &quot;Monaco&quot;, monospace; padding: \
12px; margin: 0; background: rgba(71, 87, 120, 0.08);">//in CartesianPlot::childAdded \
                if (!d-&gt;theme.isEmpty()) {
        const auto* elem = dynamic_cast&lt;const WorksheetElement*&gt;(child);
	if (elem) {
		KConfig config(ThemeHandler::themeFilePath(d-&gt;theme), KConfig::SimpleConfig);
		const_cast&lt;WorksheetElement*&gt;(elem)-&gt;loadThemeConfig(config);
	}
} else {
	//no theme is available, apply the default colors for curves only, s.a. \
XYCurve::loadThemeConfig()</pre></div>

<p>This results in d-&gt;textWrapper.text in TextLabels containing plain text without \
any formatting. I&#039;ve checked XMLs to verify:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" \
data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px \
&quot;Menlo&quot;, &quot;Consolas&quot;, &quot;Monaco&quot;, monospace; padding: \
12px; margin: 0; background: rgba(71, 87, 120, 0.08);">&lt;textLabel \
creation_time=&quot;2018-23-11 00:20:41:571&quot; name=&quot;x axis 1&quot;&gt; \
&lt;comment&gt;&lt;/comment&gt; &lt;geometry x=&quot;-10.5833&quot; \
y=&quot;605.444&quot; horizontalPosition=&quot;3&quot; verticalPosition=&quot;3&quot; \
horizontalAlignment=&quot;1&quot; verticalAlignment=&quot;1&quot; \
rotationAngle=&quot;0&quot; visible=&quot;1&quot;/&gt; &lt;text&gt;x axis \
1&lt;/text&gt; &lt;format teXUsed=&quot;0&quot; fontFamily=&quot;Computer \
Modern&quot; fontSize=&quot;-1&quot; fontPointSize=&quot;12&quot; \
fontWeight=&quot;50&quot; fontItalic=&quot;0&quot; teXFontColor_r=&quot;0&quot; \
teXFontColor_g=&quot;0&quot; teXFontColor_b=&quot;0&quot;/&gt; \
&lt;/textLabel&gt;</pre></div>

<p>Compare this to the XML obtained with theme != &quot;&quot;:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" \
data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px \
&quot;Menlo&quot;, &quot;Consolas&quot;, &quot;Monaco&quot;, monospace; padding: \
12px; margin: 0; background: rgba(71, 87, 120, 0.08);">&lt;textLabel \
creation_time=&quot;2018-23-11 00:31:30:976&quot; name=&quot;x axis 1&quot;&gt; \
&lt;comment /&gt;  &lt;geometry x=&quot;-10.5833&quot; y=&quot;605.444&quot; \
horizontalPosition=&quot;3&quot; verticalPosition=&quot;3&quot; \
horizontalAlignment=&quot;1&quot; verticalAlignment=&quot;1&quot; \
rotationAngle=&quot;0&quot; visible=&quot;1&quot; /&gt;  &lt;text&gt;
          &amp;lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; \
&quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&amp;gt;  \
&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;meta name=&quot;qrichtext&quot; \
content=&quot;1&quot; /&amp;gt;&amp;lt;style type=&quot;text/css&quot;&amp;gt;  p, li \
{ white-space: pre-wrap; }  &amp;lt;/style&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body \
style=&quot; font-family:&#039;Noto Sans&#039;; font-size:10pt; font-weight:400; \
font-style:normal;&quot;&amp;gt;  &amp;lt;p style=&quot; margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px;&quot;&amp;gt;&amp;lt;span style=&quot; color:#ffffff; \
background-color:#000000;&quot;&amp;gt;x axis \
1&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;  \
&lt;/text&gt;  &lt;format teXUsed=&quot;0&quot; fontFamily=&quot;Computer \
Modern&quot; fontSize=&quot;-1&quot; fontPointSize=&quot;12&quot; \
fontWeight=&quot;50&quot; fontItalic=&quot;0&quot; teXFontColor_r=&quot;0&quot; \
teXFontColor_g=&quot;0&quot; teXFontColor_b=&quot;0&quot; /&gt; \
&lt;/textLabel&gt;</pre></div>

<p>This text without formatting is painted with the default color, taken from the Qt \
theme. And this is the case which my original patch addressed.</p>

<p>(2) theme == &quot;None&quot;. I suppose it&#039;s what you were talking about in \
&quot;On the last screenshot...&quot;.  In this case theme != &quot;&quot;, but \
ThemeHandler::themeFilePath cannot find theme file and returns &quot;&quot;, so \
values hardcoded in KConfigGroup::readEntry calls are used. Unfortunately, both \
[Label]/FontColor (TextLabel.cpp:842) and [Worksheet]/BackgroundFirstColor \
(Worksheet.cpp:96) use Qt::white as default.</p>

<p>(3) LabelWidget doesn&#039;t look nice with some Qt theme/label colors \
combination.</p>

<p>What can be done about this? I&#039;m not deeply familiar with the codebase, but I \
have some ideas. If you find them worthwhile, I&#039;ll submit patches.</p>

<p>(1) I&#039;m not sure whether using labels text without formatting is a supposed \
mode of operation. Maybe we should somehow fallback to &quot;None&quot; (hardcoded) \
theme instead of current behaviour?</p>

<p>(2) Swap background/foreground color defaults in TextLabel::loadThemeConfig. This \
one looks harmless.</p>

<p>(3) Concerning this one, I can&#039;t come up with a solution which doesn&#039;t \
hurt present functionality. I&#039;ll think a bit more. Btw, does \
[Label]/BackgroundColor affect plot appearance in any way?</p></div></div><br \
/><div><strong>REPOSITORY</strong><div><div>R262 LabPlot</div></div></div><br \
/><div><strong>REVISION DETAIL</strong><div><a \
href="https://phabricator.kde.org/D16839">https://phabricator.kde.org/D16839</a></div></div><br \
/><div><strong>To: </strong>mikhailru, LabPlot<br /><strong>Cc: </strong>asemke, \
cfeck, kde-edu, narvaez, apol<br /></div>



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

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