<table><tr><td style="">asemke 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><blockquote style="border-left: 3px solid #8C98B8;
          color: #6B748C;
          font-style: italic;
          margin: 4px 0 12px 0;
          padding: 8px 12px;
          background-color: #F8F9FC;">
<div style="font-style: normal;
          padding-bottom: 4px;">In <a href="https://phabricator.kde.org/D16839#365584" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">D16839#365584</a>, <a href="https://phabricator.kde.org/p/mikhailru/" style="
              border-color: #f1f7ff;
              color: #19558d;
              background-color: #f1f7ff;
                border: 1px solid transparent;
                border-radius: 3px;
                font-weight: bold;
                padding: 0 4px;">@mikhailru</a> wrote:</div>
<div style="margin: 0;
          padding: 0;
          border: 0;
          color: rgb(107, 116, 140);"><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've done some research, and it looks like at least 3 issues exist:</p>

<p>(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:</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 "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">//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()</pre></div>

<p>This results in d->textWrapper.text in TextLabels containing plain text without any formatting. I'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 "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);"><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></pre></div>

<p>Compare this to the XML obtained with theme != "":</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 "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);"><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></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></div>
</blockquote>

<p>Ok. This makes sense. But let's use maybe the color QApplication::palette().color(QPalette::Active,QPalette::Text ) ) instead of hard-coded Qt::black.</p>

<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>(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.</p></blockquote>

<p>Thanks for digging into this. I just debugged a bit, too. Having "None" here is a bug. We should save an empty string if "None" was selected. I'll fix this soon.</p>

<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>(3) LabelWidget doesn't look nice with some Qt theme/label colors combination.</p>

<p>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.</p>

<p>(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?</p></blockquote>

<p>Having text without formatting is perfectly fine. User simply types in some text without the need for additional formatting. Once this bug with "None" is fixed and we have empty string for the theme name, the theme settings with hard-coded default values won't be loaded anymore as you described above. Together with the default Qt theme color for the painter as you originally proposed we should be ok here.</p>

<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>(2) Swap background/foreground color defaults in TextLabel::loadThemeConfig. This one looks harmless.</p></blockquote>

<p>This shouldn't be needed anymore once we adressed the two points mentioned above.</p>

<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>(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?</p></blockquote>

<p>In principle it should be possible to change the background color for different parts of the text as shown on this screenshot:<br />
<a href="https://phabricator.kde.org/F6451811" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">F6451811: grafik.png</a><br />
But this is ignored at the moment and I think this is a bug in QStaticText that we've mentioned somewhere in the code. We need to check this. If this is really a problem with QStaticText, we should remove (or hide for a moment) the widgets for the background color in order to reduce the confusion.</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>