digiKam
colorlabelwidget.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 : 2011-01-28
7  * Description : color label widget
8  *
9  * Copyright (C) 2011-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_COLOR_LABEL_WIDGET_H
25 #define DIGIKAM_COLOR_LABEL_WIDGET_H
26 
27 // Qt includes
28 
29 #include <QColor>
30 #include <QPushButton>
31 #include <QEvent>
32 #include <QList>
33 #include <QMetaType>
34 #include <QMenu>
35 
36 // Local includes
37 
38 #include "dlayoutbox.h"
39 #include "digikam_globals.h"
40 #include "digikam_export.h"
41 
42 namespace Digikam
43 {
44 
45 class DIGIKAM_EXPORT ColorLabelWidget : public DVBox
46 {
47  Q_OBJECT
48 
49 public:
50 
51  explicit ColorLabelWidget(QWidget* const parent = nullptr);
52  ~ColorLabelWidget() override;
53 
57  void setDescriptionBoxVisible(bool b);
58 
63  void setButtonsExclusive(bool b);
64 
68  void setColorLabels(const QList<ColorLabel>& list);
69 
73  QList<ColorLabel> colorLabels() const;
74 
75  static QColor labelColor(ColorLabel label);
76  static QString labelColorName(ColorLabel label);
77 
78  static QIcon buildIcon(ColorLabel label, int size = 12);
79 
80 Q_SIGNALS:
81 
83 
84 protected:
85 
86  bool eventFilter(QObject* obj, QEvent* ev) override;
87 
88 private:
89 
90  void updateDescription(ColorLabel label);
91 
92 private:
93 
94  class Private;
95  Private* const d;
96 };
97 
98 // ------------------------------------------------------------------------------
99 
100 class DIGIKAM_EXPORT ColorLabelSelector : public QPushButton
101 {
102  Q_OBJECT
103 
104 public:
105 
106  explicit ColorLabelSelector(QWidget* const parent = nullptr);
107  ~ColorLabelSelector() override;
108 
109  void setColorLabel(ColorLabel label);
110  ColorLabel colorLabel();
111 
112  ColorLabelWidget* colorLabelWidget() const;
113 
114 Q_SIGNALS:
115 
117 
118 private Q_SLOTS:
119 
120  void slotColorLabelChanged(int);
121 
122 private:
123 
124  class Private;
125  Private* const d;
126 };
127 
128 // ------------------------------------------------------------------------------
129 
130 class DIGIKAM_EXPORT ColorLabelMenuAction : public QMenu
131 {
132  Q_OBJECT
133 
134 public:
135 
136  explicit ColorLabelMenuAction(QMenu* const parent = nullptr);
137  ~ColorLabelMenuAction() override;
138 
139 Q_SIGNALS:
140 
142 };
143 
144 } // namespace Digikam
145 
146 Q_DECLARE_METATYPE(QList<Digikam::ColorLabel>)
147 
148 #endif // DIGIKAM_COLOR_LABEL_WIDGET_H
Definition: colorlabelwidget.h:131
Definition: colorlabelwidget.h:101
Definition: colorlabelwidget.h:46
Definition: dlayoutbox.h:75
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43
ColorLabel
Definition: digikam_globals.h:103