File indexing completed on 2024-05-19 04:26:55
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 const QString scalingFilter=QString(), 0038 QObject *parent = 0); 0039 explicit FileLayer(KisFileLayerSP layer, QObject *parent = 0); 0040 ~FileLayer() override; 0041 public Q_SLOTS: 0042 0043 /** 0044 * @brief type Krita has several types of nodes, split in layers and masks. Group 0045 * layers can contain other layers, any layer can contain masks. 0046 * 0047 * @return "filelayer" 0048 */ 0049 QString type() const override; 0050 0051 /** 0052 * @brief setProperties 0053 * Change the properties of the file layer. 0054 * @param fileName - A String containing the absolute file name. 0055 * @param scalingMethod - a string with the scaling method, defaults to "None", 0056 * other options are "ToImageSize" and "ToImagePPI" 0057 * @param scalingFilter - a string with the scaling filter, defaults to "Bicubic", 0058 * other options are "Hermite", "NearestNeighbor", "Bilinear", "Bell", "BSpline", "Lanczos3", "Mitchell" 0059 */ 0060 void setProperties(QString fileName, QString scalingMethod = QString("None"), QString scalingFilter = QString("Bicubic")); 0061 0062 /** 0063 * @brief makes the file layer to reload the connected image from disk 0064 */ 0065 void resetCache(); 0066 0067 /** 0068 * @brief path 0069 * @return A QString with the full path of the referenced image. 0070 */ 0071 QString path() const; 0072 0073 /** 0074 * @brief scalingMethod 0075 * returns how the file referenced is scaled. 0076 * @return one of the following: 0077 * <ul> 0078 * <li> None - The file is not scaled in any way. 0079 * <li> ToImageSize - The file is scaled to the full image size; 0080 * <li> ToImagePPI - The file is scaled by the PPI of the image. This keep the physical dimensions the same. 0081 * </ul> 0082 */ 0083 QString scalingMethod() const; 0084 0085 /** 0086 * @brief scalingFilter 0087 * returns the filter with which the file referenced is scaled. 0088 */ 0089 QString scalingFilter() const; 0090 0091 private: 0092 /** 0093 * @brief getFileNameFromAbsolute 0094 * referenced from the fileLayer dialog, this will jumps through all the hoops 0095 * to ensure that an appropriate filename will be gotten. 0096 * @param baseName the location of the document. 0097 * @param absolutePath the absolute location of the file referenced. 0098 * @return the appropriate relative path. 0099 */ 0100 QString getFileNameFromAbsolute(const QString &basePath, QString filePath); 0101 QString m_baseName; 0102 }; 0103 0104 #endif // LIBKIS_FILELAYER_H 0105