Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/KisNodeDelegate.cpp
Show All 36 Lines | |||||
37 | #include <QStyle> | 37 | #include <QStyle> | ||
38 | #include <QStyleOptionViewItem> | 38 | #include <QStyleOptionViewItem> | ||
39 | 39 | | |||
40 | #include <klocalizedstring.h> | 40 | #include <klocalizedstring.h> | ||
41 | #include "kis_node_view_color_scheme.h" | 41 | #include "kis_node_view_color_scheme.h" | ||
42 | #include "kis_icon_utils.h" | 42 | #include "kis_icon_utils.h" | ||
43 | #include "kis_layer_properties_icons.h" | 43 | #include "kis_layer_properties_icons.h" | ||
44 | #include "krita_utils.h" | 44 | #include "krita_utils.h" | ||
45 | #include "kis_config_notifier.h" | ||||
45 | 46 | | |||
46 | typedef KisBaseNode::Property* OptionalProperty; | 47 | typedef KisBaseNode::Property* OptionalProperty; | ||
47 | 48 | | |||
48 | #include <kis_base_node.h> | 49 | #include <kis_base_node.h> | ||
49 | 50 | | |||
50 | class KisNodeDelegate::Private | 51 | class KisNodeDelegate::Private | ||
51 | { | 52 | { | ||
52 | public: | 53 | public: | ||
53 | Private() : view(0), edit(0) { } | 54 | Private() : view(0), edit(0) { } | ||
54 | 55 | | |||
55 | KisNodeView *view; | 56 | KisNodeView *view; | ||
56 | QPointer<QWidget> edit; | 57 | QPointer<QWidget> edit; | ||
57 | KisNodeToolTip tip; | 58 | KisNodeToolTip tip; | ||
58 | 59 | | |||
60 | QColor checkersColor1; | ||||
61 | QColor checkersColor2; | ||||
62 | | ||||
59 | QList<OptionalProperty> rightmostProperties(const KisBaseNode::PropertyList &props) const; | 63 | QList<OptionalProperty> rightmostProperties(const KisBaseNode::PropertyList &props) const; | ||
60 | int numProperties(const QModelIndex &index) const; | 64 | int numProperties(const QModelIndex &index) const; | ||
61 | OptionalProperty findProperty(KisBaseNode::PropertyList &props, const OptionalProperty &refProp) const; | 65 | OptionalProperty findProperty(KisBaseNode::PropertyList &props, const OptionalProperty &refProp) const; | ||
62 | OptionalProperty findVisibilityProperty(KisBaseNode::PropertyList &props) const; | 66 | OptionalProperty findVisibilityProperty(KisBaseNode::PropertyList &props) const; | ||
63 | 67 | | |||
64 | void toggleProperty(KisBaseNode::PropertyList &props, OptionalProperty prop, bool controlPressed, const QModelIndex &index); | 68 | void toggleProperty(KisBaseNode::PropertyList &props, OptionalProperty prop, bool controlPressed, const QModelIndex &index); | ||
65 | }; | 69 | }; | ||
66 | 70 | | |||
67 | KisNodeDelegate::KisNodeDelegate(KisNodeView *view, QObject *parent) | 71 | KisNodeDelegate::KisNodeDelegate(KisNodeView *view, QObject *parent) | ||
68 | : QAbstractItemDelegate(parent) | 72 | : QAbstractItemDelegate(parent) | ||
69 | , d(new Private) | 73 | , d(new Private) | ||
70 | { | 74 | { | ||
71 | d->view = view; | 75 | d->view = view; | ||
72 | QApplication::instance()->installEventFilter(this); | 76 | QApplication::instance()->installEventFilter(this); | ||
77 | connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(slotConfigChanged())); | ||||
78 | slotConfigChanged(); | ||||
73 | } | 79 | } | ||
74 | 80 | | |||
75 | KisNodeDelegate::~KisNodeDelegate() | 81 | KisNodeDelegate::~KisNodeDelegate() | ||
76 | { | 82 | { | ||
77 | delete d; | 83 | delete d; | ||
78 | } | 84 | } | ||
79 | 85 | | |||
80 | QSize KisNodeDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const | 86 | QSize KisNodeDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const | ||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Line(s) | 267 | { | |||
271 | 277 | | |||
272 | QRect fitRect = scm.relThumbnailRect().translated(option.rect.topLeft()); | 278 | QRect fitRect = scm.relThumbnailRect().translated(option.rect.topLeft()); | ||
273 | 279 | | |||
274 | QPoint offset; | 280 | QPoint offset; | ||
275 | offset.setX((fitRect.width() - img.width()) / 2); | 281 | offset.setX((fitRect.width() - img.width()) / 2); | ||
276 | offset.setY((fitRect.height() - img.height()) / 2); | 282 | offset.setY((fitRect.height() - img.height()) / 2); | ||
277 | offset += fitRect.topLeft(); | 283 | offset += fitRect.topLeft(); | ||
278 | 284 | | |||
279 | KisConfig cfg; | | |||
280 | | ||||
281 | // paint in a checkerboard pattern behind the layer contents to represent transparent | 285 | // paint in a checkerboard pattern behind the layer contents to represent transparent | ||
282 | const int step = scm.thumbnailSize() / 6; | 286 | const int step = scm.thumbnailSize() / 6; | ||
283 | QImage checkers(2 * step, 2 * step, QImage::Format_ARGB32); | 287 | QImage checkers(2 * step, 2 * step, QImage::Format_ARGB32); | ||
284 | QPainter gc(&checkers); | 288 | QPainter gc(&checkers); | ||
285 | gc.fillRect(QRect(0, 0, step, step), cfg.checkersColor1()); | 289 | gc.fillRect(QRect(0, 0, step, step), d->checkersColor1); | ||
286 | gc.fillRect(QRect(step, 0, step, step), cfg.checkersColor2()); | 290 | gc.fillRect(QRect(step, 0, step, step), d->checkersColor2); | ||
287 | gc.fillRect(QRect(step, step, step, step), cfg.checkersColor1()); | 291 | gc.fillRect(QRect(step, step, step, step), d->checkersColor1); | ||
288 | gc.fillRect(QRect(0, step, step, step), cfg.checkersColor2()); | 292 | gc.fillRect(QRect(0, step, step, step), d->checkersColor2); | ||
289 | 293 | | |||
290 | QBrush brush(checkers); | 294 | QBrush brush(checkers); | ||
291 | p->setBrushOrigin(offset); | 295 | p->setBrushOrigin(offset); | ||
292 | p->fillRect(img.rect().translated(offset), brush); | 296 | p->fillRect(img.rect().translated(offset), brush); | ||
293 | 297 | | |||
294 | p->drawImage(offset, img); | 298 | p->drawImage(offset, img); | ||
295 | p->setOpacity(oldOpacity); // restore old opacity | 299 | p->setOpacity(oldOpacity); // restore old opacity | ||
296 | 300 | | |||
▲ Show 20 Lines • Show All 560 Lines • ▼ Show 20 Line(s) | 850 | { | |||
857 | opt.rect = r; | 861 | opt.rect = r; | ||
858 | opt.orientation = Qt::Horizontal; | 862 | opt.orientation = Qt::Horizontal; | ||
859 | opt.state = option.state; | 863 | opt.state = option.state; | ||
860 | style->drawControl(QStyle::CE_ProgressBar, &opt, p, 0); | 864 | style->drawControl(QStyle::CE_ProgressBar, &opt, p, 0); | ||
861 | } | 865 | } | ||
862 | p->restore(); | 866 | p->restore(); | ||
863 | } | 867 | } | ||
864 | } | 868 | } | ||
869 | | ||||
870 | void KisNodeDelegate::slotConfigChanged() | ||||
871 | { | ||||
872 | KisConfig cfg; | ||||
873 | | ||||
874 | d->checkersColor1 = cfg.checkersColor1(); | ||||
875 | d->checkersColor2 = cfg.checkersColor2(); | ||||
876 | } |