From 3e8cbb62abe4c8a39efdfd7d6d08c5796c4f4726 Mon Sep 17 00:00:00 2001 From: Evgeniy Kukhtinov Date: Tue, 11 Oct 2022 17:48:17 +0300 Subject: [PATCH 08/10] background-grid-size-save --- src/board/UBBoardController.cpp | 8 +++++++- src/core/UBSettings.cpp | 10 ++++++++++ src/core/UBSettings.h | 2 ++ src/gui/UBBackgroundPalette.cpp | 3 ++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index 21b2b86..b4d1c82 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -178,6 +178,10 @@ void UBBoardController::initBackgroundGridSize() //qDebug() << "dpi: " << dpi; + int gridSize; + + if(UBSettings::settings()->backgroundGridSize()==-1) + { // The display manager isn't initialized yet so we have to just assume the control view is on the main display qreal screenY = desktop->screenGeometry(mControlView).height(); qreal documentY = mActiveScene->nominalSize().height(); @@ -185,7 +189,9 @@ void UBBoardController::initBackgroundGridSize() //qDebug() << "resolution ratio: " << resolutionRatio; - int gridSize = (resolutionRatio * 10. * dpi) / UBGeometryUtils::inchSize; + gridSize = (resolutionRatio * 10. * dpi) / UBGeometryUtils::inchSize; + } else + gridSize = UBSettings::settings()->backgroundGridSize(); UBSettings::settings()->crossSize = gridSize; UBSettings::settings()->defaultCrossSize = gridSize; diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index 6a196fc..b368ac0 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -870,6 +870,16 @@ void UBSettings::setPageBackground(UBPageBackground background) setValue("Board/PageBackground", val); } +void UBSettings::setBackgroundGridSize(int value) +{ + crossSize = value; + setValue("Board/BackgroundGridSize", value); +} + +int UBSettings::backgroundGridSize() +{ + return value("Board/BackgroundGridSize", -1).toInt(); +} void UBSettings::setPenPressureSensitive(bool sensitive) { diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index fdca53c..0d81dc4 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -94,6 +94,8 @@ class UBSettings : public QObject UBPageBackground pageBackground(); void setDarkBackground(bool isDarkBackground); void setPageBackground(UBPageBackground background); + void setBackgroundGridSize(int value); + int backgroundGridSize(); // Stylus palette related bool isStylusPaletteVisible(); diff --git a/src/gui/UBBackgroundPalette.cpp b/src/gui/UBBackgroundPalette.cpp index b975b33..3c4910c 100644 --- a/src/gui/UBBackgroundPalette.cpp +++ b/src/gui/UBBackgroundPalette.cpp @@ -169,7 +169,8 @@ void UBBackgroundPalette::showEvent(QShowEvent* event) void UBBackgroundPalette::sliderValueChanged(int value) { UBApplication::boardController->activeScene()->setBackgroundGridSize(value); - UBSettings::settings()->crossSize = value; // since this function is called (indirectly, by refresh) when we switch scenes, the settings will always have the current scene's cross size. + UBSettings::settings()->setBackgroundGridSize(value); + //UBSettings::settings()->crossSize = value; // since this function is called (indirectly, by refresh) when we switch scenes, the settings will always have the current scene's cross size. } void UBBackgroundPalette::defaultBackgroundGridSize() -- 2.25.4