Krita

FileLayer.h
1 /*
2  * SPDX-FileCopyrightText: 2017 Wolthera van Hövell tot Westerflier <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 #ifndef LIBKIS_FILELAYER_H
7 #define LIBKIS_FILELAYER_H
8 
9 #include <QObject>
10 #include "Node.h"
11 
12 #include <kis_types.h>
13 
14 #include "kritalibkis_export.h"
15 #include "libkis.h"
16 
17 /**
18  * @brief The FileLayer class
19  * A file layer is a layer that can reference an external image
20  * and show said reference in the layer stack.
21  *
22  * If the external image is updated, Krita will try to update the
23  * file layer image as well.
24  */
25 
26 class KRITALIBKIS_EXPORT FileLayer : public Node
27 {
28  Q_OBJECT
30 
31 public:
32  explicit FileLayer(KisImageSP image,
33  const QString name = QString(),
34  const QString baseName=QString(),
35  const QString fileName=QString(),
36  const QString scalingMethod=QString(),
37  const QString scalingFilter=QString(),
38  QObject *parent = 0);
39  explicit FileLayer(KisFileLayerSP layer, QObject *parent = 0);
40  ~FileLayer() override;
41 public Q_SLOTS:
42 
43  /**
44  * @brief type Krita has several types of nodes, split in layers and masks. Group
45  * layers can contain other layers, any layer can contain masks.
46  *
47  * @return "filelayer"
48  */
49  QString type() const override;
50 
51  /**
52  * @brief setProperties
53  * Change the properties of the file layer.
54  * @param fileName - A String containing the absolute file name.
55  * @param scalingMethod - a string with the scaling method, defaults to "None",
56  * other options are "ToImageSize" and "ToImagePPI"
57  * @param scalingFilter - a string with the scaling filter, defaults to "Bicubic",
58  * other options are "Hermite", "NearestNeighbor", "Bilinear", "Bell", "BSpline", "Lanczos3", "Mitchell"
59  */
60  void setProperties(QString fileName, QString scalingMethod = QString("None"), QString scalingFilter = QString("Bicubic"));
61 
62  /**
63  * @brief makes the file layer to reload the connected image from disk
64  */
65  void resetCache();
66 
67  /**
68  * @brief path
69  * @return A QString with the full path of the referenced image.
70  */
71  QString path() const;
72 
73  /**
74  * @brief scalingMethod
75  * returns how the file referenced is scaled.
76  * @return one of the following:
77  * <ul>
78  * <li> None - The file is not scaled in any way.
79  * <li> ToImageSize - The file is scaled to the full image size;
80  * <li> ToImagePPI - The file is scaled by the PPI of the image. This keep the physical dimensions the same.
81  * </ul>
82  */
83  QString scalingMethod() const;
84 
85  /**
86  * @brief scalingFilter
87  * returns the filter with which the file referenced is scaled.
88  */
89  QString scalingFilter() const;
90 
91 private:
92  /**
93  * @brief getFileNameFromAbsolute
94  * referenced from the fileLayer dialog, this will jumps through all the hoops
95  * to ensure that an appropriate filename will be gotten.
96  * @param baseName the location of the document.
97  * @param absolutePath the absolute location of the file referenced.
98  * @return the appropriate relative path.
99  */
100  QString getFileNameFromAbsolute(const QString &basePath, QString filePath);
101  QString m_baseName;
102 };
103 
104 #endif // LIBKIS_FILELAYER_H
105 
virtual QString type() const
type Krita has several types of nodes, split in layers and masks.
Definition: Node.cpp:456
Q_SLOTSQ_SLOTS
The FileLayer class A file layer is a layer that can reference an external image and show said refere...
Definition: FileLayer.h:26
Node represents a layer or mask in a Krita image's Node hierarchy.
Definition: Node.h:21
Q_DISABLE_COPY(Class)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Sep 27 2023 03:58:14 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.