Changeset View
Changeset View
Standalone View
Standalone View
plugins/dockers/advancedcolorselector/kis_color_selector_base.cpp
Context not available. | |||||
48 | setWindowFlags(Qt::ToolTip); | 48 | setWindowFlags(Qt::ToolTip); | ||
---|---|---|---|---|---|
49 | setQColor(QColor(0,0,0)); | 49 | setQColor(QColor(0,0,0)); | ||
50 | setMouseTracking(true); | 50 | setMouseTracking(true); | ||
51 | m_baseColor = QColor(0,0,0,0); | ||||
52 | m_previousColor = QColor(0,0,0,0); | ||||
53 | m_lastUsedColor = QColor(0,0,0,0); | ||||
51 | } | 54 | } | ||
52 | 55 | | |||
53 | void show() | 56 | void show() | ||
Context not available. | |||||
70 | } else { | 73 | } else { | ||
71 | targetPos = QPoint(parentPos.x(), parentPos.y() + m_parent->height()); | 74 | targetPos = QPoint(parentPos.x(), parentPos.y() + m_parent->height()); | ||
72 | } | 75 | } | ||
73 | setGeometry(targetPos.x(), targetPos.y(), 100, 100); | 76 | setGeometry(targetPos.x(), targetPos.y(), 100, 150); | ||
77 | setAttribute(Qt::WA_TranslucentBackground); | ||||
74 | } | 78 | } | ||
75 | 79 | | |||
76 | void setQColor(const QColor& color) | 80 | void setQColor(const QColor& color) | ||
Context not available. | |||||
79 | update(); | 83 | update(); | ||
80 | } | 84 | } | ||
81 | 85 | | |||
86 | void setPreviousColor() | ||||
87 | { | ||||
88 | m_previousColor = m_baseColor; | ||||
89 | } | ||||
90 | | ||||
91 | void setBaseColor(const QColor& color) | ||||
92 | { | ||||
93 | m_baseColor = color; | ||||
94 | update(); | ||||
95 | } | ||||
96 | | ||||
97 | void setLastUsedColor(const QColor& color) | ||||
98 | { | ||||
99 | m_lastUsedColor = color; | ||||
100 | update(); | ||||
101 | } | ||||
102 | | ||||
82 | protected: | 103 | protected: | ||
83 | void paintEvent(QPaintEvent *e) { | 104 | void paintEvent(QPaintEvent *e) { | ||
84 | Q_UNUSED(e); | 105 | Q_UNUSED(e); | ||
85 | QPainter p(this); | 106 | QPainter p(this); | ||
86 | p.fillRect(0,0, width(), width(), m_color); | 107 | p.fillRect(0, 0, width(), width(), m_color); | ||
108 | p.fillRect(50, width(), width(), height(), m_previousColor); | ||||
109 | p.fillRect(0, width(), 50, height(), m_lastUsedColor); | ||||
87 | } | 110 | } | ||
88 | 111 | | |||
89 | private: | 112 | private: | ||
90 | KisColorSelectorBase* m_parent; | 113 | KisColorSelectorBase* m_parent; | ||
91 | QColor m_color; | 114 | QColor m_color; | ||
115 | QColor m_baseColor; | ||||
116 | QColor m_previousColor; | ||||
117 | QColor m_lastUsedColor; | ||||
92 | }; | 118 | }; | ||
93 | 119 | | |||
94 | KisColorSelectorBase::KisColorSelectorBase(QWidget *parent) : | 120 | KisColorSelectorBase::KisColorSelectorBase(QWidget *parent) : | ||
Context not available. | |||||
151 | connect(m_canvas->displayColorConverter(), SIGNAL(displayConfigurationChanged()), | 177 | connect(m_canvas->displayColorConverter(), SIGNAL(displayConfigurationChanged()), | ||
152 | SLOT(reset())); | 178 | SLOT(reset())); | ||
153 | 179 | | |||
180 | connect(canvas->imageView()->resourceProvider(), SIGNAL(sigFGColorUsed(KoColor)), | ||||
181 | this, SLOT(updateLastUsedColorPreview(KoColor)), Qt::UniqueConnection); | ||||
182 | | ||||
154 | if (m_canvas->viewManager() && m_canvas->viewManager()->resourceProvider()) { | 183 | if (m_canvas->viewManager() && m_canvas->viewManager()->resourceProvider()) { | ||
155 | setColor(Acs::currentColor(m_canvas->viewManager()->resourceProvider(), Acs::Foreground)); | 184 | setColor(Acs::currentColor(m_canvas->viewManager()->resourceProvider(), Acs::Foreground)); | ||
156 | } | 185 | } | ||
Context not available. | |||||
476 | update(); | 505 | update(); | ||
477 | } | 506 | } | ||
478 | 507 | | |||
508 | void KisColorSelectorBase::updateBaseColorPreview(const KoColor &color) | ||||
509 | { | ||||
510 | m_colorPreviewPopup->setBaseColor(converter()->toQColor(color)); | ||||
511 | } | ||||
512 | | ||||
513 | void KisColorSelectorBase::updatePreviousColorPreview() | ||||
514 | { | ||||
515 | m_colorPreviewPopup->setPreviousColor(); | ||||
516 | } | ||||
517 | | ||||
518 | void KisColorSelectorBase::updateLastUsedColorPreview(const KoColor &color) | ||||
519 | { | ||||
520 | m_colorPreviewPopup->setLastUsedColor(converter()->toQColor(color)); | ||||
521 | } | ||||
522 | | ||||
479 | KisDisplayColorConverter* KisColorSelectorBase::converter() const | 523 | KisDisplayColorConverter* KisColorSelectorBase::converter() const | ||
480 | { | 524 | { | ||
481 | return m_canvas ? | 525 | return m_canvas ? | ||
Context not available. |