From 8803239d84a2d0c839351ebb429836959c2e6fab Mon Sep 17 00:00:00 2001 From: letsfindaway Date: Mon, 18 Oct 2021 19:44:34 +0200 Subject: [PATCH 1/2] fix: subtract margin from boundingRect in UBSvgSubsetAdaptor --- src/adaptors/UBSvgSubsetAdaptor.cpp | 56 ++++++++++++++++------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index 62a4e524..cdf6900b 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -355,7 +355,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene(UBDocumentProx time.start(); mScene = 0; UBGraphicsWidgetItem *currentWidget = 0; - bool pageDpiSpecified = true; + //bool pageDpiSpecified = true; saveSceneAfterLoading = false; mFileVersion = 40100; // default to 4.1.0 @@ -443,7 +443,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene(UBDocumentProx else if (proxy->pageDpi() == 0) { proxy->setPageDpi((UBApplication::desktop()->physicalDpiX() + UBApplication::desktop()->physicalDpiY())/2); - pageDpiSpecified = false; + //pageDpiSpecified = false; } bool darkBackground = false; @@ -909,9 +909,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene(UBDocumentProx if (textDelegate) { - QDesktopWidget* desktop = UBApplication::desktop(); - qreal currentDpi = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2; - qreal textSizeMultiplier = qreal(proxy->pageDpi())/currentDpi; + //QDesktopWidget* desktop = UBApplication::desktop(); + //qreal currentDpi = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2; + //qreal textSizeMultiplier = qreal(proxy->pageDpi())/currentDpi; //textDelegate->scaleTextSize(textSizeMultiplier); } @@ -2390,8 +2390,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsItemToSvg(QGraphicsItem* ite mXmlWriter.writeAttribute("x", "0"); mXmlWriter.writeAttribute("y", "0"); - mXmlWriter.writeAttribute("width", QString("%1").arg(item->boundingRect().width())); - mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); + QRectF rect = item->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5); + mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width())); + mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height())); mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix())); @@ -2487,8 +2488,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsWidgetToSvg(UBGraphicsWidget mXmlWriter.writeStartElement(nsXHtml, "iframe"); mXmlWriter.writeAttribute("style", "border: none"); - mXmlWriter.writeAttribute("width", QString("%1").arg(item->boundingRect().width())); - mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); + QRectF rect = item->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5); + mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width())); + mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height())); QString startFileUrl; if (item->mainHtmlFileName().startsWith("http://")) @@ -2817,10 +2819,11 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::curtainItemToSvg(UBGraphicsCurtainIt */ mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "curtain"); - mXmlWriter.writeAttribute("x", QString("%1").arg(curtainItem->boundingRect().center().x())); - mXmlWriter.writeAttribute("y", QString("%1").arg(curtainItem->boundingRect().center().y())); - mXmlWriter.writeAttribute("width", QString("%1").arg(curtainItem->boundingRect().width())); - mXmlWriter.writeAttribute("height", QString("%1").arg(curtainItem->boundingRect().height())); + QRectF rect = curtainItem->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5); + mXmlWriter.writeAttribute("x", QString("%1").arg(rect.center().x())); + mXmlWriter.writeAttribute("y", QString("%1").arg(rect.center().y())); + mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width())); + mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height())); mXmlWriter.writeAttribute("transform", toSvgTransform(curtainItem->sceneMatrix())); //graphicsItemToSvg(curtainItem); @@ -2877,10 +2880,11 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::rulerToSvg(UBGraphicsRuler* item) */ mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "ruler"); - mXmlWriter.writeAttribute("x", QString("%1").arg(item->boundingRect().x())); - mXmlWriter.writeAttribute("y", QString("%1").arg(item->boundingRect().y())); - mXmlWriter.writeAttribute("width", QString("%1").arg(item->boundingRect().width())); - mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); + QRectF rect = item->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5); + mXmlWriter.writeAttribute("x", QString("%1").arg(rect.x())); + mXmlWriter.writeAttribute("y", QString("%1").arg(rect.y())); + mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width())); + mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height())); mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix())); QString zs; @@ -3005,10 +3009,11 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::compassToSvg(UBGraphicsCompass* item */ mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "compass"); - mXmlWriter.writeAttribute("x", QString("%1").arg(item->boundingRect().x())); - mXmlWriter.writeAttribute("y", QString("%1").arg(item->boundingRect().y())); - mXmlWriter.writeAttribute("width", QString("%1").arg(item->boundingRect().width())); - mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); + QRectF rect = item->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5); + mXmlWriter.writeAttribute("x", QString("%1").arg(rect.x())); + mXmlWriter.writeAttribute("y", QString("%1").arg(rect.y())); + mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width())); + mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height())); mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix())); QString zs; @@ -3139,10 +3144,11 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::triangleToSvg(UBGraphicsTriangle *it */ mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "triangle"); - mXmlWriter.writeAttribute("x", QString("%1").arg(item->boundingRect().x())); - mXmlWriter.writeAttribute("y", QString("%1").arg(item->boundingRect().y())); - mXmlWriter.writeAttribute("width", QString("%1").arg(item->boundingRect().width())); - mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); + QRectF rect = item->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5); + mXmlWriter.writeAttribute("x", QString("%1").arg(rect.x())); + mXmlWriter.writeAttribute("y", QString("%1").arg(rect.y())); + mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width())); + mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height())); mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix())); mXmlWriter.writeAttribute("orientation", UBGraphicsTriangle::orientationToStr(item->getOrientation())); From f7974f0b339024767f5186f60fdfd400f4befeb8 Mon Sep 17 00:00:00 2001 From: letsfindaway Date: Mon, 18 Oct 2021 20:23:38 +0200 Subject: [PATCH 2/2] fix: resizing of palettes in UBBoardPaletteManager --- src/board/UBBoardPaletteManager.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index 720fbe9f..31605dbd 100644 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -512,16 +512,18 @@ void UBBoardPaletteManager::containerResized() mKeyboardPalette->adjustSizeAndPosition(); } - if(mLeftPalette) +// NOTE @letsfindaway Fixed, but don't see any reason for this. +// Probably remove. + if(mLeftPalette && mLeftPalette->width() > 0) { mLeftPalette->resize(mLeftPalette->width()-1, mContainer->height()); - mLeftPalette->resize(mLeftPalette->width(), mContainer->height()); + mLeftPalette->resize(mLeftPalette->width()+1, mContainer->height()); } - if(mRightPalette) + if(mRightPalette && mRightPalette->width() > 0) { mRightPalette->resize(mRightPalette->width()-1, mContainer->height()); - mRightPalette->resize(mRightPalette->width(), mContainer->height()); + mRightPalette->resize(mRightPalette->width()+1, mContainer->height()); } }