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  QObject *parent = 0);
38  explicit FileLayer(KisFileLayerSP layer, QObject *parent = 0);
39  ~FileLayer() override;
40 public Q_SLOTS:
41 
42  /**
43  * @brief type Krita has several types of nodes, split in layers and masks. Group
44  * layers can contain other layers, any layer can contain masks.
45  *
46  * @return "filelayer"
47  */
48  QString type() const override;
49 
50  /**
51  * @brief setProperties
52  * Change the properties of the file layer.
53  * @param fileName - A String containing the absolute file name.
54  * @param scalingMethod - a string with the scaling method, defaults to "None",
55  * other options are "ToImageSize" and "ToImagePPI"
56  */
57  void setProperties(QString fileName, QString scalingMethod = QString("None"));
58 
59  /**
60  * @brief makes the file layer to reload the connected image from disk
61  */
62  void resetCache();
63 
64  /**
65  * @brief path
66  * @return A QString with the full path of the referenced image.
67  */
68  QString path() const;
69 
70  /**
71  * @brief scalingMethod
72  * returns how the file referenced is scaled.
73  * @return one of the following:
74  * <ul>
75  * <li> None - The file is not scaled in any way.
76  * <li> ToImageSize - The file is scaled to the full image size;
77  * <li> ToImagePPI - The file is scaled by the PPI of the image. This keep the physical dimensions the same.
78  * </ul>
79  */
80  QString scalingMethod() const;
81 
82 private:
83  /**
84  * @brief getFileNameFromAbsolute
85  * referenced from the fileLayer dialog, this will jumps through all the hoops
86  * to ensure that an appropriate filename will be gotten.
87  * @param baseName the location of the document.
88  * @param absolutePath the absolute location of the file referenced.
89  * @return the appropriate relative path.
90  */
91  QString getFileNameFromAbsolute(const QString &basePath, QString filePath);
92  QString m_baseName;
93 };
94 
95 #endif // LIBKIS_FILELAYER_H
96 
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-2022 The KDE developers.
Generated on Sun Sep 25 2022 04:19:21 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.