diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index 8dc1ef08..efb89425 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -433,9 +433,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() QStringRef pageDpi = mXmlReader.attributes().value("pageDpi"); if (!pageDpi.isNull()) - UBSettings::settings()->pageDpi->set(pageDpi.toString()); + UBSettings::pageDpi = pageDpi.toInt(); else - UBSettings::settings()->pageDpi->set(UBApplication::desktop()->physicalDpiX()); + UBSettings::pageDpi = (UBApplication::desktop()->physicalDpiX() + UBApplication::desktop()->physicalDpiY())/2; bool darkBackground = false; bool crossedBackground = false; @@ -766,8 +766,8 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() { QDesktopWidget* desktop = UBApplication::desktop(); qreal currentDpi = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2; - qDebug() << "currentDpi " << currentDpi; - qreal pdfScale = UBSettings::settings()->pageDpi->get().toReal()/currentDpi; + qDebug() << "currentDpi (" << desktop->physicalDpiX() << " + " << desktop->physicalDpiY() << ")/2 = " << currentDpi; + qreal pdfScale = qreal(UBSettings::pageDpi)/currentDpi; qDebug() << "pdfScale " << pdfScale; pdfItem->setScale(pdfScale); pdfItem->setFlag(QGraphicsItem::ItemIsMovable, true); @@ -827,7 +827,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() { QDesktopWidget* desktop = UBApplication::desktop(); qreal currentDpi = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2; - qreal textSizeMultiplier = UBSettings::settings()->pageDpi->get().toReal()/currentDpi; + qreal textSizeMultiplier = qreal(UBSettings::pageDpi)/currentDpi; textDelegate->scaleTextSize(textSizeMultiplier); } @@ -1051,10 +1051,10 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::writeSvgElement() QDesktopWidget* desktop = UBApplication::desktop(); - if (UBSettings::settings()->pageDpi->get() != 0) - mXmlWriter.writeAttribute("pageDpi", (UBSettings::settings()->pageDpi->get()).toString()); - else - mXmlWriter.writeAttribute("pageDpi", QString("%1").arg((desktop->physicalDpiX() + desktop->physicalDpiY()) / 2)); + if (UBSettings::pageDpi == 0) + UBSettings::pageDpi = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2; + + mXmlWriter.writeAttribute("pageDpi", QString::number(UBSettings::pageDpi)); mXmlWriter.writeStartElement("rect"); mXmlWriter.writeAttribute("fill", mScene->isDarkBackground() ? "black" : "white"); diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index 5a74a416..d0dfc237 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -110,6 +110,8 @@ const int UBSettings::longClickInterval = 1200; const qreal UBSettings::minScreenRatio = 1.33; // 800/600 or 1024/768 +int UBSettings::pageDpi = 0; + QStringList UBSettings::bitmapFileExtensions; QStringList UBSettings::vectoFileExtensions; QStringList UBSettings::imageFileExtensions; @@ -270,7 +272,7 @@ void UBSettings::init() pageSize = new UBSetting(this, "Board", "DefaultPageSize", documentSizes.value(DocumentSizeRatio::Ratio4_3)); - pageDpi = new UBSetting(this, "Board", "pageDpi", 0); + pageDpi = (UBApplication::desktop()->physicalDpiX() + UBApplication::desktop()->physicalDpiY())/ 2; QStringList penLightBackgroundColors; penLightBackgroundColors << "#000000" << "#FF0000" <<"#004080" << "#008000" << "#FFDD00" << "#C87400" << "#800040" << "#008080" << "#5F2D0A" << "#FFFFFF"; diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index bbbcfdb4..b7e0bc08 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -230,6 +230,8 @@ class UBSettings : public QObject static QString appPingMessage; + static int pageDpi; + UBSetting* productWebUrl; QString softwareHomeUrl; @@ -364,7 +366,6 @@ class UBSettings : public QObject UBSetting* communityCredentialsPersistence; UBSetting* pageSize; - UBSetting* pageDpi; UBSetting* KeyboardLocale; UBSetting* swapControlAndDisplayScreens;