File indexing completed on 2024-05-12 15:59:05
0001 /* 0002 * SPDX-FileCopyrightText: 2017 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #ifndef LIBKIS_FILELAYER_H 0007 #define LIBKIS_FILELAYER_H 0008 0009 #include <QObject> 0010 #include "Node.h" 0011 0012 #include <kis_types.h> 0013 0014 #include "kritalibkis_export.h" 0015 #include "libkis.h" 0016 0017 /** 0018 * @brief The FileLayer class 0019 * A file layer is a layer that can reference an external image 0020 * and show said reference in the layer stack. 0021 * 0022 * If the external image is updated, Krita will try to update the 0023 * file layer image as well. 0024 */ 0025 0026 class KRITALIBKIS_EXPORT FileLayer : public Node 0027 { 0028 Q_OBJECT 0029 Q_DISABLE_COPY(FileLayer) 0030 0031 public: 0032 explicit FileLayer(KisImageSP image, 0033 const QString name = QString(), 0034 const QString baseName=QString(), 0035 const QString fileName=QString(), 0036 const QString scalingMethod=QString(), 0037 QObject *parent = 0); 0038 explicit FileLayer(KisFileLayerSP layer, QObject *parent = 0); 0039 ~FileLayer() override; 0040 public Q_SLOTS: 0041 0042 /** 0043 * @brief type Krita has several types of nodes, split in layers and masks. Group 0044 * layers can contain other layers, any layer can contain masks. 0045 * 0046 * @return "filelayer" 0047 */ 0048 QString type() const override; 0049 0050 /** 0051 * @brief setProperties 0052 * Change the properties of the file layer. 0053 * @param fileName - A String containing the absolute file name. 0054 * @param scalingMethod - a string with the scaling method, defaults to "None", 0055 * other options are "ToImageSize" and "ToImagePPI" 0056 */ 0057 void setProperties(QString fileName, QString scalingMethod = QString("None")); 0058 0059 /** 0060 * @brief makes the file layer to reload the connected image from disk 0061 */ 0062 void resetCache(); 0063 0064 /** 0065 * @brief path 0066 * @return A QString with the full path of the referenced image. 0067 */ 0068 QString path() const; 0069 0070 /** 0071 * @brief scalingMethod 0072 * returns how the file referenced is scaled. 0073 * @return one of the following: 0074 * <ul> 0075 * <li> None - The file is not scaled in any way. 0076 * <li> ToImageSize - The file is scaled to the full image size; 0077 * <li> ToImagePPI - The file is scaled by the PPI of the image. This keep the physical dimensions the same. 0078 * </ul> 0079 */ 0080 QString scalingMethod() const; 0081 0082 private: 0083 /** 0084 * @brief getFileNameFromAbsolute 0085 * referenced from the fileLayer dialog, this will jumps through all the hoops 0086 * to ensure that an appropriate filename will be gotten. 0087 * @param baseName the location of the document. 0088 * @param absolutePath the absolute location of the file referenced. 0089 * @return the appropriate relative path. 0090 */ 0091 QString getFileNameFromAbsolute(const QString &basePath, QString filePath); 0092 QString m_baseName; 0093 }; 0094 0095 #endif // LIBKIS_FILELAYER_H 0096