digiKam
dnotificationpopup.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 : 2004-07-03
7  * Description : dialog-like popup that displays messages without interrupting the user
8  *
9  * Copyright (C) 2009-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2001-2006 by Richard Moore <rich at kde dot org>
11  * Copyright (C) 2004-2005 by Sascha Cunz <sascha.cunz at tiscali dot de>
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_POPUP_H
27 #define DIGIKAM_DNOTIFICATION_POPUP_H
28 
29 // Qt includes
30 
31 #include <QFrame>
32 
33 // Local includes
34 
35 #include "digikam_export.h"
36 
37 class QSystemTrayIcon;
38 
39 namespace Digikam
40 {
41 
49 class DIGIKAM_EXPORT DNotificationPopup : public QFrame
50 {
51  Q_OBJECT
52  Q_PROPERTY(bool autoDelete READ autoDelete WRITE setAutoDelete)
53  Q_PROPERTY(int timeout READ timeout WRITE setTimeout)
54 
55 public:
56 
61  {
64  };
65 
66 public:
67 
71  explicit DNotificationPopup(QWidget* const parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
72 
76  explicit DNotificationPopup(WId parent);
77 
81  ~DNotificationPopup() override;
82 
86  void setView(QWidget* child);
87 
91  void setView(const QString& caption, const QString& text = QString());
92 
96  virtual void setView(const QString& caption, const QString& text, const QPixmap& icon);
97 
119  QWidget* standardView(const QString& caption, const QString& text,
120  const QPixmap& icon, QWidget* parent = nullptr);
121 
125  QWidget* view() const;
126 
130  int timeout() const;
131 
138  virtual void setAutoDelete(bool autoDelete);
139 
145  bool autoDelete() const;
146 
150  QPoint anchor() const;
151 
157  void setAnchor(const QPoint& anchor);
158 
165  static DNotificationPopup* message(const QString& text, QWidget* parent,
166  const QPoint& p = QPoint());
167 
174  static DNotificationPopup* message(const QString& text, QSystemTrayIcon* parent);
175 
182  static DNotificationPopup* message(const QString& caption, const QString& text,
183  QWidget* parent, const QPoint& p = QPoint());
184 
191  static DNotificationPopup* message(const QString& caption, const QString& text,
192  QSystemTrayIcon* parent);
193 
200  static DNotificationPopup* message(const QString& caption, const QString& text,
201  const QPixmap& icon, QWidget* parent, int timeout = -1,
202  const QPoint& p = QPoint());
203 
210  static DNotificationPopup* message(const QString& caption, const QString& text,
211  const QPixmap& icon, QSystemTrayIcon* parent, int timeout = -1);
212 
219  static DNotificationPopup* message(const QString& caption, const QString& text,
220  const QPixmap& icon, WId parent,
221  int timeout = -1, const QPoint& p = QPoint());
222 
229  static DNotificationPopup* message(int popupStyle, const QString& text, QWidget* parent, const QPoint& p = QPoint());
230 
237  static DNotificationPopup* message(int popupStyle, const QString& text, QSystemTrayIcon* parent);
238 
245  static DNotificationPopup* message(int popupStyle, const QString& caption, const QString& text,
246  QSystemTrayIcon* parent);
247 
254  static DNotificationPopup* message(int popupStyle, const QString& caption, const QString& text,
255  QWidget* parent, const QPoint& p = QPoint());
256 
263  static DNotificationPopup* message(int popupStyle, const QString& caption, const QString& text,
264  const QPixmap& icon, QWidget* parent, int timeout = -1,
265  const QPoint& p = QPoint());
266 
273  static DNotificationPopup* message(int popupStyle, const QString& caption, const QString& text,
274  const QPixmap& icon, QSystemTrayIcon* parent, int timeout = -1);
275 
282  static DNotificationPopup* message(int popupStyle, const QString& caption, const QString& text,
283  const QPixmap& icon, WId parent, int timeout = -1,
284  const QPoint& p = QPoint());
285 
286  // we create an overloaded version of show()
287  using QFrame::show;
288 
289 public Q_SLOTS:
290 
299  void setTimeout(int delay);
300 
305  void setPopupStyle(int popupstyle);
306 
310  void show(const QPoint& p);
311 
315  void setVisible(bool visible) override;
316 
317 Q_SIGNALS:
318 
322  void clicked();
323 
327  void clicked(const QPoint& pos);
328 
329 protected:
330 
341  virtual void positionSelf();
342 
350  virtual QPoint defaultLocation() const;
351 
361  void moveNear(const QRect& target);
362 
366  void hideEvent(QHideEvent*) override;
367 
371  void mouseReleaseEvent(QMouseEvent* e) override;
372 
376  void paintEvent(QPaintEvent* pe) override;
377 
378 private:
379 
380  class Private;
381  Private* const d;
382 };
383 
384 } // namespace Digikam
385 
386 #endif // DIGIKAM_DNOTIFICATION_POPUP_H
A dialog-like popup that displays messages without interrupting the user.
Definition: dnotificationpopup.h:50
PopupStyle
Definition: dnotificationpopup.h:61
@ Balloon
Information will appear in a comic-alike balloon.
Definition: dnotificationpopup.h:63
@ Boxed
Information will appear in a framed box (default)
Definition: dnotificationpopup.h:62
void clicked(const QPoint &pos)
Definition: datefolderview.cpp:43