D16839: Force black pen when painting unstyled TextLabel

Mikhail Rudenko noreply at phabricator.kde.org
Sat Nov 24 23:09:00 GMT 2018


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>
              <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
              <html><head><meta name="qrichtext" content="1" /><style type="text/css">
              p, li { white-space: pre-wrap; }
              </style></head><body style=" font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;">
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#ffffff; background-color:#000000;">x axis 1</span></p></body></html>
        </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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-edu/attachments/20181124/13bf24a5/attachment-0001.html>


More information about the kde-edu mailing list