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

Method loadThemeConfig

src/backend/worksheet/plots/cartesian/Axis.cpp:3326–3406  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

3324// ######################### Theme management ##################################
3325// ##############################################################################
3326void Axis::loadThemeConfig(const KConfig& config) {
3327 Q_D(Axis);
3328 const KConfigGroup& group = config.group(QStringLiteral("Axis"));
3329
3330 // we don't want to show the major and minor grid lines for non-first horizontal/vertical axes
3331 // determine the index of the axis among other axes having the same orientation
3332 bool firstAxis = true;
3333 for (const auto* axis : parentAspect()->children<Axis>()) {
3334 if (orientation() == axis->orientation()) {
3335 if (axis == this) {
3336 break;
3337 } else {
3338 firstAxis = false;
3339 break;
3340 }
3341 }
3342 }
3343
3344 // Tick label
3345 this->setLabelsColor(group.readEntry(QStringLiteral("LabelsFontColor"), QColor(Qt::black)));
3346 this->setLabelsOpacity(group.readEntry(QStringLiteral("LabelsOpacity"), 1.0));
3347
3348 // use plot area color for the background color of the labels
3349 const KConfigGroup& groupPlot = config.group(QStringLiteral("CartesianPlot"));
3350 this->setLabelsBackgroundColor(groupPlot.readEntry(QStringLiteral("BackgroundFirstColor"), QColor(Qt::white)));
3351
3352 // Line
3353 d->line->setColor(group.readEntry(QStringLiteral("LineColor"), QColor(Qt::black)));
3354 d->line->setWidth(group.readEntry(QStringLiteral("LineWidth"), Worksheet::convertToSceneUnits(1.0, Worksheet::Unit::Point)));
3355 d->line->setOpacity(group.readEntry(QStringLiteral("LineOpacity"), 1.0));
3356
3357 const auto* plot = static_cast<const CartesianPlot*>(parentAspect());
3358 if (firstAxis && plot->theme() == QLatin1String("Tufte")) {
3359 setRangeType(RangeType::AutoData);
3360 d->line->setStyle(Qt::SolidLine);
3361 } else {
3362 // switch back to "Auto" range type when "AutoData" was selected (either because of Tufte or manually selected),
3363 // don't do anything if "Custom" is selected
3364 if (rangeType() == RangeType::AutoData)
3365 setRangeType(RangeType::Auto);
3366
3367 d->line->setStyle((Qt::PenStyle)group.readEntry(QStringLiteral("LineStyle"), (int)Qt::SolidLine));
3368 }
3369
3370 // Title
3371 if (plot->theme() == QLatin1String("Sparkline"))
3372 d->title->setText(QString());
3373
3374 // Major grid
3375 if (firstAxis)
3376 d->majorGridLine->setStyle((Qt::PenStyle)group.readEntry(QStringLiteral("MajorGridStyle"), (int)Qt::SolidLine));
3377 else
3378 d->majorGridLine->setStyle(Qt::NoPen);
3379
3380 d->majorGridLine->setColor(group.readEntry(QStringLiteral("MajorGridColor"), QColor(Qt::gray)));
3381 d->majorGridLine->setWidth(group.readEntry(QStringLiteral("MajorGridWidth"), 0.0));
3382 d->majorGridLine->setOpacity(group.readEntry(QStringLiteral("MajorGridOpacity"), 1.0));
3383

Callers

nothing calls this directly

Calls 15

setLabelsColorMethod · 0.95
setLabelsOpacityMethod · 0.95
setMajorTicksLengthMethod · 0.95
setMinorTicksLengthMethod · 0.95
QColorClass · 0.50
QStringClass · 0.50
groupMethod · 0.45
orientationMethod · 0.45
setColorMethod · 0.45

Tested by

no test coverage detected