MCPcopy Create free account
hub / github.com/KDE/labplot / loadThemeConfig

Method loadThemeConfig

src/backend/worksheet/TextLabel.cpp:1241–1279  ·  view source on GitHub ↗

############################################################################## ######################### Theme management ################################## ##############################################################################

Source from the content-addressed store, hash-verified

1239// ######################### Theme management ##################################
1240// ##############################################################################
1241void TextLabel::loadThemeConfig(const KConfig& config) {
1242 DEBUG(Q_FUNC_INFO << ", label = " << STDSTRING(name()))
1243 Q_D(TextLabel);
1244
1245 KConfigGroup group = config.group(QStringLiteral("Label"));
1246 // TODO: dark mode support?
1247 d->fontColor = group.readEntry(QStringLiteral("FontColor"), QColor(Qt::black)); // used when it's latex text
1248 d->backgroundColor = group.readEntry(QStringLiteral("BackgroundColor"), QColor(Qt::transparent)); // used when it's latex text
1249 if (d->textWrapper.mode == TextLabel::Mode::Text && !d->textWrapper.text.isEmpty()) {
1250 // To set the color in a html text, a QTextEdit must be used, QTextDocument is not enough
1251 QTextEdit te;
1252 te.setHtml(d->textWrapper.text);
1253 te.selectAll();
1254 te.setTextColor(d->fontColor);
1255 te.setTextBackgroundColor(d->backgroundColor); // for plain text no background color supported, due to bug https://bugreports.qt.io/browse/QTBUG-25420
1256
1257 TextWrapper wrapper(te.toHtml(), TextLabel::Mode::Text, true);
1258 te.setHtml(d->textWrapper.textPlaceholder);
1259 te.selectAll();
1260 te.setTextColor(d->fontColor);
1261 te.setTextBackgroundColor(d->backgroundColor); // for plain text no background color supported, due to bug https://bugreports.qt.io/browse/QTBUG-25420
1262 wrapper.textPlaceholder = te.toHtml();
1263 wrapper.allowPlaceholder = d->textWrapper.allowPlaceholder;
1264
1265 // update the text also in the widget to which it is connected
1266 setText(wrapper);
1267 } else if (d->textWrapper.mode == TextLabel::Mode::LaTeX) {
1268 // call updateText() to re-render the LaTeX-image with the new text colors
1269 d->updateText();
1270 }
1271
1272 // otherwise when changing theme while the textlabel dock is visible, the
1273 // color comboboxes do not change the color
1274 backgroundColorChanged(d->backgroundColor);
1275 fontColorChanged(d->fontColor);
1276
1277 group = config.group(QStringLiteral("CartesianPlot"));
1278 d->borderLine->loadThemeConfig(group);
1279}
1280
1281void TextLabel::saveThemeConfig(const KConfig& config) {
1282 KConfigGroup group = config.group(QStringLiteral("Label"));

Callers

nothing calls this directly

Calls 8

setHtmlMethod · 0.80
setTextColorMethod · 0.80
toHtmlMethod · 0.80
updateTextMethod · 0.80
QColorClass · 0.50
groupMethod · 0.45
isEmptyMethod · 0.45
selectAllMethod · 0.45

Tested by

no test coverage detected