- The background selection palette now includes a slider to change the size of the background grid. Default min/max values are 16 and 64px, defined in UBSettings. Grid resizes dynamically as the slider is moved. - Measuring tools' (ruler, triangle) markers follow grid size: 1 square of the background grid corresponds to 1cm - Grid size can be different for each page of a document - Grid size is saved in the .svg - Documents with a background grid but no specified grid size follow the default size defined in UBSettings. Previously, grid size was calculated based on DPI, which can vary from one OS, computer or display to the next. This new setting allows documents to be migrated from one machine to another with no unexpected changes in grid size happening. It also makes it easy to correct any problems importing old documents (whose grid size might be smaller or larger than expected when imported on a new version of OpenBoard).preferencesAboutTextFull
parent
9b7993c59e
commit
081dbee1ed
@ -0,0 +1,153 @@ |
|||||||
|
#include "UBBackgroundPalette.h" |
||||||
|
|
||||||
|
UBBackgroundPalette::UBBackgroundPalette(QList<QAction*> actions, QWidget * parent) |
||||||
|
: UBActionPalette(parent) |
||||||
|
{ |
||||||
|
init(); |
||||||
|
setActions(actions); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
UBBackgroundPalette::UBBackgroundPalette(QWidget * parent) |
||||||
|
: UBActionPalette(parent) |
||||||
|
{ |
||||||
|
init(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void UBBackgroundPalette::init() |
||||||
|
{ |
||||||
|
UBActionPalette::clearLayout(); |
||||||
|
delete layout(); |
||||||
|
|
||||||
|
|
||||||
|
m_customCloseProcessing = false; |
||||||
|
|
||||||
|
mButtonSize = QSize(32, 32); |
||||||
|
mIsClosable = false; |
||||||
|
mAutoClose = false; |
||||||
|
mButtonGroup = 0; |
||||||
|
mToolButtonStyle = Qt::ToolButtonIconOnly; |
||||||
|
mButtons.clear(); |
||||||
|
|
||||||
|
mVLayout = new QVBoxLayout(this); |
||||||
|
mTopLayout = new QHBoxLayout(); |
||||||
|
mBottomLayout = new QHBoxLayout(); |
||||||
|
|
||||||
|
mVLayout->addLayout(mTopLayout); |
||||||
|
mVLayout->addLayout(mBottomLayout); |
||||||
|
|
||||||
|
mSlider = new QSlider(Qt::Horizontal); |
||||||
|
|
||||||
|
mSlider->setMinimum(UBSettings::settings()->minCrossSize); |
||||||
|
mSlider->setMaximum(UBSettings::settings()->maxCrossSize); |
||||||
|
mSlider->setSingleStep(2); |
||||||
|
mSlider->setTracking(true); // valueChanged() is emitted during movement and not just upon releasing the slider
|
||||||
|
|
||||||
|
mSliderLabel = new QLabel(tr("Grid size")); |
||||||
|
|
||||||
|
mBottomLayout->addSpacing(16); |
||||||
|
mBottomLayout->addWidget(mSliderLabel); |
||||||
|
mBottomLayout->addWidget(mSlider); |
||||||
|
mBottomLayout->addSpacing(16); |
||||||
|
|
||||||
|
updateLayout(); |
||||||
|
} |
||||||
|
|
||||||
|
void UBBackgroundPalette::addAction(QAction* action) |
||||||
|
{ |
||||||
|
UBActionPaletteButton* button = createPaletteButton(action, this); |
||||||
|
|
||||||
|
mTopLayout->addWidget(button); |
||||||
|
mActions << action; |
||||||
|
} |
||||||
|
|
||||||
|
void UBBackgroundPalette::setActions(QList<QAction*> actions) |
||||||
|
{ |
||||||
|
mMapActionToButton.clear(); |
||||||
|
|
||||||
|
foreach(QAction* action, actions) |
||||||
|
{ |
||||||
|
addAction(action); |
||||||
|
} |
||||||
|
|
||||||
|
actionChanged(); |
||||||
|
} |
||||||
|
|
||||||
|
void UBBackgroundPalette::updateLayout() |
||||||
|
{ |
||||||
|
if (mToolButtonStyle == Qt::ToolButtonIconOnly) { |
||||||
|
mVLayout->setContentsMargins (sLayoutContentMargin / 2 + border(), sLayoutContentMargin / 2 + border() |
||||||
|
, sLayoutContentMargin / 2 + border(), sLayoutContentMargin / 2 + border()); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
mVLayout->setContentsMargins (sLayoutContentMargin + border(), sLayoutContentMargin + border() |
||||||
|
, sLayoutContentMargin + border(), sLayoutContentMargin + border()); |
||||||
|
|
||||||
|
} |
||||||
|
update(); |
||||||
|
} |
||||||
|
|
||||||
|
void UBBackgroundPalette::clearLayout() |
||||||
|
{ |
||||||
|
while(!mTopLayout->isEmpty()) { |
||||||
|
QLayoutItem* pItem = mTopLayout->itemAt(0); |
||||||
|
QWidget* pW = pItem->widget(); |
||||||
|
mTopLayout->removeItem(pItem); |
||||||
|
delete pItem; |
||||||
|
mTopLayout->removeWidget(pW); |
||||||
|
delete pW; |
||||||
|
} |
||||||
|
|
||||||
|
delete mTopLayout; |
||||||
|
|
||||||
|
while(!mBottomLayout->isEmpty()) { |
||||||
|
QLayoutItem* pItem = mBottomLayout->itemAt(0); |
||||||
|
QWidget* pW = pItem->widget(); |
||||||
|
mBottomLayout->removeItem(pItem); |
||||||
|
delete pItem; |
||||||
|
mBottomLayout->removeWidget(pW); |
||||||
|
delete pW; |
||||||
|
} |
||||||
|
|
||||||
|
delete mBottomLayout; |
||||||
|
|
||||||
|
delete mVLayout; |
||||||
|
|
||||||
|
mActions.clear(); |
||||||
|
mButtons.clear(); |
||||||
|
} |
||||||
|
|
||||||
|
void UBBackgroundPalette::showEvent(QShowEvent* event) |
||||||
|
{ |
||||||
|
backgroundChanged(); |
||||||
|
|
||||||
|
mSlider->setValue(UBApplication::boardController->activeScene()->backgroundGridSize()); |
||||||
|
connect(mSlider, SIGNAL(valueChanged(int)), |
||||||
|
this, SLOT(sliderValueChanged(int))); |
||||||
|
|
||||||
|
QWidget::showEvent(event); |
||||||
|
} |
||||||
|
|
||||||
|
void UBBackgroundPalette::sliderValueChanged(int value) |
||||||
|
{ |
||||||
|
UBApplication::boardController->activeScene()->setBackgroundGridSize(value); |
||||||
|
} |
||||||
|
|
||||||
|
void UBBackgroundPalette::backgroundChanged() |
||||||
|
{ |
||||||
|
bool dark = UBApplication::boardController->activeScene()->isDarkBackground(); |
||||||
|
|
||||||
|
if (dark) |
||||||
|
mSliderLabel->setStyleSheet("QLabel { color : white; }"); |
||||||
|
else |
||||||
|
mSliderLabel->setStyleSheet("QLabel { color : black; }"); |
||||||
|
} |
||||||
|
|
||||||
|
void UBBackgroundPalette::refresh() |
||||||
|
{ |
||||||
|
backgroundChanged(); |
||||||
|
mSlider->setValue(UBApplication::boardController->activeScene()->backgroundGridSize()); |
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
#ifndef UBBACKGROUNDPALETTE_H |
||||||
|
#define UBBACKGROUNDPALETTE_H |
||||||
|
|
||||||
|
#include "gui/UBActionPalette.h" |
||||||
|
#include "core/UBApplication.h" |
||||||
|
#include "board/UBBoardController.h" |
||||||
|
#include "domain/UBGraphicsScene.h" |
||||||
|
|
||||||
|
class UBBackgroundPalette : public UBActionPalette |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
|
||||||
|
public: |
||||||
|
|
||||||
|
UBBackgroundPalette(QList<QAction*> actions, QWidget* parent = 0); |
||||||
|
UBBackgroundPalette(QWidget* parent = 0); |
||||||
|
|
||||||
|
void addAction(QAction *action); |
||||||
|
void setActions(QList<QAction *> actions); |
||||||
|
void clearLayout(); |
||||||
|
|
||||||
|
|
||||||
|
public slots: |
||||||
|
void showEvent(QShowEvent* event); |
||||||
|
void backgroundChanged(); |
||||||
|
void refresh(); |
||||||
|
|
||||||
|
protected slots: |
||||||
|
void sliderValueChanged(int value); |
||||||
|
|
||||||
|
protected: |
||||||
|
virtual void updateLayout(); |
||||||
|
void init(); |
||||||
|
|
||||||
|
|
||||||
|
QVBoxLayout* mVLayout; |
||||||
|
QHBoxLayout* mTopLayout; |
||||||
|
QHBoxLayout* mBottomLayout; |
||||||
|
|
||||||
|
QSlider* mSlider; |
||||||
|
QLabel* mSliderLabel; |
||||||
|
|
||||||
|
|
||||||
|
}; |
||||||
|
|
||||||
|
#endif // UBBACKGROUNDPALETTE_H
|
Loading…
Reference in new issue