18#include "backgroundwidget.h"
20#include <QStyleOption>
25BackgroundWidget::BackgroundWidget(
QWidget* parent) :
QWidget(parent)
27 setObjectName(
"BackgroundWidget");
34BackgroundWidget::~BackgroundWidget()
41 connect(mPrefs, &PreferenceManager::optionChanged,
this, &BackgroundWidget::settingUpdated);
43 loadBackgroundStyle();
44 mHasShadow = mPrefs->isOn(SETTING::SHADOW);
49void BackgroundWidget::settingUpdated(SETTING setting)
53 case SETTING::BACKGROUND_STYLE:
55 loadBackgroundStyle();
61 mHasShadow = mPrefs->isOn(SETTING::SHADOW);
70void BackgroundWidget::paintEvent(
QPaintEvent* event)
75 painter.setClipRect(
event->rect());
83void BackgroundWidget::loadBackgroundStyle()
85 QString bgName = mPrefs->getString(SETTING::BACKGROUND_STYLE);
86 mStyle =
"background-color:white; border: 1px solid lightGrey;";
88 if ( bgName ==
"white" )
90 mStyle =
"background-color:white; border: 1px solid lightGrey;";
92 else if ( bgName ==
"grey" )
94 mStyle =
"background-color:lightGrey; border: 1px solid grey;";
96 else if ( bgName ==
"checkerboard" )
98 mStyle =
"background-image: url(:background/checkerboard.png); background-repeat: repeat-xy; border: 1px solid lightGrey;";
100 else if ( bgName ==
"dots" )
102 mStyle =
"background-image: url(:background/dots.png); background-repeat: repeat-xy; border: 1px solid lightGrey;";
104 else if ( bgName ==
"weave" )
106 mStyle =
"background-image: url(:background/weave.jpg); background-repeat: repeat-xy; border: 1px solid lightGrey;";
108 else if ( bgName ==
"grid" )
110 mStyle =
"background-image: url(:background/grid.jpg); background-repeat: repeat-xy; border: 1px solid lightGrey;";
113 mStyle =
QString(
"BackgroundWidget { %1 }").
arg(mStyle);
118void BackgroundWidget::drawShadow(
QPainter& painter)
124 qreal opacity = 0.15;
129 int g = color.
green();
130 int b = color.
blue();
qreal alphaF() const const
void setColorAt(qreal position, const QColor &color)
void setFinalStop(const QPointF &stop)
void setStart(const QPointF &start)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void drawRect(const QRectF &rectangle)
void setBrush(const QBrush &brush)
void setPen(const QColor &color)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
virtual void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const const=0
void initFrom(const QWidget *widget)