|
|
|
|
@ -663,10 +663,10 @@ public: |
|
|
|
|
return tools; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QDomElement tool(int toolID) |
|
|
|
|
QDomElement tool(int toolId) |
|
|
|
|
{ |
|
|
|
|
QDomElement toolElement = m_toolsDefinition.documentElement().firstChildElement(); |
|
|
|
|
while (!toolElement.isNull() && toolElement.attribute(QStringLiteral("id")).toInt() != toolID) { |
|
|
|
|
while (!toolElement.isNull() && toolElement.attribute(QStringLiteral("id")).toInt() != toolId) { |
|
|
|
|
toolElement = toolElement.nextSiblingElement(); |
|
|
|
|
} |
|
|
|
|
return toolElement; // can return a null element
|
|
|
|
|
@ -679,20 +679,20 @@ public: |
|
|
|
|
m_toolsDefinition.documentElement().appendChild(toolElement); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool updateTool(QDomElement newToolElement, int toolID) |
|
|
|
|
bool updateTool(QDomElement newToolElement, int toolId) |
|
|
|
|
{ |
|
|
|
|
QDomElement toolElement = tool(toolID); |
|
|
|
|
QDomElement toolElement = tool(toolId); |
|
|
|
|
if (toolElement.isNull()) |
|
|
|
|
return false; |
|
|
|
|
newToolElement = newToolElement.cloneNode().toElement(); |
|
|
|
|
newToolElement.setAttribute(QStringLiteral("id"), toolID); |
|
|
|
|
newToolElement.setAttribute(QStringLiteral("id"), toolId); |
|
|
|
|
QDomNode oldTool = m_toolsDefinition.documentElement().replaceChild(newToolElement, toolElement); |
|
|
|
|
return !oldTool.isNull(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int findToolId(const QString &type) |
|
|
|
|
{ |
|
|
|
|
int toolID = -1; |
|
|
|
|
int toolId = -1; |
|
|
|
|
if (type.isEmpty()) { |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
@ -704,12 +704,12 @@ public: |
|
|
|
|
} |
|
|
|
|
if (!toolElement.isNull() && toolElement.hasAttribute(QStringLiteral("id"))) { |
|
|
|
|
bool ok; |
|
|
|
|
toolID = toolElement.attribute(QStringLiteral("id")).toInt(&ok); |
|
|
|
|
toolId = toolElement.attribute(QStringLiteral("id")).toInt(&ok); |
|
|
|
|
if (!ok) { |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return toolID; |
|
|
|
|
return toolId; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
@ -730,7 +730,7 @@ PageViewAnnotator::PageViewAnnotator(PageView *parent, Okular::Document *storage |
|
|
|
|
, m_quickToolsDefinition(nullptr) |
|
|
|
|
, m_continuousMode(true) |
|
|
|
|
, m_constrainRatioAndAngle(false) |
|
|
|
|
, m_lastToolID(-1) |
|
|
|
|
, m_lastToolId(-1) |
|
|
|
|
, m_lockedItem(nullptr) |
|
|
|
|
{ |
|
|
|
|
reparseConfig(); |
|
|
|
|
@ -848,7 +848,7 @@ QRect PageViewAnnotator::performRouteMouseOrTabletEvent(const AnnotatorEngine::E |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (m_continuousMode) |
|
|
|
|
selectTool(m_lastToolID); |
|
|
|
|
selectTool(m_lastToolId); |
|
|
|
|
else |
|
|
|
|
detachAnnotation(); |
|
|
|
|
} |
|
|
|
|
@ -935,10 +935,10 @@ void PageViewAnnotator::routePaint(QPainter *painter, const QRect paintRect) |
|
|
|
|
painter->restore(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PageViewAnnotator::selectTool(int toolID) |
|
|
|
|
void PageViewAnnotator::selectTool(int toolId) |
|
|
|
|
{ |
|
|
|
|
// ask for Author's name if not already set
|
|
|
|
|
if (toolID > 0 && Okular::Settings::identityAuthor().isEmpty()) { |
|
|
|
|
if (toolId > 0 && Okular::Settings::identityAuthor().isEmpty()) { |
|
|
|
|
// get default username from the kdelibs/kdecore/KUser
|
|
|
|
|
KUser currentUser; |
|
|
|
|
QString userName = currentUser.property(KUser::FullName).toString(); |
|
|
|
|
@ -969,17 +969,17 @@ void PageViewAnnotator::selectTool(int toolID) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// store current tool for later usage
|
|
|
|
|
m_lastToolID = toolID; |
|
|
|
|
m_lastToolId = toolId; |
|
|
|
|
|
|
|
|
|
// handle tool deselection
|
|
|
|
|
if (toolID == -1) { |
|
|
|
|
if (toolId == -1) { |
|
|
|
|
m_pageView->displayMessage(QString()); |
|
|
|
|
m_pageView->updateCursor(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// for the selected tool create the Engine
|
|
|
|
|
QDomElement toolElement = m_builtinToolsDefinition->tool(toolID); |
|
|
|
|
QDomElement toolElement = m_builtinToolsDefinition->tool(toolId); |
|
|
|
|
if (!toolElement.isNull()) { |
|
|
|
|
// parse tool properties
|
|
|
|
|
QDomElement engineElement = toolElement.firstChildElement(QStringLiteral("engine")); |
|
|
|
|
@ -1040,7 +1040,7 @@ void PageViewAnnotator::selectTool(int toolID) |
|
|
|
|
m_pageView->updateCursor(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (toolID > 0) |
|
|
|
|
if (toolId > 0) |
|
|
|
|
emit toolSelected(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1280,10 +1280,10 @@ void PageViewAnnotator::saveAnnotationTools() |
|
|
|
|
Okular::Settings::self()->save(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int PageViewAnnotator::setQuickTool(int favToolID) |
|
|
|
|
int PageViewAnnotator::setQuickTool(int favToolId) |
|
|
|
|
{ |
|
|
|
|
int toolId = -1; |
|
|
|
|
QDomElement favToolElement = m_quickToolsDefinition->tool(favToolID); |
|
|
|
|
QDomElement favToolElement = m_quickToolsDefinition->tool(favToolId); |
|
|
|
|
if (!favToolElement.isNull()) { |
|
|
|
|
toolId = m_builtinToolsDefinition->findToolId(favToolElement.attribute(QStringLiteral("type"))); |
|
|
|
|
if (toolId == -1) { |
|
|
|
|
@ -1295,19 +1295,19 @@ int PageViewAnnotator::setQuickTool(int favToolID) |
|
|
|
|
return toolId; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QDomElement PageViewAnnotator::builtinTool(int toolID) |
|
|
|
|
QDomElement PageViewAnnotator::builtinTool(int toolId) |
|
|
|
|
{ |
|
|
|
|
return m_builtinToolsDefinition->tool(toolID); |
|
|
|
|
return m_builtinToolsDefinition->tool(toolId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QDomElement PageViewAnnotator::quickTool(int toolID) |
|
|
|
|
QDomElement PageViewAnnotator::quickTool(int toolId) |
|
|
|
|
{ |
|
|
|
|
return m_quickToolsDefinition->tool(toolID); |
|
|
|
|
return m_quickToolsDefinition->tool(toolId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QDomElement PageViewAnnotator::currentEngineElement() |
|
|
|
|
{ |
|
|
|
|
return m_builtinToolsDefinition->tool(m_lastToolID).firstChildElement(QStringLiteral("engine")); |
|
|
|
|
return m_builtinToolsDefinition->tool(m_lastToolId).firstChildElement(QStringLiteral("engine")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QDomElement PageViewAnnotator::currentAnnotationElement() |
|
|
|
|
@ -1319,7 +1319,7 @@ void PageViewAnnotator::setAnnotationWidth(double width) |
|
|
|
|
{ |
|
|
|
|
currentAnnotationElement().setAttribute(QStringLiteral("width"), QString::number(width)); |
|
|
|
|
saveAnnotationTools(); |
|
|
|
|
selectTool(m_lastToolID); |
|
|
|
|
selectTool(m_lastToolId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PageViewAnnotator::setAnnotationColor(const QColor &color) |
|
|
|
|
@ -1333,7 +1333,7 @@ void PageViewAnnotator::setAnnotationColor(const QColor &color) |
|
|
|
|
annotationElement.setAttribute(QStringLiteral("color"), color.name(QColor::HexRgb)); |
|
|
|
|
} |
|
|
|
|
saveAnnotationTools(); |
|
|
|
|
selectTool(m_lastToolID); |
|
|
|
|
selectTool(m_lastToolId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PageViewAnnotator::setAnnotationInnerColor(const QColor &color) |
|
|
|
|
@ -1345,26 +1345,26 @@ void PageViewAnnotator::setAnnotationInnerColor(const QColor &color) |
|
|
|
|
annotationElement.setAttribute(QStringLiteral("innerColor"), color.name(QColor::HexRgb)); |
|
|
|
|
} |
|
|
|
|
saveAnnotationTools(); |
|
|
|
|
selectTool(m_lastToolID); |
|
|
|
|
selectTool(m_lastToolId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PageViewAnnotator::setAnnotationOpacity(double opacity) |
|
|
|
|
{ |
|
|
|
|
currentAnnotationElement().setAttribute(QStringLiteral("opacity"), QString::number(opacity)); |
|
|
|
|
saveAnnotationTools(); |
|
|
|
|
selectTool(m_lastToolID); |
|
|
|
|
selectTool(m_lastToolId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PageViewAnnotator::setAnnotationFont(const QFont &font) |
|
|
|
|
{ |
|
|
|
|
currentAnnotationElement().setAttribute(QStringLiteral("font"), font.toString()); |
|
|
|
|
saveAnnotationTools(); |
|
|
|
|
selectTool(m_lastToolID); |
|
|
|
|
selectTool(m_lastToolId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PageViewAnnotator::addToQuickAnnotations() |
|
|
|
|
{ |
|
|
|
|
QDomElement sourceToolElement = m_builtinToolsDefinition->tool(m_lastToolID); |
|
|
|
|
QDomElement sourceToolElement = m_builtinToolsDefinition->tool(m_lastToolId); |
|
|
|
|
if (sourceToolElement.isNull()) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
@ -1384,17 +1384,17 @@ void PageViewAnnotator::addToQuickAnnotations() |
|
|
|
|
|
|
|
|
|
void PageViewAnnotator::slotAdvancedSettings() |
|
|
|
|
{ |
|
|
|
|
QDomElement toolElement = m_builtinToolsDefinition->tool(m_lastToolID); |
|
|
|
|
QDomElement toolElement = m_builtinToolsDefinition->tool(m_lastToolId); |
|
|
|
|
|
|
|
|
|
EditAnnotToolDialog t(nullptr, toolElement, true); |
|
|
|
|
if (t.exec() != QDialog::Accepted) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
QDomElement toolElementUpdated = t.toolXml().documentElement(); |
|
|
|
|
int toolID = toolElement.attribute(QStringLiteral("id")).toInt(); |
|
|
|
|
m_builtinToolsDefinition->updateTool(toolElementUpdated, toolID); |
|
|
|
|
int toolId = toolElement.attribute(QStringLiteral("id")).toInt(); |
|
|
|
|
m_builtinToolsDefinition->updateTool(toolElementUpdated, toolId); |
|
|
|
|
saveAnnotationTools(); |
|
|
|
|
selectTool(m_lastToolID); |
|
|
|
|
selectTool(m_lastToolId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#include "moc_pageviewannotator.cpp" |
|
|
|
|
|