KDEUI
kpassivepopup.h
Go to the documentation of this file.
00001 // -*- c++ -*- 00002 00003 /* 00004 * Copyright (C) 2001-2006 by Richard Moore <rich@kde.org> 00005 * Copyright (C) 2004-2005 by Sascha Cunz <sascha.cunz@tiscali.de> 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00022 #ifndef KPASSIVEPOPUP_H 00023 #define KPASSIVEPOPUP_H 00024 00025 #include <kdeui_export.h> 00026 00027 #include <QtGui/QFrame> 00028 00029 class KVBox; 00030 class QSystemTrayIcon; 00031 00079 class KDEUI_EXPORT KPassivePopup : public QFrame 00080 { 00081 Q_OBJECT 00082 Q_PROPERTY (bool autoDelete READ autoDelete WRITE setAutoDelete ) 00083 Q_PROPERTY (int timeout READ timeout WRITE setTimeout ) 00084 Q_PROPERTY (QRect defaultArea READ defaultArea ) 00085 00086 public: 00090 enum PopupStyle 00091 { 00092 Boxed, 00093 Balloon, 00094 CustomStyle=128 00095 }; 00096 00100 explicit KPassivePopup( QWidget *parent=0, Qt::WFlags f = 0 ); 00101 00105 explicit KPassivePopup( WId parent ); 00106 00107 #if 0 // These break macos and win32 where the definition of WId makes them ambiguous 00108 00112 explicit KPassivePopup( int popupStyle, QWidget *parent=0, Qt::WFlags f=0 ) KDE_DEPRECATED; 00113 00118 KPassivePopup( int popupStyle, WId parent, Qt::WFlags f=0 ) KDE_DEPRECATED; 00119 #endif 00120 00124 virtual ~KPassivePopup(); 00125 00129 void setView( QWidget *child ); 00130 00134 void setView( const QString &caption, const QString &text = QString() ); 00135 00139 virtual void setView( const QString &caption, const QString &text, const QPixmap &icon ); 00140 00161 KVBox * standardView( const QString& caption, const QString& text, 00162 const QPixmap& icon, QWidget *parent = 0L ); 00163 00167 QWidget *view() const; 00168 00172 int timeout() const; 00173 00180 virtual void setAutoDelete( bool autoDelete ); 00181 00186 bool autoDelete() const; 00187 00196 QRect defaultArea() const; 00197 00201 QPoint anchor() const; 00202 00207 void setAnchor( const QPoint& anchor ); 00208 00209 // TODO KDE4: give all the static methods a const QPoint p = QPoint() that in 00210 // case the point is not null calls the show(const QPoint &p) method instead 00211 // of the show() one. 00218 static KPassivePopup *message( const QString &text, QWidget *parent ); 00219 00226 static KPassivePopup *message( const QString &text, QSystemTrayIcon *parent ); 00227 00234 static KPassivePopup *message( const QString &caption, const QString &text, 00235 QWidget *parent ); 00236 00243 static KPassivePopup *message( const QString &caption, const QString &text, 00244 QSystemTrayIcon *parent ); 00245 00252 static KPassivePopup *message( const QString &caption, const QString &text, 00253 const QPixmap &icon, 00254 QWidget *parent, int timeout = -1 ); 00255 00262 static KPassivePopup *message( const QString &caption, const QString &text, 00263 const QPixmap &icon, 00264 QSystemTrayIcon *parent, int timeout = -1 ); 00265 00272 static KPassivePopup *message( const QString &caption, const QString &text, 00273 const QPixmap &icon, 00274 WId parent, int timeout = -1 ); 00275 00282 static KPassivePopup *message( int popupStyle, const QString &text, QWidget *parent ); 00283 00290 static KPassivePopup *message( int popupStyle, const QString &text, QSystemTrayIcon *parent ); 00291 00298 static KPassivePopup *message( int popupStyle, const QString &caption, const QString &text, 00299 QSystemTrayIcon *parent ); 00300 00307 static KPassivePopup *message( int popupStyle, const QString &caption, const QString &text, 00308 QWidget *parent ); 00309 00316 static KPassivePopup *message( int popupStyle, const QString &caption, const QString &text, 00317 const QPixmap &icon, 00318 QWidget *parent, int timeout = -1 ); 00319 00326 static KPassivePopup *message( int popupStyle, const QString &caption, const QString &text, 00327 const QPixmap &icon, 00328 QSystemTrayIcon *parent, int timeout = -1 ); 00329 00336 static KPassivePopup *message( int popupStyle, const QString &caption, const QString &text, 00337 const QPixmap &icon, 00338 WId parent, int timeout = -1 ); 00339 00340 00341 public Q_SLOTS: 00350 void setTimeout( int delay ); 00351 00356 void setPopupStyle( int popupstyle ); 00357 00361 void show(); 00362 00366 void show(const QPoint &p); 00367 00368 virtual void setVisible(bool visible); 00369 00370 Q_SIGNALS: 00374 void clicked(); 00375 00379 void clicked( const QPoint &pos ); 00380 00381 protected: 00385 virtual void positionSelf(); 00386 00391 virtual void hideEvent( QHideEvent * ); 00392 00396 void moveNear( const QRect &target ); 00397 00401 QPoint calculateNearbyPoint( const QRect &target); 00402 00406 virtual void mouseReleaseEvent( QMouseEvent *e ); 00407 00411 void updateMask(); 00412 00417 virtual void paintEvent( QPaintEvent* pe ); 00418 00419 private: 00420 void init( WId window ); 00421 00422 /* @internal */ 00423 class Private; 00424 Private *const d; 00425 }; 00426 00427 #endif // KPASSIVEPOPUP_H 00428 00429 // Local Variables: 00430 // c-basic-offset: 4 00431 // End: 00432
KDE 4.6 API Reference