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 @@
#include "kis_color_selector_container.h"
#include "kis_canvas2.h"
#include "kis_signal_compressor.h"
#include "KisViewManager.h"
KisColorSelector::KisColorSelector(KisColorSelectorConfiguration conf, QWidget* parent)
......@@ -157,6 +158,11 @@ void KisColorSelector::updateIcons() {
}
}
void KisColorSelector::hasAtLeastOneDocument(bool value)
{
m_hasAtLeastOneDocumentOpen = value;
}
void KisColorSelector::reset()
{
KisColorSelectorBase::reset();
......@@ -181,8 +187,15 @@ void KisColorSelector::paintEvent(QPaintEvent* e)
p.fillRect(0,0,width(),height(),QColor(bgColor.value(),bgColor.value(),bgColor.value()));
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_subComponent->paintEvent(&p);
p.setOpacity(1.0);
}
inline int iconSize(qreal width, qreal height) {
......
......@@ -45,6 +45,8 @@ public:
/// update icons when a theme update happens
void updateIcons();
void hasAtLeastOneDocument(bool value);
public Q_SLOTS:
void reset() override;
void updateSettings() override;
......@@ -61,7 +63,6 @@ protected:
void mouseReleaseEvent(QMouseEvent*) override;
bool displaySettingsButton();
private:
void mouseEvent(QMouseEvent* e);
void init();
......@@ -86,6 +87,12 @@ private:
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:
void setDisplayBlip(bool disp) {m_blipDisplay = disp;}
bool displayBlip() const {return m_blipDisplay;}
......
......@@ -32,6 +32,7 @@
#include <kactioncollection.h>
#include <KisDocument.h>
#include "KisViewManager.h"
#include "kis_canvas2.h"
#include "kis_canvas_resource_provider.h"
......@@ -77,16 +78,33 @@ KisColorSelectorContainer::KisColorSelectorContainer(QWidget *parent) :
m_minimalAction = KisActionRegistry::instance()->makeQAction("show_minimal_shade_selector", this);
connect(m_minimalAction, SIGNAL(triggered()), m_minimalShadeSelector, SLOT(showPopup()), Qt::UniqueConnection);
}
void KisColorSelectorContainer::unsetCanvas()
{
m_colorSelector->hasAtLeastOneDocument(doesAtleastOneDocumentExist());
m_colorSelector->unsetCanvas();
m_myPaintShadeSelector->unsetCanvas();
m_minimalShadeSelector->unsetCanvas();
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()
{
m_colorSelector->updateIcons();
......@@ -109,6 +127,10 @@ void KisColorSelectorContainer::setCanvas(KisCanvas2* canvas)
m_myPaintShadeSelector->setCanvas(canvas);
m_minimalShadeSelector->setCanvas(canvas);
m_colorSelector->hasAtLeastOneDocument(doesAtleastOneDocumentExist());
if (m_canvas && m_canvas->viewManager()) {
if (m_canvas->viewManager()->nodeManager()) {
connect(m_canvas->viewManager()->nodeManager(), SIGNAL(sigLayerActivated(KisLayerSP)), SLOT(reactOnLayerChange()), Qt::UniqueConnection);
......@@ -119,6 +141,7 @@ void KisColorSelectorContainer::setCanvas(KisCanvas2* canvas)
actionCollection->addAction("show_mypaint_shade_selector", m_mypaintAction);
actionCollection->addAction("show_minimal_shade_selector", m_minimalAction);
}
}
void KisColorSelectorContainer::updateSettings()
......
......@@ -35,6 +35,7 @@ public:
explicit KisColorSelectorContainer(QWidget *parent = 0);
void setCanvas(KisCanvas2* canvas);
void unsetCanvas();
bool doesAtleastOneDocumentExist();
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