parent
fbe36e330d
commit
4ed2c12bf8
@ -1 +1 @@
|
|||||||
SOURCES/openboard-9de37af2df1a7c0d88f71c94ab2db1815d082862.tar.gz
|
SOURCES/openboard-92dbed8305240a412fe71ae65de55a607214df1b.tar.gz
|
||||||
|
@ -1 +1 @@
|
|||||||
2e7fff009140daa634e44b895f4ceb5c8353eddb SOURCES/openboard-9de37af2df1a7c0d88f71c94ab2db1815d082862.tar.gz
|
b43c7a74bef3a00d22ba053d507c1d13411c421e SOURCES/openboard-92dbed8305240a412fe71ae65de55a607214df1b.tar.gz
|
||||||
|
@ -1,589 +0,0 @@
|
|||||||
From 31456152d403e57cdd56f6b1dd54d94d930a3029 Mon Sep 17 00:00:00 2001
|
|
||||||
From: letsfindaway <me@letsfindaway.de>
|
|
||||||
Date: Wed, 5 Jan 2022 11:15:54 +0100
|
|
||||||
Subject: [PATCH 1/3] refactor: drawBackground mostly in scene
|
|
||||||
|
|
||||||
- move all drawing of background grid to UBGraphicsScene
|
|
||||||
- only add document border in UBBoardView
|
|
||||||
- avoid some compiler warnings
|
|
||||||
---
|
|
||||||
src/board/UBBoardView.cpp | 101 ++++-----------------------------
|
|
||||||
src/domain/UBGraphicsScene.cpp | 48 +++++++++++++---
|
|
||||||
2 files changed, 51 insertions(+), 98 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp
|
|
||||||
index 817d8c4e7..c968f17d7 100644
|
|
||||||
--- a/src/board/UBBoardView.cpp
|
|
||||||
+++ b/src/board/UBBoardView.cpp
|
|
||||||
@@ -29,6 +29,7 @@
|
|
||||||
|
|
||||||
#include "UBBoardView.h"
|
|
||||||
|
|
||||||
+#include <QtGlobal>
|
|
||||||
#include <QtGui>
|
|
||||||
#include <QtXml>
|
|
||||||
#include <QListView>
|
|
||||||
@@ -92,11 +93,11 @@ UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent, bool
|
|
||||||
, mIsCreatingTextZone (false)
|
|
||||||
, mIsCreatingSceneGrabZone (false)
|
|
||||||
, mOkOnWidget(false)
|
|
||||||
+ , _movingItem(nullptr)
|
|
||||||
, suspendedMousePressEvent(NULL)
|
|
||||||
, mLongPressInterval(1000)
|
|
||||||
, mIsDragInProgress(false)
|
|
||||||
, mMultipleSelectionIsEnabled(false)
|
|
||||||
- , _movingItem(nullptr)
|
|
||||||
, bIsControl(isControl)
|
|
||||||
, bIsDesktop(isDesktop)
|
|
||||||
{
|
|
||||||
@@ -117,11 +118,11 @@ UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent, bool
|
|
||||||
UBBoardView::UBBoardView (UBBoardController* pController, int pStartLayer, int pEndLayer, QWidget* pParent, bool isControl, bool isDesktop)
|
|
||||||
: QGraphicsView (pParent)
|
|
||||||
, mController (pController)
|
|
||||||
+ , _movingItem(nullptr)
|
|
||||||
, suspendedMousePressEvent(NULL)
|
|
||||||
, mLongPressInterval(1000)
|
|
||||||
, mIsDragInProgress(false)
|
|
||||||
, mMultipleSelectionIsEnabled(false)
|
|
||||||
- , _movingItem(nullptr)
|
|
||||||
, bIsControl(isControl)
|
|
||||||
, bIsDesktop(isDesktop)
|
|
||||||
{
|
|
||||||
@@ -685,6 +686,7 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item)
|
|
||||||
return false;
|
|
||||||
if(currentTool == UBStylusTool::Play)
|
|
||||||
return false;
|
|
||||||
+ Q_FALLTHROUGH();
|
|
||||||
|
|
||||||
case UBGraphicsSvgItem::Type:
|
|
||||||
case UBGraphicsPixmapItem::Type:
|
|
||||||
@@ -692,10 +694,13 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item)
|
|
||||||
return true;
|
|
||||||
if (item->isSelected())
|
|
||||||
return false;
|
|
||||||
+ Q_FALLTHROUGH();
|
|
||||||
+
|
|
||||||
case UBGraphicsMediaItem::Type:
|
|
||||||
case UBGraphicsVideoItem::Type:
|
|
||||||
case UBGraphicsAudioItem::Type:
|
|
||||||
return true;
|
|
||||||
+
|
|
||||||
case UBGraphicsStrokesGroup::Type:
|
|
||||||
case UBGraphicsTextItem::Type:
|
|
||||||
if (currentTool == UBStylusTool::Play)
|
|
||||||
@@ -1714,98 +1719,14 @@ void UBBoardView::paintEvent(QPaintEvent *event)
|
|
||||||
|
|
||||||
void UBBoardView::drawBackground (QPainter *painter, const QRectF &rect)
|
|
||||||
{
|
|
||||||
+ // draw the background of the QGraphicsScene
|
|
||||||
+ QGraphicsView::drawBackground(painter, rect);
|
|
||||||
+
|
|
||||||
if (testAttribute (Qt::WA_TranslucentBackground))
|
|
||||||
{
|
|
||||||
- QGraphicsView::drawBackground (painter, rect);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
- bool darkBackground = scene () && scene ()->isDarkBackground ();
|
|
||||||
-
|
|
||||||
- if (darkBackground)
|
|
||||||
- {
|
|
||||||
- painter->fillRect (rect, QBrush (QColor (Qt::black)));
|
|
||||||
- }
|
|
||||||
- else
|
|
||||||
- {
|
|
||||||
- painter->fillRect (rect, QBrush (QColor (Qt::white)));
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if (transform ().m11 () > 0.5)
|
|
||||||
- {
|
|
||||||
- QColor bgCrossColor;
|
|
||||||
-
|
|
||||||
- if (darkBackground)
|
|
||||||
- bgCrossColor = QColor(UBSettings::settings()->boardCrossColorDarkBackground->get().toString());
|
|
||||||
- else
|
|
||||||
- bgCrossColor = QColor(UBSettings::settings()->boardCrossColorLightBackground->get().toString());
|
|
||||||
-
|
|
||||||
- if (transform ().m11 () < 0.7)
|
|
||||||
- {
|
|
||||||
- int alpha = 255 * transform ().m11 () / 2;
|
|
||||||
- bgCrossColor.setAlpha (alpha); // fade the crossing on small zooms
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- qreal gridSize = scene()->backgroundGridSize();
|
|
||||||
- bool intermediateLines = scene()->intermediateLines();
|
|
||||||
-
|
|
||||||
- painter->setPen (bgCrossColor);
|
|
||||||
-
|
|
||||||
- if (scene () && scene ()->pageBackground() == UBPageBackground::crossed)
|
|
||||||
- {
|
|
||||||
- qreal firstY = ((int) (rect.y () / gridSize)) * gridSize;
|
|
||||||
-
|
|
||||||
- for (qreal yPos = firstY; yPos < rect.y () + rect.height (); yPos += gridSize)
|
|
||||||
- {
|
|
||||||
- painter->drawLine (rect.x (), yPos, rect.x () + rect.width (), yPos);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- qreal firstX = ((int) (rect.x () / gridSize)) * gridSize;
|
|
||||||
-
|
|
||||||
- for (qreal xPos = firstX; xPos < rect.x () + rect.width (); xPos += gridSize)
|
|
||||||
- {
|
|
||||||
- painter->drawLine (xPos, rect.y (), xPos, rect.y () + rect.height ());
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if (intermediateLines) {
|
|
||||||
- QColor intermediateColor = bgCrossColor;
|
|
||||||
- intermediateColor.setAlphaF(0.5 * bgCrossColor.alphaF());
|
|
||||||
- painter->setPen(intermediateColor);
|
|
||||||
-
|
|
||||||
- for (qreal yPos = firstY - gridSize/2; yPos < rect.y () + rect.height (); yPos += gridSize)
|
|
||||||
- {
|
|
||||||
- painter->drawLine (rect.x (), yPos, rect.x () + rect.width (), yPos);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- for (qreal xPos = firstX - gridSize/2; xPos < rect.x () + rect.width (); xPos += gridSize)
|
|
||||||
- {
|
|
||||||
- painter->drawLine (xPos, rect.y (), xPos, rect.y () + rect.height ());
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if (scene() && scene()->pageBackground() == UBPageBackground::ruled)
|
|
||||||
- {
|
|
||||||
- qreal firstY = ((int) (rect.y () / gridSize)) * gridSize;
|
|
||||||
-
|
|
||||||
- for (qreal yPos = firstY; yPos < rect.y () + rect.height (); yPos += gridSize)
|
|
||||||
- {
|
|
||||||
- painter->drawLine (rect.x (), yPos, rect.x () + rect.width (), yPos);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if (intermediateLines) {
|
|
||||||
- QColor intermediateColor = bgCrossColor;
|
|
||||||
- intermediateColor.setAlphaF(0.5 * bgCrossColor.alphaF());
|
|
||||||
- painter->setPen(intermediateColor);
|
|
||||||
-
|
|
||||||
- for (qreal yPos = firstY - gridSize/2; yPos < rect.y () + rect.height (); yPos += gridSize)
|
|
||||||
- {
|
|
||||||
- painter->drawLine (rect.x (), yPos, rect.x () + rect.width (), yPos);
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
if (!mFilterZIndex && scene ())
|
|
||||||
{
|
|
||||||
QSize pageNominalSize = scene ()->nominalSize ();
|
|
||||||
@@ -1821,7 +1742,7 @@ void UBBoardView::drawBackground (QPainter *painter, const QRectF &rect)
|
|
||||||
|
|
||||||
QColor docSizeColor;
|
|
||||||
|
|
||||||
- if (darkBackground)
|
|
||||||
+ if (scene ()->isDarkBackground ())
|
|
||||||
docSizeColor = UBSettings::documentSizeMarkColorDarkBackground;
|
|
||||||
else
|
|
||||||
docSizeColor = UBSettings::documentSizeMarkColorLightBackground;
|
|
||||||
diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp
|
|
||||||
index aa6734dfe..48850d7e8 100644
|
|
||||||
--- a/src/domain/UBGraphicsScene.cpp
|
|
||||||
+++ b/src/domain/UBGraphicsScene.cpp
|
|
||||||
@@ -2690,15 +2690,16 @@ void UBGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect)
|
|
||||||
QGraphicsScene::drawBackground (painter, rect);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
bool darkBackground = isDarkBackground ();
|
|
||||||
|
|
||||||
if (darkBackground)
|
|
||||||
{
|
|
||||||
- painter->fillRect (rect, QBrush (QColor (Qt::black)));
|
|
||||||
+ painter->fillRect (rect, QBrush (QColor (Qt::black)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
- painter->fillRect (rect, QBrush (QColor (Qt::white)));
|
|
||||||
+ painter->fillRect (rect, QBrush (QColor (Qt::white)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mZoomFactor > 0.5)
|
|
||||||
@@ -2709,39 +2710,70 @@ void UBGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect)
|
|
||||||
bgCrossColor = QColor(UBSettings::settings()->boardCrossColorDarkBackground->get().toString());
|
|
||||||
else
|
|
||||||
bgCrossColor = QColor(UBSettings::settings()->boardCrossColorLightBackground->get().toString());
|
|
||||||
+
|
|
||||||
if (mZoomFactor < 0.7)
|
|
||||||
{
|
|
||||||
int alpha = 255 * mZoomFactor / 2;
|
|
||||||
bgCrossColor.setAlpha (alpha); // fade the crossing on small zooms
|
|
||||||
}
|
|
||||||
|
|
||||||
+ qreal gridSize = backgroundGridSize();
|
|
||||||
painter->setPen (bgCrossColor);
|
|
||||||
|
|
||||||
if (mPageBackground == UBPageBackground::crossed)
|
|
||||||
{
|
|
||||||
- qreal firstY = ((int) (rect.y () / backgroundGridSize())) * backgroundGridSize();
|
|
||||||
+ qreal firstY = ((int) (rect.y () / gridSize)) * gridSize;
|
|
||||||
|
|
||||||
- for (qreal yPos = firstY; yPos < rect.y () + rect.height (); yPos += backgroundGridSize())
|
|
||||||
+ for (qreal yPos = firstY; yPos < rect.y () + rect.height (); yPos += gridSize)
|
|
||||||
{
|
|
||||||
painter->drawLine (rect.x (), yPos, rect.x () + rect.width (), yPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
- qreal firstX = ((int) (rect.x () / backgroundGridSize())) * backgroundGridSize();
|
|
||||||
+ qreal firstX = ((int) (rect.x () / gridSize)) * gridSize;
|
|
||||||
|
|
||||||
- for (qreal xPos = firstX; xPos < rect.x () + rect.width (); xPos += backgroundGridSize())
|
|
||||||
+ for (qreal xPos = firstX; xPos < rect.x () + rect.width (); xPos += gridSize)
|
|
||||||
{
|
|
||||||
painter->drawLine (xPos, rect.y (), xPos, rect.y () + rect.height ());
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ if (mIntermediateLines)
|
|
||||||
+ {
|
|
||||||
+ QColor intermediateColor = bgCrossColor;
|
|
||||||
+ intermediateColor.setAlphaF(0.5 * bgCrossColor.alphaF());
|
|
||||||
+ painter->setPen(intermediateColor);
|
|
||||||
+
|
|
||||||
+ for (qreal yPos = firstY - gridSize/2; yPos < rect.y () + rect.height (); yPos += gridSize)
|
|
||||||
+ {
|
|
||||||
+ painter->drawLine (rect.x (), yPos, rect.x () + rect.width (), yPos);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ for (qreal xPos = firstX - gridSize/2; xPos < rect.x () + rect.width (); xPos += gridSize)
|
|
||||||
+ {
|
|
||||||
+ painter->drawLine (xPos, rect.y (), xPos, rect.y () + rect.height ());
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (mPageBackground == UBPageBackground::ruled)
|
|
||||||
{
|
|
||||||
- qreal firstY = ((int) (rect.y () / backgroundGridSize())) * backgroundGridSize();
|
|
||||||
+ qreal firstY = ((int) (rect.y () / gridSize)) * gridSize;
|
|
||||||
|
|
||||||
- for (qreal yPos = firstY; yPos < rect.y () + rect.height (); yPos += backgroundGridSize())
|
|
||||||
+ for (qreal yPos = firstY; yPos < rect.y () + rect.height (); yPos += gridSize)
|
|
||||||
{
|
|
||||||
painter->drawLine (rect.x (), yPos, rect.x () + rect.width (), yPos);
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ if (mIntermediateLines)
|
|
||||||
+ {
|
|
||||||
+ QColor intermediateColor = bgCrossColor;
|
|
||||||
+ intermediateColor.setAlphaF(0.5 * bgCrossColor.alphaF());
|
|
||||||
+ painter->setPen(intermediateColor);
|
|
||||||
+
|
|
||||||
+ for (qreal yPos = firstY - gridSize/2; yPos < rect.y () + rect.height (); yPos += gridSize)
|
|
||||||
+ {
|
|
||||||
+ painter->drawLine (rect.x (), yPos, rect.x () + rect.width (), yPos);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
From 95021acc1dbb5ab7c65fb04b7ff543fd064f41a4 Mon Sep 17 00:00:00 2001
|
|
||||||
From: letsfindaway <me@letsfindaway.de>
|
|
||||||
Date: Tue, 29 Nov 2022 08:49:36 +0100
|
|
||||||
Subject: [PATCH 2/3] fix: set document modified when changing page size
|
|
||||||
|
|
||||||
- make sure page size change is persisted
|
|
||||||
- refactor code to refresh background in common function
|
|
||||||
---
|
|
||||||
src/domain/UBGraphicsScene.cpp | 29 +++++++++++++++--------------
|
|
||||||
src/domain/UBGraphicsScene.h | 1 +
|
|
||||||
2 files changed, 16 insertions(+), 14 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp
|
|
||||||
index 48850d7e8..25760d0bd 100644
|
|
||||||
--- a/src/domain/UBGraphicsScene.cpp
|
|
||||||
+++ b/src/domain/UBGraphicsScene.cpp
|
|
||||||
@@ -1136,22 +1136,17 @@ void UBGraphicsScene::setBackground(bool pIsDark, UBPageBackground pBackground)
|
|
||||||
recolorAllItems();
|
|
||||||
|
|
||||||
needRepaint = true;
|
|
||||||
- setModified(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mPageBackground != pBackground)
|
|
||||||
{
|
|
||||||
mPageBackground = pBackground;
|
|
||||||
needRepaint = true;
|
|
||||||
- setModified(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needRepaint)
|
|
||||||
{
|
|
||||||
- foreach(QGraphicsView* view, views())
|
|
||||||
- {
|
|
||||||
- view->resetCachedContent();
|
|
||||||
- }
|
|
||||||
+ updateBackground();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1165,20 +1160,14 @@ void UBGraphicsScene::setBackgroundGridSize(int pSize)
|
|
||||||
{
|
|
||||||
if (pSize > 0) {
|
|
||||||
mBackgroundGridSize = pSize;
|
|
||||||
- setModified(true);
|
|
||||||
-
|
|
||||||
- foreach(QGraphicsView* view, views())
|
|
||||||
- view->resetCachedContent();
|
|
||||||
+ updateBackground();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UBGraphicsScene::setIntermediateLines(bool checked)
|
|
||||||
{
|
|
||||||
mIntermediateLines = checked;
|
|
||||||
- setModified(true);
|
|
||||||
-
|
|
||||||
- foreach(QGraphicsView* view, views())
|
|
||||||
- view->resetCachedContent();
|
|
||||||
+ updateBackground();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UBGraphicsScene::setDrawingMode(bool bModeDesktop)
|
|
||||||
@@ -2570,6 +2559,7 @@ void UBGraphicsScene::setNominalSize(const QSize& pSize)
|
|
||||||
if (nominalSize() != pSize)
|
|
||||||
{
|
|
||||||
mNominalSize = pSize;
|
|
||||||
+ updateBackground();
|
|
||||||
|
|
||||||
if(mDocument)
|
|
||||||
mDocument->setDefaultDocumentSize(pSize);
|
|
||||||
@@ -2918,6 +2908,17 @@ void UBGraphicsScene::setDocumentUpdated()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+void UBGraphicsScene::updateBackground()
|
|
||||||
+{
|
|
||||||
+ setModified(true);
|
|
||||||
+
|
|
||||||
+ foreach(QGraphicsView* view, views())
|
|
||||||
+ {
|
|
||||||
+ view->resetCachedContent();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
void UBGraphicsScene::createEraiser()
|
|
||||||
{
|
|
||||||
if (UBSettings::settings()->showEraserPreviewCircle->get().toBool()) {
|
|
||||||
diff --git a/src/domain/UBGraphicsScene.h b/src/domain/UBGraphicsScene.h
|
|
||||||
index e824e555f..80bad3d89 100644
|
|
||||||
--- a/src/domain/UBGraphicsScene.h
|
|
||||||
+++ b/src/domain/UBGraphicsScene.h
|
|
||||||
@@ -427,6 +427,7 @@ public slots:
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setDocumentUpdated();
|
|
||||||
+ void updateBackground();
|
|
||||||
void createEraiser();
|
|
||||||
void createPointer();
|
|
||||||
void createMarkerCircle();
|
|
||||||
|
|
||||||
From 1eafb49db2e03b0b878d7d90e621136a6bce1374 Mon Sep 17 00:00:00 2001
|
|
||||||
From: letsfindaway <me@letsfindaway.de>
|
|
||||||
Date: Tue, 29 Nov 2022 09:12:05 +0100
|
|
||||||
Subject: [PATCH 3/3] refactor: avoid clang warnings
|
|
||||||
|
|
||||||
- unneeded temporary container allocations
|
|
||||||
- reference to temporary
|
|
||||||
- possible memory leak
|
|
||||||
- unused variable
|
|
||||||
- use QHash for pointers instead of QMap
|
|
||||||
- possible nullptr reference
|
|
||||||
- not normalized signal/slot signatures
|
|
||||||
- detached container
|
|
||||||
- call to virtual function during construction
|
|
||||||
---
|
|
||||||
src/domain/UBGraphicsScene.cpp | 65 ++++++++++++++++++----------------
|
|
||||||
1 file changed, 34 insertions(+), 31 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp
|
|
||||||
index 25760d0bd..f3fed4b6f 100644
|
|
||||||
--- a/src/domain/UBGraphicsScene.cpp
|
|
||||||
+++ b/src/domain/UBGraphicsScene.cpp
|
|
||||||
@@ -164,7 +164,7 @@ qreal UBZLayerController::changeZLevelTo(QGraphicsItem *item, moveDestination de
|
|
||||||
}
|
|
||||||
|
|
||||||
//If only one item itself - do nothing, return it's z-value
|
|
||||||
- if (sortedItems.count() == 1 && sortedItems.values().first() == item) {
|
|
||||||
+ if (sortedItems.count() == 1 && sortedItems.first() == item) {
|
|
||||||
qDebug() << "only one item exists in layer. Have nothing to change";
|
|
||||||
return item->data(UBGraphicsItemData::ItemOwnZValue).toReal();
|
|
||||||
}
|
|
||||||
@@ -385,8 +385,8 @@ UBGraphicsScene::~UBGraphicsScene()
|
|
||||||
void UBGraphicsScene::selectionChangedProcessing()
|
|
||||||
{
|
|
||||||
if (selectedItems().count()){
|
|
||||||
- UBApplication::showMessage("ZValue is " + QString::number(selectedItems().first()->zValue(), 'f') + "own z value is "
|
|
||||||
- + QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f'));
|
|
||||||
+ UBApplication::showMessage("ZValue is " + QString::number(selectedItems().constFirst()->zValue(), 'f') + "own z value is "
|
|
||||||
+ + QString::number(selectedItems().constFirst()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f'));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -749,10 +749,11 @@ bool UBGraphicsScene::inputDeviceRelease(int tool)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
|
|
||||||
- UBGraphicsItemUndoCommand* udcmd = new UBGraphicsItemUndoCommand(this, mRemovedItems, mAddedItems); //deleted by the undoStack
|
|
||||||
-
|
|
||||||
- if(UBApplication::undoStack)
|
|
||||||
+ if (UBApplication::undoStack)
|
|
||||||
+ {
|
|
||||||
+ UBGraphicsItemUndoCommand* udcmd = new UBGraphicsItemUndoCommand(this, mRemovedItems, mAddedItems); //deleted by the undoStack
|
|
||||||
UBApplication::undoStack->push(udcmd);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
mRemovedItems.clear();
|
|
||||||
@@ -1177,7 +1178,7 @@ void UBGraphicsScene::setDrawingMode(bool bModeDesktop)
|
|
||||||
|
|
||||||
void UBGraphicsScene::recolorAllItems()
|
|
||||||
{
|
|
||||||
- QMap<QGraphicsView*, QGraphicsView::ViewportUpdateMode> previousUpdateModes;
|
|
||||||
+ QHash<QGraphicsView*, QGraphicsView::ViewportUpdateMode> previousUpdateModes;
|
|
||||||
foreach(QGraphicsView* view, views())
|
|
||||||
{
|
|
||||||
previousUpdateModes.insert(view, view->viewportUpdateMode());
|
|
||||||
@@ -1383,7 +1384,7 @@ UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const
|
|
||||||
copy->setNominalSize(this->mNominalSize);
|
|
||||||
|
|
||||||
QListIterator<QGraphicsItem*> itItems(this->mFastAccessItems);
|
|
||||||
- QMap<UBGraphicsStroke*, UBGraphicsStroke*> groupClone;
|
|
||||||
+ QHash<UBGraphicsStroke*, UBGraphicsStroke*> groupClone;
|
|
||||||
|
|
||||||
while (itItems.hasNext())
|
|
||||||
{
|
|
||||||
@@ -1507,8 +1508,8 @@ void UBGraphicsScene::clearContent(clearCase pCase)
|
|
||||||
|
|
||||||
groupsMap.insert(itemGroup, UBGraphicsItem::getOwnUuid(item));
|
|
||||||
if (itemGroup->childItems().count() == 1) {
|
|
||||||
- groupsMap.insert(itemGroup, UBGraphicsItem::getOwnUuid(itemGroup->childItems().first()));
|
|
||||||
- QGraphicsItem *lastItem = itemGroup->childItems().first();
|
|
||||||
+ groupsMap.insert(itemGroup, UBGraphicsItem::getOwnUuid(itemGroup->childItems().constFirst()));
|
|
||||||
+ QGraphicsItem *lastItem = itemGroup->childItems().constFirst();
|
|
||||||
bool isSelected = itemGroup->isSelected();
|
|
||||||
itemGroup->destroy(false);
|
|
||||||
lastItem->setSelected(isSelected);
|
|
||||||
@@ -1626,25 +1627,27 @@ UBGraphicsMediaItem* UBGraphicsScene::addMedia(const QUrl& pMediaFileUrl, bool s
|
|
||||||
|
|
||||||
UBGraphicsMediaItem * mediaItem = UBGraphicsMediaItem::createMediaItem(pMediaFileUrl);
|
|
||||||
|
|
||||||
- if(mediaItem)
|
|
||||||
+ if (mediaItem)
|
|
||||||
+ {
|
|
||||||
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), mediaItem, SLOT(activeSceneChanged()));
|
|
||||||
|
|
||||||
- mediaItem->setPos(pPos);
|
|
||||||
+ mediaItem->setPos(pPos);
|
|
||||||
|
|
||||||
- mediaItem->setFlag(QGraphicsItem::ItemIsMovable, true);
|
|
||||||
- mediaItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
|
||||||
+ mediaItem->setFlag(QGraphicsItem::ItemIsMovable, true);
|
|
||||||
+ mediaItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
|
||||||
|
|
||||||
- addItem(mediaItem);
|
|
||||||
+ addItem(mediaItem);
|
|
||||||
|
|
||||||
- mediaItem->show();
|
|
||||||
+ mediaItem->show();
|
|
||||||
|
|
||||||
- if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
|
|
||||||
- UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, mediaItem);
|
|
||||||
- UBApplication::undoStack->push(uc);
|
|
||||||
- }
|
|
||||||
+ if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
|
|
||||||
+ UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, mediaItem);
|
|
||||||
+ UBApplication::undoStack->push(uc);
|
|
||||||
+ }
|
|
||||||
|
|
||||||
- if (shouldPlayAsap)
|
|
||||||
- mediaItem->play();
|
|
||||||
+ if (shouldPlayAsap)
|
|
||||||
+ mediaItem->play();
|
|
||||||
+ }
|
|
||||||
|
|
||||||
setDocumentUpdated();
|
|
||||||
|
|
||||||
@@ -1904,7 +1907,7 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con
|
|
||||||
UBApplication::undoStack->push(uc);
|
|
||||||
}
|
|
||||||
|
|
||||||
- connect(textItem, SIGNAL(textUndoCommandAdded(UBGraphicsTextItem *)), this, SLOT(textUndoCommandAdded(UBGraphicsTextItem *)));
|
|
||||||
+ connect(textItem, SIGNAL(textUndoCommandAdded(UBGraphicsTextItem*)), this, SLOT(textUndoCommandAdded(UBGraphicsTextItem*)));
|
|
||||||
|
|
||||||
textItem->setSelected(true);
|
|
||||||
textItem->setFocus();
|
|
||||||
@@ -1931,7 +1934,7 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const Q
|
|
||||||
UBApplication::undoStack->push(uc);
|
|
||||||
}
|
|
||||||
|
|
||||||
- connect(textItem, SIGNAL(textUndoCommandAdded(UBGraphicsTextItem *)), this, SLOT(textUndoCommandAdded(UBGraphicsTextItem *)));
|
|
||||||
+ connect(textItem, SIGNAL(textUndoCommandAdded(UBGraphicsTextItem*)), this, SLOT(textUndoCommandAdded(UBGraphicsTextItem*)));
|
|
||||||
|
|
||||||
textItem->setFocus();
|
|
||||||
|
|
||||||
@@ -2140,10 +2143,10 @@ QRectF UBGraphicsScene::normalizedSceneRect(qreal ratio)
|
|
||||||
QGraphicsItem *UBGraphicsScene::itemForUuid(QUuid uuid)
|
|
||||||
{
|
|
||||||
QGraphicsItem *result = 0;
|
|
||||||
- QString ui = uuid.toString();
|
|
||||||
|
|
||||||
//simple search before implementing container for fast access
|
|
||||||
- foreach (QGraphicsItem *item, items()) {
|
|
||||||
+ foreach (QGraphicsItem *item, items())
|
|
||||||
+ {
|
|
||||||
if (UBGraphicsScene::getPersonalUuid(item) == uuid && !uuid.isNull()) {
|
|
||||||
result = item;
|
|
||||||
}
|
|
||||||
@@ -2514,7 +2517,7 @@ QList<QUrl> UBGraphicsScene::relativeDependencies() const
|
|
||||||
UBGraphicsGroupContainerItem* groupItem = dynamic_cast<UBGraphicsGroupContainerItem*>(item);
|
|
||||||
if(groupItem)
|
|
||||||
{
|
|
||||||
- for (auto child : groupItem->childItems())
|
|
||||||
+ foreach (QGraphicsItem* child, groupItem->childItems())
|
|
||||||
{
|
|
||||||
relativePaths << relativeDependenciesOfItem(child);
|
|
||||||
}
|
|
||||||
@@ -2932,7 +2935,7 @@ void UBGraphicsScene::createEraiser()
|
|
||||||
mEraser->setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::Eraiser)); //Necessary to set if we want z value to be assigned correctly
|
|
||||||
|
|
||||||
mTools << mEraser;
|
|
||||||
- addItem(mEraser);
|
|
||||||
+ UBGraphicsScene::addItem(mEraser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -2949,7 +2952,7 @@ void UBGraphicsScene::createPointer()
|
|
||||||
mPointer->setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::Pointer)); //Necessary to set if we want z value to be assigned correctly
|
|
||||||
|
|
||||||
mTools << mPointer;
|
|
||||||
- addItem(mPointer);
|
|
||||||
+ UBGraphicsScene::addItem(mPointer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UBGraphicsScene::createMarkerCircle()
|
|
||||||
@@ -2967,7 +2970,7 @@ void UBGraphicsScene::createMarkerCircle()
|
|
||||||
mMarkerCircle->setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::Eraiser));
|
|
||||||
|
|
||||||
mTools << mMarkerCircle;
|
|
||||||
- addItem(mMarkerCircle);
|
|
||||||
+ UBGraphicsScene::addItem(mMarkerCircle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -2986,7 +2989,7 @@ void UBGraphicsScene::createPenCircle()
|
|
||||||
mPenCircle->setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::Eraiser));
|
|
||||||
|
|
||||||
mTools << mPenCircle;
|
|
||||||
- addItem(mPenCircle);
|
|
||||||
+ UBGraphicsScene::addItem(mPenCircle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
|||||||
From d835e5ef719356c3840c11aade9e671a26d5c6ce Mon Sep 17 00:00:00 2001
|
|
||||||
From: letsfindaway <me@letsfindaway.de>
|
|
||||||
Date: Sun, 9 Jan 2022 10:40:12 +0100
|
|
||||||
Subject: [PATCH] fix: scaling of mirror pixmap
|
|
||||||
|
|
||||||
- when scaling the pixmap take the devicePixelRatio into account
|
|
||||||
- do not scale the already scaled pixmap when drawing in UBScreenMirror
|
|
||||||
- use device independent coordinates when positioning the pixmap
|
|
||||||
---
|
|
||||||
src/gui/UBScreenMirror.cpp | 10 ++++++----
|
|
||||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/gui/UBScreenMirror.cpp b/src/gui/UBScreenMirror.cpp
|
|
||||||
index db5b65116..ff9810862 100644
|
|
||||||
--- a/src/gui/UBScreenMirror.cpp
|
|
||||||
+++ b/src/gui/UBScreenMirror.cpp
|
|
||||||
@@ -66,10 +66,12 @@ void UBScreenMirror::paintEvent(QPaintEvent *event)
|
|
||||||
|
|
||||||
if (!mLastPixmap.isNull())
|
|
||||||
{
|
|
||||||
- int x = (width() - mLastPixmap.width()) / 2;
|
|
||||||
- int y = (height() - mLastPixmap.height()) / 2;
|
|
||||||
+ // compute size and offset in device independent coordinates
|
|
||||||
+ QSizeF pixmapSize = mLastPixmap.size() / mLastPixmap.devicePixelRatioF();
|
|
||||||
+ int x = (width() - pixmapSize.width()) / 2;
|
|
||||||
+ int y = (height() - pixmapSize.height()) / 2;
|
|
||||||
|
|
||||||
- painter.drawPixmap(x, y, width(), height(), mLastPixmap);
|
|
||||||
+ painter.drawPixmap(x, y, mLastPixmap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -95,7 +97,7 @@ void UBScreenMirror::grabPixmap()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mLastPixmap.isNull())
|
|
||||||
- mLastPixmap = mLastPixmap.scaled(width(), height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
+ mLastPixmap = mLastPixmap.scaled(size() * mLastPixmap.devicePixelRatioF(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,274 +0,0 @@
|
|||||||
From 2f6394ce1f085285c5c0a44857bb6ea2c79b8769 Mon Sep 17 00:00:00 2001
|
|
||||||
From: letsfindaway <me@letsfindaway.de>
|
|
||||||
Date: Wed, 28 Sep 2022 16:12:50 +0200
|
|
||||||
Subject: [PATCH] fix: size of exported PDF page
|
|
||||||
|
|
||||||
- add functions to retrieve original PDF page size in Points
|
|
||||||
- make output pages the same size
|
|
||||||
- align page sizes between overlay and base PDF
|
|
||||||
- use QSizeF where necessary to improve accuracy
|
|
||||||
- compute sceneBoundingRect only once
|
|
||||||
- catch exception by const reference (best practice)
|
|
||||||
---
|
|
||||||
src/adaptors/UBExportFullPDF.cpp | 50 +++++++++++++++++---------------
|
|
||||||
src/domain/UBGraphicsScene.cpp | 19 ++++++++++++
|
|
||||||
src/domain/UBGraphicsScene.h | 1 +
|
|
||||||
src/pdf/GraphicsPDFItem.h | 1 +
|
|
||||||
src/pdf/PDFRenderer.h | 2 ++
|
|
||||||
src/pdf/XPDFRenderer.cpp | 32 +++++++++++---------
|
|
||||||
src/pdf/XPDFRenderer.h | 1 +
|
|
||||||
7 files changed, 68 insertions(+), 38 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/adaptors/UBExportFullPDF.cpp b/src/adaptors/UBExportFullPDF.cpp
|
|
||||||
index 5aaa93b45..4b11517ae 100644
|
|
||||||
--- a/src/adaptors/UBExportFullPDF.cpp
|
|
||||||
+++ b/src/adaptors/UBExportFullPDF.cpp
|
|
||||||
@@ -122,7 +122,7 @@ void UBExportFullPDF::saveOverlayPdf(UBDocumentProxy* pDocumentProxy, const QStr
|
|
||||||
|
|
||||||
// pageSize is the output PDF page size; it is set to equal the scene's boundary size; if the contents
|
|
||||||
// of the scene overflow from the boundaries, they will be scaled down.
|
|
||||||
- QSize pageSize = scene->sceneSize();
|
|
||||||
+ QSizeF pageSize = scene->sceneSizeF() * mScaleFactor; // points
|
|
||||||
|
|
||||||
UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*>(scene->backgroundObject());
|
|
||||||
|
|
||||||
@@ -130,13 +130,14 @@ void UBExportFullPDF::saveOverlayPdf(UBDocumentProxy* pDocumentProxy, const QStr
|
|
||||||
{
|
|
||||||
mHasPDFBackgrounds = true;
|
|
||||||
sceneHasPDFBackground = true;
|
|
||||||
+ pageSize = pdfItem->pageSize(); // original PDF document page size
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sceneHasPDFBackground = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
- QPageSize size(QSizeF(pageSize.width()*mScaleFactor, pageSize.height()*mScaleFactor), QPageSize::Point);
|
|
||||||
+ QPageSize size(pageSize, QPageSize::Point);
|
|
||||||
pdfPrinter.setPageSize(size);
|
|
||||||
|
|
||||||
if (!pdfPainter) pdfPainter = new QPainter(&pdfPrinter);
|
|
||||||
@@ -222,47 +223,46 @@ bool UBExportFullPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, const QS
|
|
||||||
UBGraphicsScene* scene = UBPersistenceManager::persistenceManager()->loadDocumentScene(pDocumentProxy, pageIndex);
|
|
||||||
UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*>(scene->backgroundObject());
|
|
||||||
|
|
||||||
- QSize pageSize = scene->nominalSize();
|
|
||||||
-
|
|
||||||
if (pdfItem)
|
|
||||||
{
|
|
||||||
+ QRectF pdfSceneRect = pdfItem->sceneBoundingRect();
|
|
||||||
QString pdfName = UBPersistenceManager::objectDirectory + "/" + pdfItem->fileUuid().toString() + ".pdf";
|
|
||||||
QString backgroundPath = pDocumentProxy->persistencePath() + "/" + pdfName;
|
|
||||||
QRectF annotationsRect = scene->annotationsBoundingRect();
|
|
||||||
|
|
||||||
- // Original datas
|
|
||||||
- double xAnnotation = qRound(annotationsRect.x());
|
|
||||||
- double yAnnotation = qRound(annotationsRect.y());
|
|
||||||
- double xPdf = qRound(pdfItem->sceneBoundingRect().x());
|
|
||||||
- double yPdf = qRound(pdfItem->sceneBoundingRect().y());
|
|
||||||
- double hPdf = qRound(pdfItem->sceneBoundingRect().height());
|
|
||||||
+ // Original data
|
|
||||||
+ double xAnnotation = annotationsRect.x();
|
|
||||||
+ double yAnnotation = annotationsRect.y();
|
|
||||||
+ double xPdf = pdfSceneRect.x();
|
|
||||||
+ double yPdf = pdfSceneRect.y();
|
|
||||||
+ double hPdf = pdfSceneRect.height();
|
|
||||||
|
|
||||||
- // Exportation-transformed datas
|
|
||||||
- double hScaleFactor = pageSize.width()/annotationsRect.width();
|
|
||||||
- double vScaleFactor = pageSize.height()/annotationsRect.height();
|
|
||||||
+ // Exportation-transformed data
|
|
||||||
+ double hScaleFactor = pdfSceneRect.width() / annotationsRect.width();
|
|
||||||
+ double vScaleFactor = pdfSceneRect.height() / annotationsRect.height();
|
|
||||||
double scaleFactor = qMin(hScaleFactor, vScaleFactor);
|
|
||||||
|
|
||||||
double xAnnotationsOffset = 0;
|
|
||||||
double yAnnotationsOffset = 0;
|
|
||||||
- double hPdfTransformed = qRound(hPdf * scaleFactor);
|
|
||||||
+ double hPdfTransformed = hPdf * scaleFactor;
|
|
||||||
|
|
||||||
// Here, we force the PDF page to be on the topleft corner of the page
|
|
||||||
double xPdfOffset = 0;
|
|
||||||
- double yPdfOffset = (hPdf - hPdfTransformed) * mScaleFactor;
|
|
||||||
+ double yPdfOffset = (hPdf - hPdfTransformed);
|
|
||||||
|
|
||||||
// Now we align the items
|
|
||||||
- xPdfOffset += (xPdf - xAnnotation) * scaleFactor * mScaleFactor;
|
|
||||||
- yPdfOffset -= (yPdf - yAnnotation) * scaleFactor * mScaleFactor;
|
|
||||||
+ xPdfOffset += (xPdf - xAnnotation) * scaleFactor;
|
|
||||||
+ yPdfOffset -= (yPdf - yAnnotation) * scaleFactor;
|
|
||||||
|
|
||||||
// If the PDF was scaled when added to the scene (e.g if it was loaded from a document with a different DPI
|
|
||||||
// than the current one), it should also be scaled here.
|
|
||||||
- qreal pdfScale = pdfItem->sceneTransform().m11();
|
|
||||||
|
|
||||||
- TransformationDescription pdfTransform(xPdfOffset, yPdfOffset, scaleFactor * pdfScale, 0);
|
|
||||||
+ TransformationDescription pdfTransform(xPdfOffset, yPdfOffset, scaleFactor, 0);
|
|
||||||
TransformationDescription annotationTransform(xAnnotationsOffset, yAnnotationsOffset, 1, 0);
|
|
||||||
|
|
||||||
- MergePageDescription pageDescription(pageSize.width() * mScaleFactor,
|
|
||||||
- pageSize.height() * mScaleFactor,
|
|
||||||
+ QSizeF pageSize = pdfItem->pageSize();
|
|
||||||
+ MergePageDescription pageDescription(pageSize.width(),
|
|
||||||
+ pageSize.height(),
|
|
||||||
pdfItem->pageNumber(),
|
|
||||||
QFile::encodeName(backgroundPath).constData(),
|
|
||||||
pdfTransform,
|
|
||||||
@@ -276,8 +276,10 @@ bool UBExportFullPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, const QS
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
- MergePageDescription pageDescription(pageSize.width() * mScaleFactor,
|
|
||||||
- pageSize.height() * mScaleFactor,
|
|
||||||
+ QSizeF pageSize = scene->nominalSize() * mScaleFactor;
|
|
||||||
+
|
|
||||||
+ MergePageDescription pageDescription(pageSize.width(),
|
|
||||||
+ pageSize.height(),
|
|
||||||
0,
|
|
||||||
"",
|
|
||||||
TransformationDescription(),
|
|
||||||
@@ -294,7 +296,7 @@ bool UBExportFullPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, const QS
|
|
||||||
merger.saveMergedDocumentsAs(QFile::encodeName(filename).constData());
|
|
||||||
|
|
||||||
}
|
|
||||||
- catch(Exception e)
|
|
||||||
+ catch(const Exception& e)
|
|
||||||
{
|
|
||||||
qDebug() << "PdfMerger failed to merge documents to " << filename << " - Exception : " << e.what();
|
|
||||||
|
|
||||||
diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp
|
|
||||||
index 51995ade2..74cb3e9db 100644
|
|
||||||
--- a/src/domain/UBGraphicsScene.cpp
|
|
||||||
+++ b/src/domain/UBGraphicsScene.cpp
|
|
||||||
@@ -2565,6 +2565,25 @@ QSize UBGraphicsScene::sceneSize()
|
|
||||||
return nominalSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
+QSizeF UBGraphicsScene::sceneSizeF() const
|
|
||||||
+{
|
|
||||||
+ UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*>(backgroundObject());
|
|
||||||
+
|
|
||||||
+ if (pdfItem)
|
|
||||||
+ {
|
|
||||||
+ QRectF targetRect = pdfItem->sceneBoundingRect();
|
|
||||||
+ return targetRect.size();
|
|
||||||
+ }
|
|
||||||
+ else if (mDocument && !mNominalSize.isValid())
|
|
||||||
+ {
|
|
||||||
+ return mDocument->defaultDocumentSize();
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ {
|
|
||||||
+ return mNominalSize;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
void UBGraphicsScene::setNominalSize(const QSize& pSize)
|
|
||||||
{
|
|
||||||
if (nominalSize() != pSize)
|
|
||||||
diff --git a/src/domain/UBGraphicsScene.h b/src/domain/UBGraphicsScene.h
|
|
||||||
index e824e555f..7723880a8 100644
|
|
||||||
--- a/src/domain/UBGraphicsScene.h
|
|
||||||
+++ b/src/domain/UBGraphicsScene.h
|
|
||||||
@@ -308,6 +308,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
|
|
||||||
QSize nominalSize();
|
|
||||||
|
|
||||||
QSize sceneSize();
|
|
||||||
+ QSizeF sceneSizeF() const;
|
|
||||||
|
|
||||||
void setNominalSize(const QSize& pSize);
|
|
||||||
|
|
||||||
diff --git a/src/pdf/GraphicsPDFItem.h b/src/pdf/GraphicsPDFItem.h
|
|
||||||
index 44858e53c..0eb9ed5cd 100644
|
|
||||||
--- a/src/pdf/GraphicsPDFItem.h
|
|
||||||
+++ b/src/pdf/GraphicsPDFItem.h
|
|
||||||
@@ -52,6 +52,7 @@ class GraphicsPDFItem : public QObject, public QGraphicsItem
|
|
||||||
QUuid fileUuid() const { return mRenderer->fileUuid(); }
|
|
||||||
QByteArray fileData() const { return mRenderer->fileData(); }
|
|
||||||
void setCacheAllowed(bool const value) { mIsCacheAllowed = value; }
|
|
||||||
+ QSizeF pageSize() const { return mRenderer->pointSizeF(mPageNumber); }
|
|
||||||
virtual void updateChild() = 0;
|
|
||||||
protected:
|
|
||||||
PDFRenderer *mRenderer;
|
|
||||||
diff --git a/src/pdf/PDFRenderer.h b/src/pdf/PDFRenderer.h
|
|
||||||
index f3b0bf268..8f0cb93e0 100644
|
|
||||||
--- a/src/pdf/PDFRenderer.h
|
|
||||||
+++ b/src/pdf/PDFRenderer.h
|
|
||||||
@@ -56,6 +56,8 @@ class PDFRenderer : public QObject
|
|
||||||
|
|
||||||
virtual int pageRotation(int pageNumber) const = 0;
|
|
||||||
|
|
||||||
+ virtual QSizeF pointSizeF(int pageNumber) const = 0;
|
|
||||||
+
|
|
||||||
virtual QString title() const = 0;
|
|
||||||
|
|
||||||
void attach();
|
|
||||||
diff --git a/src/pdf/XPDFRenderer.cpp b/src/pdf/XPDFRenderer.cpp
|
|
||||||
index 27291dda9..97e258bfd 100644
|
|
||||||
--- a/src/pdf/XPDFRenderer.cpp
|
|
||||||
+++ b/src/pdf/XPDFRenderer.cpp
|
|
||||||
@@ -195,6 +195,20 @@ QString XPDFRenderer::title() const
|
|
||||||
|
|
||||||
|
|
||||||
QSizeF XPDFRenderer::pageSizeF(int pageNumber) const
|
|
||||||
+{
|
|
||||||
+ return pointSizeF(pageNumber) * this->dpiForRendering / 72.0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+int XPDFRenderer::pageRotation(int pageNumber) const
|
|
||||||
+{
|
|
||||||
+ if (mDocument)
|
|
||||||
+ return mDocument->getPageRotate(pageNumber);
|
|
||||||
+ else
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+QSizeF XPDFRenderer::pointSizeF(int pageNumber) const
|
|
||||||
{
|
|
||||||
qreal cropWidth = 0;
|
|
||||||
qreal cropHeight = 0;
|
|
||||||
@@ -203,27 +217,17 @@ QSizeF XPDFRenderer::pageSizeF(int pageNumber) const
|
|
||||||
{
|
|
||||||
int rotate = mDocument->getPageRotate(pageNumber);
|
|
||||||
|
|
||||||
- cropWidth = mDocument->getPageCropWidth(pageNumber) * this->dpiForRendering / 72.0;
|
|
||||||
- cropHeight = mDocument->getPageCropHeight(pageNumber) * this->dpiForRendering / 72.0;
|
|
||||||
+ cropWidth = mDocument->getPageCropWidth(pageNumber);
|
|
||||||
+ cropHeight = mDocument->getPageCropHeight(pageNumber);
|
|
||||||
|
|
||||||
if (rotate == 90 || rotate == 270)
|
|
||||||
{
|
|
||||||
//switching width and height
|
|
||||||
- qreal tmpVar = cropWidth;
|
|
||||||
- cropWidth = cropHeight;
|
|
||||||
- cropHeight = tmpVar;
|
|
||||||
+ std::swap(cropWidth, cropHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- return QSizeF(cropWidth, cropHeight);
|
|
||||||
-}
|
|
||||||
|
|
||||||
-
|
|
||||||
-int XPDFRenderer::pageRotation(int pageNumber) const
|
|
||||||
-{
|
|
||||||
- if (mDocument)
|
|
||||||
- return mDocument->getPageRotate(pageNumber);
|
|
||||||
- else
|
|
||||||
- return 0;
|
|
||||||
+ return QSizeF(cropWidth, cropHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/pdf/XPDFRenderer.h b/src/pdf/XPDFRenderer.h
|
|
||||||
index 919c2ad1c..5ae48ff48 100644
|
|
||||||
--- a/src/pdf/XPDFRenderer.h
|
|
||||||
+++ b/src/pdf/XPDFRenderer.h
|
|
||||||
@@ -85,6 +85,7 @@ class XPDFRenderer : public PDFRenderer
|
|
||||||
virtual int pageCount() const override;
|
|
||||||
virtual QSizeF pageSizeF(int pageNumber) const override;
|
|
||||||
virtual int pageRotation(int pageNumber) const override;
|
|
||||||
+ virtual QSizeF pointSizeF(int pageNumber) const override;
|
|
||||||
virtual QString title() const override;
|
|
||||||
virtual void render(QPainter *p, int pageNumber, const bool cacheAllowed, const QRectF &bounds = QRectF()) override;
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue