diff --git a/plugins/dockers/advancedcolorselector/kis_color_selector.cpp b/plugins/dockers/advancedcolorselector/kis_color_selector.cpp --- a/plugins/dockers/advancedcolorselector/kis_color_selector.cpp +++ b/plugins/dockers/advancedcolorselector/kis_color_selector.cpp @@ -256,6 +256,7 @@ m_grabbingComponent=m_subComponent; mouseEvent(e); + updatePreviousColorPreview(); e->accept(); } } @@ -280,6 +281,7 @@ m_lastColorRole = Acs::buttonToRole(e->button()); updateColor(m_lastRealColor, m_lastColorRole, false); + updateBaseColorPreview(m_currentRealColor); e->accept(); } diff --git a/plugins/dockers/advancedcolorselector/kis_color_selector_base.h b/plugins/dockers/advancedcolorselector/kis_color_selector_base.h --- a/plugins/dockers/advancedcolorselector/kis_color_selector_base.h +++ b/plugins/dockers/advancedcolorselector/kis_color_selector_base.h @@ -55,6 +55,8 @@ void updateColor(const KoColor &color, Acs::ColorRole role, bool needsExplicitColorReset); void updateColorPreview(const KoColor &color); void showColorPreview(); + void updateBaseColorPreview(const KoColor &color); + void updatePreviousColorPreview(); virtual void setColor(const KoColor& color); @@ -94,6 +96,8 @@ /// if you overwrite this, keep in mind, that you should set the colour only, if m_colorUpdateAllowed is true virtual void canvasResourceChanged(int key, const QVariant& v); + void updateLastUsedColorPreview(const KoColor &color); + public: // This is a private interface for signal compressor, don't use it. // Use requestUpdateColorAndPreview() instead diff --git a/plugins/dockers/advancedcolorselector/kis_color_selector_base.cpp b/plugins/dockers/advancedcolorselector/kis_color_selector_base.cpp --- a/plugins/dockers/advancedcolorselector/kis_color_selector_base.cpp +++ b/plugins/dockers/advancedcolorselector/kis_color_selector_base.cpp @@ -48,6 +48,9 @@ setWindowFlags(Qt::ToolTip); setQColor(QColor(0,0,0)); setMouseTracking(true); + m_baseColor = QColor(0,0,0,0); + m_previousColor = QColor(0,0,0,0); + m_lastUsedColor = QColor(0,0,0,0); } void show() @@ -70,7 +73,8 @@ } else { targetPos = QPoint(parentPos.x(), parentPos.y() + m_parent->height()); } - setGeometry(targetPos.x(), targetPos.y(), 100, 100); + setGeometry(targetPos.x(), targetPos.y(), 100, 150); + setAttribute(Qt::WA_TranslucentBackground); } void setQColor(const QColor& color) @@ -79,16 +83,38 @@ update(); } + void setPreviousColor() + { + m_previousColor = m_baseColor; + } + + void setBaseColor(const QColor& color) + { + m_baseColor = color; + update(); + } + + void setLastUsedColor(const QColor& color) + { + m_lastUsedColor = color; + update(); + } + protected: void paintEvent(QPaintEvent *e) { Q_UNUSED(e); QPainter p(this); - p.fillRect(0,0, width(), width(), m_color); + p.fillRect(0, 0, width(), width(), m_color); + p.fillRect(50, width(), width(), height(), m_previousColor); + p.fillRect(0, width(), 50, height(), m_lastUsedColor); } private: KisColorSelectorBase* m_parent; QColor m_color; + QColor m_baseColor; + QColor m_previousColor; + QColor m_lastUsedColor; }; KisColorSelectorBase::KisColorSelectorBase(QWidget *parent) : @@ -151,6 +177,9 @@ connect(m_canvas->displayColorConverter(), SIGNAL(displayConfigurationChanged()), SLOT(reset())); + connect(canvas->imageView()->resourceProvider(), SIGNAL(sigFGColorUsed(KoColor)), + this, SLOT(updateLastUsedColorPreview(KoColor)), Qt::UniqueConnection); + if (m_canvas->viewManager() && m_canvas->viewManager()->resourceProvider()) { setColor(Acs::currentColor(m_canvas->viewManager()->resourceProvider(), Acs::Foreground)); } @@ -476,6 +505,21 @@ update(); } +void KisColorSelectorBase::updateBaseColorPreview(const KoColor &color) +{ + m_colorPreviewPopup->setBaseColor(converter()->toQColor(color)); +} + +void KisColorSelectorBase::updatePreviousColorPreview() +{ + m_colorPreviewPopup->setPreviousColor(); +} + +void KisColorSelectorBase::updateLastUsedColorPreview(const KoColor &color) +{ + m_colorPreviewPopup->setLastUsedColor(converter()->toQColor(color)); +} + KisDisplayColorConverter* KisColorSelectorBase::converter() const { return m_canvas ?