Changeset View
Changeset View
Standalone View
Standalone View
libs/libkis/FileLayer.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (c) 2017 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU Lesser General Public License as published by | ||||
6 | * the Free Software Foundation; either version 2 of the License, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Lesser General Public License | ||||
15 | * along with this program; if not, write to the Free Software | ||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
17 | */ | ||||
18 | #ifndef LIBKIS_FILELAYER_H | ||||
19 | #define LIBKIS_FILELAYER_H | ||||
20 | | ||||
21 | #include <QObject> | ||||
22 | #include "Node.h" | ||||
23 | | ||||
24 | #include <kis_types.h> | ||||
25 | | ||||
26 | #include "kritalibkis_export.h" | ||||
27 | #include "libkis.h" | ||||
28 | | ||||
29 | /** | ||||
30 | * @brief The FileLayer class | ||||
31 | * A file layer is a layer that can reference an external image | ||||
32 | * and show said reference in the layer stack. | ||||
33 | * | ||||
34 | * If the external image is updated, Krita will try to update the | ||||
35 | * file layer image as well. | ||||
36 | */ | ||||
37 | | ||||
38 | class KRITALIBKIS_EXPORT FileLayer : public Node | ||||
39 | { | ||||
40 | Q_OBJECT | ||||
41 | Q_DISABLE_COPY(FileLayer) | ||||
42 | | ||||
43 | public: | ||||
44 | explicit FileLayer(KisImageSP image, | ||||
45 | const QString name = QString(), | ||||
46 | const QString baseName=QString(), | ||||
47 | const QString fileName=QString(), | ||||
48 | const QString scalingMethod=QString(), | ||||
49 | QObject *parent = 0); | ||||
50 | explicit FileLayer(KisFileLayerSP layer, QObject *parent = 0); | ||||
51 | ~FileLayer() override; | ||||
52 | public Q_SLOTS: | ||||
53 | | ||||
54 | /** | ||||
55 | * @brief type Krita has several types of nodes, split in layers and masks. Group | ||||
56 | * layers can contain other layers, any layer can contain masks. | ||||
57 | * | ||||
58 | * @return "filelayer" | ||||
59 | */ | ||||
60 | QString type() const override; | ||||
61 | | ||||
62 | /** | ||||
63 | * @brief setProperties | ||||
64 | * Change the properties of the file layer. | ||||
65 | * @param FileName - A String containing the absolute file name. | ||||
66 | * @param ScalingMethod - a string with the scaling method, defaults to "None", | ||||
67 | * other options are "ToImageSize" and "ToImagePPI" | ||||
68 | */ | ||||
69 | void setProperties(QString FileName, QString ScalingMethod = QString("None")); | ||||
70 | | ||||
71 | /** | ||||
72 | * @brief path | ||||
73 | * @return A QString with the full path of the referenced image. | ||||
74 | */ | ||||
75 | QString path() const; | ||||
76 | | ||||
77 | /** | ||||
78 | * @brief scalingMethod | ||||
79 | * returns how the file referenced is scaled. | ||||
80 | * @return one of the following: | ||||
81 | * <li> None - The file is not scaled in any way. | ||||
82 | * <li> ToImageSize - The file is scaled to the full image size; | ||||
83 | * <li> ToImagePPI - The file is scaled by the PPI of the image. This keep the physical dimensions the same. | ||||
84 | */ | ||||
85 | QString scalingMethod() const; | ||||
86 | | ||||
87 | private: | ||||
88 | /** | ||||
89 | * @brief getFileNameFromAbsolute | ||||
90 | * referenced from the fileLayer dialog, this will jumps through all the hoops | ||||
91 | * to ensure that an appropriate filename will be gotten. | ||||
92 | * @param baseName the location of the document. | ||||
93 | * @param absolutePath the absolute location of the file referenced. | ||||
94 | * @return the appropriate relative path. | ||||
95 | */ | ||||
96 | QString getFileNameFromAbsolute(QString baseName, QString absolutePath); | ||||
97 | QString m_baseName; | ||||
98 | }; | ||||
99 | | ||||
100 | #endif // LIBKIS_FILELAYER_H | ||||
101 | |