Merge pull request #533 from letsfindaway/bug-527-palette-and-tool-resize

Fix bug 527: palette and tool resize
preferencesAboutTextFull
kaamui 3 years ago committed by GitHub
commit a578f53bb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 56
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 10
      src/board/UBBoardPaletteManager.cpp

@ -357,7 +357,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene(UBDocumentProx
time.start(); time.start();
mScene = 0; mScene = 0;
UBGraphicsWidgetItem *currentWidget = 0; UBGraphicsWidgetItem *currentWidget = 0;
bool pageDpiSpecified = true; //bool pageDpiSpecified = true;
saveSceneAfterLoading = false; saveSceneAfterLoading = false;
mFileVersion = 40100; // default to 4.1.0 mFileVersion = 40100; // default to 4.1.0
@ -445,7 +445,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene(UBDocumentProx
else if (proxy->pageDpi() == 0) { else if (proxy->pageDpi() == 0) {
proxy->setPageDpi((UBApplication::desktop()->physicalDpiX() + UBApplication::desktop()->physicalDpiY())/2); proxy->setPageDpi((UBApplication::desktop()->physicalDpiX() + UBApplication::desktop()->physicalDpiY())/2);
pageDpiSpecified = false; //pageDpiSpecified = false;
} }
bool darkBackground = false; bool darkBackground = false;
@ -911,9 +911,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene(UBDocumentProx
if (textDelegate) if (textDelegate)
{ {
QDesktopWidget* desktop = UBApplication::desktop(); //QDesktopWidget* desktop = UBApplication::desktop();
qreal currentDpi = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2; //qreal currentDpi = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2;
qreal textSizeMultiplier = qreal(proxy->pageDpi())/currentDpi; //qreal textSizeMultiplier = qreal(proxy->pageDpi())/currentDpi;
//textDelegate->scaleTextSize(textSizeMultiplier); //textDelegate->scaleTextSize(textSizeMultiplier);
} }
@ -2392,8 +2392,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsItemToSvg(QGraphicsItem* ite
mXmlWriter.writeAttribute("x", "0"); mXmlWriter.writeAttribute("x", "0");
mXmlWriter.writeAttribute("y", "0"); mXmlWriter.writeAttribute("y", "0");
mXmlWriter.writeAttribute("width", QString("%1").arg(item->boundingRect().width())); QRectF rect = item->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5);
mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width()));
mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height()));
mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix())); mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix()));
@ -2489,8 +2490,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsWidgetToSvg(UBGraphicsWidget
mXmlWriter.writeStartElement(nsXHtml, "iframe"); mXmlWriter.writeStartElement(nsXHtml, "iframe");
mXmlWriter.writeAttribute("style", "border: none"); mXmlWriter.writeAttribute("style", "border: none");
mXmlWriter.writeAttribute("width", QString("%1").arg(item->boundingRect().width())); QRectF rect = item->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5);
mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width()));
mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height()));
QString startFileUrl; QString startFileUrl;
if (item->mainHtmlFileName().startsWith("http://")) if (item->mainHtmlFileName().startsWith("http://"))
@ -2819,10 +2821,11 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::curtainItemToSvg(UBGraphicsCurtainIt
*/ */
mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "curtain"); mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "curtain");
mXmlWriter.writeAttribute("x", QString("%1").arg(curtainItem->boundingRect().center().x())); QRectF rect = curtainItem->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5);
mXmlWriter.writeAttribute("y", QString("%1").arg(curtainItem->boundingRect().center().y())); mXmlWriter.writeAttribute("x", QString("%1").arg(rect.center().x()));
mXmlWriter.writeAttribute("width", QString("%1").arg(curtainItem->boundingRect().width())); mXmlWriter.writeAttribute("y", QString("%1").arg(rect.center().y()));
mXmlWriter.writeAttribute("height", QString("%1").arg(curtainItem->boundingRect().height())); mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width()));
mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height()));
mXmlWriter.writeAttribute("transform", toSvgTransform(curtainItem->sceneMatrix())); mXmlWriter.writeAttribute("transform", toSvgTransform(curtainItem->sceneMatrix()));
//graphicsItemToSvg(curtainItem); //graphicsItemToSvg(curtainItem);
@ -2879,10 +2882,11 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::rulerToSvg(UBGraphicsRuler* item)
*/ */
mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "ruler"); mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "ruler");
mXmlWriter.writeAttribute("x", QString("%1").arg(item->boundingRect().x())); QRectF rect = item->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5);
mXmlWriter.writeAttribute("y", QString("%1").arg(item->boundingRect().y())); mXmlWriter.writeAttribute("x", QString("%1").arg(rect.x()));
mXmlWriter.writeAttribute("width", QString("%1").arg(item->boundingRect().width())); mXmlWriter.writeAttribute("y", QString("%1").arg(rect.y()));
mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width()));
mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height()));
mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix())); mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix()));
QString zs; QString zs;
@ -3007,10 +3011,11 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::compassToSvg(UBGraphicsCompass* item
*/ */
mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "compass"); mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "compass");
mXmlWriter.writeAttribute("x", QString("%1").arg(item->boundingRect().x())); QRectF rect = item->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5);
mXmlWriter.writeAttribute("y", QString("%1").arg(item->boundingRect().y())); mXmlWriter.writeAttribute("x", QString("%1").arg(rect.x()));
mXmlWriter.writeAttribute("width", QString("%1").arg(item->boundingRect().width())); mXmlWriter.writeAttribute("y", QString("%1").arg(rect.y()));
mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width()));
mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height()));
mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix())); mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix()));
QString zs; QString zs;
@ -3141,10 +3146,11 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::triangleToSvg(UBGraphicsTriangle *it
*/ */
mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "triangle"); mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "triangle");
mXmlWriter.writeAttribute("x", QString("%1").arg(item->boundingRect().x())); QRectF rect = item->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5);
mXmlWriter.writeAttribute("y", QString("%1").arg(item->boundingRect().y())); mXmlWriter.writeAttribute("x", QString("%1").arg(rect.x()));
mXmlWriter.writeAttribute("width", QString("%1").arg(item->boundingRect().width())); mXmlWriter.writeAttribute("y", QString("%1").arg(rect.y()));
mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width()));
mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height()));
mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix())); mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix()));
mXmlWriter.writeAttribute("orientation", UBGraphicsTriangle::orientationToStr(item->getOrientation())); mXmlWriter.writeAttribute("orientation", UBGraphicsTriangle::orientationToStr(item->getOrientation()));

@ -512,16 +512,18 @@ void UBBoardPaletteManager::containerResized()
mKeyboardPalette->adjustSizeAndPosition(); 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()-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()-1, mContainer->height());
mRightPalette->resize(mRightPalette->width(), mContainer->height()); mRightPalette->resize(mRightPalette->width()+1, mContainer->height());
} }
} }

Loading…
Cancel
Save