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
11 changes: 2 additions & 9 deletions src/board/UBBoardController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ void UBBoardController::init()

setActiveDocumentScene(doc);

connect(UBApplication::displayManager, &UBDisplayManager::screenRolesAssigned, this, [this](){
initBackgroundGridSize();
});

undoRedoStateChange(true);

}
Expand All @@ -170,7 +166,7 @@ UBBoardController::~UBBoardController()
/**
* @brief Set the default background grid size to appear as roughly 1cm on screen
*/
void UBBoardController::initBackgroundGridSize()
int UBBoardController::determineBackgroundGridSize() const
{
// Besides adjusting for DPI, we also need to scale the grid size by the ratio of the control view size
// to document size. Here we approximate this ratio as (document resolution) / (screen resolution).
Expand All @@ -188,10 +184,7 @@ void UBBoardController::initBackgroundGridSize()

int gridSize = (resolutionRatio * 10. * dpi) / UBGeometryUtils::inchSize;

UBSettings::settings()->crossSize = gridSize;
UBSettings::settings()->defaultCrossSize = gridSize;
mActiveScene->setBackgroundGridSize(gridSize);

return gridSize;
//qDebug() << "grid size: " << gridSize;
}

Expand Down
4 changes: 3 additions & 1 deletion src/board/UBBoardController.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ class UBBoardController : public UBDocumentContainer

void saveData(SaveFlags fls = sf_none);

int determineBackgroundGridSize() const;


//void regenerateThumbnails();

signals:
Expand Down Expand Up @@ -291,7 +294,6 @@ class UBBoardController : public UBDocumentContainer
void appMainModeChanged(UBApplicationController::MainMode);

private:
void initBackgroundGridSize();
void updatePageSizeState();
void saveViewState();
int autosaveTimeoutFromSettings();
Expand Down
2 changes: 1 addition & 1 deletion src/core/UBPersistenceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ std::shared_ptr<UBGraphicsScene> UBPersistenceManager::createDocumentSceneAt(std
newScene->setBackground(UBSettings::settings()->isDarkBackground(),
UBSettings::settings()->UBSettings::pageBackground());

newScene->setBackgroundGridSize(UBSettings::settings()->crossSize);
newScene->setBackgroundGridSize(UBSettings::settings()->crossSize->get().toInt());

proxy->incPageCount();

Expand Down
1 change: 1 addition & 0 deletions src/core/UBPreferencesController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ void UBPreferencesController::wire()
mPreferencesUI->crossColorDarkBackgroundFrame->setPalette(darkBackgroundPalette);
mPreferencesUI->crossColorDarkBackgroundLabel->setPalette(darkBackgroundPalette);


QList<QColor> gridLightBackgroundColors = settings->boardGridLightBackgroundColors->colors();
QColor selectedCrossColorLightBackground(settings->boardCrossColorLightBackground->get().toString());

Expand Down
4 changes: 2 additions & 2 deletions src/core/UBSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
QPointer<UBSettings> UBSettings::sSingleton = 0;

int UBSettings::pointerDiameter = 40;
int UBSettings::crossSize = 24;
int UBSettings::defaultCrossSize = 24;
int UBSettings::minCrossSize = 12;
int UBSettings::maxCrossSize = 96; //TODO: user-settable?
bool UBSettings::intermediateLines = false;
Expand Down Expand Up @@ -304,6 +302,8 @@ void UBSettings::init()
boardCrossColorDarkBackground = new UBSetting(this, "Board", "CrossColorDarkBackground", "#C8C0C0C0");
boardCrossColorLightBackground = new UBSetting(this, "Board", "CrossColorLightBackground", "#A5E1FF");

crossSize = new UBSetting(this, "Board", "GridSize", 40);

QStringList gridLightBackgroundColors;
gridLightBackgroundColors << "#000000" << "#FF0000" << "#004080" << "#008000" << "#FFDD00" << "#C87400" << "#800040" << "#008080" << "#A5E1FF";
boardGridLightBackgroundColors = new UBColorListSetting(this, "Board", "GridLightBackgroundColors", gridLightBackgroundColors, -1.0);
Expand Down
4 changes: 2 additions & 2 deletions src/core/UBSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ class UBSettings : public QObject
static QColor documentSizeMarkColorLightBackground;

// Background grid
static int crossSize;
static int defaultCrossSize;
static int minCrossSize;
static int maxCrossSize;
static bool intermediateLines;
Expand Down Expand Up @@ -306,6 +304,8 @@ class UBSettings : public QObject
UBSetting* boardCrossColorDarkBackground;
UBSetting* boardCrossColorLightBackground;

UBSetting* crossSize;

UBColorListSetting* boardGridLightBackgroundColors;
UBColorListSetting* boardGridDarkBackgroundColors;

Expand Down
2 changes: 1 addition & 1 deletion src/domain/UBGraphicsScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ UBGraphicsScene::UBGraphicsScene(std::shared_ptr<UBDocumentProxy> document, bool
UBApplication::applicationController->initialVScroll()));
}

mBackgroundGridSize = UBSettings::settings()->crossSize;
mBackgroundGridSize = UBSettings::settings()->crossSize->get().toInt();
mIntermediateLines = UBSettings::settings()->intermediateLines;

// Just for debug. Do not delete please
Expand Down
7 changes: 4 additions & 3 deletions src/gui/UBBackgroundPalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,15 @@ void UBBackgroundPalette::showEvent(QShowEvent* event)

void UBBackgroundPalette::sliderValueChanged(int value)
{
UBSettings::settings()->crossSize->setInt(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.
}

void UBBackgroundPalette::defaultBackgroundGridSize()
{
mSlider->setValue(UBSettings::settings()->defaultCrossSize);
sliderValueChanged(UBSettings::settings()->defaultCrossSize);
int crossSize = UBApplication::boardController->determineBackgroundGridSize();
mSlider->setValue(crossSize);
sliderValueChanged(crossSize);
}

void UBBackgroundPalette::toggleIntermediateLines(bool checked)
Expand Down