1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2002-12-09
7  * Description : a tool to print images
8  *
9  * Copyright (C) 2002-2003 by Todd Shoemaker <todd at theshoemakers dot net>
10  * Copyright (C) 2007-2012 by Angelo Naselli <anaselli at linux dot it>
11  * Copyright (C) 2006-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_ADV_PRINT_PHOTO_H
26 #define DIGIKAM_ADV_PRINT_PHOTO_H
27 
28 // Qt includes
29 
30 #include <QRect>
31 #include <QFont>
32 #include <QColor>
33 #include <QUrl>
34 #include <QPointer>
35 #include <QIcon>
36 #include <QList>
37 #include <QSize>
38 #include <QMatrix>
39 
40 // Local includes
41 
42 #include "dinfointerface.h"
43 #include "dimg.h"
44 #include "advprintsettings.h"
45 
46 using namespace Digikam;
47 
48 namespace DigikamGenericPrintCreatorPlugin
49 {
50 
51 class AdvPrintPhotoSize
52 {
53 public:
54 
55     explicit AdvPrintPhotoSize();
56     AdvPrintPhotoSize(const AdvPrintPhotoSize& other);
57     ~AdvPrintPhotoSize();
58 
59 public:
60 
61     QString       m_label;
62     int           m_dpi;
63     bool          m_autoRotate;
64     QList<QRect*> m_layouts;     ///< first element is page size
65     QIcon         m_icon;
66 };
67 
68 // -----------------------------------------------------------
69 
70 class AdvPrintAdditionalInfo
71 {
72 public:
73 
74     explicit AdvPrintAdditionalInfo();
75     AdvPrintAdditionalInfo(const AdvPrintAdditionalInfo& other);
76     ~AdvPrintAdditionalInfo();
77 
78 public:
79 
80     int    m_unit;
81     int    m_printPosition;
82     int    m_scaleMode;
83     bool   m_keepRatio;
84     bool   m_autoRotate;
85     double m_printWidth;
86     double m_printHeight;
87     bool   m_enlargeSmallerImages;
88 };
89 
90 // -----------------------------------------------------------
91 
92 class AdvPrintCaptionInfo
93 {
94 
95 public:
96 
97     explicit AdvPrintCaptionInfo();
98 
99     /// Copy constructor to get old photo info.
100     AdvPrintCaptionInfo(const AdvPrintCaptionInfo& other);
101     ~AdvPrintCaptionInfo();
102 
103 public:
104 
105     AdvPrintSettings::CaptionType m_captionType;
106     QFont                         m_captionFont;
107     QColor                        m_captionColor;
108     int                           m_captionSize;
109     QString                       m_captionText;
110 };
111 
112 // -----------------------------------------------------------
113 
114 class AdvPrintPhoto
115 {
116 
117 public:
118 
119     explicit AdvPrintPhoto(int thumbnailSize, DInfoInterface* const iface);
120     AdvPrintPhoto(const AdvPrintPhoto& other);
121     ~AdvPrintPhoto();
122 
123     DImg&  thumbnail();
124     DImg   loadPhoto();
125     int    width();
126     int    height();
127     QSize& size();
128 
129     QMatrix updateCropRegion(int woutlay, int houtlay, bool autoRotate);
130 
131     double scaleWidth(double unitToInches);
132     double scaleHeight(double unitToInches);
133 
134 public:
135 
136     /// Url of original image file.
137     QUrl                    m_url;
138 
139     /// Thumbnail size in pixels.
140     int                     m_thumbnailSize;
141 
142     /// Region to crop while print from original image.
143     QRect                   m_cropRegion;
144 
145     /// To get first copy quickly.
146     bool                    m_first;
147 
148     /// Number of copies while printing stage.
149     int                     m_copies;
150 
151     /// Rotation angle in degrees.
152     int                     m_rotation;
153 
154     AdvPrintAdditionalInfo* m_pAddInfo;
155     AdvPrintCaptionInfo*    m_pAdvPrintCaptionInfo;
156     DInfoInterface*         m_iface;
157 
158 private:
159 
160     void loadInCache();
161 
162 private:
163 
164     DImg*                   m_thumbnail;
165     QSize*                  m_size;
166 };
167 
168 } // Namespace Digikam
169 
170 #endif // DIGIKAM_ADV_PRINT_PHOTO_H
171