Commit 386df2f7 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Disable dockers and toolbars if there is no active canvas

parent 86d74353
......@@ -70,6 +70,20 @@ KisColorSelectorContainer::KisColorSelectorContainer(QWidget *parent) :
connect(this, SIGNAL(settingsChanged()), this, SLOT(updateSettings()));
connect(this, SIGNAL(settingsChanged()), m_minimalShadeSelector, SLOT(updateSettings()));
m_colorSelAction = new KAction("Show color selector", this);
m_colorSelAction->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_I));
connect(m_colorSelAction, SIGNAL(triggered()), m_colorSelector, SLOT(showPopup()), Qt::UniqueConnection);
m_mypaintAction = new KAction("Show MyPaint shade selector", this);
m_mypaintAction->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_M));
connect(m_mypaintAction, SIGNAL(triggered()), m_myPaintShadeSelector, SLOT(showPopup()), Qt::UniqueConnection);
m_minimalAction = new KAction("Show minimal shade selector", this);
m_minimalAction->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_N));
connect(m_minimalAction, SIGNAL(triggered()), m_minimalShadeSelector, SLOT(showPopup()), Qt::UniqueConnection);
}
void KisColorSelectorContainer::unsetCanvas()
......@@ -97,32 +111,16 @@ void KisColorSelectorContainer::setCanvas(KisCanvas2* canvas)
m_myPaintShadeSelector->setCanvas(canvas);
m_minimalShadeSelector->setCanvas(canvas);
if (m_canvas && m_canvas->viewManager()->nodeManager()) {
connect(m_canvas->viewManager()->nodeManager(), SIGNAL(sigLayerActivated(KisLayerSP)), SLOT(reactOnLayerChange()), Qt::UniqueConnection);
}
KActionCollection* actionCollection = canvas->viewManager()->actionCollection();
if (!m_colorSelAction) {
m_colorSelAction = new KAction("Show color selector", this);
m_colorSelAction->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_I));
connect(m_colorSelAction, SIGNAL(triggered()), m_colorSelector, SLOT(showPopup()), Qt::UniqueConnection);
}
actionCollection->addAction("show_color_selector", m_colorSelAction);
if (!m_mypaintAction) {
m_mypaintAction = new KAction("Show MyPaint shade selector", this);
m_mypaintAction->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_M));
connect(m_mypaintAction, SIGNAL(triggered()), m_myPaintShadeSelector, SLOT(showPopup()), Qt::UniqueConnection);
}
actionCollection->addAction("show_mypaint_shade_selector", m_mypaintAction);
if (m_canvas && m_canvas->viewManager()) {
if (m_canvas->viewManager()->nodeManager()) {
connect(m_canvas->viewManager()->nodeManager(), SIGNAL(sigLayerActivated(KisLayerSP)), SLOT(reactOnLayerChange()), Qt::UniqueConnection);
}
if (!m_minimalAction) {
m_minimalAction = new KAction("Show minimal shade selector", this);
m_minimalAction->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_N));
connect(m_minimalAction, SIGNAL(triggered()), m_minimalShadeSelector, SLOT(showPopup()), Qt::UniqueConnection);
KActionCollection* actionCollection = canvas->viewManager()->actionCollection();
actionCollection->addAction("show_color_selector", m_colorSelAction);
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()
......
......@@ -90,6 +90,16 @@ KisColorSelectorNgDockerWidget::KisColorSelectorNgDockerWidget(QWidget *parent)
emit settingsChanged();
m_colorHistoryAction = new KAction("Show color history", this);
m_colorHistoryAction->setShortcut(QKeySequence(tr("H")));
connect(m_colorHistoryAction, SIGNAL(triggered()), m_colorHistoryWidget, SLOT(showPopup()), Qt::UniqueConnection);
m_commonColorsAction = new KAction("Show common colors", this);
m_commonColorsAction->setShortcut(QKeySequence(tr("U")));
connect(m_commonColorsAction, SIGNAL(triggered()), m_commonColorsWidget, SLOT(showPopup()), Qt::UniqueConnection);
}
void KisColorSelectorNgDockerWidget::unsetCanvas()
......@@ -115,25 +125,15 @@ void KisColorSelectorNgDockerWidget::setCanvas(KisCanvas2 *canvas)
m_colorHistoryWidget->setCanvas(canvas);
m_colorSelectorContainer->setCanvas(canvas);
if (m_canvas && m_canvas->viewManager() && m_canvas->viewManager()->nodeManager()) {
connect(m_canvas->viewManager()->nodeManager(), SIGNAL(sigLayerActivated(KisLayerSP)), SLOT(reactOnLayerChange()), Qt::UniqueConnection);
}
KActionCollection* actionCollection = canvas->viewManager()->actionCollection();
if (!m_colorHistoryAction) {
m_colorHistoryAction = new KAction("Show color history", this);
m_colorHistoryAction->setShortcut(QKeySequence(tr("H")));
connect(m_colorHistoryAction, SIGNAL(triggered()), m_colorHistoryWidget, SLOT(showPopup()), Qt::UniqueConnection);
}
actionCollection->addAction("show_color_history", m_colorHistoryAction);
if (m_canvas) {
if (m_canvas->viewManager() && m_canvas->viewManager()->nodeManager()) {
connect(m_canvas->viewManager()->nodeManager(), SIGNAL(sigLayerActivated(KisLayerSP)), SLOT(reactOnLayerChange()), Qt::UniqueConnection);
}
KActionCollection* actionCollection = canvas->viewManager()->actionCollection();
if (!m_commonColorsAction) {
m_commonColorsAction = new KAction("Show common colors", this);
m_commonColorsAction->setShortcut(QKeySequence(tr("U")));
connect(m_commonColorsAction, SIGNAL(triggered()), m_commonColorsWidget, SLOT(showPopup()), Qt::UniqueConnection);
actionCollection->addAction("show_color_history", m_colorHistoryAction);
actionCollection->addAction("show_common_colors", m_commonColorsAction);
}
actionCollection->addAction("show_common_colors", m_commonColorsAction);
reactOnLayerChange();
}
......
......@@ -46,14 +46,18 @@ AnimatorDock::AnimatorDock()
void AnimatorDock::setCanvas(KoCanvasBase *canvasBase)
{
setEnabled(canvasBase != 0);
KisCanvas2 *canvas = dynamic_cast<KisCanvas2*>(canvasBase);
if (canvas && canvas->viewManager() && canvas->viewManager()->document()) {
m_timeLine->setCanvas(canvas);
}
}
void AnimatorDock::unsetCanvas()
{
setEnabled(false);
m_timeLine->unsetCanvas();
}
......
......@@ -104,6 +104,7 @@ OnionSkinDock::OnionSkinDock() : QDockWidget(i18n("Onion Skin")), m_canvas(0), m
void OnionSkinDock::setCanvas(KoCanvasBase *canvas)
{
setEnabled(canvas != 0);
m_canvas = dynamic_cast<KisCanvas2*>(canvas);
if (m_canvas && m_canvas->viewManager() && m_canvas->viewManager()->document()) {
KisAnimationDoc *doc = qobject_cast<KisAnimationDoc*>(m_canvas->viewManager()->document());
......
......@@ -40,6 +40,7 @@ public:
virtual void setCanvas(KoCanvasBase *canvas);
virtual void unsetCanvas() {
m_canvas = 0;
setEnabled(false);
}
private:
......
......@@ -199,3 +199,14 @@ void ArtisticColorSelectorDock::slotLightModeChanged(bool setToAbsolute)
m_selectorUI->colorSelector->setLight(m_selectorUI->colorSelector->getLight(), !setToAbsolute);
}
void ArtisticColorSelectorDock::setCanvas(KoCanvasBase *canvas)
{
setEnabled(canvas != 0);
}
void ArtisticColorSelectorDock::unsetCanvas()
{
setEnabled(false);
}
......@@ -33,10 +33,13 @@ class ArtisticColorSelectorDock: public QDockWidget, public KisMainwindowObserve
Q_OBJECT
public:
ArtisticColorSelectorDock();
ArtisticColorSelectorDock();
~ArtisticColorSelectorDock();
QString observerName() { return "ArtisticColorSelectorDock"; }
QString observerName() { return "ArtisticColorSelectorDock"; }
virtual void setMainWindow(KisViewManager* kisview);
virtual void setCanvas(KoCanvasBase *canvas);
virtual void unsetCanvas();
private slots:
void slotCanvasResourceChanged(int key, const QVariant& value);
......
......@@ -46,9 +46,8 @@ ChannelDockerDock::ChannelDockerDock( ) : QDockWidget(i18n("Channels")), m_canva
void ChannelDockerDock::setCanvas(KoCanvasBase * canvas)
{
// if (m_canvas) {
// m_canvas->disconnect();
// }
setEnabled(canvas != 0);
if (!canvas) {
m_canvas = 0;
return;
......
......@@ -31,7 +31,7 @@ public:
ChannelDockerDock();
QString observerName() { return "ChannelDockerDock"; }
virtual void setCanvas(KoCanvasBase *canvas);
virtual void unsetCanvas() { m_canvas = 0; }
virtual void unsetCanvas() { m_canvas = 0; setEnabled(false);}
private:
KisCanvas2 *m_canvas;
QTableView *m_channelTable;
......
......@@ -47,6 +47,8 @@ ColorSliderDock::ColorSliderDock()
void ColorSliderDock::setCanvas(KoCanvasBase * canvas)
{
setEnabled(canvas != 0);
if (m_canvas) {
m_canvas->disconnectCanvasObserver(this);
}
......@@ -57,59 +59,57 @@ void ColorSliderDock::setCanvas(KoCanvasBase * canvas)
}
KisCanvas2* kisCanvas = dynamic_cast<KisCanvas2*>(canvas);
KIS_ASSERT_RECOVER_RETURN(kisCanvas);
KisViewManager* view = kisCanvas->viewManager();
if (kisCanvas) {
KisViewManager* view = kisCanvas->viewManager();
if (m_colorSliders) {
m_colorSliders->disconnect(); // explicit disconnect in case Qt gets confused.
delete m_colorSliders;
}
QWidget *m_sliderdockerwidget = new QWidget;
QVBoxLayout *m_layout = new QVBoxLayout(m_sliderdockerwidget);
setWidget(m_sliderdockerwidget);
//m_updateAllowed = true;
//settings//
QBitArray m_SlidersConfigArray(12);
KConfigGroup cfg = KGlobal::config()->group("hsxColorSlider");
m_SlidersConfigArray[0] =cfg.readEntry("hsvH", false);
m_SlidersConfigArray[1] =cfg.readEntry("hsvS", false);
m_SlidersConfigArray[2] =cfg.readEntry("hsvV", false);
m_SlidersConfigArray[3] =cfg.readEntry("hslH", true);
m_SlidersConfigArray[4] =cfg.readEntry("hslS", true);
m_SlidersConfigArray[5] =cfg.readEntry("hslL", true);
m_SlidersConfigArray[6] =cfg.readEntry("hsiH", false);
m_SlidersConfigArray[7] =cfg.readEntry("hsiS", false);
m_SlidersConfigArray[8] =cfg.readEntry("hsiI", false);
m_SlidersConfigArray[9] =cfg.readEntry("hsyH", false);
m_SlidersConfigArray[10]=cfg.readEntry("hsyS", false);
m_SlidersConfigArray[11]=cfg.readEntry("hsyY", false);
m_colorSliders = new KisColorSliderWidget(kisCanvas->displayColorConverter()->displayRendererInterface(), this, kisCanvas, m_SlidersConfigArray);
m_layout->addWidget(m_colorSliders);
connect(m_colorSliders, SIGNAL(colorChanged(const KoColor&)), view->resourceProvider(), SLOT(slotSetFGColor(const KoColor&)));
connect(view->resourceProvider(), SIGNAL(sigFGColorChanged(const KoColor&)), m_colorSliders, SLOT(setColor(const KoColor&)));
connect(view->resourceProvider(), SIGNAL(sigNodeChanged(const KisNodeSP)), this, SLOT(layerChanged(const KisNodeSP)));
connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), m_colorSliders, SLOT(slotConfigChanged()));
if (m_colorSliders) {
m_colorSliders->disconnect(); // explicit disconnect in case Qt gets confused.
delete m_colorSliders;
m_canvas = kisCanvas;
m_view = view;
}
QWidget *m_sliderdockerwidget = new QWidget;
QVBoxLayout *m_layout = new QVBoxLayout(m_sliderdockerwidget);
setWidget(m_sliderdockerwidget);
//m_updateAllowed = true;
//settings//
QBitArray m_SlidersConfigArray(12);
KConfigGroup cfg = KGlobal::config()->group("hsxColorSlider");
m_SlidersConfigArray[0] =cfg.readEntry("hsvH", false);
m_SlidersConfigArray[1] =cfg.readEntry("hsvS", false);
m_SlidersConfigArray[2] =cfg.readEntry("hsvV", false);
m_SlidersConfigArray[3] =cfg.readEntry("hslH", true);
m_SlidersConfigArray[4] =cfg.readEntry("hslS", true);
m_SlidersConfigArray[5] =cfg.readEntry("hslL", true);
m_SlidersConfigArray[6] =cfg.readEntry("hsiH", false);
m_SlidersConfigArray[7] =cfg.readEntry("hsiS", false);
m_SlidersConfigArray[8] =cfg.readEntry("hsiI", false);
m_SlidersConfigArray[9] =cfg.readEntry("hsyH", false);
m_SlidersConfigArray[10]=cfg.readEntry("hsyS", false);
m_SlidersConfigArray[11]=cfg.readEntry("hsyY", false);
m_colorSliders = new KisColorSliderWidget(kisCanvas->displayColorConverter()->displayRendererInterface(), this, kisCanvas, m_SlidersConfigArray);
m_layout->addWidget(m_colorSliders);
connect(m_colorSliders, SIGNAL(colorChanged(const KoColor&)), view->resourceProvider(), SLOT(slotSetFGColor(const KoColor&)));
connect(view->resourceProvider(), SIGNAL(sigFGColorChanged(const KoColor&)), m_colorSliders, SLOT(setColor(const KoColor&)));
connect(view->resourceProvider(), SIGNAL(sigNodeChanged(const KisNodeSP)), this, SLOT(layerChanged(const KisNodeSP)));
connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), m_colorSliders, SLOT(slotConfigChanged()));
//connect(view->image(), SIGNAL(sigColorSpaceChanged(const KoColorSpace*)), m_colorSliders, SLOT(setColorSpace(const KoColorSpace*)));
m_canvas = kisCanvas;
m_view = view;
//b_canvas = canvas;
}
void ColorSliderDock::unsetCanvas()
{
setEnabled(false);
m_canvas = 0;
m_view = 0;
......
......@@ -97,16 +97,23 @@ CompositionDockerDock::~CompositionDockerDock()
void CompositionDockerDock::setCanvas(KoCanvasBase * canvas)
{
setEnabled(canvas != 0);
unsetCanvas();
m_canvas = dynamic_cast<KisCanvas2*>(canvas);
KActionCollection *actionCollection = m_canvas->viewManager()->actionCollection();
foreach(KisAction *action, m_actions) {
m_canvas->viewManager()->actionManager()->addAction(action->objectName(), action, actionCollection);
if (m_canvas) {
KActionCollection *actionCollection = m_canvas->viewManager()->actionCollection();
foreach(KisAction *action, m_actions) {
m_canvas->viewManager()->actionManager()->addAction(action->objectName(), action, actionCollection);
}
updateModel();
}
updateModel();
}
void CompositionDockerDock::unsetCanvas()
{
setEnabled(false);
if (m_canvas) {
KActionCollection *actionCollection = m_canvas->viewManager()->actionCollection();
foreach(KisAction *action, m_actions) {
......
......@@ -306,6 +306,7 @@ void KisLayerBox::setMainWindow(KisViewManager* kisview)
void KisLayerBox::setCanvas(KoCanvasBase *canvas)
{
setEnabled(canvas != 0);
if (m_canvas) {
m_canvas->disconnectCanvasObserver(this);
m_nodeModel->setDummiesFacade(0, 0, 0);
......@@ -385,6 +386,7 @@ void KisLayerBox::setCanvas(KoCanvasBase *canvas)
void KisLayerBox::unsetCanvas()
{
setEnabled(false);
if (m_canvas) {
KActionCollection *actionCollection = m_canvas->viewManager()->actionCollection();
foreach(KisAction *action, m_actions) {
......
......@@ -72,13 +72,16 @@ KisPaletteDocker::~KisPaletteDocker()
void KisPaletteDocker::setCanvas(KoCanvasBase * canvas)
{
setEnabled(canvas != 0);
m_canvas = canvas;
KisCanvas2* kisCanvas = dynamic_cast<KisCanvas2*>(canvas);
Q_ASSERT(canvas);
KisViewManager* view = kisCanvas->viewManager();
connect(view->resourceProvider(), SIGNAL(sigSavingWorkspace(KisWorkspaceResource*)), SLOT(saveToWorkspace(KisWorkspaceResource*)));
connect(view->resourceProvider(), SIGNAL(sigLoadingWorkspace(KisWorkspaceResource*)), SLOT(loadFromWorkspace(KisWorkspaceResource*)));
if (kisCanvas && kisCanvas->viewManager()) {
KisViewManager* view = kisCanvas->viewManager();
connect(view->resourceProvider(), SIGNAL(sigSavingWorkspace(KisWorkspaceResource*)), SLOT(saveToWorkspace(KisWorkspaceResource*)));
connect(view->resourceProvider(), SIGNAL(sigLoadingWorkspace(KisWorkspaceResource*)), SLOT(loadFromWorkspace(KisWorkspaceResource*)));
}
}
void KisPaletteDocker::colorSelected(const KoColor& c, bool final)
......
......@@ -51,7 +51,7 @@ public:
/// reimplemented from KoCanvasObserverBase
virtual void setCanvas(KoCanvasBase *canvas);
virtual void unsetCanvas() { m_canvas = 0; }
virtual void unsetCanvas() { m_canvas = 0; setEnabled(false);}
private slots:
......
......@@ -100,17 +100,22 @@ DigitalMixerDock::DigitalMixerDock( )
void DigitalMixerDock::setCanvas(KoCanvasBase * canvas)
{
setEnabled(canvas != 0);
if (m_canvas) {
m_canvas->disconnectCanvasObserver(this);
}
m_canvas = canvas;
connect(m_canvas->resourceManager(), SIGNAL(canvasResourceChanged(int, const QVariant&)),
this, SLOT(canvasResourceChanged(int, const QVariant&)));
m_tellCanvas=false;
setCurrentColor(m_canvas->resourceManager()->foregroundColor());
m_tellCanvas=true;
if (m_canvas) {
connect(m_canvas->resourceManager(), SIGNAL(canvasResourceChanged(int, const QVariant&)),
this, SLOT(canvasResourceChanged(int, const QVariant&)));
m_tellCanvas=false;
setCurrentColor(m_canvas->resourceManager()->foregroundColor());
m_tellCanvas=true;
}
}
void DigitalMixerDock::popupColorChanged(int i)
......
......@@ -34,7 +34,7 @@ public:
QString observerName() { return "DigitalMixerDock"; }
/// reimplemented from KoCanvasObserverBase
virtual void setCanvas(KoCanvasBase *canvas);
virtual void unsetCanvas() { m_canvas = 0; }
virtual void unsetCanvas() { m_canvas = 0; setEnabled(false);}
public slots:
void setCurrentColor(const KoColor& );
void canvasResourceChanged(int, const QVariant&);
......
......@@ -29,18 +29,21 @@ HistoryDock::HistoryDock() : QDockWidget(), historyCanvas(0) {
void HistoryDock::setCanvas(KoCanvasBase *canvas) {
KisCanvas2* myCanvas = dynamic_cast<KisCanvas2*>( canvas );
KUndo2Stack* undoStack = canvas->shapeController()->resourceManager()->undoStack();
undoView->setStack(undoStack);
KisConfig cfg;
undoView->stack()->setUseCumulativeUndoRedo(cfg.useCumulativeUndoRedo());
undoView->stack()->setTimeT1(cfg.stackT1());
undoView->stack()->setTimeT2(cfg.stackT2());
undoView->stack()->setStrokesN(cfg.stackN());
setEnabled(canvas != 0);
KisCanvas2* myCanvas = dynamic_cast<KisCanvas2*>( canvas );
if (myCanvas) {
KUndo2Stack* undoStack = canvas->shapeController()->resourceManager()->undoStack();
undoView->setStack(undoStack);
KisConfig cfg;
undoView->stack()->setUseCumulativeUndoRedo(cfg.useCumulativeUndoRedo());
undoView->stack()->setTimeT1(cfg.stackT1());
undoView->stack()->setTimeT2(cfg.stackT2());
undoView->stack()->setStrokesN(cfg.stackN());
}
undoView->setCanvas( myCanvas );
}
#include <HistoryDock.moc>
......@@ -41,7 +41,7 @@ public:
HistoryDock();
QString observerName() { return "HistoryDock"; }
virtual void setCanvas(KoCanvasBase *canvas);
virtual void unsetCanvas() { historyCanvas = 0; }
virtual void unsetCanvas() { historyCanvas = 0; setEnabled(false);}
private:
KisUndoView* undoView;
......
......@@ -300,6 +300,8 @@ void ImageDockerDock::dropEvent(QDropEvent *event)
void ImageDockerDock::setCanvas(KoCanvasBase* canvas)
{
// Intentionally not disabled if there's no canvas
// "Every connection you make emits a signal, so duplicate connections emit two signals"
if(m_canvas)
m_canvas->disconnectCanvasObserver(this);
......
......@@ -57,7 +57,9 @@ public:
virtual ~ImageDockerDock();
QString observerName() { return "ImageDockerDock"; }
virtual void setCanvas(KoCanvasBase* canvas);
virtual void unsetCanvas() { m_canvas = 0; }
virtual void unsetCanvas() {
m_canvas = 0; // Intentionally not disabled if there's no canvas
}
private slots:
void slotItemDoubleClicked(const QModelIndex& index);
......
......@@ -179,6 +179,8 @@ LutDockerDock::~LutDockerDock()
void LutDockerDock::setCanvas(KoCanvasBase* _canvas)
{
setEnabled(_canvas != 0);
if (KisCanvas2* canvas = dynamic_cast<KisCanvas2*>(_canvas)) {
m_canvas = canvas;
if (m_canvas) {
......
......@@ -61,7 +61,7 @@ public:
QString observerName() { return "LutDockerDock"; }
/// reimplemented from KoCanvasObserverBase
virtual void setCanvas(KoCanvasBase *canvas);
virtual void unsetCanvas() { m_canvas = 0; }
virtual void unsetCanvas() { m_canvas = 0; setEnabled(false);}
bool canChangeExposureAndGamma() const;
qreal currentExposure() const;
......
......@@ -50,25 +50,30 @@ OverviewDockerDock::OverviewDockerDock( )
void OverviewDockerDock::setCanvas(KoCanvasBase * canvas)
{
setEnabled(canvas != 0);
if (m_canvas) {
m_canvas->disconnectCanvasObserver(this);
m_canvas->image()->disconnect(this);
}
if (m_zoomSlider) {
m_layout->removeWidget(m_zoomSlider);
delete m_zoomSlider;
}
m_canvas = dynamic_cast<KisCanvas2*>(canvas);
KIS_ASSERT_RECOVER_RETURN(m_canvas);
m_overviewWidget->setCanvas(canvas);
m_zoomSlider = m_canvas->viewManager()->zoomController()->zoomAction()->createWidget(m_canvas->imageView()->KisView::statusBar());
m_layout->addWidget(m_zoomSlider);
if (m_canvas) {
m_zoomSlider = m_canvas->viewManager()->zoomController()->zoomAction()->createWidget(m_canvas->imageView()->KisView::statusBar());
m_layout->addWidget(m_zoomSlider);
}
}
void OverviewDockerDock::unsetCanvas()
{
setEnabled(false);
m_canvas = 0;
m_overviewWidget->unsetCanvas();
}
......
......@@ -57,13 +57,12 @@ void OverviewWidget::setCanvas(KoCanvasBase * canvas)
}
m_canvas = dynamic_cast<KisCanvas2*>(canvas);
KIS_ASSERT_RECOVER_RETURN(m_canvas);
connect(m_canvas->image(), SIGNAL(sigImageUpdated(QRect)), m_compressor, SLOT(start()), Qt::UniqueConnection);
connect(m_canvas->canvasController()->proxyObject, SIGNAL(canvasOffsetXChanged(int)),
this, SLOT(update()));
m_compressor->start();
if (m_canvas) {
connect(m_canvas->image(), SIGNAL(sigImageUpdated(QRect)), m_compressor, SLOT(start()), Qt::UniqueConnection);
connect(m_canvas->canvasController()->proxyObject, SIGNAL(canvasOffsetXChanged(int)), this, SLOT(update()), Qt::UniqueConnection);
m_compressor->start();
}
}
QSize OverviewWidget::calculatePreviewSize()
......
......@@ -40,6 +40,7 @@
#include <kis_canvas_resource_provider.h>
#include <KisViewManager.h>
#include <kis_display_color_converter.h>
#include <kis_canvas2.h>
#include "palettemodel.h"
#include "colorsetchooser.h"
......@@ -193,11 +194,24 @@ void PaletteDockerDock::setMainWindow(KisViewManager* kisview)
kisview->nodeManager()->disconnect(m_model);
// XXX: FIX!!!
//m_model->setDisplayRenderer(kisview->canvas()->displayColorConverter()->displayRendererInterface());
}
void PaletteDockerDock::setCanvas(KoCanvasBase *canvas)
{
setEnabled(canvas != 0);
if (canvas) {
KisCanvas2 *cv = dynamic_cast<KisCanvas2*>(canvas);
m_model->setDisplayRenderer(cv->displayColorConverter()->displayRendererInterface());
}
}
void PaletteDockerDock::unsetCanvas()
{
setEnabled(false);
}
void PaletteDockerDock::unsetResourceServer()
{
KoResourceServer<KoColorSet>* rServer = KoResourceServerProvider::instance()->paletteServer();
......
......@@ -44,6 +44,8 @@ public:
virtual ~PaletteDockerDock();
QString observerName() { return "PaletteDockerDock"; }
virtual void setMainWindow(KisViewManager* kisview);
virtual void setCanvas(KoCanvasBase *canvas);
virtual void unsetCanvas();
public: // KoResourceServerObserver
......
......@@ -47,6 +47,19 @@ void PatternDockerDock::setMainWindow(KisViewManager* kisview)
resourceProvider, SLOT(slotPatternActivated(KoResource*)));
}
void PatternDockerDock::setCanvas(KoCanvasBase *canvas)
{
setEnabled(canvas != 0);
}
void PatternDockerDock::unsetCanvas()
{
setEnabled(false);
}
void PatternDockerDock::patternChanged(KoPattern *pattern)
{
m_patternChooser->setCurrentPattern(pattern);
......