void KisProcessingApplicatorTest::testNoUIUpdates() { KisSurrogateUndoStore *undoStore = new KisSurrogateUndoStore(); KisPaintLayerSP paintLayer1; KisPaintLayerSP paintLayer2; KisImageSP image = createImage(undoStore, paintLayer1, paintLayer2); QSignalSpy uiSignalsCounter(image.data(), SIGNAL(sigImageUpdated(const QRect&))); QRect cropRect1(40,40,86,86); { KisProcessingApplicator applicator(image, image->rootLayer(), KisProcessingApplicator::RECURSIVE | KisProcessingApplicator::NO_UI_UPDATES); KisProcessingVisitorSP visitor = new KisCropProcessingVisitor(cropRect1, true, true); applicator.applyVisitor(visitor); applicator.end(); image->waitForDone(); } QCOMPARE(uiSignalsCounter.size(), 0); uiSignalsCounter.clear(); undoStore->undo(); image->waitForDone(); QCOMPARE(uiSignalsCounter.size(), 0); }
void KisPasteNewActionFactory::run(KisView2 *view) { Q_UNUSED(view); KisPaintDeviceSP clip = KisClipboard::instance()->clip(QRect(), true); if (!clip) return; QRect rect = clip->exactBounds(); if (rect.isEmpty()) return; KisDoc2 *doc = new KisDoc2(); if (!doc) return; KisImageSP image = new KisImage(doc->createUndoStore(), rect.width(), rect.height(), clip->colorSpace(), i18n("Pasted")); KisPaintLayerSP layer = new KisPaintLayer(image.data(), clip->objectName(), OPACITY_OPAQUE_U8, clip->colorSpace()); KisPainter p(layer->paintDevice()); p.setCompositeOp(COMPOSITE_COPY); p.bitBlt(0, 0, clip, rect.x(), rect.y(), rect.width(), rect.height()); p.end(); image->addNode(layer.data(), image->rootLayer()); doc->setCurrentImage(image); KoMainWindow *win = doc->documentPart()->createMainWindow(); win->show(); win->setRootDocument(doc); }
void KisPasteNewActionFactory::run(KisViewManager *viewManager) { Q_UNUSED(viewManager); KisPaintDeviceSP clip = KisClipboard::instance()->clip(QRect(), true); if (!clip) return; QRect rect = clip->exactBounds(); if (rect.isEmpty()) return; KisDocument *doc = KisPart::instance()->createDocument(); KisImageSP image = new KisImage(doc->createUndoStore(), rect.width(), rect.height(), clip->colorSpace(), i18n("Pasted")); KisPaintLayerSP layer = new KisPaintLayer(image.data(), clip->objectName(), OPACITY_OPAQUE_U8, clip->colorSpace()); KisPainter::copyAreaOptimized(QPoint(), clip, layer->paintDevice(), rect); image->addNode(layer.data(), image->rootLayer()); doc->setCurrentImage(image); KisPart::instance()->addDocument(doc); KisMainWindow *win = viewManager->mainWindow(); win->addViewAndNotifyLoadingCompleted(doc); }
void KisPasteNewActionFactory::run(KisView2 *view) { Q_UNUSED(view); KisPaintDeviceSP clip = KisClipboard::instance()->clip(QPoint()); if (!clip) return; QRect rect = clip->exactBounds(); if (rect.isEmpty()) return; const QByteArray mimetype = KoServiceProvider::readNativeFormatMimeType(); KoDocumentEntry entry = KoDocumentEntry::queryByMimeType(mimetype); QString error; KisPart2* part = dynamic_cast<KisPart2*>(entry.createKoPart(&error)); if (!part) return; KisDoc2 *doc = new KisDoc2(part); if (!doc) return; part->setDocument(doc); KisImageSP image = new KisImage(doc->createUndoStore(), rect.width(), rect.height(), clip->colorSpace(), i18n("Pasted")); KisPaintLayerSP layer = new KisPaintLayer(image.data(), clip->objectName(), OPACITY_OPAQUE_U8, clip->colorSpace()); KisPainter p(layer->paintDevice()); p.setCompositeOp(COMPOSITE_COPY); p.bitBlt(0, 0, clip, rect.x(), rect.y(), rect.width(), rect.height()); p.end(); image->addNode(layer.data(), image->rootLayer()); doc->setCurrentImage(image); KoMainWindow *win = new KoMainWindow(part->componentData()); win->show(); win->setRootDocument(doc); }