digiKam
ratingwidget.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 : 2005-08-15
7  * Description : a widget to draw stars rating
8  *
9  * Copyright (C) 2005 by Owen Hirst <n8rider@sbcglobal.net>
10  * Copyright (C) 2006-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
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_RATING_WIDGET_H
26 #define DIGIKAM_RATING_WIDGET_H
27 
28 // Qt includes
29 
30 #include <QWidget>
31 #include <QPaintEvent>
32 #include <QMouseEvent>
33 #include <QPolygon>
34 #include <QIcon>
35 #include <QMenu>
36 
37 // Local includes
38 
39 #include "dlayoutbox.h"
40 #include "digikam_export.h"
41 
42 namespace Digikam
43 {
44 
45 class DIGIKAM_EXPORT RatingWidget : public QWidget
46 {
47  Q_OBJECT
48 
49 public:
50 
51  explicit RatingWidget(QWidget* const parent);
52  ~RatingWidget() override;
53 
54  void setRating(int val);
55  int rating() const;
56 
57  void setTracking(bool tracking);
58  bool hasTracking() const;
59 
60  void setFading(bool fading);
61  bool hasFading() const;
62 
63  void startFading();
64  void stopFading();
65  void setVisibleImmediately();
66 
67  void setVisible(bool visible) override;
68  int maximumVisibleWidth() const;
69 
73  static QPolygon starPolygon();
74  static QIcon buildIcon(int rate, int size);
75 
76 Q_SIGNALS:
77 
80 
81 protected:
82 
83  int regPixmapWidth() const;
84 
85  QPixmap starPixmap() const;
86  QPixmap starPixmapFilled() const;
87  QPixmap starPixmapDisabled() const;
88 
89  void regeneratePixmaps();
90  void setupTimeLine();
91  void applyFading(QPixmap& pix);
92 
93  void mousePressEvent(QMouseEvent*) override;
94  void mouseMoveEvent(QMouseEvent*) override;
95  void mouseReleaseEvent(QMouseEvent*) override;
96  void paintEvent(QPaintEvent*) override;
97 
98 protected Q_SLOTS:
99 
100  void setFadingValue(int value);
101 
102 private Q_SLOTS:
103 
104  void slotThemeChanged();
105 
106 private:
107 
108  class Private;
109  Private* const d;
110 };
111 
112 // --------------------------------------------------------------------
113 
114 class DIGIKAM_EXPORT RatingBox : public DVBox
115 {
116  Q_OBJECT
117 
118 public:
119 
120  explicit RatingBox(QWidget* const parent);
121  ~RatingBox() override;
122 
123 Q_SIGNALS:
124 
126 
127 private Q_SLOTS:
128 
129  void slotUpdateDescription(int);
130 
131 private:
132 
133  class Private;
134  Private* const d;
135 };
136 
137 // --------------------------------------------------------------------
138 
139 class DIGIKAM_EXPORT RatingMenuAction : public QMenu
140 {
141  Q_OBJECT
142 
143 public:
144 
145  explicit RatingMenuAction(QMenu* const parent = nullptr);
146  ~RatingMenuAction() override;
147 
148 Q_SIGNALS:
149 
151 };
152 
153 } // namespace Digikam
154 
155 #endif // DIGIKAM_RATING_WIDGET_H
Definition: dlayoutbox.h:75
Definition: ratingwidget.h:115
void signalRatingChanged(int)
Definition: ratingwidget.h:140
Definition: ratingwidget.h:46
void signalRatingModified(int)
Not managed by tracking properties.
void signalRatingChanged(int)
qulonglong value
Definition: itemviewutilities.cpp:592
Definition: datefolderview.cpp:43