| 111 | } |
| 112 | |
| 113 | void TextLabel::init() { |
| 114 | QString groupName; |
| 115 | switch (m_type) { |
| 116 | case Type::General: |
| 117 | groupName = QStringLiteral("TextLabel"); |
| 118 | break; |
| 119 | case Type::PlotTitle: |
| 120 | groupName = QStringLiteral("PlotTitle"); |
| 121 | break; |
| 122 | case Type::AxisTitle: |
| 123 | groupName = QStringLiteral("AxisTitle"); |
| 124 | break; |
| 125 | case Type::PlotLegendTitle: |
| 126 | groupName = QStringLiteral("PlotLegendTitle"); |
| 127 | break; |
| 128 | case Type::InfoElementLabel: |
| 129 | groupName = QStringLiteral("InfoElementLabel"); |
| 130 | } |
| 131 | |
| 132 | const KConfig config; |
| 133 | DEBUG(" config has group \"" << STDSTRING(groupName) << "\": " << config.hasGroup(groupName)); |
| 134 | // group is always valid if you call config.group(..; |
| 135 | KConfigGroup group; |
| 136 | if (config.hasGroup(groupName)) |
| 137 | group = config.group(groupName); |
| 138 | |
| 139 | Q_D(TextLabel); |
| 140 | d->position.point = QPointF(0, 0); |
| 141 | if (m_type == Type::PlotTitle || m_type == Type::PlotLegendTitle) { |
| 142 | d->position.verticalPosition = WorksheetElement::VerticalPosition::Top; |
| 143 | d->position.horizontalPosition = WorksheetElement::HorizontalPosition::Center; |
| 144 | d->verticalAlignment = WorksheetElement::VerticalAlignment::Top; |
| 145 | } else if (m_type == Type::AxisTitle) { |
| 146 | d->position.horizontalPosition = WorksheetElement::HorizontalPosition::Center; |
| 147 | d->position.verticalPosition = WorksheetElement::VerticalPosition::Center; |
| 148 | } |
| 149 | |
| 150 | auto conf = Settings::group(QStringLiteral("Settings_Worksheet")); |
| 151 | const auto& engine = conf.readEntry(QStringLiteral("LaTeXEngine"), ""); |
| 152 | if (engine == QLatin1String("lualatex")) |
| 153 | d->teXFont.setFamily(QStringLiteral("Latin Modern Roman")); |
| 154 | |
| 155 | // border line |
| 156 | d->borderLine = new Line(QStringLiteral("borderLine")); |
| 157 | d->borderLine->setPrefix(QStringLiteral("Border")); |
| 158 | d->borderLine->setCreateXmlElement(false); |
| 159 | d->borderLine->setHidden(true); |
| 160 | addChild(d->borderLine); |
| 161 | connect(d->borderLine, &Line::updatePixmapRequested, [=] { |
| 162 | d->update(); |
| 163 | }); |
| 164 | connect(d->borderLine, &Line::updateRequested, [=] { |
| 165 | d->recalcShapeAndBoundingRect(); |
| 166 | Q_EMIT changed(); |
| 167 | }); |
| 168 | |
| 169 | // read settings from config if group exists |
| 170 | if (group.isValid()) { |
nothing calls this directly
no test coverage detected