Commit bc691c01 authored by Scott Petrovic's avatar Scott Petrovic

Make the advanced color selector look disabled if there are no documents open

parent cc311cd1
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "kis_color_selector_container.h" #include "kis_color_selector_container.h"
#include "kis_canvas2.h" #include "kis_canvas2.h"
#include "kis_signal_compressor.h" #include "kis_signal_compressor.h"
#include "KisViewManager.h"
KisColorSelector::KisColorSelector(KisColorSelectorConfiguration conf, QWidget* parent) KisColorSelector::KisColorSelector(KisColorSelectorConfiguration conf, QWidget* parent)
...@@ -157,6 +158,11 @@ void KisColorSelector::updateIcons() { ...@@ -157,6 +158,11 @@ void KisColorSelector::updateIcons() {
} }
} }
void KisColorSelector::hasAtLeastOneDocument(bool value)
{
m_hasAtLeastOneDocumentOpen = value;
}
void KisColorSelector::reset() void KisColorSelector::reset()
{ {
KisColorSelectorBase::reset(); KisColorSelectorBase::reset();
...@@ -181,8 +187,15 @@ void KisColorSelector::paintEvent(QPaintEvent* e) ...@@ -181,8 +187,15 @@ void KisColorSelector::paintEvent(QPaintEvent* e)
p.fillRect(0,0,width(),height(),QColor(bgColor.value(),bgColor.value(),bgColor.value())); p.fillRect(0,0,width(),height(),QColor(bgColor.value(),bgColor.value(),bgColor.value()));
p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::Antialiasing);
// this variable name isn't entirely accurate to what always happens. see definition in header file to understand it better
if (!m_hasAtLeastOneDocumentOpen) {
p.setOpacity(0.2);
}
m_mainComponent->paintEvent(&p); m_mainComponent->paintEvent(&p);
m_subComponent->paintEvent(&p); m_subComponent->paintEvent(&p);
p.setOpacity(1.0);
} }
inline int iconSize(qreal width, qreal height) { inline int iconSize(qreal width, qreal height) {
......
...@@ -45,6 +45,8 @@ public: ...@@ -45,6 +45,8 @@ public:
/// update icons when a theme update happens /// update icons when a theme update happens
void updateIcons(); void updateIcons();
void hasAtLeastOneDocument(bool value);
public Q_SLOTS: public Q_SLOTS:
void reset() override; void reset() override;
void updateSettings() override; void updateSettings() override;
...@@ -61,7 +63,6 @@ protected: ...@@ -61,7 +63,6 @@ protected:
void mouseReleaseEvent(QMouseEvent*) override; void mouseReleaseEvent(QMouseEvent*) override;
bool displaySettingsButton(); bool displaySettingsButton();
private: private:
void mouseEvent(QMouseEvent* e); void mouseEvent(QMouseEvent* e);
void init(); void init();
...@@ -86,6 +87,12 @@ private: ...@@ -86,6 +87,12 @@ private:
Acs::ColorRole m_lastColorRole; Acs::ColorRole m_lastColorRole;
/// if Krita starts with a reference to this componenet that is attached to a canvas, it will call setCanvas()
/// that check will be what ultimately decides whether this component will look enabled or disabled
/// This color selector is sometimes not attached to the canvas, so we shouldn't disable it in that situation
/// One instane of that is when you select the color wheel type from the settings.
bool m_hasAtLeastOneDocumentOpen = true;
public: public:
void setDisplayBlip(bool disp) {m_blipDisplay = disp;} void setDisplayBlip(bool disp) {m_blipDisplay = disp;}
bool displayBlip() const {return m_blipDisplay;} bool displayBlip() const {return m_blipDisplay;}
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <kactioncollection.h> #include <kactioncollection.h>
#include <KisDocument.h>
#include "KisViewManager.h" #include "KisViewManager.h"
#include "kis_canvas2.h" #include "kis_canvas2.h"
#include "kis_canvas_resource_provider.h" #include "kis_canvas_resource_provider.h"
...@@ -77,16 +78,33 @@ KisColorSelectorContainer::KisColorSelectorContainer(QWidget *parent) : ...@@ -77,16 +78,33 @@ KisColorSelectorContainer::KisColorSelectorContainer(QWidget *parent) :
m_minimalAction = KisActionRegistry::instance()->makeQAction("show_minimal_shade_selector", this); m_minimalAction = KisActionRegistry::instance()->makeQAction("show_minimal_shade_selector", this);
connect(m_minimalAction, SIGNAL(triggered()), m_minimalShadeSelector, SLOT(showPopup()), Qt::UniqueConnection); connect(m_minimalAction, SIGNAL(triggered()), m_minimalShadeSelector, SLOT(showPopup()), Qt::UniqueConnection);
} }
void KisColorSelectorContainer::unsetCanvas() void KisColorSelectorContainer::unsetCanvas()
{ {
m_colorSelector->hasAtLeastOneDocument(doesAtleastOneDocumentExist());
m_colorSelector->unsetCanvas(); m_colorSelector->unsetCanvas();
m_myPaintShadeSelector->unsetCanvas(); m_myPaintShadeSelector->unsetCanvas();
m_minimalShadeSelector->unsetCanvas(); m_minimalShadeSelector->unsetCanvas();
m_canvas = 0; m_canvas = 0;
} }
bool KisColorSelectorContainer::doesAtleastOneDocumentExist()
{
if (m_canvas && m_canvas->viewManager() && m_canvas->viewManager()->document() ) {
if (m_canvas->viewManager()->document()->image()->height() == 0) {
return false;
} else {
return true;
}
} else {
return false;
}
}
void KisColorSelectorContainer::slotUpdateIcons() void KisColorSelectorContainer::slotUpdateIcons()
{ {
m_colorSelector->updateIcons(); m_colorSelector->updateIcons();
...@@ -109,6 +127,10 @@ void KisColorSelectorContainer::setCanvas(KisCanvas2* canvas) ...@@ -109,6 +127,10 @@ void KisColorSelectorContainer::setCanvas(KisCanvas2* canvas)
m_myPaintShadeSelector->setCanvas(canvas); m_myPaintShadeSelector->setCanvas(canvas);
m_minimalShadeSelector->setCanvas(canvas); m_minimalShadeSelector->setCanvas(canvas);
m_colorSelector->hasAtLeastOneDocument(doesAtleastOneDocumentExist());
if (m_canvas && m_canvas->viewManager()) { if (m_canvas && m_canvas->viewManager()) {
if (m_canvas->viewManager()->nodeManager()) { if (m_canvas->viewManager()->nodeManager()) {
connect(m_canvas->viewManager()->nodeManager(), SIGNAL(sigLayerActivated(KisLayerSP)), SLOT(reactOnLayerChange()), Qt::UniqueConnection); connect(m_canvas->viewManager()->nodeManager(), SIGNAL(sigLayerActivated(KisLayerSP)), SLOT(reactOnLayerChange()), Qt::UniqueConnection);
...@@ -119,6 +141,7 @@ void KisColorSelectorContainer::setCanvas(KisCanvas2* canvas) ...@@ -119,6 +141,7 @@ void KisColorSelectorContainer::setCanvas(KisCanvas2* canvas)
actionCollection->addAction("show_mypaint_shade_selector", m_mypaintAction); actionCollection->addAction("show_mypaint_shade_selector", m_mypaintAction);
actionCollection->addAction("show_minimal_shade_selector", m_minimalAction); actionCollection->addAction("show_minimal_shade_selector", m_minimalAction);
} }
} }
void KisColorSelectorContainer::updateSettings() void KisColorSelectorContainer::updateSettings()
......
...@@ -35,6 +35,7 @@ public: ...@@ -35,6 +35,7 @@ public:
explicit KisColorSelectorContainer(QWidget *parent = 0); explicit KisColorSelectorContainer(QWidget *parent = 0);
void setCanvas(KisCanvas2* canvas); void setCanvas(KisCanvas2* canvas);
void unsetCanvas(); void unsetCanvas();
bool doesAtleastOneDocumentExist();
enum ShadeSelectorType{MyPaintSelector, MinimalSelector, NoSelector}; enum ShadeSelectorType{MyPaintSelector, MinimalSelector, NoSelector};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment