diff --git a/Pdf4QtLib/sources/pdfpagecontenteditorwidget.cpp b/Pdf4QtLib/sources/pdfpagecontenteditorwidget.cpp index 11d129f..ee89cb8 100644 --- a/Pdf4QtLib/sources/pdfpagecontenteditorwidget.cpp +++ b/Pdf4QtLib/sources/pdfpagecontenteditorwidget.cpp @@ -121,6 +121,11 @@ void PDFPageContentEditorWidget::addAction(QAction* action) ui->toolGroupBoxLayout->addWidget(button, row, column, Qt::AlignCenter); } +QToolButton* PDFPageContentEditorWidget::getToolButtonForOperation(int operation) const +{ + return qobject_cast(m_operationMapper.mapping(operation)); +} + void PDFPageContentEditorWidget::onActionTriggerRequest(QObject* actionObject) { QAction* action = qobject_cast(actionObject); diff --git a/Pdf4QtLib/sources/pdfpagecontenteditorwidget.h b/Pdf4QtLib/sources/pdfpagecontenteditorwidget.h index 19a6d9f..995f11e 100644 --- a/Pdf4QtLib/sources/pdfpagecontenteditorwidget.h +++ b/Pdf4QtLib/sources/pdfpagecontenteditorwidget.h @@ -23,6 +23,8 @@ #include #include +class QToolButton; + namespace Ui { class PDFPageContentEditorWidget; @@ -42,6 +44,8 @@ public: /// Adds external action to the tool box void addAction(QAction* action); + QToolButton* getToolButtonForOperation(int operation) const; + signals: void operationTriggered(int operation); diff --git a/Pdf4QtLib/sources/pdfpagecontentelements.cpp b/Pdf4QtLib/sources/pdfpagecontentelements.cpp index a538ab3..6375e33 100644 --- a/Pdf4QtLib/sources/pdfpagecontentelements.cpp +++ b/Pdf4QtLib/sources/pdfpagecontentelements.cpp @@ -1920,6 +1920,15 @@ void PDFPageContentElementManipulator::performOperation(Operation operation) QRectF currentBoundingBox = (*it)->getBoundingBox(); if (isRectangleVerticallyOverlapped(boundingBox, currentBoundingBox)) { + QRectF unitedRect = boundingBox.united(currentBoundingBox); + qreal currentOverlap = boundingBox.height() + currentBoundingBox.height() - unitedRect.height(); + + if (qFuzzyIsNull(currentOverlap)) + { + ++it; + continue; + } + elementToRow[*it] = row; maxHeight = qMax(currentBoundingBox.height(), maxHeight); it = rowElementsToProcess.erase(it); @@ -1960,6 +1969,15 @@ void PDFPageContentElementManipulator::performOperation(Operation operation) QRectF currentBoundingBox = (*it)->getBoundingBox(); if (isRectangleHorizontallyOverlapped(boundingBox, currentBoundingBox)) { + QRectF unitedRect = boundingBox.united(currentBoundingBox); + qreal currentOverlap = boundingBox.width() + currentBoundingBox.width() - unitedRect.width(); + + if (qFuzzyIsNull(currentOverlap)) + { + ++it; + continue; + } + elementToColumn[*it] = column; maxWidth = qMax(currentBoundingBox.width(), maxWidth); it = columnElementsToProcess.erase(it); @@ -2038,13 +2056,16 @@ void PDFPageContentElementManipulator::startManipulation(PDFInteger pageIndex, continue; } - const uint manipulationMode = element->getManipulationMode(startPoint, snapPointDistanceThreshold); - if (manipulationMode) + uint manipulationMode = element->getManipulationMode(startPoint, snapPointDistanceThreshold); + + if (!manipulationMode) { - // Jakub Melka: yes, we can manipulate this element - m_manipulatedElements.emplace_back(element->clone()); - m_manipulationModes[id] = manipulationMode; + manipulationMode = PDFPageContentElement::Translate; } + + // Jakub Melka: manipulate this element + m_manipulatedElements.emplace_back(element->clone()); + m_manipulationModes[id] = manipulationMode; } if (!m_manipulatedElements.empty()) diff --git a/Pdf4QtViewer/pdf4qtviewer.qrc b/Pdf4QtViewer/pdf4qtviewer.qrc index 985f175..6f2a227 100644 --- a/Pdf4QtViewer/pdf4qtviewer.qrc +++ b/Pdf4QtViewer/pdf4qtviewer.qrc @@ -74,5 +74,21 @@ resources/save.svg resources/save-as.svg resources/select-all-text.svg + resources/pce-align-bottom.svg + resources/pce-align-h-center.svg + resources/pce-align-left.svg + resources/pce-align-right.svg + resources/pce-align-top.svg + resources/pce-align-v-center.svg + resources/pce-center-h.svg + resources/pce-center-v.svg + resources/pce-center-vh.svg + resources/pce-layout-form.svg + resources/pce-layout-grid.svg + resources/pce-layout-h.svg + resources/pce-layout-v.svg + resources/pce-same-height.svg + resources/pce-same-size.svg + resources/pce-same-width.svg diff --git a/Pdf4QtViewer/resources/pce-align-bottom.svg b/Pdf4QtViewer/resources/pce-align-bottom.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-align-bottom.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/pce-align-h-center.svg b/Pdf4QtViewer/resources/pce-align-h-center.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-align-h-center.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/pce-align-left.svg b/Pdf4QtViewer/resources/pce-align-left.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-align-left.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/pce-align-right.svg b/Pdf4QtViewer/resources/pce-align-right.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-align-right.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/pce-align-top.svg b/Pdf4QtViewer/resources/pce-align-top.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-align-top.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/pce-align-v-center.svg b/Pdf4QtViewer/resources/pce-align-v-center.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-align-v-center.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/pce-center-h.svg b/Pdf4QtViewer/resources/pce-center-h.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-center-h.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/pce-center-v.svg b/Pdf4QtViewer/resources/pce-center-v.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-center-v.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/pce-center-vh.svg b/Pdf4QtViewer/resources/pce-center-vh.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-center-vh.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/pce-layout-form.svg b/Pdf4QtViewer/resources/pce-layout-form.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-layout-form.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/pce-layout-grid.svg b/Pdf4QtViewer/resources/pce-layout-grid.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-layout-grid.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/pce-layout-h.svg b/Pdf4QtViewer/resources/pce-layout-h.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-layout-h.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/pce-layout-v.svg b/Pdf4QtViewer/resources/pce-layout-v.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-layout-v.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/pce-same-height.svg b/Pdf4QtViewer/resources/pce-same-height.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-same-height.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/pce-same-size.svg b/Pdf4QtViewer/resources/pce-same-size.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-same-size.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/pce-same-width.svg b/Pdf4QtViewer/resources/pce-same-width.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/pce-same-width.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewer/resources/placeholder.svg b/Pdf4QtViewer/resources/placeholder.svg new file mode 100644 index 0000000..d2a3670 --- /dev/null +++ b/Pdf4QtViewer/resources/placeholder.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml + +? + \ No newline at end of file diff --git a/Pdf4QtViewerPlugins/SignaturePlugin/signatureplugin.cpp b/Pdf4QtViewerPlugins/SignaturePlugin/signatureplugin.cpp index 04ce4cd..03c33d1 100644 --- a/Pdf4QtViewerPlugins/SignaturePlugin/signatureplugin.cpp +++ b/Pdf4QtViewerPlugins/SignaturePlugin/signatureplugin.cpp @@ -20,6 +20,7 @@ #include "pdfpagecontenteditorwidget.h" #include +#include #include namespace pdfplugin @@ -276,6 +277,23 @@ void SignaturePlugin::updateDockWidget() m_editorWidget->setWindowTitle(tr("Signature Toolbox")); connect(m_editorWidget, &pdf::PDFPageContentEditorWidget::operationTriggered, &m_scene, &pdf::PDFPageContentScene::performOperation); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::AlignTop))->setIcon(QIcon(":/resources/pce-align-top.svg")); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::AlignCenterVertically))->setIcon(QIcon(":/resources/pce-align-v-center.svg")); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::AlignBottom))->setIcon(QIcon(":/resources/pce-align-bottom.svg")); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::AlignLeft))->setIcon(QIcon(":/resources/pce-align-left.svg")); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::AlignCenterHorizontally))->setIcon(QIcon(":/resources/pce-align-h-center.svg")); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::AlignRight))->setIcon(QIcon(":/resources/pce-align-right.svg")); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::SetSameHeight))->setIcon(QIcon(":/resources/pce-same-height.svg")); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::SetSameWidth))->setIcon(QIcon(":/resources/pce-same-width.svg")); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::SetSameSize))->setIcon(QIcon(":/resources/pce-same-size.svg")); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::CenterHorizontally))->setIcon(QIcon(":/resources/pce-center-h.svg")); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::CenterVertically))->setIcon(QIcon(":/resources/pce-center-v.svg")); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::CenterHorAndVert))->setIcon(QIcon(":/resources/pce-center-vh.svg")); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::LayoutVertically))->setIcon(QIcon(":/resources/pce-layout-v.svg")); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::LayoutHorizontally))->setIcon(QIcon(":/resources/pce-layout-h.svg")); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::LayoutForm))->setIcon(QIcon(":/resources/pce-layout-form.svg")); + m_editorWidget->getToolButtonForOperation(static_cast(pdf::PDFPageContentElementManipulator::Operation::LayoutGrid))->setIcon(QIcon(":/resources/pce-layout-grid.svg")); + for (QAction* action : m_actions) { m_editorWidget->addAction(action);