kpassivepopup.h
00001 // -*- c++ -*- 00002 00003 /* 00004 * Copyright : (C) 2001-2002 by Richard Moore 00005 * Copyright : (C) 2004-2005 by Sascha Cunz 00006 * License : This file is released under the terms of the LGPL, version 2. 00007 * Email : rich@kde.org 00008 * Email : sascha.cunz@tiscali.de 00009 */ 00010 00011 #ifndef KPASSIVEPOPUP_H 00012 #define KPASSIVEPOPUP_H 00013 00014 #include <qframe.h> 00015 00016 #include <kdelibs_export.h> 00017 00018 class QBoxLayout; 00019 class QTimer; 00020 class QLabel; 00021 class QVBox; 00022 00068 class KDEUI_EXPORT KPassivePopup : public QFrame 00069 { 00070 Q_OBJECT 00071 Q_PROPERTY (bool autoDelete READ autoDelete WRITE setAutoDelete ) 00072 Q_PROPERTY (int timeout READ timeout WRITE setTimeout ) 00073 00074 public: 00079 enum PopupStyle 00080 { 00081 Boxed, 00082 Balloon, 00083 CustomStyle=128 00084 }; 00085 00089 KPassivePopup( QWidget *parent=0, const char *name=0, WFlags f=0 ); 00090 00094 KPassivePopup( WId parent, const char *name=0, WFlags f=0 ); 00095 00100 KPassivePopup( int popupStyle, QWidget *parent=0, const char *name=0, WFlags f=0 ); 00101 00106 KPassivePopup( int popupStyle, WId parent, const char *name=0, WFlags f=0 ); 00107 00111 virtual ~KPassivePopup(); 00112 00116 void setView( QWidget *child ); 00117 00121 void setView( const QString &caption, const QString &text = QString::null ); 00122 00126 virtual void setView( const QString &caption, const QString &text, const QPixmap &icon ); 00127 00148 QVBox * standardView( const QString& caption, const QString& text, 00149 const QPixmap& icon, QWidget *parent = 0L ); 00150 00154 QWidget *view() const { return msgView; } 00155 00159 int timeout() const { return hideDelay; } 00160 00167 virtual void setAutoDelete( bool autoDelete ); 00168 00173 bool autoDelete() const { return m_autoDelete; } 00174 00180 void setAnchor( const QPoint& anchor ); 00181 00182 // TODO KDE4: give all the statics method a const QPoint p = QPoint() that in 00183 // case the point is not null calls the show(cosnt QPoint &p) method instead 00184 // the show() one. 00191 static KPassivePopup *message( const QString &text, QWidget *parent, const char *name=0 ); 00192 00199 static KPassivePopup *message( const QString &caption, const QString &text, 00200 QWidget *parent, const char *name=0 ); 00201 00208 static KPassivePopup *message( const QString &caption, const QString &text, 00209 const QPixmap &icon, 00210 QWidget *parent, const char *name=0, int timeout = -1 ); 00211 00218 static KPassivePopup *message( const QString &caption, const QString &text, 00219 const QPixmap &icon, 00220 WId parent, const char *name=0, int timeout = -1 ); 00221 00228 static KPassivePopup *message( int popupStyle, const QString &text, QWidget *parent, 00229 const char *name=0 ); 00230 00237 static KPassivePopup *message( int popupStyle, const QString &caption, const QString &text, 00238 QWidget *parent, const char *name=0 ); 00239 00246 static KPassivePopup *message( int popupStyle, const QString &caption, const QString &text, 00247 const QPixmap &icon, 00248 QWidget *parent, const char *name=0, int timeout = -1 ); 00249 00256 static KPassivePopup *message( int popupStyle, const QString &caption, const QString &text, 00257 const QPixmap &icon, 00258 WId parent, const char *name=0, int timeout = -1 ); 00259 00260 00261 public slots: 00270 void setTimeout( int delay ); 00271 00275 virtual void show(); 00276 00281 void show(const QPoint &p); 00282 00283 signals: 00287 void clicked(); 00288 00292 void clicked( QPoint pos ); 00293 00294 protected: 00298 virtual void positionSelf(); 00299 00304 virtual void hideEvent( QHideEvent * ); 00305 00309 void moveNear( QRect target ); 00310 00314 virtual void mouseReleaseEvent( QMouseEvent *e ); 00315 00324 QRect defaultArea() const; 00325 00330 void updateMask(); 00331 00336 virtual void paintEvent( QPaintEvent* pe ); 00337 00338 private: 00339 void init( int popupStyle ); 00340 00341 WId window; 00342 QWidget *msgView; 00343 QBoxLayout *topLayout; 00344 int hideDelay; 00345 QTimer *hideTimer; 00346 00347 QLabel *ttlIcon; 00348 QLabel *ttl; 00349 QLabel *msg; 00350 00351 bool m_autoDelete; 00352 00353 /* @internal */ 00354 class Private; 00355 Private *d; 00356 }; 00357 00358 #endif // KPASSIVEPOPUP_H 00359 00360 // Local Variables: 00361 // c-basic-offset: 4 00362 // End: 00363