| 207 | } |
| 208 | |
| 209 | void 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 | |
| 266 | void AnnotationActionHandlerPrivate::updateConfigActions(const QString &annotType) |
no test coverage detected