MCPcopy Create free account
hub / github.com/KDE/okular / parseTool

Method parseTool

part/annotationactionhandler.cpp:209–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209void AnnotationActionHandlerPrivate::parseTool(int toolId)
210{
211 if (toolId == -1) {
212 updateConfigActions();
213 return;
214 }
215
216 QDomElement toolElement = annotator->builtinTool(toolId);
217 const QString annotType = toolElement.attribute(QStringLiteral("type"));
218 QDomElement engineElement = toolElement.firstChildElement(QStringLiteral("engine"));
219 QDomElement annElement = engineElement.firstChildElement(QStringLiteral("annotation"));
220
221 QColor color, innerColor, textColor;
222 if (annElement.hasAttribute(QStringLiteral("color"))) {
223 color = QColor(annElement.attribute(QStringLiteral("color")));
224 }
225 if (annElement.hasAttribute(QStringLiteral("innerColor"))) {
226 innerColor = QColor(annElement.attribute(QStringLiteral("innerColor")));
227 }
228 if (annElement.hasAttribute(QStringLiteral("textColor"))) {
229 textColor = QColor(annElement.attribute(QStringLiteral("textColor")));
230 }
231 if (textColor.isValid()) {
232 currentColor = textColor;
233 currentInnerColor = color;
234 } else {
235 currentColor = color;
236 currentInnerColor = innerColor;
237 }
238
239 if (annElement.hasAttribute(QStringLiteral("font"))) {
240 currentFont.fromString(annElement.attribute(QStringLiteral("font")));
241 }
242
243 // if the width value is not a default one, insert a new action in the width list
244 if (annElement.hasAttribute(QStringLiteral("width"))) {
245 double width = annElement.attribute(QStringLiteral("width")).toDouble();
246 aCustomWidth = selectActionItem(aWidth, aCustomWidth, width, widthStandardValues, widthIcon(width), i18nc("@item:inlistbox", "Width %1", width));
247 }
248
249 // if the opacity value is not a default one, insert a new action in the opacity list
250 if (annElement.hasAttribute(QStringLiteral("opacity"))) {
251 double opacity = annElement.attribute(QStringLiteral("opacity")).toDouble();
252 aCustomOpacity = selectActionItem(aOpacity, aCustomOpacity, opacity, opacityStandardValues, GuiUtils::createOpacityIcon(opacity), i18nc("@item:inlistbox", "%1%", opacity * 100));
253 } else {
254 aOpacity->setCurrentItem(opacityStandardValues.size() - 1); // 100 %
255 }
256
257 // if the tool is a custom stamp, insert a new action in the stamp list
258 if (annotType == QStringLiteral("stamp")) {
259 QString stampIconName = annElement.attribute(QStringLiteral("icon"));
260 maybeUpdateCustomStampAction(stampIconName);
261 }
262
263 updateConfigActions(annotType);
264}
265
266void AnnotationActionHandlerPrivate::updateConfigActions(const QString &annotType)

Callers 1

Calls 7

createOpacityIconFunction · 0.85
builtinToolMethod · 0.80
toDoubleMethod · 0.80
setCurrentItemMethod · 0.80
QColorClass · 0.70
isValidMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected