digiKam
Loading...
Searching...
No Matches
dexpanderbox.h
Go to the documentation of this file.
1/* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2008-03-14
7 * Description : A widget to host settings as expander box
8 *
9 * SPDX-FileCopyrightText: 2008-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10 * SPDX-FileCopyrightText: 2008-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
11 * SPDX-FileCopyrightText: 2010 by Manuel Viet <contact at 13zenrv dot fr>
12 *
13 * SPDX-License-Identifier: GPL-2.0-or-later
14 *
15 * ============================================================ */
16
17#pragma once
18
19// Qt includes
20
21#include <QObject>
22#include <QPixmap>
23#include <QLabel>
24#include <QWidget>
25#include <QScrollArea>
26#include <QFrame>
27
28// Local includes
29
30#include "digikam_export.h"
31
32class KConfigGroup;
33
34namespace Digikam
35{
36
40class DIGIKAM_EXPORT DLineWidget : public QFrame
41{
42 Q_OBJECT
43
44public:
45
46 explicit DLineWidget(Qt::Orientation orientation, QWidget* const parent = nullptr);
47 ~DLineWidget() override;
48};
49
50// -------------------------------------------------------------------------
51
55class DIGIKAM_EXPORT DAdjustableLabel : public QLabel
56{
57 Q_OBJECT
58
59public:
60
61 explicit DAdjustableLabel(QWidget* const parent = nullptr);
62 ~DAdjustableLabel() override;
63
64 QSize minimumSizeHint() const override;
65 QSize sizeHint() const override;
66
67 void setAlignment(Qt::Alignment align);
68 void setElideMode(Qt::TextElideMode mode);
69
70 QString adjustedText() const;
71
72public Q_SLOTS:
73
74 void setAdjustedText(const QString& text = QString());
75
76private:
77
78 void resizeEvent(QResizeEvent*) override;
79 void adjustTextToLabel();
80
81 // Disabled methods from QLabel
82 QString text() const { return QString(); };
83 void setText(const QString&) {};
84 void clear() {};
85
86private:
87
88 class Private;
89 Private* const d = nullptr;
90};
91
92// -------------------------------------------------------------------------
93
94class DIGIKAM_EXPORT DClickLabel : public QLabel
95{
96 Q_OBJECT
97
98public:
99
100 explicit DClickLabel(QWidget* const parent = nullptr);
101 explicit DClickLabel(const QString& text, QWidget* const parent = nullptr);
102 ~DClickLabel() override;
103
104Q_SIGNALS:
105
108
110 void activated();
111
112protected:
113
114 void mousePressEvent(QMouseEvent* event) override;
115 void mouseReleaseEvent(QMouseEvent* event) override;
116 void keyPressEvent(QKeyEvent* event) override;
117};
118
119// -------------------------------------------------------------------------
120
121class DIGIKAM_EXPORT DSqueezedClickLabel : public DAdjustableLabel
122{
123 Q_OBJECT
124
125public:
126
127 explicit DSqueezedClickLabel(QWidget* const parent = nullptr);
128 explicit DSqueezedClickLabel(const QString& text, QWidget* const parent = nullptr);
129 ~DSqueezedClickLabel() override;
130
131Q_SIGNALS:
132
134 void activated();
135
136protected:
137
138 void mousePressEvent(QMouseEvent* event) override;
139 void mouseReleaseEvent(QMouseEvent* event) override;
140 void keyPressEvent(QKeyEvent* event) override;
141};
142
143// -------------------------------------------------------------------------
144
145class DIGIKAM_EXPORT DArrowClickLabel : public QWidget
146{
147 Q_OBJECT
148
149public:
150
151 explicit DArrowClickLabel(QWidget* const parent = nullptr);
152 ~DArrowClickLabel() override = default;
153
154 void setArrowType(Qt::ArrowType arrowType);
155 Qt::ArrowType arrowType() const;
156
157 QSize sizeHint () const override;
158
159Q_SIGNALS:
160
162
163protected:
164
165 void mousePressEvent(QMouseEvent* event) override;
166 void mouseReleaseEvent(QMouseEvent* event) override;
167 void paintEvent(QPaintEvent* event) override;
168
169protected:
170
171 Qt::ArrowType m_arrowType = Qt::DownArrow;
172 int m_size = 8;
173 int m_margin = 2;
174};
175
176// -------------------------------------------------------------------------
177
178class DIGIKAM_EXPORT DLabelExpander : public QWidget
179{
180 Q_OBJECT
181
182public:
183
184 explicit DLabelExpander(QWidget* const parent = nullptr);
185 ~DLabelExpander() override;
186
187 void setCheckBoxVisible(bool b);
188 bool checkBoxIsVisible() const;
189
190 void setChecked(bool b);
191 bool isChecked() const;
192
193 void setLineVisible(bool b);
194 bool lineIsVisible() const;
195
196 void setText(const QString& txt);
197 QString text() const;
198
199 void setButtonVisible(bool b);
200 bool buttonIsVisible() const;
201 void setButtonIcon(const QIcon& icon);
202
203 void setIcon(const QIcon &icon);
204 QIcon icon() const;
205
206 void setWidget(QWidget* const widget);
207 QWidget* widget() const;
208
209 void setExpanded(bool b);
210 bool isExpanded() const;
211
212 void setExpandByDefault(bool b);
213 bool isExpandByDefault() const;
214
215Q_SIGNALS:
216
217 void signalExpanded(bool);
218 void signalToggled(bool);
220
221private Q_SLOTS:
222
223 void slotToggleContainer();
224 void slotUpdateIcon();
225
226private:
227
228 bool eventFilter(QObject* obj,
229 QEvent* ev) override;
230
231private:
232
233 class Private;
234 Private* const d = nullptr;
235};
236
237// -------------------------------------------------------------------------
238
239class DIGIKAM_EXPORT DExpanderBox : public QScrollArea
240{
241 Q_OBJECT
242
243public:
244
245 explicit DExpanderBox(QWidget* const parent = nullptr);
246 ~DExpanderBox() override;
247
256 void addItem(QWidget* const w, const QIcon &icon, const QString& txt,
257 const QString& objName, bool expandBydefault);
258 void addItem(QWidget* const w, const QString& txt,
259 const QString& objName, bool expandBydefault);
260
269 void insertItem(int index, QWidget* const w, const QIcon &icon, const QString& txt,
270 const QString& objName, bool expandBydefault);
271 void insertItem(int index, QWidget* const w, const QString& txt,
272 const QString& objName, bool expandBydefault);
273
274 void removeItem(int index);
275
276 void setCheckBoxVisible(int index, bool b);
277 bool checkBoxIsVisible(int index) const;
278
279 void setChecked(int index, bool b);
280 bool isChecked(int index) const;
281
282 void setItemText(int index, const QString& txt);
283 QString itemText (int index) const;
284
285 void setItemIcon(int index, const QIcon &icon);
286 QIcon itemIcon(int index) const;
287
288 void setButtonVisible(int index, bool b);
289 bool buttonIsVisible(int index) const;
290 void setButtonIcon(int index, const QIcon& icon);
291
292 void setItemToolTip(int index, const QString& tip);
293 QString itemToolTip(int index) const;
294
295 void setItemEnabled(int index, bool enabled);
296 bool isItemEnabled(int index) const;
297
298 void addStretch();
299 void insertStretch(int index);
300
301 void setItemExpanded(int index, bool b);
302 bool isItemExpanded(int index) const;
303
304 int count() const;
305
306 DLabelExpander* widget(int index) const;
307 int indexOf(DLabelExpander* const widget) const;
308
309 virtual void readSettings(KConfigGroup& group);
310 virtual void writeSettings(KConfigGroup& group);
311
312Q_SIGNALS:
313
314 void signalItemExpanded(int index, bool b);
315 void signalItemToggled(int index, bool b);
316 void signalItemButtonPressed(int index);
317
318private Q_SLOTS:
319
320 void slotItemExpanded(bool b);
321 void slotItemToggled(bool b);
322 void slotItemButtonPressed();
323
324private:
325
326 class Private;
327 Private* const d = nullptr;
328};
329
330// -------------------------------------------------------------------------
331
332class DIGIKAM_EXPORT DExpanderBoxExclusive : public DExpanderBox
333{
334 Q_OBJECT
335
336public:
337
338 explicit DExpanderBoxExclusive(QWidget* const parent = nullptr);
339 ~DExpanderBoxExclusive() override = default;;
340
344 void setIsToolBox(bool b);
345 bool isToolBox() const;
346
347private Q_SLOTS:
348
349 void slotItemExpanded(bool b);
350
351private:
352
353 bool m_toolbox = true;
354};
355
356} // namespace Digikam
Definition dexpanderbox.h:56
Definition dexpanderbox.h:146
~DArrowClickLabel() override=default
Definition dexpanderbox.h:95
void leftClicked()
Emitted when activated by left mouse click.
void activated()
Emitted when activated, by mouse or key press.
Definition dexpanderbox.h:333
~DExpanderBoxExclusive() override=default
Definition dexpanderbox.h:240
void signalItemButtonPressed(int index)
void signalItemToggled(int index, bool b)
void signalItemExpanded(int index, bool b)
Definition dexpanderbox.h:179
Definition dexpanderbox.h:41
Definition dexpanderbox.h:122
Definition datefolderview.cpp:34