Commit c0088926 authored by Tusooa Zhu's avatar Tusooa Zhu

Make KisView create another canvas when switching documents

parent 0793ef42
This diff is collapsed.
......@@ -100,6 +100,7 @@
#include "kis_image_signal_router.h"
#include "KisSnapPixelStrategy.h"
#include <kis_signal_auto_connection.h>
class Q_DECL_HIDDEN KisCanvas2::KisCanvas2Private
......@@ -157,6 +158,9 @@ public:
QRect renderingLimit;
int isBatchUpdateActive = 0;
KisSignalAutoConnectionsStore docConnections;
KisSignalAutoConnectionsStore imageConnections;
bool effectiveLodAllowedInImage() {
return lodAllowedInImage && !bootstrapLodBlocked;
}
......@@ -260,7 +264,7 @@ void KisCanvas2::setup()
connect(&m_d->regionOfInterestUpdateCompressor, SIGNAL(timeout()), SLOT(slotUpdateRegionOfInterest()));
connect(m_d->view->document(), SIGNAL(sigReferenceImagesChanged()), this, SLOT(slotReferenceImagesChanged()));
setupDocument();
initializeFpsDecoration();
}
......@@ -569,21 +573,23 @@ void KisCanvas2::initializeImage()
{
KisImageSP image = m_d->view->image();
m_d->imageConnections.clear();
m_d->displayColorConverter.setImageColorSpace(image->colorSpace());
m_d->coordinatesConverter->setImage(image);
m_d->toolProxy.initializeImage(image);
connect(image, SIGNAL(sigImageUpdated(QRect)), SLOT(startUpdateCanvasProjection(QRect)), Qt::DirectConnection);
connect(image->signalRouter(), SIGNAL(sigNotifyBatchUpdateStarted()), SLOT(slotBeginUpdatesBatch()), Qt::DirectConnection);
connect(image->signalRouter(), SIGNAL(sigNotifyBatchUpdateEnded()), SLOT(slotEndUpdatesBatch()), Qt::DirectConnection);
connect(image->signalRouter(), SIGNAL(sigRequestLodPlanesSyncBlocked(bool)), SLOT(slotSetLodUpdatesBlocked(bool)), Qt::DirectConnection);
m_d->imageConnections.addConnection(image, SIGNAL(sigImageUpdated(QRect)), this, SLOT(startUpdateCanvasProjection(QRect)), Qt::DirectConnection);
m_d->imageConnections.addConnection(image->signalRouter(), SIGNAL(sigNotifyBatchUpdateStarted()), this, SLOT(slotBeginUpdatesBatch()), Qt::DirectConnection);
m_d->imageConnections.addConnection(image->signalRouter(), SIGNAL(sigNotifyBatchUpdateEnded()), this, SLOT(slotEndUpdatesBatch()), Qt::DirectConnection);
m_d->imageConnections.addConnection(image->signalRouter(), SIGNAL(sigRequestLodPlanesSyncBlocked(bool)), this, SLOT(slotSetLodUpdatesBlocked(bool)), Qt::DirectConnection);
connect(image, SIGNAL(sigProofingConfigChanged()), SLOT(slotChangeProofingConfig()));
connect(image, SIGNAL(sigSizeChanged(QPointF,QPointF)), SLOT(startResizingImage()), Qt::DirectConnection);
connect(image->undoAdapter(), SIGNAL(selectionChanged()), SLOT(slotTrySwitchShapeManager()));
m_d->imageConnections.addConnection(image, SIGNAL(sigProofingConfigChanged()), this, SLOT(slotChangeProofingConfig()));
m_d->imageConnections.addConnection(image, SIGNAL(sigSizeChanged(QPointF,QPointF)), this, SLOT(startResizingImage()), Qt::DirectConnection);
m_d->imageConnections.addConnection(image->undoAdapter(), SIGNAL(selectionChanged()), this, SLOT(slotTrySwitchShapeManager()));
connect(image, SIGNAL(sigColorSpaceChanged(const KoColorSpace*)), SLOT(slotImageColorSpaceChanged()));
connect(image, SIGNAL(sigProfileChanged(const KoColorProfile*)), SLOT(slotImageColorSpaceChanged()));
m_d->imageConnections.addConnection(image, SIGNAL(sigColorSpaceChanged(const KoColorSpace*)), this, SLOT(slotImageColorSpaceChanged()));
m_d->imageConnections.addConnection(image, SIGNAL(sigProfileChanged(const KoColorProfile*)), this, SLOT(slotImageColorSpaceChanged()));
connectCurrentCanvas();
}
......@@ -1109,6 +1115,13 @@ void KisCanvas2::slotConfigChanged()
initializeFpsDecoration();
}
void KisCanvas2::setupDocument()
{
m_d->docConnections.clear();
m_d->docConnections.addConnection(m_d->view->document(), SIGNAL(sigReferenceImagesChanged()),
this, SLOT(slotReferenceImagesChanged()));
}
void KisCanvas2::refetchDataFromImage()
{
KisImageSP image = this->image();
......
......@@ -273,7 +273,7 @@ public Q_SLOTS:
* Called whenever the configuration settings change.
*/
void slotConfigChanged();
void setupDocument();
private Q_SLOTS:
......
......@@ -137,6 +137,9 @@ void OverviewDockerDock::rotateCanvasView(qreal rotation)
void OverviewDockerDock::updateSlider()
{
if (!m_canvas) {
return;
}
KisSignalsBlocker l(m_rotateSlider);
qreal rotation = m_canvas->rotationAngle();
......
......@@ -26,6 +26,8 @@
#include <KisDocument.h>
#include <KisView.h>
#include <KisPart.h>
#include <KisViewManager.h>
struct KisSnapshotModel::Private
{
......@@ -62,8 +64,13 @@ QPointer<KisDocument> KisSnapshotModel::Private::curDocument()
bool KisSnapshotModel::Private::switchToDocument(QPointer<KisDocument> doc)
{
if (curCanvas && curCanvas->imageView()) {
KisPart::instance()->addDocument(doc);
KisView *view = curCanvas->imageView();
view->setDocument(doc);
view->slotLoadingFinished();
// to reset the view
view->viewManager()->setCurrentView(view);
curCanvas->updateCanvas();
// FIXME: more things need to be done
return true;
}
......
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