Commit c6c0120a authored by Clément Fauconnier's avatar Clément Fauconnier

added grid tab on preferences to handle grid color and opacity parameters

parent 0d66ec25
......@@ -25,12 +25,14 @@ UseSystemOnScreenKeyboard=true
[Board]
AutoSaveIntervalInMinutes=3
CrossColorDarkBackground=#C8C0C0C0
CrossColorDarkBackground=#C82C2C2C
CrossColorLightBackground=#A5E1FF
DarkBackground=0
DefaultPageSize=@Size(1280 960)
EraserCircleWidthIndex=1
FeatureSliderPosition=40
GridDarkBackgroundColors=#FFFFFF, #FF3400, #66C0FF, #81FF5C, #FFFF00, #B68360, #FF497E, #8D69FF, #C82C2C2C
GridLightBackgroundColors=#000000, #FF0000, #004080, #008000, #FFDD00, #C87400, #800040, #008080, #5F2D0A, #A5E1FF
InterpolateMarkerStrokes=true
InterpolatePenStrokes=true
KeyboardPaletteKeyBtnSize=16x16
......
This diff is collapsed.
This diff is collapsed.
......@@ -39,6 +39,7 @@
#include "core/UBDisplayManager.h"
#include "board/UBBoardController.h"
#include "domain/UBGraphicsScene.h"
#include "board/UBDrawingController.h"
#include "podcast/UBPodcastController.h"
......@@ -76,6 +77,8 @@ UBPreferencesController::UBPreferencesController(QWidget *parent)
, mPreferencesUI(0)
, mPenProperties(0)
, mMarkerProperties(0)
, mDarkBackgroundGridColorPicker(0)
, mLightBackgroundGridColorPicker(0)
{
mDesktop = qApp->desktop();
mPreferencesWindow = new UBPreferencesDialog(this,parent, Qt::Dialog);
......@@ -97,6 +100,10 @@ UBPreferencesController::~UBPreferencesController()
delete mPenProperties;
delete mMarkerProperties;
delete mDarkBackgroundGridColorPicker;
delete mLightBackgroundGridColorPicker;
}
void UBPreferencesController::adjustScreens(int screen)
......@@ -149,6 +156,43 @@ void UBPreferencesController::wire()
connect(mPreferencesUI->verticalChoice, SIGNAL(clicked(bool)), this, SLOT(toolbarOrientationVertical(bool)));
connect(mPreferencesUI->toolbarDisplayTextCheckBox, SIGNAL(clicked(bool)), settings->appToolBarDisplayText, SLOT(setBool(bool)));
//grid tab
//On light background
QList<QColor> gridLightBackgroundColors = settings->boardGridLightBackgroundColors->colors();
QColor selectedCrossColorLightBackground(settings->boardCrossColorLightBackground->get().toString());
mLightBackgroundGridColorPicker = new UBColorPicker(mPreferencesUI->crossColorLightBackgroundFrame);
mLightBackgroundGridColorPicker->setObjectName(QString::fromUtf8("crossColorLightBackgroundFrame"));
mLightBackgroundGridColorPicker->setMinimumSize(QSize(32, 32));
mLightBackgroundGridColorPicker->setFrameShape(QFrame::StyledPanel);
mLightBackgroundGridColorPicker->setFrameShadow(QFrame::Raised);
mPreferencesUI->crossColorLightBackgroundLayout->addWidget(mLightBackgroundGridColorPicker);
mLightBackgroundGridColorPicker->setColors(gridLightBackgroundColors);
mLightBackgroundGridColorPicker->setSelectedColorIndex(gridLightBackgroundColors.indexOf(selectedCrossColorLightBackground));
mPreferencesUI->lightBackgroundOpacitySlider->setValue(selectedCrossColorLightBackground.alpha()*100 / 255);
QObject::connect(mLightBackgroundGridColorPicker, SIGNAL(colorSelected(const QColor&)), this, SLOT(setCrossColorOnLightBackground(const QColor&)));
connect(mPreferencesUI->lightBackgroundOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(lightBackgroundCrossOpacityValueChanged(int)));
//On dark background
QList<QColor> gridDarkBackgroundColors = settings->boardGridDarkBackgroundColors->colors();
QColor selectedCrossColorDarkBackground(settings->boardCrossColorDarkBackground->get().toString());
mDarkBackgroundGridColorPicker = new UBColorPicker(mPreferencesUI->crossColorDarkBackgroundFrame);
mDarkBackgroundGridColorPicker->setObjectName(QString::fromUtf8("crossColorDarkBackgroundFrame"));
mDarkBackgroundGridColorPicker->setMinimumSize(QSize(32, 32));
mDarkBackgroundGridColorPicker->setFrameShape(QFrame::StyledPanel);
mDarkBackgroundGridColorPicker->setFrameShadow(QFrame::Raised);
mPreferencesUI->crossColorDarkBackgroundLayout->addWidget(mDarkBackgroundGridColorPicker);
mDarkBackgroundGridColorPicker->setColors(gridDarkBackgroundColors);
mDarkBackgroundGridColorPicker->setSelectedColorIndex(gridDarkBackgroundColors.indexOf(selectedCrossColorDarkBackground));
mPreferencesUI->darkBackgroundOpacitySlider->setValue(selectedCrossColorDarkBackground.alpha()*100 / 255);
QObject::connect(mDarkBackgroundGridColorPicker, SIGNAL(colorSelected(const QColor&)), this, SLOT(setCrossColorOnDarkBackground(const QColor&)));
connect(mPreferencesUI->darkBackgroundOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(darkBackgroundCrossOpacityValueChanged(int)));
// pen
QList<QColor> penLightBackgroundColors = settings->boardPenLightBackgroundColors->colors();
QList<QColor> penDarkBackgroundColors = settings->boardPenDarkBackgroundColors->colors();
......@@ -340,6 +384,54 @@ void UBPreferencesController::defaultSettings()
}
void UBPreferencesController::darkBackgroundCrossOpacityValueChanged(int value)
{
UBSettings* settings = UBSettings::settings();
int opacity = value * 255 / 100;
QList<QColor> gridDarkBackgroundColors = settings->boardGridDarkBackgroundColors->colors();
int index = mDarkBackgroundGridColorPicker->selectedColorIndex();
QColor currentColor = gridDarkBackgroundColors.at(index);
currentColor.setAlpha(opacity);
gridDarkBackgroundColors.replace(index, currentColor);
mDarkBackgroundGridColorPicker->setColors(gridDarkBackgroundColors);
settings->boardGridDarkBackgroundColors->setColor(index, currentColor);
UBSettings::settings()->boardCrossColorDarkBackground->set(currentColor.name(QColor::HexArgb));
if (UBApplication::boardController && UBApplication::boardController->activeScene())
{
foreach(QGraphicsView* view, UBApplication::boardController->activeScene()->views())
view->resetCachedContent();
}
}
void UBPreferencesController::lightBackgroundCrossOpacityValueChanged(int value)
{
UBSettings* settings = UBSettings::settings();
int opacity = value * 255 / 100;
QList<QColor> gridLightBackgroundColors = settings->boardGridLightBackgroundColors->colors();
int index = mLightBackgroundGridColorPicker->selectedColorIndex();
QColor currentColor = gridLightBackgroundColors.at(index);
currentColor.setAlpha(opacity);
gridLightBackgroundColors.replace(index, currentColor);
mLightBackgroundGridColorPicker->setColors(gridLightBackgroundColors);
settings->boardGridLightBackgroundColors->setColor(index, currentColor);
UBSettings::settings()->boardCrossColorLightBackground->set(currentColor.name(QColor::HexArgb));
if (UBApplication::boardController && UBApplication::boardController->activeScene())
{
foreach(QGraphicsView* view, UBApplication::boardController->activeScene()->views())
view->resetCachedContent();
}
}
void UBPreferencesController::penPreviewFromSizeChanged(int value)
{
UBSettings::settings()->setPenPreviewFromSize(value);
......@@ -446,6 +538,31 @@ void UBPreferencesController::colorSelected(const QColor& color)
}
void UBPreferencesController::setCrossColorOnDarkBackground(const QColor& color)
{
UBSettings::settings()->boardCrossColorDarkBackground->set(color.name(QColor::HexArgb));
mPreferencesUI->darkBackgroundOpacitySlider->setValue(color.alpha() * 100 / 255);
if (UBApplication::boardController && UBApplication::boardController->activeScene())
{
foreach(QGraphicsView* view, UBApplication::boardController->activeScene()->views())
view->resetCachedContent();
}
}
void UBPreferencesController::setCrossColorOnLightBackground(const QColor& color)
{
UBSettings::settings()->boardCrossColorLightBackground->set(color.name(QColor::HexArgb));
mPreferencesUI->lightBackgroundOpacitySlider->setValue(color.alpha() * 100 / 255);
if (UBApplication::boardController && UBApplication::boardController->activeScene())
{
foreach(QGraphicsView* view, UBApplication::boardController->activeScene()->views())
view->resetCachedContent();
}
}
void UBPreferencesController::toolbarPositionChanged(bool checked)
{
......
......@@ -47,7 +47,6 @@ namespace Ui
class UBBrushPropertiesFrame;
class UBPreferencesDialog : public QDialog
{
Q_OBJECT;
......@@ -84,15 +83,21 @@ class UBPreferencesController : public QObject
Ui::preferencesDialog* mPreferencesUI;
UBBrushPropertiesFrame* mPenProperties;
UBBrushPropertiesFrame* mMarkerProperties;
UBColorPicker* mDarkBackgroundGridColorPicker;
UBColorPicker* mLightBackgroundGridColorPicker;
protected slots:
void close();
void defaultSettings();
void penPreviewFromSizeChanged(int value);
void darkBackgroundCrossOpacityValueChanged(int value);
void lightBackgroundCrossOpacityValueChanged(int value);
void widthSliderChanged(int value);
void opacitySliderChanged(int value);
void colorSelected(const QColor&);
void setCrossColorOnDarkBackground(const QColor& color);
void setCrossColorOnLightBackground(const QColor& color);
void toolbarPositionChanged(bool checked);
void toolbarOrientationVertical(bool checked);
void toolbarOrientationHorizontal(bool checked);
......@@ -122,5 +127,4 @@ class UBBrushPropertiesFrame : public Ui::brushProperties
};
#endif /* UBPREFERENCESCONTROLLER_H_ */
......@@ -105,13 +105,16 @@ UBColorListSetting::UBColorListSetting(UBSettings* owner, const QString& pDomain
: UBSetting(owner, pDomain, pKey, pDefaultValue)
, mAlpha(pAlpha)
{
foreach(QString s, get().toStringList())
{
QColor color;
color.setNamedColor(s);
color.setAlphaF(mAlpha);
if (mAlpha>=0)
color.setAlphaF(mAlpha);
mColors.append(color);
}
}
UBColorListSetting::~UBColorListSetting()
......@@ -129,7 +132,9 @@ QVariant UBColorListSetting::reset()
{
QColor color;
color.setNamedColor(s);
color.setAlphaF(mAlpha);
if (mAlpha>=0)
color.setAlphaF(mAlpha);
mColors.append(color);
}
......@@ -146,10 +151,15 @@ QList<QColor> UBColorListSetting::colors() const
void UBColorListSetting::setColor(int pIndex, const QColor& color)
{
QStringList list = get().toStringList();
list.replace(pIndex, color.name());
QColor c = color;
c.setAlphaF(mAlpha);
mColors.replace(pIndex, c);
list.replace(pIndex, color.name(QColor::HexArgb));
if (mAlpha>=0)
{
QColor c = color;
c.setAlphaF(mAlpha);
mColors.replace(pIndex, c);
}
else
mColors.replace(pIndex, color);
set(list);
}
......
......@@ -286,10 +286,17 @@ void UBSettings::init()
pageSize = new UBSetting(this, "Board", "DefaultPageSize", documentSizes.value(DocumentSizeRatio::Ratio4_3));
boardCrossColorDarkBackground = new UBSetting(this, "Board", "CrossColorDarkBackground", "#C8C0C0C0");
boardCrossColorDarkBackground = new UBSetting(this, "Board", "CrossColorDarkBackground", "#C82C2C2C");
boardCrossColorLightBackground = new UBSetting(this, "Board", "CrossColorLightBackground", "#A5E1FF");
QStringList gridLightBackgroundColors;
gridLightBackgroundColors << "#FFFFFF" << "#FF3400" << "#66C0FF" << "#81FF5C" << "#FFFF00" << "#B68360" << "#FF497E" << "#8D69FF" << "#C82C2C2C";
boardGridLightBackgroundColors = new UBColorListSetting(this, "Board", "GridLightBackgroundColors", gridLightBackgroundColors, -1.0);
QStringList gridDarkBackgroundColors;
gridDarkBackgroundColors << "#000000" << "#FF0000" << "#004080" << "#008000" << "#FFDD00" << "#C87400" << "#800040" << "#008080" << "#A5E1FF";
boardGridDarkBackgroundColors = new UBColorListSetting(this, "Board", "GridDarkBackgroundColors", gridDarkBackgroundColors, -1.0);
QStringList penLightBackgroundColors;
penLightBackgroundColors << "#000000" << "#FF0000" <<"#004080" << "#008000" << "#FFDD00" << "#C87400" << "#800040" << "#008080" << "#5F2D0A" << "#FFFFFF";
boardPenLightBackgroundColors = new UBColorListSetting(this, "Board", "PenLightBackgroundColors", penLightBackgroundColors, 1.0);
......
......@@ -294,6 +294,9 @@ class UBSettings : public QObject
UBSetting* boardCrossColorDarkBackground;
UBSetting* boardCrossColorLightBackground;
UBColorListSetting* boardGridLightBackgroundColors;
UBColorListSetting* boardGridDarkBackgroundColors;
UBColorListSetting* boardPenLightBackgroundColors;
UBColorListSetting* boardPenLightBackgroundSelectedColors;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment