Debian Codegraph @

plugins/impex/raw/3rdparty/libkdcraw/src/rwidgetutils.h

raw
1 /** ===========================================================
2 * @file
3 *
4 * This file is a part of digiKam project
5 * <a href="https://www.digikam.org">https://www.digikam.org</a>
6 *
7 * @date 2014-09-12
8 * @brief Simple helpher widgets collection
9 *
10 * @author Copyright (C) 2014-2015 by Gilles Caulier
11 * <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
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)
17 * any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * ============================================================ */
25
26 #ifndef RWIDGETUTILS_H
27 #define RWIDGETUTILS_H
28
29 // Qt includes
30
31 #include <QLabel>
32 #include <QString>
33 #include <QFrame>
34 #include <QLineEdit>
35 #include <QSize>
36 #include <QPixmap>
37 #include <QFileDialog>
38 #include <QColor>
39 #include <QPushButton>
40
41 // Local includes
42
43
44
45 namespace KDcrawIface
46 {
47
48 /** A widget to host an image into a label with an active url which can be
49 * open to default web browser using simple mouse click.
50 */
51 class RActiveLabel : public QLabel
52 {
53 Q_OBJECT
54
55 public:
56
57 explicit RActiveLabel(const QUrl& url=QUrl(), const QString& imgPath=QString(), QWidget* const parent=0);
58 ~RActiveLabel() override;
59
60 void updateData(const QUrl& url, const QImage& img);
61 };
62
63 // ------------------------------------------------------------------------------------
64
65 /**
66 * A widget to show an horizontal or vertical line separator
67 **/
68 class RLineWidget : public QFrame
69 {
70 Q_OBJECT
71
72 public:
73
74 explicit RLineWidget(Qt::Orientation orientation, QWidget* const parent=0);
75 ~RLineWidget() override;
76 };
77
78 // ------------------------------------------------------------------------------------
79
80 /** An Horizontal widget to host children widgets
81 */
82 class RHBox : public QFrame
83 {
84 Q_OBJECT
85 Q_DISABLE_COPY(RHBox)
86
87 public:
88
89 explicit RHBox(QWidget* const parent=0);
90 ~RHBox() override;
91
92 void setMargin(int margin);
93 void setSpacing(int space);
94 void setStretchFactor(QWidget* const widget, int stretch);
95
96 QSize sizeHint() const override;
97 QSize minimumSizeHint() const override;
98
99 protected:
100
101 RHBox(bool vertical, QWidget* const parent);
102
103 void childEvent(QChildEvent* e) override;
104 };
105
106 // ------------------------------------------------------------------------------------
107
108 /** A Vertical widget to host children widgets
109 */
110 class RVBox : public RHBox
111 {
112 Q_OBJECT
113 Q_DISABLE_COPY(RVBox)
114
115 public:
116
117 explicit RVBox(QWidget* const parent=0);
118 ~RVBox() override;
119 };
120
121 // ------------------------------------------------------------------------------------
122
123 /** A label to show text adjusted to widget size
124 */
125 class RAdjustableLabel : public QLabel
126 {
127 Q_OBJECT
128
129 public:
130
131 explicit RAdjustableLabel(QWidget* const parent=0);
132 ~RAdjustableLabel() override;
133
134 QSize minimumSizeHint() const override;
135 QSize sizeHint() const override;
136
137 void setAlignment(Qt::Alignment align);
138 void setElideMode(Qt::TextElideMode mode);
139
140 QString adjustedText() const;
141
142 public Q_SLOTS:
143
144 void setAdjustedText(const QString& text=QString());
145
146 private:
147
148 void resizeEvent(QResizeEvent*) override;
149 void adjustTextToLabel();
150
151 // Disabled methods from QLabel
152 QString text() const { return QString(); }; // Use adjustedText() instead.
153 void setText(const QString&) {}; // Use setAdjustedText(text) instead.
154 void clear() {}; // Use setdjustedText(QString()) instead.
155
156 private:
157
158 class Private;
159 Private* const d;
160 };
161
162 // ------------------------------------------------------------------------------------
163
164 /** A widget to chosse a single local file or path.
165 * Use line edit and file dialog properties to customize operation modes.
166 */
167 class RFileSelector : public RHBox
168 {
169 Q_OBJECT
170
171 public:
172
173 explicit RFileSelector(QWidget* const parent=0);
174 ~RFileSelector() override;
175
176 QLineEdit* lineEdit() const;
177
178 void setFileDlgMode(QFileDialog::FileMode mode);
179 void setFileDlgFilter(const QString& filter);
180 void setFileDlgTitle(const QString& title);
181 void setFileDlgOptions(QFileDialog::Options opts);
182
183 Q_SIGNALS:
184
185 void signalOpenFileDialog();
186 void signalUrlSelected(const QUrl&);
187
188 private Q_SLOTS:
189
190 void slotBtnClicked();
191
192 private:
193
194 class Private;
195 Private* const d;
196 };
197
198 // --------------------------------------------------------------------------------------
199
200 /** A widget to draw progress wheel indicator over thumbnails.
201 */
202 class WorkingPixmap
203 {
204 public:
205
206 explicit WorkingPixmap();
207 ~WorkingPixmap();
208
209 bool isEmpty() const;
210 QSize frameSize() const;
211 int frameCount() const;
212 QPixmap frameAt(int index) const;
213
214 private:
215
216 QVector<QPixmap> m_frames;
217 };
218
219 // ------------------------------------------------------------------------------------
220
221 /** A widget to chosse a color from a palette.
222 */
223 class RColorSelector : public QPushButton
224 {
225 Q_OBJECT
226
227 public:
228
229 explicit RColorSelector(QWidget* const parent=0);
230 ~RColorSelector() override;
231
232 void setColor(const QColor& color);
233 QColor color() const;
234
235 Q_SIGNALS:
236
237 void signalColorSelected(const QColor&);
238
239 private Q_SLOTS:
240
241 void slotBtnClicked();
242
243 private:
244
245 void paintEvent(QPaintEvent*) override;
246
247 private:
248
249 class Private;
250 Private* const d;
251 };
252
253 } // namespace KDcrawIface
254
255 #endif // RWIDGETUTILS_H