Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/board/UBBoardController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,19 @@ void UBBoardController::initBackgroundGridSize()
qreal dpi = UBApplication::displayManager->logicalDpi(ScreenRole::Control);

//qDebug() << "dpi: " << dpi;
int gridSize;

if(UBSettings::settings()->backgroundGridSize()==-1)
{
qreal screenY = UBApplication::displayManager->screenSize(ScreenRole::Control).height();
qreal documentY = mActiveScene->nominalSize().height();
qreal resolutionRatio = documentY / screenY;

//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;
Expand Down
10 changes: 10 additions & 0 deletions src/core/UBSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,16 @@ void UBSettings::setDarkBackground(bool isDarkBackground)
emit colorContextChanged();
}

void UBSettings::setBackgroundGridSize(int value)
{
crossSize = value;
setValue("Board/BackgroundGridSize", value);
}

int UBSettings::backgroundGridSize()
{
return value("Board/BackgroundGridSize", -1).toInt();
}

void UBSettings::setPageBackground(UBPageBackground background)
{
Expand Down
2 changes: 2 additions & 0 deletions src/core/UBSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class UBSettings : public QObject
void setDarkBackground(bool isDarkBackground);
void setPageBackground(UBPageBackground background);
void setSeyesRuledBackground(bool isSeyesRuledBackground);
void setBackgroundGridSize(int value);
int backgroundGridSize();

// Stylus palette related
bool isStylusPaletteVisible();
Expand Down
3 changes: 2 additions & 1 deletion src/gui/UBBackgroundPalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,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()
Expand Down