digiKam
dconfigdlgwidgets_p.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) 2007 by Matthias Kretz <kretz 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_PRIVATE_H
26 #define DIGIKAM_DCONFIG_DLG_WIDGETS_PRIVATE_H
27 
28 #include "dconfigdlgwidgets.h"
29 #include "dconfigdlgview_p.h"
30 
31 // Qt includes
32 
33 #include <QLabel>
34 #include <QApplication>
35 
36 namespace Digikam
37 {
38 
39 class DConfigDlgWdgModel;
40 
41 class Q_DECL_HIDDEN DConfigDlgWdgPrivate : public DConfigDlgViewPrivate
42 {
43  Q_DECLARE_PUBLIC(DConfigDlgWdg)
44 
45 protected:
46 
47  explicit DConfigDlgWdgPrivate(DConfigDlgWdg* const q);
48 
50  {
52  }
53 
54  void _k_slotCurrentPageChanged(const QModelIndex&, const QModelIndex&);
55 };
56 
57 // -----------------------------------------------------------------------------------
58 
59 class Q_DECL_HIDDEN DConfigDlgTitle::Private
60 {
61 public:
62 
63  explicit Private(DConfigDlgTitle* const parent)
64  : q (parent),
65  headerLayout (nullptr),
66  imageLabel (nullptr),
67  textLabel (nullptr),
68  commentLabel (nullptr),
69  autoHideTimeout(0),
70  messageType (InfoMessage)
71  {
72  }
73 
74  QString textStyleSheet() const
75  {
76  const int fontSize = qRound(QApplication::font().pointSize() * 1.4);
77 
78  return (QString::fromLatin1("QLabel { font-size: %1pt; color: %2 }")
79  .arg(QString::number(fontSize), q->palette().color(QPalette::WindowText).name()));
80  }
81 
82  QString commentStyleSheet() const
83  {
84  QString styleSheet;
85 
86  switch (messageType)
87  {
88  // FIXME: we need the usability color styles to implement different
89  // yet palette appropriate colours for the different use cases!
90  // also .. should we include an icon here,
91  // perhaps using the imageLabel?
92 
93  case InfoMessage:
94  case WarningMessage:
95  case ErrorMessage:
96  styleSheet = QString::fromLatin1("QLabel { color: palette(%1); background: palette(%2); }")
97  .arg(q->palette().color(QPalette::HighlightedText).name())
98  .arg(q->palette().color(QPalette::Highlight).name());
99  break;
100 
101  case PlainMessage:
102  default:
103  break;
104  }
105 
106  return styleSheet;
107  }
108 
115  {
116  switch (type)
117  {
119  return QLatin1String("dialog-information");
120  break;
121 
123  return QLatin1String("dialog-error");
124  break;
125 
127  return QLatin1String("dialog-warning");
128  break;
129 
131  break;
132  }
133 
134  return QString();
135  }
136 
138  {
139  q->setVisible(false);
140  }
141 
142 public:
143 
145  QGridLayout* headerLayout;
146  QLabel* imageLabel;
147  QLabel* textLabel;
148  QLabel* commentLabel;
151 };
152 
153 } // namespace Digikam
154 
155 #endif // DIGIKAM_DCONFIG_DLG_WIDGETS_PRIVATE_H
Definition: dconfigdlgwidgets_p.h:60
QString commentStyleSheet() const
Definition: dconfigdlgwidgets_p.h:82
QString textStyleSheet() const
Definition: dconfigdlgwidgets_p.h:74
QLabel * commentLabel
Definition: dconfigdlgwidgets_p.h:148
MessageType messageType
Definition: dconfigdlgwidgets_p.h:150
QLabel * imageLabel
Definition: dconfigdlgwidgets_p.h:146
DConfigDlgTitle * q
Definition: dconfigdlgwidgets_p.h:144
QGridLayout * headerLayout
Definition: dconfigdlgwidgets_p.h:145
QLabel * textLabel
Definition: dconfigdlgwidgets_p.h:147
Private(DConfigDlgTitle *const parent)
Definition: dconfigdlgwidgets_p.h:63
void _k_timeoutFinished()
Definition: dconfigdlgwidgets_p.h:137
QString iconTypeToIconName(DConfigDlgTitle::MessageType type)
Get the icon name from the icon type.
Definition: dconfigdlgwidgets_p.h:114
int autoHideTimeout
Definition: dconfigdlgwidgets_p.h:149
Definition: dconfigdlgwidgets.h:185
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
Definition: dconfigdlgview_p.h:77
QAbstractItemModel * model
Definition: dconfigdlgview_p.h:104
Definition: dconfigdlgmodels.h:248
Definition: dconfigdlgwidgets_p.h:42
DConfigDlgWdgModel * model() const
Definition: dconfigdlgwidgets_p.h:49
Page widget with many layouts (faces).
Definition: dconfigdlgwidgets.h:48
Definition: datefolderview.cpp:43