digiKam
dconfigdlgwidgets.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 : 2009-11-03
7  * Description : A dialog base class which can handle multiple pages.
8  *
9  * Copyright (C) 2009-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2006 by Tobias Koenig <tokoe at kde dot org>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * 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_DCONFIG_DLG_WIDGETS_H
26 #define DIGIKAM_DCONFIG_DLG_WIDGETS_H
27 
28 // Qt includes
29 
30 #include <QWidget>
31 
32 // Local includes
33 
34 #include "dconfigdlgmodels.h"
35 #include "dconfigdlgview.h"
36 #include "digikam_export.h"
37 
38 namespace Digikam
39 {
40 
41 class DConfigDlgWdgPrivate;
42 
47 class DIGIKAM_EXPORT DConfigDlgWdg : public DConfigDlgView
48 {
49  Q_OBJECT
50  Q_DECLARE_PRIVATE(DConfigDlgWdg)
51 
52 public:
53 
59  explicit DConfigDlgWdg(QWidget* const parent = nullptr);
60 
64  ~DConfigDlgWdg() override;
65 
74  DConfigDlgWdgItem* addPage(QWidget* widget, const QString& name);
75 
81  void addPage(DConfigDlgWdgItem* item);
82 
93  DConfigDlgWdgItem* insertPage(DConfigDlgWdgItem* before, QWidget* widget, const QString& name);
94 
103  void insertPage(DConfigDlgWdgItem* before, DConfigDlgWdgItem* item);
104 
114  DConfigDlgWdgItem* addSubPage(DConfigDlgWdgItem* parent, QWidget* widget, const QString& name);
115 
123  void addSubPage(DConfigDlgWdgItem* parent, DConfigDlgWdgItem* item);
124 
128  void removePage(DConfigDlgWdgItem* item);
129 
134  void setCurrentPage(DConfigDlgWdgItem* item);
135 
140  DConfigDlgWdgItem* currentPage() const;
141 
142 Q_SIGNALS:
143 
150 
155  void pageToggled(DConfigDlgWdgItem* page, bool checked);
156 
162 
163 protected:
164 
165  DConfigDlgWdg(DConfigDlgWdgPrivate& dd, QWidget* const parent);
166 
167 private:
168 
169  Q_PRIVATE_SLOT(d_func(), void _k_slotCurrentPageChanged(const QModelIndex&, const QModelIndex&))
170 };
171 
172 // ----------------------------------------------------------------------------------------------------------------
173 
184 class DConfigDlgTitle : public QWidget
185 {
186  Q_OBJECT
187  Q_PROPERTY(QString text READ text WRITE setText)
188  Q_PROPERTY(QString comment READ comment WRITE setComment)
189  Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
190  Q_PROPERTY(int autoHideTimeout READ autoHideTimeout WRITE setAutoHideTimeout)
191 
192 public:
193 
201  {
203  ImageRight
204  };
205  Q_ENUM(ImageAlignment)
206 
207 
211  {
215  ErrorMessage
216  };
217 
218 public:
219 
223  explicit DConfigDlgTitle(QWidget* const parent = nullptr);
224 
225  ~DConfigDlgTitle() override;
226 
230  void setWidget(QWidget* const widget);
231 
236  QString text() const;
237 
242  QString comment() const;
243 
248  QPixmap pixmap() const;
249 
257  void setBuddy(QWidget* const buddy);
258 
263  int autoHideTimeout() const;
264 
265 public Q_SLOTS:
266 
273  void setText(const QString& text, Qt::Alignment alignment = Qt::AlignLeft | Qt::AlignVCenter);
280  void setText(const QString& text, MessageType type);
281 
288  void setComment(const QString& comment, MessageType type = PlainMessage);
289 
295  void setPixmap(const QPixmap& pixmap, ImageAlignment alignment = ImageRight);
296 
302  void setPixmap(const QString& icon, ImageAlignment alignment = ImageRight);
303 
309  void setPixmap(const QIcon& icon, ImageAlignment alignment = ImageRight);
310 
316  void setPixmap(MessageType type, ImageAlignment alignment = ImageRight);
317 
323  void setAutoHideTimeout(int msecs);
324 
325 protected:
326 
327  void changeEvent(QEvent*) override;
328  void showEvent(QShowEvent*) override;
329  bool eventFilter(QObject*, QEvent*) override;
330 
331 private:
332 
333  class Private;
334  Private* const d;
335 
336  Q_PRIVATE_SLOT(d, void _k_timeoutFinished())
337  Q_DISABLE_COPY(DConfigDlgTitle)
338 };
339 
340 } // namespace Digikam
341 
342 #endif // DIGIKAM_DCONFIG_DLG_WIDGETS_H
Definition: dconfigdlgwidgets.h:185
~DConfigDlgTitle() override
Definition: dconfigdlgwidgets.cpp:218
bool eventFilter(QObject *, QEvent *) override
Definition: dconfigdlgwidgets.cpp:223
void setBuddy(QWidget *const buddy)
Definition: dconfigdlgwidgets.cpp:270
ImageAlignment
Definition: dconfigdlgwidgets.h:201
@ ImageRight
Display the pixmap on the right.
Definition: dconfigdlgwidgets.h:203
@ ImageLeft
Display the pixmap on the left.
Definition: dconfigdlgwidgets.h:202
void changeEvent(QEvent *) override
Definition: dconfigdlgwidgets.cpp:275
void showEvent(QShowEvent *) override
Definition: dconfigdlgwidgets.cpp:384
void setText(const QString &text, Qt::Alignment alignment=Qt::AlignLeft|Qt::AlignVCenter)
Definition: dconfigdlgwidgets.cpp:288
void setPixmap(const QPixmap &pixmap, ImageAlignment alignment=ImageRight)
Definition: dconfigdlgwidgets.cpp:320
DConfigDlgTitle(QWidget *const parent=nullptr)
Definition: dconfigdlgwidgets.cpp:177
QString text
Definition: dconfigdlgwidgets.h:187
int autoHideTimeout
Definition: dconfigdlgwidgets.h:190
void setWidget(QWidget *const widget)
Definition: dconfigdlgwidgets.cpp:242
MessageType
Definition: dconfigdlgwidgets.h:211
@ WarningMessage
A warning the user should be alerted to.
Definition: dconfigdlgwidgets.h:214
@ InfoMessage
Information the user should be alerted to.
Definition: dconfigdlgwidgets.h:213
@ ErrorMessage
An error message.
Definition: dconfigdlgwidgets.h:215
@ PlainMessage
Normal comment.
Definition: dconfigdlgwidgets.h:212
void setComment(const QString &comment, MessageType type=PlainMessage)
Definition: dconfigdlgwidgets.cpp:308
QString comment
Definition: dconfigdlgwidgets.h:188
QPixmap pixmap
Definition: dconfigdlgwidgets.h:189
void setAutoHideTimeout(int msecs)
Definition: dconfigdlgwidgets.cpp:370
A base class which can handle multiple pages.
Definition: dconfigdlgview.h:59
Definition: dconfigdlgmodels.h:105
Definition: dconfigdlgwidgets_p.h:42
Page widget with many layouts (faces).
Definition: dconfigdlgwidgets.h:48
void currentPageChanged(DConfigDlgWdgItem *current, DConfigDlgWdgItem *before)
void pageRemoved(DConfigDlgWdgItem *page)
void pageToggled(DConfigDlgWdgItem *page, bool checked)
Definition: datefolderview.cpp:43