2
//Modified KPassivePopup from KDE, original Copyright below
4
* Copyright : (C) 2001-2002 by Richard Moore
5
* License : This file is released under the terms of the LGPL, version 2.
9
#ifndef QPASSIVEPOPUP_H
10
#define QPASSIVEPOPUP_H
19
* A dialog-like popup that displays messages without interupting the user.
20
* The simplest uses of QPassivePopup are by using the various @ref message() static
21
* methods. The position the popup appears at depends on the type of the parent window:
23
* @li Normal Windows: The popup is placed adjacent to the icon of the window.
24
* @li System Tray Windows: The popup is placed adjact to the system tray window itself.
25
* @li Skip Taskbar Windows: The popup is placed adjact to the window
26
* itself if it is visible, and at the edge of the desktop otherwise.
28
* The most basic use of QPassivePopup displays a popup containing a piece of text:
30
* QPassivePopup::message( "This is the message", this );
32
* We can create popups with titles and icons too, as this example shows:
35
* px.load( "hi32-app-logtracker.png" );
36
* QPassivePopup::message( "Some title", "This is the main text", px, this );
38
* For more control over the popup, you can use the @ref setView(QWidget *) method
39
* to create a custom popup.
41
* QPassivePopup *pop = new QPassivePopup( parent );
43
* QVBox *vb = new QVBox( pop );
44
* (void) new QLabel( "<b>Isn't this great?</b>", vb );
46
* QHBox *box = new QHBox( vb );
47
* (void) new QPushButton( "Yes", box );
48
* (void) new QPushButton( "No", box );
54
* @version $Id: qpassivepopup.h,v 1.2 2003/06/30 17:45:39 mblsha Exp $
56
* @author Richard Moore, rich@kde.org
58
class QPassivePopup : public QFrame
64
* Creates a popup for the specified widget.
66
QPassivePopup( QWidget *parent, const char *name=0, WFlags f=0 );
67
QPassivePopup( const char *name=0, WFlags f=0 );
70
* Creates a popup for the specified window.
72
QPassivePopup( WId parent, const char *name=0, WFlags f=0 );
77
virtual ~QPassivePopup();
80
* Sets the main view to be the specified widget (which must be a child of the popup).
82
void setView( QWidget *child );
85
* Creates a standard view then calls @ref #setView(QWidget*) .
87
void setView( const QString &caption, const QString &text = QString::null );
90
* Creates a standard view then calls @ref #setView(QWidget*) .
92
virtual void setView( const QString &caption, const QString &text, const QPixmap &icon );
95
* Returns the main view.
97
QWidget *view() const { return msgView; }
100
* Returns the delay before the popup is removed automatically.
102
int timeout() const { return hideDelay; }
105
* Enables / disables auto-deletion of this widget when the #timeout
107
* The default is false. If you use the class-methods message(),
108
* auto-delection is turned on by default.
110
virtual void setAutoDelete( bool autoDelete );
113
* @returns true if the widget auto-deletes itself when the #timeout occurs.
114
* @see #setAutoDelete
116
bool autoDelete() const { return m_autoDelete; }
119
* Convenience method that displays popup with the specified message beside the
120
* icon of the specified widget.
121
* Note that the returned object is destroyed when it is hidden.
122
* @see #setAutoDelete
124
static QPassivePopup *message( const QString &text, QWidget *parent, const char *name=0 );
127
* Convenience method that displays popup with the specified caption and message
128
* beside the icon of the specified widget.
129
* Note that the returned object is destroyed when it is hidden.
130
* @see #setAutoDelete
132
static QPassivePopup *message( const QString &caption, const QString &text,
133
QWidget *parent, const char *name=0 );
136
* Convenience method that displays popup with the specified icon, caption and
137
* message beside the icon of the specified widget.
138
* Note that the returned object is destroyed when it is hidden.
139
* @see #setAutoDelete
141
static QPassivePopup *message( const QString &caption, const QString &text,
143
QWidget *parent, const char *name=0, int timeout = -1 );
146
* Convenience method that displays popup with the specified icon, caption and
147
* message beside the icon of the specified window.
148
* Note that the returned object is destroyed when it is hidden.
149
* @see #setAutoDelete
151
static QPassivePopup *message( const QString &caption, const QString &text,
153
WId parent, const char *name=0, int timeout = -1 );
156
* Returns a QString broken with <br> tags around every size chars
159
static QString *splitMessage(QString caption, uint splitsize, uint maxsize);
163
* Sets the delay for the popup is removed automatically. Setting the delay to 0
164
* disables the #timeout, if you're doing this, you may want to connect the
165
* @ref clicked() signal to the hide() slot.
166
* Setting the delay to -1 makes it use the default value.
168
void setTimeout( int delay );
171
* Reimplemented to reposition the popup.
177
* Emitted when the popup is clicked.
182
* Emitted when the popup is clicked.
184
void clicked( QPoint pos );
188
* This method positions the popup.
190
virtual void positionSelf();
193
* Reimplemented to destroy the object when @ref autoDelete() is
196
virtual void hideEvent( QHideEvent * );
199
* Moves the popup to be adjacent to the icon of the specified rectangle.
201
void moveNear( QRect target );
204
* Reimplemented to detect mouse clicks.
206
virtual void mouseReleaseEvent( QMouseEvent *e );
229
#endif // QPASSIVEPOPUP_H