KNotifications

kpassivepopup.h
1 // -*- c++ -*-
2 
3 /*
4  * Copyright (C) 2001-2006 by Richard Moore <[email protected]>
5  * Copyright (C) 2004-2005 by Sascha Cunz <[email protected]>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef KPASSIVEPOPUP_H
23 #define KPASSIVEPOPUP_H
24 
25 #include <knotifications_export.h>
26 
27 #include <QFrame>
28 
29 class QSystemTrayIcon;
30 
87 class KNOTIFICATIONS_EXPORT KPassivePopup : public QFrame
88 {
89  Q_OBJECT
90  Q_PROPERTY(bool autoDelete READ autoDelete WRITE setAutoDelete)
91  Q_PROPERTY(int timeout READ timeout WRITE setTimeout)
92 
93 public:
97  enum PopupStyle {
100  };
101 
105  explicit KPassivePopup(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
106 
110  explicit KPassivePopup(WId parent);
111 
115  virtual ~KPassivePopup();
116 
120  void setView(QWidget *child);
121 
125  void setView(const QString &caption, const QString &text = QString());
126 
130  virtual void setView(const QString &caption, const QString &text, const QPixmap &icon);
131 
153  QWidget *standardView(const QString &caption, const QString &text,
154  const QPixmap &icon, QWidget *parent = nullptr);
155 
159  QWidget *view() const;
160 
164  int timeout() const;
165 
172  virtual void setAutoDelete(bool autoDelete);
173 
179  bool autoDelete() const;
180 
184  QPoint anchor() const;
185 
191  void setAnchor(const QPoint &anchor);
192 
199  static KPassivePopup *message(const QString &text, QWidget *parent,
200  const QPoint &p = QPoint());
201 
208  static KPassivePopup *message(const QString &text, QSystemTrayIcon *parent);
209 
216  static KPassivePopup *message(const QString &caption, const QString &text,
217  QWidget *parent, const QPoint &p = QPoint());
218 
225  static KPassivePopup *message(const QString &caption, const QString &text,
226  QSystemTrayIcon *parent);
227 
234  static KPassivePopup *message(const QString &caption, const QString &text,
235  const QPixmap &icon, QWidget *parent, int timeout = -1,
236  const QPoint &p = QPoint());
237 
244  static KPassivePopup *message(const QString &caption, const QString &text,
245  const QPixmap &icon, QSystemTrayIcon *parent, int timeout = -1);
246 
253  static KPassivePopup *message(const QString &caption, const QString &text,
254  const QPixmap &icon, WId parent,
255  int timeout = -1, const QPoint &p = QPoint());
256 
263  static KPassivePopup *message(int popupStyle, const QString &text, QWidget *parent, const QPoint &p = QPoint());
264 
271  static KPassivePopup *message(int popupStyle, const QString &text, QSystemTrayIcon *parent);
272 
279  static KPassivePopup *message(int popupStyle, const QString &caption, const QString &text,
280  QSystemTrayIcon *parent);
281 
288  static KPassivePopup *message(int popupStyle, const QString &caption, const QString &text,
289  QWidget *parent, const QPoint &p = QPoint());
290 
297  static KPassivePopup *message(int popupStyle, const QString &caption, const QString &text,
298  const QPixmap &icon, QWidget *parent, int timeout = -1,
299  const QPoint &p = QPoint());
300 
307  static KPassivePopup *message(int popupStyle, const QString &caption, const QString &text,
308  const QPixmap &icon, QSystemTrayIcon *parent, int timeout = -1);
309 
316  static KPassivePopup *message(int popupStyle, const QString &caption, const QString &text,
317  const QPixmap &icon, WId parent, int timeout = -1,
318  const QPoint &p = QPoint());
319 
320  // we create an overloaded version of show()
321  using QFrame::show;
322 
323 public Q_SLOTS:
332  void setTimeout(int delay);
333 
338  void setPopupStyle(int popupstyle);
339 
343  void show(const QPoint &p);
344 
346  void setVisible(bool visible) override;
347 
348 Q_SIGNALS:
352  void clicked();
353 
357  void clicked(const QPoint &pos);
358 
359 protected:
370  virtual void positionSelf();
371 
379  virtual QPoint defaultLocation() const;
380 
390  void moveNear(const QRect &target);
391 
393  void hideEvent(QHideEvent *) override;
394 
396  void mouseReleaseEvent(QMouseEvent *e) override;
397 
399  void paintEvent(QPaintEvent *pe) override;
400 
401 private:
402  /* @internal */
403  class Private;
404  Private *const d;
405 };
406 
407 #endif // KPASSIVEPOPUP_H
408 
409 // Local Variables:
410 // End:
411 
virtual void setVisible(bool visible)
PopupStyle
Styles that a KPassivePopup can have.
Definition: kpassivepopup.h:97
Information will appear in a comic-alike balloon.
Definition: kpassivepopup.h:99
virtual void mouseReleaseEvent(QMouseEvent *event)
virtual void paintEvent(QPaintEvent *) override
virtual void hideEvent(QHideEvent *event)
A dialog-like popup that displays messages without interrupting the user.
Definition: kpassivepopup.h:87
Q_PROPERTY(...)
void show()
Information will appear in a framed box (default)
Definition: kpassivepopup.h:98
typedef WindowFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun May 31 2020 22:51:15 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.