diff --git a/libs/flake/KoDocumentResourceManager.cpp b/libs/flake/KoDocumentResourceManager.cpp index 553f3f8785..d917b81342 100644 --- a/libs/flake/KoDocumentResourceManager.cpp +++ b/libs/flake/KoDocumentResourceManager.cpp @@ -1,214 +1,200 @@ /* Copyright (c) 2006 Boudewijn Rempt (boud@valdyas.org) Copyright (C) 2007, 2010 Thomas Zander Copyright (c) 2008 Carlos Licea Copyright (c) 2011 Jan Hambrecht This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "KoDocumentResourceManager.h" #include #include #include #include "KoShape.h" #include "KoShapeController.h" #include "KoResourceManager_p.h" class Q_DECL_HIDDEN KoDocumentResourceManager::Private { public: KoResourceManager manager; }; KoDocumentResourceManager::KoDocumentResourceManager(QObject *parent) : QObject(parent), d(new Private()) { connect(&d->manager, &KoResourceManager::resourceChanged, this, &KoDocumentResourceManager::resourceChanged); } KoDocumentResourceManager::~KoDocumentResourceManager() { delete d; } void KoDocumentResourceManager::setResource(int key, const QVariant &value) { d->manager.setResource(key, value); } QVariant KoDocumentResourceManager::resource(int key) const { return d->manager.resource(key); } void KoDocumentResourceManager::setResource(int key, const KoColor &color) { QVariant v; v.setValue(color); setResource(key, v); } void KoDocumentResourceManager::setResource(int key, KoShape *shape) { QVariant v; v.setValue(shape); setResource(key, v); } void KoDocumentResourceManager::setResource(int key, const KoUnit &unit) { QVariant v; v.setValue(unit); setResource(key, v); } KoColor KoDocumentResourceManager::koColorResource(int key) const { return d->manager.koColorResource(key); } bool KoDocumentResourceManager::boolResource(int key) const { return d->manager.boolResource(key); } int KoDocumentResourceManager::intResource(int key) const { return d->manager.intResource(key); } QString KoDocumentResourceManager::stringResource(int key) const { return d->manager.stringResource(key); } QSizeF KoDocumentResourceManager::sizeResource(int key) const { return d->manager.sizeResource(key); } bool KoDocumentResourceManager::hasResource(int key) const { return d->manager.hasResource(key); } void KoDocumentResourceManager::clearResource(int key) { d->manager.clearResource(key); } KUndo2Stack *KoDocumentResourceManager::undoStack() const { if (!hasResource(UndoStack)) return 0; return static_cast(resource(UndoStack).value()); } void KoDocumentResourceManager::setHandleRadius(int handleRadius) { // do not allow arbitrary small handles if (handleRadius < 5) handleRadius = 5; setResource(HandleRadius, QVariant(handleRadius)); } int KoDocumentResourceManager::handleRadius() const { if (hasResource(HandleRadius)) return intResource(HandleRadius); return 5; // default value (and is used just about everywhere) } void KoDocumentResourceManager::setGrabSensitivity(int grabSensitivity) { // do not allow arbitrary small grab sensitivity if (grabSensitivity < 5) grabSensitivity = 5; setResource(GrabSensitivity, QVariant(grabSensitivity)); } int KoDocumentResourceManager::grabSensitivity() const { if (hasResource(GrabSensitivity)) return intResource(GrabSensitivity); return 5; // default value (and is used just about everywhere) } void KoDocumentResourceManager::setUndoStack(KUndo2Stack *undoStack) { QVariant variant; variant.setValue(undoStack); setResource(UndoStack, variant); } KoImageCollection *KoDocumentResourceManager::imageCollection() const { if (!hasResource(ImageCollection)) return 0; return static_cast(resource(ImageCollection).value()); } void KoDocumentResourceManager::setImageCollection(KoImageCollection *ic) { QVariant variant; variant.setValue(ic); setResource(ImageCollection, variant); } -KoDocumentBase *KoDocumentResourceManager::odfDocument() const -{ - if (!hasResource(OdfDocument)) - return 0; - return static_cast(resource(OdfDocument).value()); -} - -void KoDocumentResourceManager::setOdfDocument(KoDocumentBase *currentDocument) -{ - QVariant variant; - variant.setValue(currentDocument); - setResource(OdfDocument, variant); -} - qreal KoDocumentResourceManager::documentResolution() const { KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(hasResource(DocumentResolution), 72.0); return resource(DocumentResolution).toReal(); } QRectF KoDocumentResourceManager::documentRectInPixels() const { KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(hasResource(DocumentRectInPixels), QRectF(0,0, 777, 666)); return resource(DocumentRectInPixels).toRectF(); } KoShapeController *KoDocumentResourceManager::globalShapeController() const { if (!hasResource(GlobalShapeController)) return 0; return resource(GlobalShapeController).value(); } void KoDocumentResourceManager::setGlobalShapeController(KoShapeController *shapeController) { QVariant variant; variant.setValue(shapeController); setResource(GlobalShapeController, variant); } diff --git a/libs/flake/KoDocumentResourceManager.h b/libs/flake/KoDocumentResourceManager.h index 7c44583f58..7ef045df86 100644 --- a/libs/flake/KoDocumentResourceManager.h +++ b/libs/flake/KoDocumentResourceManager.h @@ -1,263 +1,259 @@ /* Copyright (c) 2006 Boudewijn Rempt (boud@valdyas.org) Copyright (C) 2007, 2009, 2010 Thomas Zander Copyright (c) 2008 Carlos Licea This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KO_DOCUMENTRESOURCEMANAGER_H #define KO_DOCUMENTRESOURCEMANAGER_H #include #include "kritaflake_export.h" class KoShape; class KUndo2Stack; class KoImageCollection; -class KoDocumentBase; class KoShapeController; class KoColor; class KoUnit; class QVariant; class QSizeF; /** * The KoResourceManager contains a set of per-canvas or per-document * properties, like current foreground color, current background * color and more. All tools belonging to the current canvas are * notified when a Resource changes (is set). * * The properties come from the KoDocumentResourceManager::DocumentResource * See KoShapeController::resourceManager * * The manager can contain all sorts of variable types and there are accessors * for the most common ones. All variables are always stored inside a QVariant * instance internally and you can always just use the resource() method to get * that directly. * The way to store arbitrary data objects that are stored as pointers you can use * the following code snippets; * @code * QVariant variant; * variant.setValue(textShapeData->document()); * resourceManager->setResource(KoText::CurrentTextDocument, variant); * // and get it out again. * QVariant var = resourceManager->resource(KoText::CurrentTextDocument); * document = static_cast(var.value()); * @endcode */ class KRITAFLAKE_EXPORT KoDocumentResourceManager : public QObject { Q_OBJECT public: /** * This enum holds identifiers to the resources that can be stored in here. */ enum DocumentResource { UndoStack, ///< The document-wide undo stack (KUndo2Stack) ImageCollection, ///< The KoImageCollection for the document - OdfDocument, ///< The document this canvas shows (KoDocumentBase) + OdfDocument, ///< OBSOLETE The document this canvas shows HandleRadius, ///< The handle radius used for drawing handles of any kind GrabSensitivity, ///< The grab sensitivity used for grabbing handles of any kind MarkerCollection, ///< The collection holding all markers GlobalShapeController, ///< The KoShapeController for the document DocumentResolution, ///< Pixels-per-inch resoluton of the document DocumentRectInPixels, ///< Bounds of the document in pixels KarbonStart = 1000, ///< Base number for Karbon specific values. KexiStart = 2000, ///< Base number for Kexi specific values. FlowStart = 3000, ///< Base number for Flow specific values. PlanStart = 4000, ///< Base number for Plan specific values. StageStart = 5000, ///< Base number for Stage specific values. KritaStart = 6000, ///< Base number for Krita specific values. SheetsStart = 7000, ///< Base number for Sheets specific values. WordsStart = 8000, ///< Base number for Words specific values. KoPageAppStart = 9000, ///< Base number for KoPageApp specific values. KoTextStart = 10000 ///< Base number for KoText specific values. }; /** * Constructor. * @param parent the parent QObject, used for memory management. */ explicit KoDocumentResourceManager(QObject *parent = 0); ~KoDocumentResourceManager() override; /** * Set a resource of any type. * @param key the integer key * @param value the new value for the key. * @see KoDocumentResourceManager::DocumentResource */ void setResource(int key, const QVariant &value); /** * Set a resource of type KoColor. * @param key the integer key * @param color the new value for the key. * @see KoDocumentResourceManager::DocumentResource */ void setResource(int key, const KoColor &color); /** * Set a resource of type KoShape*. * @param key the integer key * @param id the new value for the key. * @see KoDocumentResourceManager::DocumentResource */ void setResource(int key, KoShape *shape); /** * Set a resource of type KoUnit * @param key the integer key * @param id the new value for the key. * @see KoDocumentResourceManager::DocumentResource */ void setResource(int key, const KoUnit &unit); /** * Returns a qvariant containing the specified resource or a standard one if the * specified resource does not exist. * @param key the key * @see KoDocumentResourceManager::DocumentResource */ QVariant resource(int key) const; /** * Return the resource determined by param key as a boolean. * @param key the identifying key for the resource * @see KoDocumentResourceManager::DocumentResource */ bool boolResource(int key) const; /** * Return the resource determined by param key as an integer. * @param key the identifying key for the resource * @see KoDocumentResourceManager::DocumentResource */ int intResource(int key) const; /** * Return the resource determined by param key as a KoColor. * @param key the identifying key for the resource * @see KoDocumentResourceManager::DocumentResource */ KoColor koColorResource(int key) const; /** * Return the resource determined by param key as a pointer to a KoShape. * @param key the identifying key for the resource * @see KoDocumentResourceManager::DocumentResource */ KoShape *koShapeResource(int key) const; /** * Return the resource determined by param key as a QString . * @param key the identifying key for the resource * @see KoDocumentResourceManager::DocumentResource */ QString stringResource(int key) const; /** * Return the resource determined by param key as a QSizeF. * @param key the identifying key for the resource * @see KoDocumentResourceManager::DocumentResource */ QSizeF sizeResource(int key) const; /** * Return the resource determined by param key as a KoUnit. * @param key the identifying key for the resource * @see KoDocumentResourceManager::DocumentResource */ KoUnit unitResource(int key) const; /** * Returns true if there is a resource set with the requested key. * @param key the identifying key for the resource * @see KoDocumentResourceManager::DocumentResource */ bool hasResource(int key) const; /** * Remove the resource with @p key from the provider. * @param key the key that will be used to remove the resource * There will be a signal emitted with a variable that will return true on QVariable::isNull(); * @see KoDocumentResourceManager::DocumentResource */ void clearResource(int key); /** * Tools that provide a handle for controlling the content that the tool can edit can * use this property to alter the radius that a circular handle should have on screen. * @param handleSize the radius in pixels. */ void setHandleRadius(int handleSize); /// Returns the actual handle radius int handleRadius() const; /** * Tools that are used to grab handles or similar with the mouse * should use this value to determine if the mouse is near enough * @param grabSensitivity the grab sensitivity in pixels */ void setGrabSensitivity(int grabSensitivity); /// Returns the actual grab sensitivity int grabSensitivity() const; KUndo2Stack *undoStack() const; void setUndoStack(KUndo2Stack *undoStack); KoImageCollection *imageCollection() const; void setImageCollection(KoImageCollection *ic); - KoDocumentBase *odfDocument() const; - void setOdfDocument(KoDocumentBase *currentDocument); - qreal documentResolution() const; QRectF documentRectInPixels() const; /** * TODO: remove these methods after legacy ODF text shape is removed. * New code must use documentResolution() and documentRectInPixels() * instead. */ Q_DECL_DEPRECATED KoShapeController *globalShapeController() const; Q_DECL_DEPRECATED void setGlobalShapeController(KoShapeController *globalShapeController); Q_SIGNALS: /** * This signal is emitted every time a resource is set that is either * new or different from the previous set value. * @param key the identifying key for the resource * @param value the variants new value. * @see KoDocumentResourceManager::DocumentResource */ void resourceChanged(int key, const QVariant &value); private: KoDocumentResourceManager(const KoDocumentResourceManager&); KoDocumentResourceManager& operator=(const KoDocumentResourceManager&); class Private; Private *const d; }; #endif diff --git a/libs/flake/KoDrag.cpp b/libs/flake/KoDrag.cpp index d991d94259..23d4636373 100644 --- a/libs/flake/KoDrag.cpp +++ b/libs/flake/KoDrag.cpp @@ -1,127 +1,126 @@ /* This file is part of the KDE project * Copyright (C) 2007-2008 Thorsten Zachmann * Copyright (C) 2009 Thomas Zander * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KoDrag.h" #include #include #include #include #include #include #include #include #include #include #include #include -#include #include #include "KoShapeSavingContext.h" #include #include #include #include class KoDragPrivate { public: KoDragPrivate() : mimeData(0) { } ~KoDragPrivate() { delete mimeData; } QMimeData *mimeData; }; KoDrag::KoDrag() : d(new KoDragPrivate()) { } KoDrag::~KoDrag() { delete d; } bool KoDrag::setSvg(const QList originalShapes) { QRectF boundingRect; QList shapes; Q_FOREACH (KoShape *shape, originalShapes) { boundingRect |= shape->boundingRect(); KoShape *clonedShape = shape->cloneShape(); /** * The shape is cloned without its parent's transformation, so we should * adjust it manually. */ KoShape *oldParentShape = shape->parent(); if (oldParentShape) { clonedShape->applyAbsoluteTransformation(oldParentShape->absoluteTransformation()); } shapes.append(clonedShape); } std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); QBuffer buffer; QLatin1String mimeType("image/svg+xml"); buffer.open(QIODevice::WriteOnly); const QSizeF pageSize(boundingRect.right(), boundingRect.bottom()); SvgWriter writer(shapes); writer.save(buffer, pageSize); buffer.close(); qDeleteAll(shapes); setData(mimeType, buffer.data()); return true; } void KoDrag::setData(const QString &mimeType, const QByteArray &data) { if (d->mimeData == 0) { d->mimeData = new QMimeData(); } d->mimeData->setData(mimeType, data); } void KoDrag::addToClipboard() { if (d->mimeData) { QApplication::clipboard()->setMimeData(d->mimeData); d->mimeData = 0; } } QMimeData * KoDrag::mimeData() { QMimeData *mimeData = d->mimeData; d->mimeData = 0; return mimeData; } diff --git a/libs/odf/CMakeLists.txt b/libs/odf/CMakeLists.txt index e030002c8b..85898b012e 100644 --- a/libs/odf/CMakeLists.txt +++ b/libs/odf/CMakeLists.txt @@ -1,32 +1,30 @@ add_subdirectory( tests ) set(kritaodf_LIB_SRCS KoOdfManifestEntry.cpp - KoDocumentInfo.cpp KoGenStyle.cpp KoGenStyles.cpp KoFontFace.cpp KoOdfLoadingContext.cpp KoOdfStylesReader.cpp KoOdfReadStore.cpp KoOdfWriteStore.cpp KoStyleStack.cpp KoOdfGraphicStyles.cpp - KoDocumentBase.cpp KoEmbeddedDocumentSaver.cpp KoBorder.cpp KoShadowStyle.cpp KoElementReference.cpp OdfDebug.cpp ) add_library(kritaodf SHARED ${kritaodf_LIB_SRCS}) generate_export_header(kritaodf BASE_NAME kritaodf) target_link_libraries(kritaodf kritaglobal kritaversion kritaplugin kritastore KF5::CoreAddons KF5::ConfigCore KF5::I18n Qt5::PrintSupport Qt5::Gui Qt5::Xml) set_target_properties(kritaodf PROPERTIES VERSION ${GENERIC_KRITA_LIB_VERSION} SOVERSION ${GENERIC_KRITA_LIB_SOVERSION} ) install(TARGETS kritaodf ${INSTALL_TARGETS_DEFAULT_ARGS} ) diff --git a/libs/odf/KoDocumentBase.cpp b/libs/odf/KoDocumentBase.cpp deleted file mode 100644 index cfd4e59ce1..0000000000 --- a/libs/odf/KoDocumentBase.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 1998, 1999 Torben Weis - Copyright (C) 2000-2005 David Faure - Copyright (C) 2007 Thorsten Zachmann - Copyright (C) 2009 Boudewijn Rempt - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - - -#include "KoDocumentBase.h" - -#include - -class Q_DECL_HIDDEN KoDocumentBase::Private { -public: -}; - -KoDocumentBase::KoDocumentBase() - : d( new Private ) -{ -} - - -KoDocumentBase::~KoDocumentBase() -{ - delete d; -} diff --git a/libs/odf/KoDocumentBase.h b/libs/odf/KoDocumentBase.h deleted file mode 100644 index 570b72534b..0000000000 --- a/libs/odf/KoDocumentBase.h +++ /dev/null @@ -1,104 +0,0 @@ -/* This file is part of the KDE project - - Copyright (C) 1998, 1999 Torben Weis - Copyright (C) 2000-2005 David Faure - Copyright (C) 2007 Thorsten Zachmann - Copyright (C) 2009 Boudewijn Rempt - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -#ifndef KODOCUMENTBASE_H -#define KODOCUMENTBASE_H - -class KoStore; -class KoOdfReadStore; -class KoOdfWriteStore; -class KoEmbeddedDocumentSaver; - -class QUrl; -class QByteArray; -class QString; - -#include "kritaodf_export.h" - -/** - * Base class for documents that can load and save ODF. Most of the - * implementation is still in KoDocument, though that should probably - * change. - */ -class KRITAODF_EXPORT KoDocumentBase -{ -public: - - // context passed on saving to saveOdf - struct SavingContext { - SavingContext(KoOdfWriteStore &odfStore, KoEmbeddedDocumentSaver &embeddedSaver) - : odfStore(odfStore) - , embeddedSaver(embeddedSaver) {} - - KoOdfWriteStore &odfStore; - KoEmbeddedDocumentSaver &embeddedSaver; - }; - - /** - * create a new KoDocumentBase - */ - KoDocumentBase(); - - /** - * delete this document - */ - virtual ~KoDocumentBase(); - - /** - * @return the current URL - */ - virtual QUrl url() const = 0; - - virtual void setUrl(const QUrl &url) = 0; - - /** - * Checks whether the document is currently in the process of autosaving - */ - virtual bool isAutosaving() const = 0; - - /** - * Returns true if this document or any of its internal child documents are modified. - */ - virtual bool isModified() const = 0; - - /** - * Returns the actual mimetype of the document - */ - virtual QByteArray mimeType() const = 0; - - /** - * @brief Sets the mime type for the document. - * - * When choosing "save as" this is also the mime type - * selected by default. - */ - virtual void setMimeType(const QByteArray & mimeType) = 0; - - virtual QString localFilePath() const = 0; - -private: - class Private; - Private *const d; -}; - - -#endif diff --git a/libs/odf/KoEmbeddedDocumentSaver.cpp b/libs/odf/KoEmbeddedDocumentSaver.cpp index f947700efa..3a37beb332 100644 --- a/libs/odf/KoEmbeddedDocumentSaver.cpp +++ b/libs/odf/KoEmbeddedDocumentSaver.cpp @@ -1,189 +1,141 @@ /* This file is part of the KDE project Copyright (C) 2004-2006 David Faure Copyright (C) 2007 Thorsten Zachmann Copyright (C) 2010 Thomas Zander Copyright (C) 2011 Inge Wallin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KoEmbeddedDocumentSaver.h" #include #include #include #include #include #include -#include "KoDocumentBase.h" #include #define INTERNAL_PROTOCOL "intern" struct FileEntry { QString path; QByteArray mimeType; // QBA because this is what addManifestEntry wants QByteArray contents; }; class Q_DECL_HIDDEN KoEmbeddedDocumentSaver::Private { public: Private() {} QHash prefixes; // Used in getFilename(); // These will be saved when saveEmbeddedDocuments() is called. QList files; // Embedded files. QList manifestEntries; }; KoEmbeddedDocumentSaver::KoEmbeddedDocumentSaver() : d(new Private()) { } KoEmbeddedDocumentSaver::~KoEmbeddedDocumentSaver() { qDeleteAll(d->files); qDeleteAll(d->manifestEntries); delete d; } QString KoEmbeddedDocumentSaver::getFilename(const QString &prefix) { int index = 1; if (d->prefixes.contains(prefix)) { index = d->prefixes.value(prefix); } // This inserts prefix into the map if it's not there. d->prefixes[prefix] = index + 1; //return prefix + QString("%1").arg(index, 4, 10, QChar('0')); return prefix + QString("%1").arg(index); } // Examples: // Videos/Video1.mov ← the number is autogenerated // Videos/Video2.mov // Object1/foo ← the number is autogenerated // Object1/bar // Note: The contents QByteArray is implicitly shared. It needs to be // copied since otherwise the actual array may disappear before // the real saving is done. // void KoEmbeddedDocumentSaver::embedFile(KoXmlWriter &writer, const char *element, const QString &path, const QByteArray &mimeType, const QByteArray &contents) { // Put the file in the list of files to be written to the store later. FileEntry *entry = new FileEntry; entry->mimeType = mimeType; entry->path = path; entry->contents = contents; d->files.append(entry); writer.startElement(element); // Write the attributes that refer to the file. // writer.addAttribute("xlink:type", "simple"); writer.addAttribute("xlink:show", "embed"); writer.addAttribute("xlink:actuate", "onLoad"); debugOdf << "saving reference to embedded file as" << path; writer.addAttribute("xlink:href", path); writer.endElement(); } void KoEmbeddedDocumentSaver::saveFile(const QString &path, const QByteArray &mimeType, const QByteArray &contents) { // Put the file in the list of files to be written to the store later. FileEntry *entry = new FileEntry; entry->mimeType = mimeType; entry->path = path; entry->contents = contents; d->files.append(entry); debugOdf << "saving reference to embedded file as" << path; } /** * */ void KoEmbeddedDocumentSaver::saveManifestEntry(const QString &fullPath, const QString &mediaType, const QString &version) { d->manifestEntries.append(new KoOdfManifestEntry(fullPath, mediaType, version)); } - - -bool KoEmbeddedDocumentSaver::saveEmbeddedDocuments(KoDocumentBase::SavingContext & documentContext) -{ - KoStore *store = documentContext.odfStore.store(); - - // Write the embedded files. - Q_FOREACH (FileEntry *entry, d->files) { - QString path = entry->path; - debugOdf << "saving" << path; - - // To make the children happy cd to the correct directory - store->pushDirectory(); - - int index = path.lastIndexOf('/'); - const QString dirPath = path.left(index); - const QString fileName = path.right(path.size() - index - 1); - store->enterDirectory(dirPath); - - if (!store->open(fileName)) { - return false; - } - store->write(entry->contents); - store->close(); - - // Now that we're done leave the directory again - store->popDirectory(); - - // Create the manifest entry. - if (path.startsWith(QLatin1String("./"))) { - path.remove(0, 2); // remove leading './', not wanted in manifest - } - documentContext.odfStore.manifestWriter()->addManifestEntry(path, entry->mimeType); - } - - // Write the manifest entries. - KoXmlWriter *manifestWriter = documentContext.odfStore.manifestWriter(); - Q_FOREACH (KoOdfManifestEntry *entry, d->manifestEntries) { - manifestWriter->startElement("manifest:file-entry"); - manifestWriter->addAttribute("manifest:version", entry->version()); - manifestWriter->addAttribute("manifest:media-type", entry->mediaType()); - manifestWriter->addAttribute("manifest:full-path", entry->fullPath()); - manifestWriter->endElement(); // manifest:file-entry - } - - return true; -} diff --git a/libs/odf/KoEmbeddedDocumentSaver.h b/libs/odf/KoEmbeddedDocumentSaver.h index 015d37dfd1..121b607f78 100644 --- a/libs/odf/KoEmbeddedDocumentSaver.h +++ b/libs/odf/KoEmbeddedDocumentSaver.h @@ -1,91 +1,86 @@ /* This file is part of the KDE project Copyright (C) 2007 Thorsten Zachmann Copyright (C) 2011 Inge Wallin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KOEMBEDDEDDOCUMENTSAVER_H #define KOEMBEDDEDDOCUMENTSAVER_H -#include "KoDocumentBase.h" #include "kritaodf_export.h" #include class KoXmlWriter; /** * This class is used to save embedded objects in ODF documents. * * @see KoEmbeddedFileSaver */ class KRITAODF_EXPORT KoEmbeddedDocumentSaver { public: KoEmbeddedDocumentSaver(); ~KoEmbeddedDocumentSaver(); /** * Get a unique file name with the given prefix, to be used as a name for an embedded file in the ODF store. * @param the prefix of the filename to be created. * return a unique file name for use in the odf store. */ QString getFilename(const QString &prefix); /** * Adds the object specific attributes to the tag, and queues the * file for saving into the store. * * However, it does NOT write the content of the embedded document * to the store. Saving of the embedded files themselves is done * in @ref saveEmbeddedFiles. This function should be called from * within saveOdf in a shape or a document. */ void embedFile(KoXmlWriter &writer, const char *element, const QString &path, const QByteArray &mimeType, const QByteArray &contents); /** * Queues the file for saving into the store. * * Saving of the embedded files themselves is done in @ref * saveEmbeddedFiles. This function should be called from within * saveOdf in a shape or a document if you don't wish to have a * reference to the file within content.xml, e.g. when the file is * part of an embedded object with embedded files within it. */ void saveFile(const QString &path, const QByteArray &mimeType, const QByteArray &contents); /** * */ void saveManifestEntry(const QString &fullPath, const QString &mediaType, const QString &version = QString()); - /** - * Save all embedded documents to the store. - */ - bool saveEmbeddedDocuments(KoDocumentBase::SavingContext &documentContext); private: class Private; Private * const d; Q_DISABLE_COPY(KoEmbeddedDocumentSaver) }; #endif /* KOEMBEDDEDDOCUMENTSAVER_H */ diff --git a/libs/ui/CMakeLists.txt b/libs/ui/CMakeLists.txt index 49c3acc0bb..c78ee941d6 100644 --- a/libs/ui/CMakeLists.txt +++ b/libs/ui/CMakeLists.txt @@ -1,650 +1,656 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/qtlockedfile ) include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR} ${OCIO_INCLUDE_DIR} ) if (ANDROID) add_definitions(-DQT_OPENGL_ES_3) add_definitions(-DHAS_ONLY_OPENGL_ES) include_directories (${Qt5AndroidExtras_INCLUDE_DIRS}) endif() add_subdirectory( tests ) if (APPLE) find_library(FOUNDATION_LIBRARY Foundation) find_library(APPKIT_LIBRARY AppKit) endif () set(kritaui_LIB_SRCS canvas/kis_canvas_widget_base.cpp canvas/kis_canvas2.cpp canvas/kis_canvas_updates_compressor.cpp canvas/kis_canvas_controller.cpp canvas/kis_display_color_converter.cpp canvas/kis_display_filter.cpp canvas/kis_exposure_gamma_correction_interface.cpp canvas/kis_tool_proxy.cpp canvas/kis_canvas_decoration.cc canvas/kis_coordinates_converter.cpp canvas/kis_grid_manager.cpp canvas/kis_grid_decoration.cpp canvas/kis_grid_config.cpp canvas/kis_prescaled_projection.cpp canvas/kis_qpainter_canvas.cpp canvas/kis_projection_backend.cpp canvas/kis_update_info.cpp canvas/kis_image_patch.cpp canvas/kis_image_pyramid.cpp canvas/kis_infinity_manager.cpp canvas/kis_change_guides_command.cpp canvas/kis_guides_decoration.cpp canvas/kis_guides_manager.cpp canvas/kis_guides_config.cpp canvas/kis_snap_config.cpp canvas/kis_snap_line_strategy.cpp canvas/KisSnapPointStrategy.cpp canvas/KisSnapPixelStrategy.cpp canvas/KisMirrorAxisConfig.cpp dialogs/kis_about_application.cpp dialogs/kis_dlg_adj_layer_props.cc dialogs/kis_dlg_adjustment_layer.cc dialogs/kis_dlg_filter.cpp dialogs/kis_dlg_generator_layer.cpp dialogs/kis_dlg_file_layer.cpp dialogs/kis_dlg_filter.cpp dialogs/kis_dlg_stroke_selection_properties.cpp dialogs/kis_dlg_image_properties.cc dialogs/kis_dlg_layer_properties.cc dialogs/kis_dlg_preferences.cc dialogs/slider_and_spin_box_sync.cpp dialogs/kis_dlg_layer_style.cpp dialogs/kis_dlg_png_import.cpp dialogs/kis_dlg_import_image_sequence.cpp dialogs/kis_delayed_save_dialog.cpp dialogs/KisSessionManagerDialog.cpp dialogs/KisNewWindowLayoutDialog.cpp dialogs/KisDlgChangeCloneSource.cpp dialogs/KisRecoverNamedAutosaveDialog.cpp flake/kis_node_dummies_graph.cpp flake/kis_dummies_facade_base.cpp flake/kis_dummies_facade.cpp flake/kis_node_shapes_graph.cpp flake/kis_node_shape.cpp flake/kis_shape_controller.cpp flake/kis_shape_layer.cc flake/kis_shape_layer_canvas.cpp flake/kis_shape_selection.cpp flake/kis_shape_selection_canvas.cpp flake/kis_shape_selection_model.cpp flake/kis_take_all_shapes_command.cpp brushhud/kis_uniform_paintop_property_widget.cpp brushhud/kis_brush_hud.cpp brushhud/kis_round_hud_button.cpp brushhud/kis_dlg_brush_hud_config.cpp brushhud/kis_brush_hud_properties_list.cpp brushhud/kis_brush_hud_properties_config.cpp kis_aspect_ratio_locker.cpp kis_autogradient.cc kis_bookmarked_configurations_editor.cc kis_bookmarked_configurations_model.cc kis_bookmarked_filter_configurations_model.cc KisPaintopPropertiesBase.cpp kis_canvas_resource_provider.cpp kis_derived_resources.cpp kis_categories_mapper.cpp kis_categorized_list_model.cpp kis_categorized_item_delegate.cpp kis_clipboard.cc kis_config.cc KisOcioConfiguration.cpp kis_control_frame.cpp kis_composite_ops_model.cc kis_paint_ops_model.cpp kis_custom_pattern.cc kis_file_layer.cpp kis_change_file_layer_command.h kis_safe_document_loader.cpp kis_splash_screen.cpp kis_filter_manager.cc kis_filters_model.cc KisImageBarrierLockerWithFeedback.cpp kis_image_manager.cc kis_image_view_converter.cpp kis_import_catcher.cc kis_layer_manager.cc kis_mask_manager.cc kis_mimedata.cpp kis_node_commands_adapter.cpp kis_node_manager.cpp kis_node_juggler_compressed.cpp kis_node_selection_adapter.cpp kis_node_insertion_adapter.cpp KisNodeDisplayModeAdapter.cpp kis_node_model.cpp kis_node_filter_proxy_model.cpp kis_model_index_converter_base.cpp kis_model_index_converter.cpp kis_model_index_converter_show_all.cpp kis_painting_assistant.cc kis_painting_assistants_decoration.cpp KisDecorationsManager.cpp kis_paintop_box.cc kis_paintop_option.cpp kis_paintop_options_model.cpp kis_paintop_settings_widget.cpp kis_popup_palette.cpp kis_png_converter.cpp kis_preference_set_registry.cpp KisResourceServerProvider.cpp KisSelectedShapesProxy.cpp kis_selection_decoration.cc kis_selection_manager.cc KisSelectionActionsAdapter.cpp kis_statusbar.cc kis_zoom_manager.cc kis_favorite_resource_manager.cpp kis_workspace_resource.cpp kis_action.cpp kis_action_manager.cpp KisActionPlugin.cpp kis_canvas_controls_manager.cpp kis_tooltip_manager.cpp kis_multinode_property.cpp kis_stopgradient_editor.cpp KisWelcomePageWidget.cpp KisChangeCloneLayersCommand.cpp kisexiv2/kis_exif_io.cpp kisexiv2/kis_exiv2.cpp kisexiv2/kis_iptc_io.cpp kisexiv2/kis_xmp_io.cpp opengl/kis_opengl.cpp opengl/kis_opengl_canvas2.cpp opengl/kis_opengl_canvas_debugger.cpp opengl/kis_opengl_image_textures.cpp opengl/kis_texture_tile.cpp opengl/kis_opengl_shader_loader.cpp opengl/kis_texture_tile_info_pool.cpp opengl/KisOpenGLUpdateInfoBuilder.cpp opengl/KisOpenGLModeProber.cpp opengl/KisScreenInformationAdapter.cpp kis_fps_decoration.cpp tool/KisToolChangesTracker.cpp tool/KisToolChangesTrackerData.cpp tool/kis_selection_tool_helper.cpp tool/kis_selection_tool_config_widget_helper.cpp tool/kis_rectangle_constraint_widget.cpp tool/kis_shape_tool_helper.cpp tool/kis_tool.cc tool/kis_delegated_tool_policies.cpp tool/kis_tool_freehand.cc tool/kis_speed_smoother.cpp tool/kis_painting_information_builder.cpp tool/kis_stabilized_events_sampler.cpp tool/kis_tool_freehand_helper.cpp tool/kis_tool_multihand_helper.cpp tool/kis_figure_painting_tool_helper.cpp tool/KisAsyncronousStrokeUpdateHelper.cpp tool/kis_tool_paint.cc tool/kis_tool_shape.cc tool/kis_tool_ellipse_base.cpp tool/kis_tool_rectangle_base.cpp tool/kis_tool_polyline_base.cpp tool/kis_tool_utils.cpp tool/kis_resources_snapshot.cpp tool/kis_smoothing_options.cpp tool/KisStabilizerDelayedPaintHelper.cpp tool/KisStrokeSpeedMonitor.cpp tool/strokes/freehand_stroke.cpp tool/strokes/KisStrokeEfficiencyMeasurer.cpp tool/strokes/kis_painter_based_stroke_strategy.cpp tool/strokes/kis_filter_stroke_strategy.cpp tool/strokes/kis_color_picker_stroke_strategy.cpp tool/strokes/KisFreehandStrokeInfo.cpp tool/strokes/KisMaskedFreehandStrokePainter.cpp tool/strokes/KisMaskingBrushRenderer.cpp tool/strokes/KisMaskingBrushCompositeOpFactory.cpp tool/strokes/move_stroke_strategy.cpp tool/strokes/KisNodeSelectionRecipe.cpp tool/KisSelectionToolFactoryBase.cpp tool/KisToolPaintFactoryBase.cpp widgets/kis_cmb_composite.cc widgets/kis_cmb_contour.cpp widgets/kis_cmb_gradient.cpp widgets/kis_paintop_list_widget.cpp widgets/kis_cmb_idlist.cc widgets/kis_color_space_selector.cc widgets/kis_advanced_color_space_selector.cc widgets/kis_cie_tongue_widget.cpp widgets/kis_tone_curve_widget.cpp widgets/kis_curve_widget.cpp widgets/kis_custom_image_widget.cc widgets/kis_image_from_clipboard_widget.cpp widgets/kis_double_widget.cc widgets/kis_filter_selector_widget.cc widgets/kis_gradient_chooser.cc widgets/kis_iconwidget.cc widgets/kis_mask_widgets.cpp widgets/kis_meta_data_merge_strategy_chooser_widget.cc widgets/kis_multi_bool_filter_widget.cc widgets/kis_multi_double_filter_widget.cc widgets/kis_multi_integer_filter_widget.cc widgets/kis_multipliers_double_slider_spinbox.cpp widgets/kis_paintop_presets_popup.cpp widgets/kis_tool_options_popup.cpp widgets/kis_paintop_presets_chooser_popup.cpp widgets/kis_paintop_presets_save.cpp widgets/kis_paintop_preset_icon_library.cpp widgets/kis_pattern_chooser.cc widgets/kis_preset_chooser.cpp widgets/kis_progress_widget.cpp widgets/kis_selection_options.cc widgets/kis_scratch_pad.cpp widgets/kis_scratch_pad_event_filter.cpp widgets/kis_preset_selector_strip.cpp widgets/KisSelectionPropertySlider.cpp widgets/kis_size_group.cpp widgets/kis_size_group_p.cpp widgets/kis_wdg_generator.cpp widgets/kis_workspace_chooser.cpp widgets/kis_categorized_list_view.cpp widgets/kis_widget_chooser.cpp widgets/kis_tool_button.cpp widgets/kis_floating_message.cpp widgets/kis_lod_availability_widget.cpp widgets/kis_color_label_selector_widget.cpp widgets/kis_color_filter_combo.cpp widgets/kis_elided_label.cpp widgets/kis_stopgradient_slider_widget.cpp widgets/kis_preset_live_preview_view.cpp widgets/KisScreenColorPicker.cpp widgets/KoDualColorButton.cpp widgets/KoStrokeConfigWidget.cpp widgets/KoFillConfigWidget.cpp widgets/KisLayerStyleAngleSelector.cpp widgets/KisMemoryReportButton.cpp widgets/KisDitherWidget.cpp KisPaletteEditor.cpp dialogs/KisDlgPaletteEditor.cpp widgets/KisNewsWidget.cpp widgets/KisGamutMaskToolbar.cpp utils/kis_document_aware_spin_box_unit_manager.cpp utils/KisSpinBoxSplineUnitConverter.cpp utils/KisClipboardUtil.cpp utils/KisDitherUtil.cpp utils/KisFileIconCreator.cpp input/kis_input_manager.cpp input/kis_input_manager_p.cpp input/kis_extended_modifiers_mapper.cpp input/kis_abstract_input_action.cpp input/kis_tool_invocation_action.cpp input/kis_pan_action.cpp input/kis_alternate_invocation_action.cpp input/kis_rotate_canvas_action.cpp input/kis_zoom_action.cpp input/kis_change_frame_action.cpp input/kis_gamma_exposure_action.cpp input/kis_show_palette_action.cpp input/kis_change_primary_setting_action.cpp input/kis_abstract_shortcut.cpp input/kis_native_gesture_shortcut.cpp input/kis_single_action_shortcut.cpp input/kis_stroke_shortcut.cpp input/kis_shortcut_matcher.cpp input/kis_select_layer_action.cpp input/KisQtWidgetsTweaker.cpp input/KisInputActionGroup.cpp input/kis_zoom_and_rotate_action.cpp operations/kis_operation.cpp operations/kis_operation_configuration.cpp operations/kis_operation_registry.cpp operations/kis_operation_ui_factory.cpp operations/kis_operation_ui_widget.cpp operations/kis_filter_selection_operation.cpp actions/kis_selection_action_factories.cpp actions/KisPasteActionFactories.cpp actions/KisTransformToolActivationCommand.cpp input/kis_touch_shortcut.cpp kis_document_undo_store.cpp kis_gui_context_command.cpp kis_gui_context_command_p.cpp input/kis_tablet_debugger.cpp input/kis_input_profile_manager.cpp input/kis_input_profile.cpp input/kis_shortcut_configuration.cpp input/config/kis_input_configuration_page.cpp input/config/kis_edit_profiles_dialog.cpp input/config/kis_input_profile_model.cpp input/config/kis_input_configuration_page_item.cpp input/config/kis_action_shortcuts_model.cpp input/config/kis_input_type_delegate.cpp input/config/kis_input_mode_delegate.cpp input/config/kis_input_button.cpp input/config/kis_input_editor_delegate.cpp input/config/kis_mouse_input_editor.cpp input/config/kis_wheel_input_editor.cpp input/config/kis_key_input_editor.cpp processing/fill_processing_visitor.cpp canvas/kis_mirror_axis.cpp kis_abstract_perspective_grid.cpp KisApplication.cpp KisAutoSaveRecoveryDialog.cpp KisDetailsPane.cpp KisDocument.cpp KisCloneDocumentStroke.cpp kis_node_view_color_scheme.cpp KisImportExportFilter.cpp KisImportExportManager.cpp KisImportExportUtils.cpp kis_async_action_feedback.cpp KisMainWindow.cpp KisOpenPane.cpp KisPart.cpp KisTemplate.cpp KisTemplateCreateDia.cpp KisTemplateGroup.cpp KisTemplates.cpp KisTemplatesPane.cpp KisTemplateTree.cpp KisUndoActionsUpdateManager.cpp KisView.cpp KisCanvasWindow.cpp KisImportExportErrorCode.cpp KisImportExportAdditionalChecks.cpp thememanager.cpp kis_mainwindow_observer.cpp KisViewManager.cpp kis_mirror_manager.cpp qtlockedfile/qtlockedfile.cpp qtsingleapplication/qtlocalpeer.cpp qtsingleapplication/qtsingleapplication.cpp KisApplicationArguments.cpp KisNetworkAccessManager.cpp KisRssReader.cpp KisMultiFeedRSSModel.cpp KisRemoteFileFetcher.cpp KisSaveGroupVisitor.cpp KisWindowLayoutResource.cpp KisWindowLayoutManager.cpp KisSessionResource.cpp KisReferenceImagesDecoration.cpp KisReferenceImage.cpp flake/KisReferenceImagesLayer.cpp flake/KisReferenceImagesLayer.h KisMouseClickEater.cpp KisDecorationsWrapperLayer.cpp + + KoDocumentInfoDlg.cpp + KoDocumentInfo.cpp ) if(WIN32) # Private headers are needed for: # * KisDlgCustomTabletResolution # * KisScreenInformationAdapter include_directories(SYSTEM ${Qt5Gui_PRIVATE_INCLUDE_DIRS}) set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} qtlockedfile/qtlockedfile_win.cpp ) if (NOT USE_QT_TABLET_WINDOWS) set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} input/wintab/kis_tablet_support_win.cpp input/wintab/kis_screen_size_choice_dialog.cpp input/wintab/kis_tablet_support_win8.cpp ) else() set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} dialogs/KisDlgCustomTabletResolution.cpp ) endif() endif() set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} kis_animation_frame_cache.cpp kis_animation_cache_populator.cpp KisAsyncAnimationRendererBase.cpp KisAsyncAnimationCacheRenderer.cpp KisAsyncAnimationFramesSavingRenderer.cpp dialogs/KisAsyncAnimationRenderDialogBase.cpp dialogs/KisAsyncAnimationCacheRenderDialog.cpp dialogs/KisAsyncAnimationFramesSaveDialog.cpp canvas/kis_animation_player.cpp kis_animation_importer.cpp KisSyncedAudioPlayback.cpp KisFrameDataSerializer.cpp KisFrameCacheStore.cpp KisFrameCacheSwapper.cpp KisAbstractFrameCacheSwapper.cpp KisInMemoryFrameCacheSwapper.cpp input/wintab/drawpile_tablettester/tablettester.cpp input/wintab/drawpile_tablettester/tablettest.cpp ) if (UNIX) set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} qtlockedfile/qtlockedfile_unix.cpp ) endif() if (ENABLE_UPDATERS) if (UNIX) set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} utils/KisAppimageUpdater.cpp ) endif() set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} utils/KisUpdaterBase.cpp utils/KisManualUpdater.cpp utils/KisUpdaterStatus.cpp ) endif() if(APPLE) set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} input/kis_extended_modifiers_mapper_osx.mm osx.mm ) endif() if (ANDROID) set (kritaui_LIB_SRCS ${kritaui_LIB_SRCS} KisAndroidFileManager.cpp) endif() ki18n_wrap_ui(kritaui_LIB_SRCS widgets/KoFillConfigWidget.ui widgets/KoStrokeConfigWidget.ui widgets/KisDitherWidget.ui forms/wdgdlgpngimport.ui forms/wdgfullscreensettings.ui forms/wdgautogradient.ui forms/wdggeneralsettings.ui forms/wdgperformancesettings.ui forms/wdggenerators.ui forms/wdgbookmarkedconfigurationseditor.ui forms/wdgapplyprofile.ui forms/wdgcustompattern.ui forms/wdglayerproperties.ui forms/wdgcolorsettings.ui forms/wdgtabletsettings.ui forms/wdgcolorspaceselector.ui forms/wdgcolorspaceselectoradvanced.ui forms/wdgdisplaysettings.ui forms/kis_previewwidgetbase.ui forms/kis_matrix_widget.ui forms/wdgselectionoptions.ui forms/wdggeometryoptions.ui forms/wdgnewimage.ui forms/wdgimageproperties.ui forms/wdgmaskfromselection.ui forms/wdgmasksource.ui forms/wdgfilterdialog.ui forms/wdgmetadatamergestrategychooser.ui forms/wdgpaintoppresets.ui forms/wdgpaintopsettings.ui forms/wdgdlggeneratorlayer.ui forms/wdgdlgfilelayer.ui forms/wdgfilterselector.ui forms/wdgfilternodecreation.ui forms/wdgmultipliersdoublesliderspinbox.ui forms/wdgnodequerypatheditor.ui forms/wdgpresetselectorstrip.ui forms/wdgsavebrushpreset.ui forms/wdgpreseticonlibrary.ui forms/wdgrectangleconstraints.ui forms/wdgimportimagesequence.ui forms/wdgstrokeselectionproperties.ui forms/KisDetailsPaneBase.ui forms/KisOpenPaneBase.ui forms/wdgstopgradienteditor.ui forms/wdgsessionmanager.ui forms/wdgnewwindowlayout.ui forms/KisWelcomePage.ui forms/WdgDlgPaletteEditor.ui forms/KisNewsPage.ui forms/wdgGamutMaskToolbar.ui forms/wdgchangeclonesource.ui + forms/koDocumentInfoAboutWidget.ui + forms/koDocumentInfoAuthorWidget.ui + brushhud/kis_dlg_brush_hud_config.ui dialogs/kis_delayed_save_dialog.ui dialogs/KisRecoverNamedAutosaveDialog.ui input/config/kis_input_configuration_page.ui input/config/kis_edit_profiles_dialog.ui input/config/kis_input_configuration_page_item.ui input/config/kis_mouse_input_editor.ui input/config/kis_wheel_input_editor.ui input/config/kis_key_input_editor.ui layerstyles/wdgBevelAndEmboss.ui layerstyles/wdgblendingoptions.ui layerstyles/WdgColorOverlay.ui layerstyles/wdgContour.ui layerstyles/wdgdropshadow.ui layerstyles/WdgGradientOverlay.ui layerstyles/wdgInnerGlow.ui layerstyles/wdglayerstyles.ui layerstyles/WdgPatternOverlay.ui layerstyles/WdgSatin.ui layerstyles/WdgStroke.ui layerstyles/wdgstylesselector.ui layerstyles/wdgTexture.ui layerstyles/wdgKisLayerStyleAngleSelector.ui wdgsplash.ui input/wintab/kis_screen_size_choice_dialog.ui input/wintab/drawpile_tablettester/tablettest.ui ) if(WIN32) if(USE_QT_TABLET_WINDOWS) ki18n_wrap_ui(kritaui_LIB_SRCS dialogs/KisDlgCustomTabletResolution.ui ) else() ki18n_wrap_ui(kritaui_LIB_SRCS input/wintab/kis_screen_size_choice_dialog.ui ) endif() endif() add_library(kritaui SHARED ${kritaui_HEADERS_MOC} ${kritaui_LIB_SRCS} ) generate_export_header(kritaui BASE_NAME kritaui) target_link_libraries(kritaui KF5::CoreAddons KF5::Completion KF5::I18n KF5::ItemViews Qt5::Network kritaversion kritaimpex kritacolor kritaimage kritalibbrush kritawidgets kritawidgetutils kritaresources ${PNG_LIBRARIES} LibExiv2::LibExiv2 ) if (ANDROID) target_link_libraries(kritaui GLESv3) target_link_libraries(kritaui Qt5::Gui) target_link_libraries(kritaui Qt5::AndroidExtras) endif() if (HAVE_QT_MULTIMEDIA) target_link_libraries(kritaui Qt5::Multimedia) endif() if (NOT WIN32 AND NOT APPLE AND NOT ANDROID) target_link_libraries(kritaui ${X11_X11_LIB} ${X11_Xinput_LIB}) endif() if(APPLE) target_link_libraries(kritaui ${FOUNDATION_LIBRARY}) target_link_libraries(kritaui ${APPKIT_LIBRARY}) endif () target_link_libraries(kritaui ${OPENEXR_LIBRARIES}) # Add VSync disable workaround if(NOT WIN32 AND NOT APPLE AND NOT ANDROID) target_link_libraries(kritaui ${CMAKE_DL_LIBS} Qt5::X11Extras) endif() if(X11_FOUND) target_link_libraries(kritaui Qt5::X11Extras ${X11_LIBRARIES}) endif() target_include_directories(kritaui PUBLIC $ $ $ $ $ $ $ ) set_target_properties(kritaui PROPERTIES VERSION ${GENERIC_KRITA_LIB_VERSION} SOVERSION ${GENERIC_KRITA_LIB_SOVERSION} ) install(TARGETS kritaui ${INSTALL_TARGETS_DEFAULT_ARGS}) if (APPLE) install(FILES osx.stylesheet DESTINATION ${DATA_INSTALL_DIR}/krita) endif () if (UNIX AND BUILD_TESTING AND ENABLE_UPDATERS) install(FILES tests/data/AppImageUpdateDummy PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) endif () diff --git a/libs/ui/KisDocument.h b/libs/ui/KisDocument.h index 2a0beb2963..c874ff964f 100644 --- a/libs/ui/KisDocument.h +++ b/libs/ui/KisDocument.h @@ -1,709 +1,708 @@ /* This file is part of the Krita project * * Copyright (C) 2014 Boudewijn Rempt * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KISDOCUMENT_H #define KISDOCUMENT_H #include #include #include #include -#include #include #include #include #include #include #include #include #include #include #include #include #include "kritaui_export.h" #include class QString; class KUndo2Command; class KoUnit; class KoColor; class KoColorSpace; class KoShapeControllerBase; class KoShapeLayer; class KoStore; class KoOdfReadStore; class KoDocumentInfo; class KoDocumentInfoDlg; class KisImportExportManager; class KisUndoStore; class KisPart; class KisGridConfig; class KisGuidesConfig; class KisMirrorAxisConfig; class QDomDocument; class KisReferenceImagesLayer; #define KIS_MIME_TYPE "application/x-krita" /** * The %Calligra document class * * This class provides some functionality each %Calligra document should have. * * @short The %Calligra document class */ -class KRITAUI_EXPORT KisDocument : public QObject, public KoDocumentBase +class KRITAUI_EXPORT KisDocument : public QObject { Q_OBJECT protected: explicit KisDocument(bool addStorage = true); /** * @brief KisDocument makes a deep copy of the document \p rhs. * The caller *must* ensure that the image is properly * locked and is in consistent state before asking for * cloning. * @param rhs the source document to copy from */ explicit KisDocument(const KisDocument &rhs); public: enum OpenFlag { None = 0, DontAddToRecent = 0x1, RecoveryFile = 0x2 }; Q_DECLARE_FLAGS(OpenFlags, OpenFlag) /** * Destructor. * * The destructor does not delete any attached KisView objects and it does not * delete the attached widget as returned by widget(). */ - ~KisDocument() override; + ~KisDocument(); /** * @brief uniqueID is a temporary unique ID that identifies the document. It is * generated on creation and can be used to uniquely associated temporary objects * with this document. * * @return the temporary unique id for this document. */ QString uniqueID() const; /** * @brief creates a clone of the document and returns it. Please make sure that you * hold all the necessary locks on the image before asking for a clone! */ KisDocument* clone(); /** * @brief openUrl Open an URL * @param url The URL to open * @param flags Control specific behavior * @return success status */ bool openUrl(const QUrl &url, OpenFlags flags = None); /** * Opens the document given by @p url, without storing the URL * in the KisDocument. * Call this instead of openUrl() to implement KisMainWindow's * File --> Import feature. * * @note This will call openUrl(). To differentiate this from an ordinary * Open operation (in any reimplementation of openUrl() or openFile()) * call isImporting(). */ bool importDocument(const QUrl &url); /** * Saves the document as @p url without changing the state of the * KisDocument (URL, modified flag etc.). Call this instead of * KisParts::ReadWritePart::saveAs() to implement KisMainWindow's * File --> Export feature. */ bool exportDocument(const QUrl &url, const QByteArray &mimeType, bool showWarnings = false, KisPropertiesConfigurationSP exportConfiguration = 0); /** * Exports he document is a synchronous way. The caller must ensure that the * image is not accessed by any other actors, because the exporting happens * without holding the image lock. */ bool exportDocumentSync(const QUrl &url, const QByteArray &mimeType, KisPropertiesConfigurationSP exportConfiguration = 0); private: bool exportDocumentImpl(const KritaUtils::ExportFileJob &job, KisPropertiesConfigurationSP exportConfiguration); public: /** * @brief Sets whether the document can be edited or is read only. * * This recursively applied to all child documents and * KisView::updateReadWrite is called for every attached * view. */ void setReadWrite(bool readwrite = true); /** * To be preferred when a document exists. It is fast when calling * it multiple times since it caches the result that readNativeFormatMimeType() * delivers. * This comes from the X-KDE-NativeMimeType key in the .desktop file. */ static QByteArray nativeFormatMimeType() { return KIS_MIME_TYPE; } /// Checks whether a given mimetype can be handled natively. bool isNativeFormat(const QByteArray& mimetype) const; /// Returns a list of the mimetypes considered "native", i.e. which can /// be saved by KisDocument without a filter, in *addition* to the main one static QStringList extraNativeMimeTypes() { return QStringList() << KIS_MIME_TYPE; } /** * Returns the actual mimetype of the document */ - QByteArray mimeType() const override; + QByteArray mimeType() const; /** * @brief Sets the mime type for the document. * * When choosing "save as" this is also the mime type * selected by default. */ - void setMimeType(const QByteArray & mimeType) override; + void setMimeType(const QByteArray & mimeType); /** * @return true if file operations should inhibit the option dialog */ bool fileBatchMode() const; /** * @param batchMode if true, do not show the option dialog for file operations. */ void setFileBatchMode(const bool batchMode); /** * Sets the error message to be shown to the user (use i18n()!) * when loading or saving fails. * If you asked the user about something and they chose "Cancel", */ void setErrorMessage(const QString& errMsg); /** * Return the last error message. Usually KisDocument takes care of * showing it; this method is mostly provided for non-interactive use. */ QString errorMessage() const; /** * Sets the warning message to be shown to the user (use i18n()!) * when loading or saving fails. */ void setWarningMessage(const QString& warningMsg); /** * Return the last warning message set by loading or saving. Warnings * mean that the document could not be completely loaded, but the errors * were not absolutely fatal. */ QString warningMessage() const; /** * @brief Generates a preview picture of the document * @note The preview is used in the File Dialog and also to create the Thumbnail */ QPixmap generatePreview(const QSize& size); /** * Tells the document that its title has been modified, either because * the modified status changes (this is done by setModified() ) or * because the URL or the document-info's title changed. */ void setTitleModified(); /** * @brief Sets the document to empty. * * Used after loading a template * (which is not empty, but not the user's input). * * @see isEmpty() */ void setEmpty(bool empty = true); /** * Return a correctly created QDomDocument for this KisDocument, * including processing instruction, complete DOCTYPE tag (with systemId and publicId), and root element. * @param tagName the name of the tag for the root element * @param version the DTD version (usually the application's version). */ QDomDocument createDomDocument(const QString& tagName, const QString& version) const; /** * Return a correctly created QDomDocument for an old (1.3-style) %Calligra document, * including processing instruction, complete DOCTYPE tag (with systemId and publicId), and root element. * This static method can be used e.g. by filters. * @param appName the app's instance name, e.g. words, kspread, kpresenter etc. * @param tagName the name of the tag for the root element, e.g. DOC for words/kpresenter. * @param version the DTD version (usually the application's version). */ static QDomDocument createDomDocument(const QString& appName, const QString& tagName, const QString& version); /** * Loads a document in the native format from a given URL. * Reimplement if your native format isn't XML. * * @param file the file to load - usually KReadOnlyPart::m_file or the result of a filter */ bool loadNativeFormat(const QString & file); /** * Set standard autosave interval that is set by a config file */ void setNormalAutoSaveInterval(); /** * Set emergency interval that autosave uses when the image is busy, * by default it is 10 sec */ void setEmergencyAutoSaveInterval(); /** * Disable autosave */ void setInfiniteAutoSaveInterval(); /** * @return the information concerning this document. * @see KoDocumentInfo */ KoDocumentInfo *documentInfo() const; /** * Performs a cleanup of unneeded backup files */ void removeAutoSaveFiles(const QString &autosaveBaseName, bool wasRecovered); /** * Returns true if this document or any of its internal child documents are modified. */ - bool isModified() const override; + bool isModified() const; /** * @return caption of the document * * Caption is of the form "[title] - [url]", * built out of the document info (title) and pretty-printed * document URL. * If the title is not present, only the URL it returned. */ QString caption() const; /** * Sets the document URL to empty URL * KParts doesn't allow this, but %Calligra apps have e.g. templates * After using loadNativeFormat on a template, one wants * to set the url to QUrl() */ void resetURL(); /** * @internal (public for KisMainWindow) */ void setMimeTypeAfterLoading(const QString& mimeType); /** * Returns the unit used to display all measures/distances. */ KoUnit unit() const; /** * Sets the unit used to display all measures/distances. */ void setUnit(const KoUnit &unit); KisGridConfig gridConfig() const; void setGridConfig(const KisGridConfig &config); /// returns the guides data for this document. const KisGuidesConfig& guidesConfig() const; void setGuidesConfig(const KisGuidesConfig &data); /** * @brief paletteList returns all the palettes found in the document's local resource storage */ QList paletteList(); /** * @brief setPaletteList replaces the palettes in the document's local resource storage with the list * of palettes passed to this function. It will then emitsigPaletteListChanged with both the old and * the new list, if emitsignal is true. */ void setPaletteList(const QList &paletteList, bool emitSignal = false); const KisMirrorAxisConfig& mirrorAxisConfig() const; void setMirrorAxisConfig(const KisMirrorAxisConfig& config); void clearUndoHistory(); /** * Sets the modified flag on the document. This means that it has * to be saved or not before deleting it. */ void setModified(bool _mod); void setRecovered(bool value); bool isRecovered() const; void updateEditingTime(bool forceStoreElapsed); /** * Returns the global undo stack */ KUndo2Stack *undoStack(); /** * @brief importExportManager gives access to the internal import/export manager * @return the document's import/export manager */ KisImportExportManager *importExportManager() const; /** * @brief serializeToNativeByteArray daves the document into a .kra file wtitten * to a memory-based byte-array * @return a byte array containing the .kra file */ QByteArray serializeToNativeByteArray(); /** * @brief isInSaving shown if the document has any (background) saving process or not * @return true if there is some saving in action */ bool isInSaving() const; public Q_SLOTS: /** * Adds a command to the undo stack and executes it by calling the redo() function. * @param command command to add to the undo stack */ void addCommand(KUndo2Command *command); /** * Begins recording of a macro command. At the end endMacro needs to be called. * @param text command description */ void beginMacro(const KUndo2MagicString &text); /** * Ends the recording of a macro command. */ void endMacro(); Q_SIGNALS: /** * This signal is emitted when the unit is changed by setUnit(). * It is common to connect views to it, in order to change the displayed units * (e.g. in the rulers) */ void unitChanged(const KoUnit &unit); /** * Emitted e.g. at the beginning of a save operation * This is emitted by KisDocument and used by KisView to display a statusbar message */ void statusBarMessage(const QString& text, int timeout = 0); /** * Emitted e.g. at the end of a save operation * This is emitted by KisDocument and used by KisView to clear the statusbar message */ void clearStatusBarMessage(); /** * Emitted when the document is modified */ void modified(bool); void titleModified(const QString &caption, bool isModified); void sigLoadingFinished(); void sigSavingFinished(); void sigGuidesConfigChanged(const KisGuidesConfig &config); void sigBackgroundSavingFinished(KisImportExportErrorCode status, const QString &errorMessage); void sigCompleteBackgroundSaving(const KritaUtils::ExportFileJob &job, KisImportExportErrorCode status, const QString &errorMessage); void sigReferenceImagesChanged(); void sigMirrorAxisConfigChanged(); void sigGridConfigChanged(const KisGridConfig &config); void sigReferenceImagesLayerChanged(KisSharedPtr layer); /** * Emitted when the palette list has changed. * The pointers in oldPaletteList are to be deleted by the resource server. **/ void sigPaletteListChanged(const QList &oldPaletteList, const QList &newPaletteList); void sigAssistantsChanged(); private Q_SLOTS: void finishExportInBackground(); void slotChildCompletedSavingInBackground(KisImportExportErrorCode status, const QString &errorMessage); void slotCompleteAutoSaving(const KritaUtils::ExportFileJob &job, KisImportExportErrorCode status, const QString &errorMessage); void slotCompleteSavingDocument(const KritaUtils::ExportFileJob &job, KisImportExportErrorCode status, const QString &errorMessage); void slotInitiateAsyncAutosaving(KisDocument *clonedDocument); void slotPerformIdleRoutines(); private: friend class KisPart; friend class SafeSavingLocker; bool initiateSavingInBackground(const QString actionName, const QObject *receiverObject, const char *receiverMethod, const KritaUtils::ExportFileJob &job, KisPropertiesConfigurationSP exportConfiguration, std::unique_ptr &&optionalClonedDocument); bool initiateSavingInBackground(const QString actionName, const QObject *receiverObject, const char *receiverMethod, const KritaUtils::ExportFileJob &job, KisPropertiesConfigurationSP exportConfiguration); bool startExportInBackground(const QString &actionName, const QString &location, const QString &realLocation, const QByteArray &mimeType, bool showWarnings, KisPropertiesConfigurationSP exportConfiguration); /** * Activate/deactivate/configure the autosave feature. * @param delay in seconds, 0 to disable */ void setAutoSaveDelay(int delay); /** * Generate a name for the document. */ QString newObjectName(); QString generateAutoSaveFileName(const QString & path) const; /** * Loads a document * * Applies a filter if necessary, and calls loadNativeFormat in any case * You should not have to reimplement, except for very special cases. * * NOTE: this method also creates a new KisView instance! * * This method is called from the KReadOnlyPart::openUrl method. */ bool openFile(); public: - bool isAutosaving() const override; + bool isAutosaving() const; public: - QString localFilePath() const override; + QString localFilePath() const; void setLocalFilePath( const QString &localFilePath ); KoDocumentInfoDlg* createDocumentInfoDialog(QWidget *parent, KoDocumentInfo *docInfo) const; bool isReadWrite() const; - QUrl url() const override; - void setUrl(const QUrl &url) override; + QUrl url() const; + void setUrl(const QUrl &url); bool closeUrl(bool promptToSave = true); bool saveAs(const QUrl &url, const QByteArray &mimeType, bool showWarnings, KisPropertiesConfigurationSP exportConfigration = 0); /** * Create a new image that has this document as a parent and * replace the current image with this image. */ bool newImage(const QString& name, qint32 width, qint32 height, const KoColorSpace * cs, const KoColor &bgColor, KisConfig::BackgroundStyle bgStyle, int numberOfLayers, const QString &imageDescription, const double imageResolution); bool isSaving() const; void waitForSavingToComplete(); KisImageWSP image() const; /** * @brief savingImage provides a detached, shallow copy of the original image that must be used when saving. * Any strokes in progress will not be applied to this image, so the result might be missing some data. On * the other hand, it won't block. * * @return a shallow copy of the original image, or 0 is saving is not in progress */ KisImageSP savingImage() const; /** * Set the current image to the specified image and turn undo on. */ void setCurrentImage(KisImageSP image, bool forceInitialUpdate = true); /** * Set the image of the document preliminary, before the document * has completed loading. Some of the document items (shapes) may want * to access image properties (bounds and resolution), so we should provide * it to them even before the entire image is loaded. * * Right now, the only use by KoShapeRegistry::createShapeFromOdf(), remove * after it is deprecated. */ void hackPreliminarySetImage(KisImageSP image); KisUndoStore* createUndoStore(); /** * The shape controller matches internal krita image layers with * the flake shape hierarchy. */ KoShapeControllerBase * shapeController() const; KoShapeLayer* shapeForNode(KisNodeSP layer) const; /** * Set the list of nodes that was marked as currently active. Used *only* * for saving loading. Never use it for tools or processing. */ void setPreActivatedNode(KisNodeSP activatedNode); /** * @return the node that was set as active during loading. Used *only* * for saving loading. Never use it for tools or processing. */ KisNodeSP preActivatedNode() const; /// @return the list of assistants associated with this document QList assistants() const; /// @replace the current list of assistants with @param value void setAssistants(const QList &value); void setAssistantsGlobalColor(QColor color); QColor assistantsGlobalColor(); /** * Get existing reference images layer or null if none exists. */ KisSharedPtr referenceImagesLayer() const; void setReferenceImagesLayer(KisSharedPtr layer, bool updateImage); bool save(bool showWarnings, KisPropertiesConfigurationSP exportConfiguration); /** * Return the bounding box of the image and associated elements (e.g. reference images) */ QRectF documentBounds() const; /** * @brief Start saving when android activity is pushed to the background */ void autoSaveOnPause(); Q_SIGNALS: void completed(); void canceled(const QString &); private Q_SLOTS: void setImageModified(); void slotAutoSave(); void slotUndoStackCleanChanged(bool value); void slotConfigChanged(); void slotImageRootChanged(); /** * @brief try to clone the image. This method handles all the locking for you. If locking * has failed, no cloning happens * @return cloned document on success, null otherwise */ KisDocument *lockAndCloneForSaving(); public: KisDocument *lockAndCreateSnapshot(); void copyFromDocument(const KisDocument &rhs); private: enum CopyPolicy { CONSTRUCT = 0, ///< we are copy-constructing a new KisDocument REPLACE ///< we are replacing the current KisDocument with another }; void copyFromDocumentImpl(const KisDocument &rhs, CopyPolicy policy); QString exportErrorToUserMessage(KisImportExportErrorCode status, const QString &errorMessage); QString prettyPathOrUrl() const; bool openUrlInternal(const QUrl &url); void slotAutoSaveImpl(std::unique_ptr &&optionalClonedDocument); class Private; Private *const d; }; Q_DECLARE_OPERATORS_FOR_FLAGS(KisDocument::OpenFlags) Q_DECLARE_METATYPE(KisDocument*) #endif diff --git a/libs/odf/KoDocumentInfo.cpp b/libs/ui/KoDocumentInfo.cpp similarity index 98% rename from libs/odf/KoDocumentInfo.cpp rename to libs/ui/KoDocumentInfo.cpp index 76b9753047..9f6f2a5db0 100644 --- a/libs/odf/KoDocumentInfo.cpp +++ b/libs/ui/KoDocumentInfo.cpp @@ -1,467 +1,467 @@ /* This file is part of the KDE project Copyright (C) 1998, 1999, 2000 Torben Weis Copyright (C) 2004 David Faure This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KoDocumentInfo.h" -#include "KoDocumentBase.h" +#include "KisDocument.h" #include "KoOdfWriteStore.h" #include "KoXmlNS.h" #include #include #include #include #include #include #include #include #include #include #include #include #include KoDocumentInfo::KoDocumentInfo(QObject *parent) : QObject(parent) { m_aboutTags << "title" << "description" << "subject" << "abstract" << "keyword" << "initial-creator" << "editing-cycles" << "editing-time" << "date" << "creation-date" << "language" << "license"; m_authorTags << "creator" << "creator-first-name" << "creator-last-name" << "initial" << "author-title" << "position" << "company"; m_contactTags << "email" << "telephone" << "telephone-work" << "fax" << "country" << "postal-code" << "city" << "street"; setAboutInfo("editing-cycles", "0"); setAboutInfo("time-elapsed", "0"); setAboutInfo("initial-creator", i18n("Unknown")); setAboutInfo("creation-date", QDateTime::currentDateTime() .toString(Qt::ISODate)); } KoDocumentInfo::KoDocumentInfo(const KoDocumentInfo &rhs, QObject *parent) : QObject(parent), m_aboutTags(rhs.m_aboutTags), m_authorTags(rhs.m_authorTags), m_contact(rhs.m_contact), m_authorInfo(rhs.m_authorInfo), m_authorInfoOverride(rhs.m_authorInfoOverride), m_aboutInfo(rhs.m_aboutInfo), m_generator(rhs.m_generator) { } KoDocumentInfo::~KoDocumentInfo() { } bool KoDocumentInfo::load(const KoXmlDocument &doc) { m_authorInfo.clear(); if (!loadAboutInfo(doc.documentElement())) return false; if (!loadAuthorInfo(doc.documentElement())) return false; return true; } QDomDocument KoDocumentInfo::save(QDomDocument &doc) { updateParametersAndBumpNumCycles(); QDomElement s = saveAboutInfo(doc); if (!s.isNull()) doc.documentElement().appendChild(s); s = saveAuthorInfo(doc); if (!s.isNull()) doc.documentElement().appendChild(s); if (doc.documentElement().isNull()) return QDomDocument(); return doc; } void KoDocumentInfo::setAuthorInfo(const QString &info, const QString &data) { if (!m_authorTags.contains(info) && !m_contactTags.contains(info) && !info.contains("contact-mode-")) { return; } m_authorInfoOverride.insert(info, data); } void KoDocumentInfo::setActiveAuthorInfo(const QString &info, const QString &data) { if (!m_authorTags.contains(info) && !m_contactTags.contains(info) && !info.contains("contact-mode-")) { return; } if (m_contactTags.contains(info)) { m_contact.insert(data, info); } else { m_authorInfo.insert(info, data); } emit infoUpdated(info, data); } QString KoDocumentInfo::authorInfo(const QString &info) const { if (!m_authorTags.contains(info) && !m_contactTags.contains(info) && !info.contains("contact-mode-")) return QString(); return m_authorInfo[ info ]; } QStringList KoDocumentInfo::authorContactInfo() const { return m_contact.keys(); } void KoDocumentInfo::setAboutInfo(const QString &info, const QString &data) { if (!m_aboutTags.contains(info)) return; m_aboutInfo.insert(info, data); emit infoUpdated(info, data); } QString KoDocumentInfo::aboutInfo(const QString &info) const { if (!m_aboutTags.contains(info)) { return QString(); } return m_aboutInfo[info]; } bool KoDocumentInfo::saveOasisAuthorInfo(KoXmlWriter &xmlWriter) { Q_FOREACH (const QString & tag, m_authorTags) { if (!authorInfo(tag).isEmpty() && tag == "creator") { xmlWriter.startElement("dc:creator"); xmlWriter.addTextNode(authorInfo("creator")); xmlWriter.endElement(); } else if (!authorInfo(tag).isEmpty()) { xmlWriter.startElement("meta:user-defined"); xmlWriter.addAttribute("meta:name", tag); xmlWriter.addTextNode(authorInfo(tag)); xmlWriter.endElement(); } } return true; } bool KoDocumentInfo::loadOasisAuthorInfo(const KoXmlNode &metaDoc) { KoXmlElement e = KoXml::namedItemNS(metaDoc, KoXmlNS::dc, "creator"); if (!e.isNull() && !e.text().isEmpty()) setActiveAuthorInfo("creator", e.text()); KoXmlNode n = metaDoc.firstChild(); for (; !n.isNull(); n = n.nextSibling()) { if (!n.isElement()) continue; KoXmlElement e = n.toElement(); if (!(e.namespaceURI() == KoXmlNS::meta && e.localName() == "user-defined" && !e.text().isEmpty())) continue; QString name = e.attributeNS(KoXmlNS::meta, "name", QString()); setActiveAuthorInfo(name, e.text()); } return true; } bool KoDocumentInfo::loadAuthorInfo(const KoXmlElement &e) { m_contact.clear(); KoXmlNode n = e.namedItem("author").firstChild(); for (; !n.isNull(); n = n.nextSibling()) { KoXmlElement e = n.toElement(); if (e.isNull()) continue; if (e.tagName() == "full-name") { setActiveAuthorInfo("creator", e.text().trimmed()); } else if (e.tagName() == "contact") { m_contact.insert(e.text(), e.attribute("type")); } else { setActiveAuthorInfo(e.tagName(), e.text().trimmed()); } } return true; } QDomElement KoDocumentInfo::saveAuthorInfo(QDomDocument &doc) { QDomElement e = doc.createElement("author"); QDomElement t; Q_FOREACH (const QString &tag, m_authorTags) { if (tag == "creator") t = doc.createElement("full-name"); else t = doc.createElement(tag); e.appendChild(t); t.appendChild(doc.createTextNode(authorInfo(tag))); } for (int i=0; i 0) { setAboutInfo("keyword", keywords.join(", ")); } return true; } bool KoDocumentInfo::loadAboutInfo(const KoXmlElement &e) { KoXmlNode n = e.namedItem("about").firstChild(); KoXmlElement tmp; for (; !n.isNull(); n = n.nextSibling()) { tmp = n.toElement(); if (tmp.isNull()) continue; if (tmp.tagName() == "abstract") setAboutInfo("abstract", tmp.text()); setAboutInfo(tmp.tagName(), tmp.text()); } return true; } QDomElement KoDocumentInfo::saveAboutInfo(QDomDocument &doc) { QDomElement e = doc.createElement("about"); QDomElement t; Q_FOREACH (const QString &tag, m_aboutTags) { if (tag == "abstract") { t = doc.createElement("abstract"); e.appendChild(t); t.appendChild(doc.createCDATASection(aboutInfo(tag))); } else { t = doc.createElement(tag); e.appendChild(t); t.appendChild(doc.createTextNode(aboutInfo(tag))); } } return e; } void KoDocumentInfo::updateParametersAndBumpNumCycles() { - KoDocumentBase *doc = dynamic_cast< KoDocumentBase *>(parent()); + KisDocument *doc = dynamic_cast< KisDocument *>(parent()); if (doc && doc->isAutosaving()) { return; } setAboutInfo("editing-cycles", QString::number(aboutInfo("editing-cycles").toInt() + 1)); setAboutInfo("date", QDateTime::currentDateTime().toString(Qt::ISODate)); updateParameters(); } void KoDocumentInfo::updateParameters() { - KoDocumentBase *doc = dynamic_cast< KoDocumentBase *>(parent()); + KisDocument *doc = dynamic_cast< KisDocument *>(parent()); if (doc && (!doc->isModified())) { return; } KConfig config("kritarc"); config.reparseConfiguration(); KConfigGroup appAuthorGroup(&config, "Author"); QString profile = appAuthorGroup.readEntry("active-profile", ""); QString authorInfo = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/authorinfo/"; QDir dir(authorInfo); QStringList filters = QStringList() << "*.authorinfo"; //Anon case setActiveAuthorInfo("creator", QString()); setActiveAuthorInfo("initial", ""); setActiveAuthorInfo("author-title", ""); setActiveAuthorInfo("position", ""); setActiveAuthorInfo("company", ""); if (dir.entryList(filters).contains(profile+".authorinfo")) { QFile file(dir.absoluteFilePath(profile+".authorinfo")); if (file.exists()) { file.open(QFile::ReadOnly); QByteArray ba = file.readAll(); file.close(); QDomDocument doc = QDomDocument(); doc.setContent(ba); QDomElement root = doc.firstChildElement(); QDomElement el = root.firstChildElement("nickname"); if (!el.isNull()) { setActiveAuthorInfo("creator", el.text()); } el = root.firstChildElement("givenname"); if (!el.isNull()) { setActiveAuthorInfo("creator-first-name", el.text()); } el = root.firstChildElement("middlename"); if (!el.isNull()) { setActiveAuthorInfo("initial", el.text()); } el = root.firstChildElement("familyname"); if (!el.isNull()) { setActiveAuthorInfo("creator-last-name", el.text()); } el = root.firstChildElement("title"); if (!el.isNull()) { setActiveAuthorInfo("author-title", el.text()); } el = root.firstChildElement("position"); if (!el.isNull()) { setActiveAuthorInfo("position", el.text()); } el = root.firstChildElement("company"); if (!el.isNull()) { setActiveAuthorInfo("company", el.text()); } m_contact.clear(); el = root.firstChildElement("contact"); while (!el.isNull()) { m_contact.insert(el.text(), el.attribute("type")); el = el.nextSiblingElement("contact"); } } } //allow author info set programmatically to override info from author profile Q_FOREACH (const QString &tag, m_authorTags) { if (m_authorInfoOverride.contains(tag)) { setActiveAuthorInfo(tag, m_authorInfoOverride.value(tag)); } } } void KoDocumentInfo::resetMetaData() { setAboutInfo("editing-cycles", QString::number(0)); setAboutInfo("initial-creator", authorInfo("creator")); setAboutInfo("creation-date", QDateTime::currentDateTime().toString(Qt::ISODate)); setAboutInfo("editing-time", QString::number(0)); } QString KoDocumentInfo::originalGenerator() const { return m_generator; } void KoDocumentInfo::setOriginalGenerator(const QString &generator) { m_generator = generator; } diff --git a/libs/odf/KoDocumentInfo.h b/libs/ui/KoDocumentInfo.h similarity index 98% rename from libs/odf/KoDocumentInfo.h rename to libs/ui/KoDocumentInfo.h index 019b0b45fb..b73932c88c 100644 --- a/libs/odf/KoDocumentInfo.h +++ b/libs/ui/KoDocumentInfo.h @@ -1,224 +1,224 @@ /* This file is part of the KDE project Copyright (C) 1998, 1999, 2000 Torben Weis Copyright (C) 2004 David Faure Copyright (C) 2006 Martin Pfeiffer This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KO_DOCUMENT_INFO_H #define KO_DOCUMENT_INFO_H #include #include #include #include -#include "kritaodf_export.h" +#include "kritaui_export.h" #include class QDomDocument; class QDomElement; class KoStore; class KoXmlWriter; /** * @short The class containing all meta information about a document * * @author Torben Weis * @author David Faure * @author Martin Pfeiffer * @see KoDocumentInfoDlg * * This class contains the meta information for a document. They are * stored in two QMap and can be accessed through aboutInfo() and authorInfo(). * The about info can be changed with setAboutInfo() and setAuthorInfo() */ -class KRITAODF_EXPORT KoDocumentInfo : public QObject +class KRITAUI_EXPORT KoDocumentInfo : public QObject { Q_OBJECT public: /** * The constructor * @param parent a pointer to the parent object */ explicit KoDocumentInfo(QObject *parent = 0); explicit KoDocumentInfo(const KoDocumentInfo &rhs, QObject *parent = 0); /** The destructor */ ~KoDocumentInfo() override; /** * Load the KoDocumentInfo from an Calligra-1.3 DomDocument * @param doc the QDomDocument to load from * @return true if success */ bool load(const KoXmlDocument& doc); /** * Save the KoDocumentInfo to an Calligra-1.3 DomDocument * @return the QDomDocument to which was saved */ QDomDocument save(QDomDocument &doc); /** * Set information about the author. * This will override any information retrieved from the author profile * But it does not change the author profile * Note: authorInfo() will not return the new value until the document has been * saved by the user.(autosave doesn't count) * @param info the kind of information to set * @param data the data to set for this information */ void setAuthorInfo(const QString& info, const QString& data); /** * Obtain information about the author * @param info the kind of information to obtain * @return a QString with the information */ QString authorInfo(const QString& info) const; /** * @brief authorContactInfo * @return returns list of contact info for author. */ QStringList authorContactInfo() const; /** * Set information about the document * @param info the kind of information to set * @param data the data to set for this information */ void setAboutInfo(const QString& info, const QString& data); /** * Obtain information about the document * @param info the kind of information to obtain * @return a QString with the information */ QString aboutInfo(const QString& info) const; /** * Obtain the generator of the document, as it was loaded from the document */ QString originalGenerator() const; /** * Sets the original generator of the document. This does not affect what gets * saved to a document in the meta:generator field, it only changes what * originalGenerator() will return. */ void setOriginalGenerator(const QString& generator); /** Resets part of the meta data */ void resetMetaData(); /** Takes care of updating the document info from configuration correctly */ void updateParameters(); private: /// Bumps the editing cycles count and save date, and then calls updateParameters void updateParametersAndBumpNumCycles(); /** * Set information about the author * This sets what is actually saved to file. The public method setAuthorInfo() can be used to set * values that override what is fetched from the author profile. During saveParameters() author * profile and any overrides is combined resulting in calls to this method. * @param info the kind of information to set * @param data the data to set for this information */ void setActiveAuthorInfo(const QString& info, const QString& data); /** * Load the information about the document from an OASIS file * @param metaDoc a reference to the information node * @return true if success */ bool loadOasisAboutInfo(const KoXmlNode& metaDoc); /** * Save the information about the document to an OASIS file * @param xmlWriter a reference to the KoXmlWriter to write in * @return true if success */ bool saveOasisAboutInfo(KoXmlWriter &xmlWriter); /** * Load the information about the document from a Calligra-1.3 file * @param e the element to load from * @return true if success */ bool loadAboutInfo(const KoXmlElement& e); /** * Save the information about the document to a Calligra-1.3 file * @param doc the QDomDocument to save in * @return the QDomElement to which was saved */ QDomElement saveAboutInfo(QDomDocument& doc); /** * Load the information about the document from an OASIS file * @param metaDoc a reference to the information node * @return true if success */ bool loadOasisAuthorInfo(const KoXmlNode& metaDoc); /** * Load the information about the document from a Calligra-1.3 file * @param e the element to load from * @return true if success */ bool loadAuthorInfo(const KoXmlElement& e); /** * Save the information about the author to a Calligra-1.3 file * @param doc the QDomDocument to save in * @return the QDomElement to which was saved */ QDomElement saveAuthorInfo(QDomDocument& doc); /** * Save the information about the document to an OASIS file * @param xmlWriter a reference to the KoXmlWriter to write in * @return true if success */ bool saveOasisAuthorInfo(KoXmlWriter &xmlWriter); /** A QStringList containing all tags for the document information */ QStringList m_aboutTags; /** A QStringList containing all tags for the author information */ QStringList m_authorTags; /** A QStringList containing all valid contact tags */ QStringList m_contactTags; /** A QMap with the contact modes and their type in the second string */ QMap m_contact; /** The map containing information about the author */ QMap m_authorInfo; /** The map containing information about the author set programmatically*/ QMap m_authorInfoOverride; /** The map containing information about the document */ QMap m_aboutInfo; /** The original meta:generator of the document */ QString m_generator; Q_SIGNALS: void infoUpdated(const QString &info, const QString &data); }; #endif diff --git a/libs/widgets/KoDocumentInfoDlg.cpp b/libs/ui/KoDocumentInfoDlg.cpp similarity index 98% rename from libs/widgets/KoDocumentInfoDlg.cpp rename to libs/ui/KoDocumentInfoDlg.cpp index a08f3af681..c4b762f5ce 100644 --- a/libs/widgets/KoDocumentInfoDlg.cpp +++ b/libs/ui/KoDocumentInfoDlg.cpp @@ -1,327 +1,327 @@ /* This file is part of the KDE project Copyright (c) 2000 Simon Hausmann 2006 Martin Pfeiffer This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "KoDocumentInfoDlg.h" #include "ui_koDocumentInfoAboutWidget.h" #include "ui_koDocumentInfoAuthorWidget.h" #include "KoDocumentInfo.h" -#include "KoDocumentBase.h" +#include "KisDocument.h" #include "KoPageWidgetItem.h" #include #include #include #include #include #include #include #include #include class KoPageWidgetItemAdapter : public KPageWidgetItem { public: KoPageWidgetItemAdapter(KoPageWidgetItem *item) : KPageWidgetItem(item->widget(), item->name()) , m_item(item) { setHeader(item->name()); setIcon(KisIconUtils::loadIcon(item->iconName())); } ~KoPageWidgetItemAdapter() override { delete m_item; } bool shouldDialogCloseBeVetoed() { return m_item->shouldDialogCloseBeVetoed(); } void apply() { m_item->apply(); } private: KoPageWidgetItem * const m_item; }; class KoDocumentInfoDlg::KoDocumentInfoDlgPrivate { public: KoDocumentInfoDlgPrivate() : documentSaved(false) {} ~KoDocumentInfoDlgPrivate() {} KoDocumentInfo* info; QList pages; Ui::KoDocumentInfoAboutWidget* aboutUi; Ui::KoDocumentInfoAuthorWidget* authorUi; bool documentSaved; }; KoDocumentInfoDlg::KoDocumentInfoDlg(QWidget* parent, KoDocumentInfo* docInfo) : KPageDialog(parent) , d(new KoDocumentInfoDlgPrivate) { d->info = docInfo; setWindowTitle(i18n("Document Information")); // setInitialSize(QSize(500, 500)); setFaceType(KPageDialog::List); setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); button(QDialogButtonBox::Ok)->setDefault(true); d->aboutUi = new Ui::KoDocumentInfoAboutWidget(); QWidget *infodlg = new QWidget(); d->aboutUi->setupUi(infodlg); QStringList licenseExamples; licenseExamples << "CC-BY 4.0" << "CC-BY-SA 4.0" << "CC-BY-SA-NC 4.0" << "CC-0"; QCompleter *examples = new QCompleter(licenseExamples); examples->setCaseSensitivity(Qt::CaseInsensitive); examples->setCompletionMode(QCompleter::PopupCompletion); d->aboutUi->leLicense->setCompleter(examples); KPageWidgetItem *page = new KPageWidgetItem(infodlg, i18n("General")); page->setHeader(i18n("General")); // Ugly hack, the mimetype should be a parameter, instead - KoDocumentBase* doc = dynamic_cast< KoDocumentBase* >(d->info->parent()); + KisDocument* doc = dynamic_cast< KisDocument* >(d->info->parent()); if (doc) { page->setIcon(KisIconUtils::loadIcon(KisMimeDatabase::iconNameForMimeType(doc->mimeType()))); } else { // hide all entries not used in pages for KoDocumentInfoPropsPage d->aboutUi->filePathInfoLabel->setVisible(false); d->aboutUi->filePathLabel->setVisible(false); d->aboutUi->filePathSeparatorLine->setVisible(false); d->aboutUi->lblTypeDesc->setVisible(false); d->aboutUi->lblType->setVisible(false); } addPage(page); d->pages.append(page); initAboutTab(); d->authorUi = new Ui::KoDocumentInfoAuthorWidget(); QWidget *authordlg = new QWidget(); d->authorUi->setupUi(authordlg); page = new KPageWidgetItem(authordlg, i18n("Author")); page->setHeader(i18n("Last saved by")); page->setIcon(koIcon("user-identity")); addPage(page); d->pages.append(page); initAuthorTab(); } KoDocumentInfoDlg::~KoDocumentInfoDlg() { delete d->authorUi; delete d->aboutUi; delete d; } void KoDocumentInfoDlg::accept() { // check if any pages veto the close Q_FOREACH (KPageWidgetItem* item, d->pages) { KoPageWidgetItemAdapter *page = dynamic_cast(item); if (page) { if (page->shouldDialogCloseBeVetoed()) { return; } } } // all fine, go and apply saveAboutData(); Q_FOREACH (KPageWidgetItem* item, d->pages) { KoPageWidgetItemAdapter *page = dynamic_cast(item); if (page) { page->apply(); } } KPageDialog::accept(); } bool KoDocumentInfoDlg::isDocumentSaved() { return d->documentSaved; } void KoDocumentInfoDlg::initAboutTab() { - KoDocumentBase* doc = dynamic_cast< KoDocumentBase* >(d->info->parent()); + KisDocument* doc = dynamic_cast< KisDocument* >(d->info->parent()); if (doc) { d->aboutUi->filePathLabel->setText(doc->localFilePath()); } d->aboutUi->leTitle->setText(d->info->aboutInfo("title")); d->aboutUi->leSubject->setText(d->info->aboutInfo("subject")); d->aboutUi->leKeywords->setToolTip(i18n("Use ';' (Example: Office;KDE;Calligra)")); if (!d->info->aboutInfo("keyword").isEmpty()) d->aboutUi->leKeywords->setText(d->info->aboutInfo("keyword")); if (!d->info->aboutInfo("license").isEmpty()) { d->aboutUi->leLicense->setText(d->info->aboutInfo("license")); } d->aboutUi->meDescription->setPlainText(d->info->aboutInfo("abstract")); if (doc && !doc->mimeType().isEmpty()) { d->aboutUi->lblType->setText(KisMimeDatabase::descriptionForMimeType(doc->mimeType())); } if (!d->info->aboutInfo("creation-date").isEmpty()) { QDateTime t = QDateTime::fromString(d->info->aboutInfo("creation-date"), Qt::ISODate); QString s = QLocale().toString(t); d->aboutUi->lblCreated->setText(s + ", " + d->info->aboutInfo("initial-creator")); } if (!d->info->aboutInfo("date").isEmpty()) { QDateTime t = QDateTime::fromString(d->info->aboutInfo("date"), Qt::ISODate); QString s = QLocale().toString(t); d->aboutUi->lblModified->setText(s + ", " + d->info->authorInfo("creator")); } d->aboutUi->lblRevision->setText(d->info->aboutInfo("editing-cycles")); updateEditingTime(); connect(d->aboutUi->pbReset, SIGNAL(clicked()), this, SLOT(slotResetMetaData())); } void KoDocumentInfoDlg::initAuthorTab() { d->authorUi->nickName->setText(d->info->authorInfo("creator")); d->authorUi->firstName->setText(d->info->authorInfo("creator-first-name")); d->authorUi->lastName->setText(d->info->authorInfo("creator-last-name")); d->authorUi->initials->setText(d->info->authorInfo("initial")); d->authorUi->title->setText(d->info->authorInfo("author-title")); d->authorUi->company->setText(d->info->authorInfo("company")); d->authorUi->position->setText(d->info->authorInfo("position")); QListWidget *contact = d->authorUi->leContact; Q_FOREACH(QString contactMode, d->info->authorContactInfo()) { if (!contactMode.isEmpty()) { contact->addItem(contactMode); } } } void KoDocumentInfoDlg::saveAboutData() { d->info->setAboutInfo("keyword", d->aboutUi->leKeywords->text()); d->info->setAboutInfo("title", d->aboutUi->leTitle->text()); d->info->setAboutInfo("subject", d->aboutUi->leSubject->text()); d->info->setAboutInfo("abstract", d->aboutUi->meDescription->toPlainText()); d->info->setAboutInfo("license", d->aboutUi->leLicense->text()); } void KoDocumentInfoDlg::hideEvent( QHideEvent *event ) { Q_UNUSED(event); } void KoDocumentInfoDlg::slotResetMetaData() { d->info->resetMetaData(); if (!d->info->aboutInfo("creation-date").isEmpty()) { QDateTime t = QDateTime::fromString(d->info->aboutInfo("creation-date"), Qt::ISODate); QString s = QLocale().toString(t); d->aboutUi->lblCreated->setText(s + ", " + d->info->aboutInfo("initial-creator")); } if (!d->info->aboutInfo("date").isEmpty()) { QDateTime t = QDateTime::fromString(d->info->aboutInfo("date"), Qt::ISODate); QString s = QLocale().toString(t); d->aboutUi->lblModified->setText(s + ", " + d->info->authorInfo("creator")); } d->aboutUi->lblRevision->setText(d->info->aboutInfo("editing-cycles")); } QList KoDocumentInfoDlg::pages() const { return d->pages; } void KoDocumentInfoDlg::setReadOnly(bool ro) { d->aboutUi->meDescription->setReadOnly(ro); Q_FOREACH(KPageWidgetItem* page, d->pages) { Q_FOREACH(QLineEdit* le, page->widget()->findChildren()) { le->setReadOnly(ro); } Q_FOREACH(QPushButton* le, page->widget()->findChildren()) { le->setDisabled(ro); } } } void KoDocumentInfoDlg::addPageItem(KoPageWidgetItem *item) { KPageWidgetItem * page = new KoPageWidgetItemAdapter(item); addPage(page); d->pages.append(page); } void KoDocumentInfoDlg::updateEditingTime() { const int timeElapsed = d->info->aboutInfo("editing-time").toInt(); const int secondsElapsed = timeElapsed % 60; const int minutesElapsed = (timeElapsed / 60) % 60; const int hoursElapsed = (timeElapsed / 3600) % 24; const int daysElapsed = (timeElapsed / 86400) % 7; const int weeksElapsed = timeElapsed / 604800; QString majorTimeUnit; QString minorTimeUnit; if (weeksElapsed > 0) { majorTimeUnit = i18np("%1 week", "%1 weeks", weeksElapsed); minorTimeUnit = i18np("%1 day", "%1 days", daysElapsed); } else if (daysElapsed > 0) { majorTimeUnit = i18np("%1 day", "%1 days", daysElapsed); minorTimeUnit = i18np("%1 hour", "%1 hours", hoursElapsed); } else if (hoursElapsed > 0) { majorTimeUnit = i18np("%1 hour", "%1 hours", hoursElapsed); minorTimeUnit = i18np("%1 minute", "%1 minutes", minutesElapsed); } else if (minutesElapsed > 0) { majorTimeUnit = i18np("%1 minute", "%1 minutes", minutesElapsed); minorTimeUnit = i18np("%1 second", "%1 seconds", secondsElapsed); } else { d->aboutUi->lblEditing->setText(i18np("%1 second", "%1 seconds", secondsElapsed)); return; } d->aboutUi->lblEditing->setText(i18nc( "major time unit and minor time unit", "%1 and %2", majorTimeUnit, minorTimeUnit )); } diff --git a/libs/widgets/KoDocumentInfoDlg.h b/libs/ui/KoDocumentInfoDlg.h similarity index 96% rename from libs/widgets/KoDocumentInfoDlg.h rename to libs/ui/KoDocumentInfoDlg.h index 10d626a645..50deb3c627 100644 --- a/libs/widgets/KoDocumentInfoDlg.h +++ b/libs/ui/KoDocumentInfoDlg.h @@ -1,102 +1,102 @@ /* This file is part of the KDE project Copyright (c) 2000 Simon Hausmann 2006 Martin Pfeiffer This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef __koDocumentInfoDlg_h__ #define __koDocumentInfoDlg_h__ #include class KoDocumentInfo; class KPageWidgetItem; class KoPageWidgetItem; -#include "kritawidgets_export.h" +#include "kritaui_export.h" /** * @short The dialog that shows information about the document * @author Simon Hausmann * @author Martin Pfeiffer * @see KoDocumentInfo * * This dialog is invoked by KoMainWindow and shows the content * of the given KoDocumentInfo class. It consists of several pages, * one showing general information about the document and an other * showing information about the author. * This dialog implements only things that are stored in the OASIS * meta.xml file and therefore available through the KoDocumentInfo * class. * The widgets shown in the tabs are koDocumentInfoAboutWidget and * koDocumentInfoAuthorWidget. This class here is derived from * KPageDialog and uses the face type Tabbed. */ -class KRITAWIDGETS_EXPORT KoDocumentInfoDlg : public KPageDialog +class KRITAUI_EXPORT KoDocumentInfoDlg : public KPageDialog { Q_OBJECT public: /** * The constructor * @param parent a pointer to the parent widget * @param docInfo a pointer to the shown KoDocumentInfo */ KoDocumentInfoDlg(QWidget *parent, KoDocumentInfo* docInfo); /** The destructor */ ~KoDocumentInfoDlg() override; QList pages() const; /** Returns true if the document was saved when the dialog was closed */ bool isDocumentSaved(); /** Sets all fields to read-only mode. Used by the property dialog. */ void setReadOnly(bool ro); void addPageItem(KoPageWidgetItem *item); public Q_SLOTS: // QDialog API void accept() override; protected: // QWidget API void hideEvent(QHideEvent * event) override; private Q_SLOTS: /** Connected with clicked() from pbReset - Reset parts of the metadata */ void slotResetMetaData(); Q_SIGNALS: void saveRequested(); private: /** Sets up the aboutWidget and fills the widgets with content */ void initAboutTab(); /** Sets up the authorWidget and fills the widgets with content */ void initAuthorTab(); /** Saves the changed data back to the KoDocumentInfo class */ void saveAboutData(); void updateEditingTime(); class KoDocumentInfoDlgPrivate; KoDocumentInfoDlgPrivate * const d; }; #endif diff --git a/libs/widgets/koDocumentInfoAboutWidget.ui b/libs/ui/forms/koDocumentInfoAboutWidget.ui similarity index 100% rename from libs/widgets/koDocumentInfoAboutWidget.ui rename to libs/ui/forms/koDocumentInfoAboutWidget.ui diff --git a/libs/widgets/koDocumentInfoAuthorWidget.ui b/libs/ui/forms/koDocumentInfoAuthorWidget.ui similarity index 100% rename from libs/widgets/koDocumentInfoAuthorWidget.ui rename to libs/ui/forms/koDocumentInfoAuthorWidget.ui diff --git a/libs/widgets/CMakeLists.txt b/libs/widgets/CMakeLists.txt index 9244804bb7..28ad5cd973 100644 --- a/libs/widgets/CMakeLists.txt +++ b/libs/widgets/CMakeLists.txt @@ -1,115 +1,111 @@ add_subdirectory( tests ) include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(kritawidgets_LIB_SRCS KoVBox.cpp KoDialog.cpp KoZoomWidget.cpp KoAspectButton.cpp KoSliderCombo.cpp KoColorPopupButton.cpp KoConfigAuthorPage.cpp KoUnitDoubleSpinBox.cpp KoZoomAction.cpp KoZoomController.cpp KoZoomInput.cpp KoZoomHandler.cpp KoZoomMode.cpp KoDpi.cpp KoColorPatch.cpp KoColorPopupAction.cpp KoColorSetWidget.cpp KoColorSlider.cpp KoTriangleColorSelector.cpp KoResourcePopupAction.cpp KoRuler.cpp KoResourceServerProvider.cpp KoLineStyleSelector.cpp KoLineStyleItemDelegate.cpp KoLineStyleModel.cpp KoTitledTabWidget.cpp KoToolBoxButton.cpp KoToolBox.cpp KoToolBoxDocker.cpp KoToolBoxFactory.cpp KoToolDocker.cpp KoShadowConfigWidget.cpp KoMarkerSelector.cpp KoMarkerModel.cpp KoMarkerItemDelegate.cpp - KoDocumentInfoDlg.cpp - WidgetsDebug.cpp kis_file_name_requester.cpp KisColorSelectorInterface.cpp KoAnchorSelectionWidget.cpp KisGradientSlider.cpp KisGradientSliderWidget.cpp kis_color_input.cpp # classes used by internal color selector kis_spinbox_color_selector.cpp KisSpinboxHSXSelector.cpp KisVisualColorSelector.cpp KisVisualColorSelectorShape.cpp KisVisualEllipticalSelectorShape.cpp KisVisualRectangleSelectorShape.cpp KisVisualTriangleSelectorShape.cpp KisScreenColorPickerBase.cpp KisDlgInternalColorSelector.cpp KisPaletteModel.cpp KisPaletteDelegate.cpp kis_palette_view.cpp KisPaletteChooser.cpp KisPaletteComboBox.cpp kis_color_button.cpp ) ki18n_wrap_ui( kritawidgets_LIB_SRCS KoConfigAuthorPage.ui - koDocumentInfoAboutWidget.ui - koDocumentInfoAuthorWidget.ui wdg_file_name_requester.ui KoShadowConfigWidget.ui WdgDlgInternalColorSelector.ui WdgPaletteListWidget.ui ) add_library(kritawidgets SHARED ${kritawidgets_LIB_SRCS}) generate_export_header(kritawidgets BASE_NAME kritawidgets) target_link_libraries(kritawidgets kritaodf kritaglobal kritaflake kritapigment kritawidgetutils kritaresources kritaresourcewidgets Qt5::PrintSupport KF5::CoreAddons KF5::ConfigGui KF5::GuiAddons KF5::WidgetsAddons KF5::ConfigCore KF5::Completion ) if(X11_FOUND) target_link_libraries(kritawidgets Qt5::X11Extras ${X11_LIBRARIES}) endif() set_target_properties(kritawidgets PROPERTIES VERSION ${GENERIC_KRITA_LIB_VERSION} SOVERSION ${GENERIC_KRITA_LIB_SOVERSION} ) install(TARGETS kritawidgets ${INSTALL_TARGETS_DEFAULT_ARGS})