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

Method loadThemeConfig

src/backend/worksheet/plots/cartesian/XYCurve.cpp:3167–3209  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

3165// ######################### Theme management ##################################
3166// ##############################################################################
3167void XYCurve::loadThemeConfig(const KConfig& config) {
3168 KConfigGroup group = config.group(QStringLiteral("XYCurve"));
3169
3170 Q_D(XYCurve);
3171 const auto* plot = d->m_plot;
3172 const int index = plot->curveChildIndex(this);
3173 const QColor themeColor = plot->themeColorPalette(index);
3174
3175 d->suppressRecalc = true;
3176
3177 d->line->loadThemeConfig(group, themeColor);
3178 d->dropLine->loadThemeConfig(group, themeColor);
3179 d->symbol->loadThemeConfig(group, themeColor);
3180 d->background->loadThemeConfig(group);
3181 d->errorBar->loadThemeConfig(group, themeColor);
3182
3183 // line
3184 // Check if the plot's theme is "Sparkline"
3185 if (plot->theme() == QLatin1String("Sparkline")) {
3186 // Check if the plot's name is "add-sparkline"
3187 if (plot->name() == QLatin1String("add-sparkline"))
3188 // Set line color based on dark or light mode
3189 d->line->setColor(GuiTools::isDarkMode() ? Qt::white : Qt::black);
3190 else
3191 // Set line color based on background color lightness
3192 d->line->setColor(d->background->firstColor().lightness() > 125 ? Qt::black : Qt::white);
3193 }
3194 // Values
3195 this->setValuesOpacity(group.readEntry(QStringLiteral("ValuesOpacity"), 1.0));
3196 this->setValuesColor(group.readEntry(QStringLiteral("ValuesColor"), themeColor));
3197
3198 // margins, activate for XYCurve only, not for analysis curves
3199 if (type() == AspectType::XYCurve && plot->theme() == QLatin1String("Tufte")) {
3200 if (d->xColumn && d->xColumn->rowCount() < 100) {
3201 setRugEnabled(true);
3202 setRugOrientation(WorksheetElement::Orientation::Both);
3203 }
3204 } else
3205 setRugEnabled(false);
3206
3207 d->suppressRecalc = false;
3208 d->recalcShapeAndBoundingRect();
3209}
3210
3211void XYCurve::saveThemeConfig(const KConfig& config) {
3212 KConfigGroup group = config.group(QStringLiteral("XYCurve"));

Callers

nothing calls this directly

Calls 10

setValuesOpacityMethod · 0.95
setValuesColorMethod · 0.95
curveChildIndexMethod · 0.80
groupMethod · 0.45
themeColorPaletteMethod · 0.45
themeMethod · 0.45
nameMethod · 0.45
setColorMethod · 0.45
rowCountMethod · 0.45

Tested by

no test coverage detected