digiKam
dnotificationwidget.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-07-03
7  * Description : A widget to provide feedback or propose opportunistic interactions
8  *
9  * Copyright (C) 2009-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (c) 2011 by Aurelien Gateau <agateau at kde dot org>
11  * Copyright (c) 2014 by Dominik Haumann <dhaumann at kde dot org>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_DNOTIFICATION_WIDGET_H
27 #define DIGIKAM_DNOTIFICATION_WIDGET_H
28 
29 // Qt includes
30 
31 #include <QFrame>
32 #include <QIcon>
33 #include <QString>
34 #include <QAction>
35 
36 // Local includes
37 
38 #include "digikam_export.h"
39 
40 namespace Digikam
41 {
42 
47 class DIGIKAM_EXPORT DNotificationWidget : public QFrame
48 {
49  Q_OBJECT
50  Q_PROPERTY(QString text READ text WRITE setText)
51  Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
52  Q_PROPERTY(bool closeButtonVisible READ isCloseButtonVisible WRITE setCloseButtonVisible)
53  Q_PROPERTY(MessageType messageType READ messageType WRITE setMessageType)
54  Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
55 
56 public:
57 
63  {
67  Error
68  };
69  Q_ENUM(MessageType)
70 
71 public:
72 
76  explicit DNotificationWidget(QWidget* const parent = nullptr);
77 
82  explicit DNotificationWidget(const QString& text, QWidget* const parent = nullptr);
83 
87  ~DNotificationWidget() override;
88 
93  QString text() const;
94 
104  bool wordWrap() const;
105 
111  bool isCloseButtonVisible() const;
112 
119  MessageType messageType() const;
120 
129  void addAction(QAction* action);
130 
137  void removeAction(QAction* action);
138 
144  void clearAllActions();
145 
149  QSize sizeHint() const override;
150 
154  QSize minimumSizeHint() const override;
155 
160  int heightForWidth(int width) const override;
161 
165  QIcon icon() const;
166 
174  bool isHideAnimationRunning() const;
175 
183  bool isShowAnimationRunning() const;
184 
188  void animatedShowTemporized(int delay);
189 
190 public Q_SLOTS:
191 
199  void setText(const QString& text);
200 
210  void setWordWrap(bool wordWrap);
211 
218  void setCloseButtonVisible(bool visible);
219 
226  void setMessageType(DNotificationWidget::MessageType type);
227 
231  void animatedShow();
232 
236  void animatedHide();
237 
241  void setIcon(const QIcon& icon);
242 
243 Q_SIGNALS:
244 
251  void linkActivated(const QString& contents);
252 
259  void linkHovered(const QString& contents);
260 
273 
286 
287 private Q_SLOTS:
288 
289  void slotTimerTimeout();
290 
291 protected:
292 
293  void paintEvent(QPaintEvent* event) override;
294  bool event(QEvent* event) override;
295  void resizeEvent(QResizeEvent* event) override;
296 
297 private:
298 
299  class Private;
300  Private* const d;
301 
302  friend class Private;
303 };
304 
305 } // namespace Digikam
306 
307 #endif // DIGIKAM_DNOTIFICATION_WIDGET_H
Definition: dnotificationwidget_p.h:47
Definition: dnotificationwidget.h:48
void linkHovered(const QString &contents)
MessageType
Definition: dnotificationwidget.h:63
@ Positive
Definition: dnotificationwidget.h:64
@ Warning
Definition: dnotificationwidget.h:66
@ Information
Definition: dnotificationwidget.h:65
void linkActivated(const QString &contents)
Definition: datefolderview.cpp:43