Commit c0a8eea0 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Open the mergedimage.png for ora or kra file layers

BUG:403816
parent e3465e91
......@@ -222,7 +222,7 @@ bool KoQuaZipStore::openRead(const QString &name)
debugStore << "openRead" << name << fixedPath << currentPath();
if (!dd->archive->setCurrentFile(fixedPath)) {
qWarning() << "\t\tCould not set current file" << dd->archive->getZipError();
qWarning() << "\t\tCould not set current file" << dd->archive->getZipError() << fixedPath;
return false;
}
......
......@@ -208,7 +208,7 @@ void KisWelcomePageWidget::populateRecentDocuments()
}
else {
if (QFileInfo(recentFileUrlPath).exists()) {
if (recentFileUrlPath.endsWith("ora") || recentFileUrlPath.endsWith("kra")) {
if (recentFileUrlPath.toLower().endsWith("ora") || recentFileUrlPath.toLower().endsWith("kra")) {
QScopedPointer<KoStore> store(KoStore::createStore(recentFileUrlPath, KoStore::Read));
if (store) {
if (store->open(QString("Thumbnails/thumbnail.png"))
......
......@@ -44,8 +44,6 @@ KisDlgFileLayer::KisDlgFileLayer(const QString &basePath, const QString & name,
QWidget * page = new QWidget(this);
dlgWidget.setupUi(page);
QStringList mimes = KisImportExportManager::supportedMimeTypes(KisImportExportManager::Import);
// Nesting .kra files is not supported, so do not offer that option. See https://bugs.kde.org/show_bug.cgi?id=386515
mimes.removeAll("application/x-krita");
dlgWidget.wdgUrlRequester->setMimeTypeFilters(mimes);
setMainWidget(page);
......
......@@ -195,9 +195,9 @@ void KisLayerManager::updateGUI()
const bool isGroupLayer = layer && layer->inherits("KisGroupLayer");
m_imageMergeLayer->setText(
isGroupLayer ?
i18nc("@action:inmenu", "Merge Group") :
i18nc("@action:inmenu", "Merge with Layer Below"));
isGroupLayer ?
i18nc("@action:inmenu", "Merge Group") :
i18nc("@action:inmenu", "Merge with Layer Below"));
m_flattenLayer->setVisible(!isGroupLayer);
if (m_view->statusBar())
......@@ -215,9 +215,9 @@ void KisLayerManager::imageResizeToActiveLayer()
image->cropImage(cropRect);
} else {
m_view->showFloatingMessage(
i18nc("floating message in layer manager",
"Layer is empty "),
QIcon(), 2000, KisFloatingMessage::Low);
i18nc("floating message in layer manager",
"Layer is empty "),
QIcon(), 2000, KisFloatingMessage::Low);
}
}
}
......@@ -268,12 +268,12 @@ void KisLayerManager::layerProperties()
if(xmlBefore != xmlAfter) {
KisChangeFilterCmd *cmd
= new KisChangeFilterCmd(alayer,
configBefore->name(),
xmlBefore,
configAfter->name(),
xmlAfter,
false);
= new KisChangeFilterCmd(alayer,
configBefore->name(),
xmlBefore,
configAfter->name(),
xmlAfter,
false);
// FIXME: check whether is needed
cmd->redo();
m_view->undoAdapter()->addCommand(cmd);
......@@ -329,12 +329,12 @@ void KisLayerManager::layerProperties()
if (fileNameOld!= fileNameNew || scalingMethodOld != scalingMethodNew) {
KisChangeFileLayerCmd *cmd
= new KisChangeFileLayerCmd(flayer,
basePath,
fileNameOld,
scalingMethodOld,
basePath,
fileNameNew,
scalingMethodNew);
basePath,
fileNameOld,
scalingMethodOld,
basePath,
fileNameNew,
scalingMethodNew);
m_view->undoAdapter()->addCommand(cmd);
}
}
......@@ -365,7 +365,7 @@ void KisLayerManager::convertNodeToPaintLayer(KisNodeSP source)
KisPaintDeviceSP srcDevice =
source->paintDevice() ? source->projection() : source->original();
source->paintDevice() ? source->projection() : source->original();
bool putBehind = false;
QString newCompositeOp = source->compositeOpId();
......@@ -383,7 +383,7 @@ void KisLayerManager::convertNodeToPaintLayer(KisNodeSP source)
KisPaintDeviceSP clone;
if (*srcDevice->colorSpace() !=
*srcDevice->compositionSourceColorSpace()) {
*srcDevice->compositionSourceColorSpace()) {
clone = new KisPaintDevice(srcDevice->compositionSourceColorSpace());
......@@ -427,7 +427,7 @@ void KisLayerManager::convertGroupToAnimated()
KisPaintLayerSP animatedLayer = new KisPaintLayer(m_view->image(), group->name(), OPACITY_OPAQUE_U8);
animatedLayer->enableAnimation();
KisRasterKeyframeChannel *contentChannel = dynamic_cast<KisRasterKeyframeChannel*>(
animatedLayer->getKeyframeChannel(KisKeyframeChannel::Content.id(), true));
animatedLayer->getKeyframeChannel(KisKeyframeChannel::Content.id(), true));
KIS_ASSERT_RECOVER_RETURN(contentChannel);
KisNodeSP child = group->firstChild();
......@@ -542,9 +542,9 @@ void KisLayerManager::adjustLayerPosition(KisNodeSP node, KisNodeSP activeNode,
above = parent->lastChild();
if (parent->inherits("KisGroupLayer") && parent->collapsed()) {
above = parent;
parent = parent->parent();
return;
above = parent;
parent = parent->parent();
return;
}
while (parent &&
......@@ -556,7 +556,7 @@ void KisLayerManager::adjustLayerPosition(KisNodeSP node, KisNodeSP activeNode,
if (!parent) {
warnKrita << "KisLayerManager::adjustLayerPosition:"
<< "No node accepted newly created node";
<< "No node accepted newly created node";
parent = m_view->image()->root();
above = parent->lastChild();
......@@ -713,7 +713,7 @@ bool tryMergeSelectionMasks(KisNodeSP currentNode, KisImageSP image)
KisNodeSP prevNode = currentNode->prevSibling();
if (isSelectionMask(currentNode) &&
prevNode && isSelectionMask(prevNode)) {
prevNode && isSelectionMask(prevNode)) {
QList<KisNodeSP> mergedNodes;
mergedNodes.append(currentNode);
......@@ -753,11 +753,11 @@ void KisLayerManager::mergeLayer()
if (!m_view->blockUntilOperationsFinished(image)) return;
QList<KisNodeSP> selectedNodes = m_view->nodeManager()->selectedNodes();
if (selectedNodes.size() > 1) {
if (selectedNodes.size() > 1) {
image->mergeMultipleLayers(selectedNodes, m_view->activeNode());
}
else if (tryMergeSelectionMasks(m_view->activeNode(), image)) {
else if (tryMergeSelectionMasks(m_view->activeNode(), image)) {
// already done!
} else if (tryFlattenGroupLayer(m_view->activeNode(), image)) {
// already done!
......@@ -768,9 +768,9 @@ void KisLayerManager::mergeLayer()
if (!prevLayer) return;
if (prevLayer->userLocked()) {
m_view->showFloatingMessage(
i18nc("floating message in layer manager",
"Layer is locked "),
QIcon(), 2000, KisFloatingMessage::Low);
i18nc("floating message in layer manager",
"Layer is locked "),
QIcon(), 2000, KisFloatingMessage::Low);
}
else if (layer->metaData()->isEmpty() && prevLayer->metaData()->isEmpty()) {
......@@ -951,7 +951,7 @@ void KisLayerManager::layerStyle()
KisPSDLayerStyleSP newStyle = dlg.style();
KUndo2CommandSP command = toQShared(
new KisSetLayerStyleCommand(layer, oldStyle, newStyle));
new KisSetLayerStyleCommand(layer, oldStyle, newStyle));
image->postExecutionUndoAdapter()->addCommand(command);
}
......
......@@ -25,8 +25,12 @@
#include <QDir>
#include <QUrl>
#include <KoStore.h>
#include <kis_paint_layer.h>
#include <kis_group_layer.h>
#include "KisDocument.h"
#include "kis_image.h"
#include <kis_image.h>
#include "kis_signal_compressor.h"
#include "KisPart.h"
......@@ -188,11 +192,11 @@ void KisSafeDocumentLoader::fileChangedCompressed(bool sync)
m_d->fileChangedFlag = false;
m_d->temporaryPath =
QDir::tempPath() + QDir::separator() +
QString("krita_file_layer_copy_%1_%2.%3")
.arg(QApplication::applicationPid())
.arg(qrand())
.arg(initialFileInfo.suffix());
QDir::tempPath() + QDir::separator() +
QString("krita_file_layer_copy_%1_%2.%3")
.arg(QApplication::applicationPid())
.arg(qrand())
.arg(initialFileInfo.suffix());
QFile::copy(m_d->path, m_d->temporaryPath);
......@@ -212,13 +216,32 @@ void KisSafeDocumentLoader::delayedLoadStart()
bool successfullyLoaded = false;
if (!m_d->fileChangedFlag &&
originalInfo.size() == m_d->initialFileSize &&
originalInfo.lastModified() == m_d->initialFileTimeStamp &&
tempInfo.size() == m_d->initialFileSize) {
originalInfo.size() == m_d->initialFileSize &&
originalInfo.lastModified() == m_d->initialFileTimeStamp &&
tempInfo.size() == m_d->initialFileSize) {
m_d->doc.reset(KisPart::instance()->createDocument());
successfullyLoaded = m_d->doc->openUrl(QUrl::fromLocalFile(m_d->temporaryPath),
KisDocument::DontAddToRecent);
if (m_d->path.toLower().endsWith("ora") || m_d->path.toLower().endsWith("kra")) {
QScopedPointer<KoStore> store(KoStore::createStore(m_d->temporaryPath, KoStore::Read));
if (store) {
if (store->open(QString("mergedimage.png"))) {
QByteArray bytes = store->read(store->size());
store->close();
QImage mergedImage;
mergedImage.loadFromData(bytes);
KisImageSP image = new KisImage(0, mergedImage.width(), mergedImage.height(), KoColorSpaceRegistry::instance()->rgb8(), "");
KisPaintLayerSP layer = new KisPaintLayer(image, "", OPACITY_OPAQUE_U8);
layer->paintDevice()->convertFromQImage(mergedImage, 0);
image->addNode(layer, image->rootLayer());
m_d->doc->setCurrentImage(image);
}
}
}
else {
successfullyLoaded = m_d->doc->openUrl(QUrl::fromLocalFile(m_d->temporaryPath),
KisDocument::DontAddToRecent);
}
} else {
dbgKrita << "File was modified externally. Restarting.";
dbgKrita << ppVar(m_d->fileChangedFlag);
......
......@@ -25,11 +25,12 @@
class KisSafeDocumentLoader : public QObject
{
Q_OBJECT
public:
private:
friend class KisFileLayer;
KisSafeDocumentLoader(const QString &path = "", QObject *parent = 0);
~KisSafeDocumentLoader() override;
public:
void setPath(const QString &path);
void reloadImage();
private Q_SLOTS:
......
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