Changeset View
Changeset View
Standalone View
Standalone View
plugins/dockers/defaultdockers/kis_layer_box.cpp
Context not available. | |||||
91 | 91 | | |||
---|---|---|---|---|---|
92 | #include "ui_wdglayerbox.h" | 92 | #include "ui_wdglayerbox.h" | ||
93 | 93 | | |||
94 | #include <QProxyStyle> | ||||
95 | #include <QPainter> | ||||
96 | | ||||
97 | class KisLayerBoxStyle : public QProxyStyle | ||||
98 | { | ||||
99 | public: | ||||
100 | KisLayerBoxStyle(QStyle *baseStyle = 0) : QProxyStyle(baseStyle) {} | ||||
101 | | ||||
102 | void drawPrimitive(PrimitiveElement element, const QStyleOption *option, | ||||
103 | QPainter *painter, const QWidget *widget) const | ||||
104 | { | ||||
105 | if (element == QStyle::PE_IndicatorItemViewItemDrop) | ||||
106 | { | ||||
107 | QColor color(widget->palette().color(QPalette::Highlight).lighter()); | ||||
108 | | ||||
109 | if (option->rect.height() == 0) { | ||||
110 | QBrush brush(color); | ||||
111 | | ||||
112 | QRect r(option->rect); | ||||
113 | r.setTop(r.top() - 2); | ||||
114 | r.setBottom(r.bottom() + 2); | ||||
115 | | ||||
116 | painter->fillRect(r, brush); | ||||
117 | } else { | ||||
118 | color.setAlpha(200); | ||||
119 | QBrush brush(color); | ||||
120 | painter->fillRect(option->rect, brush); | ||||
121 | } | ||||
122 | } | ||||
123 | else | ||||
124 | { | ||||
125 | QProxyStyle::drawPrimitive(element, option, painter, widget); | ||||
126 | } | ||||
127 | } | ||||
128 | }; | ||||
129 | | ||||
94 | inline void KisLayerBox::connectActionToButton(KisViewManager* viewManager, QAbstractButton *button, const QString &id) | 130 | inline void KisLayerBox::connectActionToButton(KisViewManager* viewManager, QAbstractButton *button, const QString &id) | ||
95 | { | 131 | { | ||
96 | if (!viewManager || !button) return; | 132 | if (!viewManager || !button) return; | ||
Context not available. | |||||
125 | 161 | | |||
126 | m_wdgLayerBox->setupUi(mainWidget); | 162 | m_wdgLayerBox->setupUi(mainWidget); | ||
127 | 163 | | |||
164 | m_wdgLayerBox->listLayers->setStyle(new KisLayerBoxStyle(m_wdgLayerBox->listLayers->style())); | ||||
165 | | ||||
128 | connect(m_wdgLayerBox->listLayers, | 166 | connect(m_wdgLayerBox->listLayers, | ||
129 | SIGNAL(contextMenuRequested(const QPoint&, const QModelIndex&)), | 167 | SIGNAL(contextMenuRequested(const QPoint&, const QModelIndex&)), | ||
130 | this, SLOT(slotContextMenuRequested(const QPoint&, const QModelIndex&))); | 168 | this, SLOT(slotContextMenuRequested(const QPoint&, const QModelIndex&))); | ||
Context not available. |