diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch) | |
tree | 5ac38a06f3dde268dc7927dc155896926aaf7012 /kdeui/kwindowinfo.h | |
download | tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdeui/kwindowinfo.h')
-rw-r--r-- | kdeui/kwindowinfo.h | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/kdeui/kwindowinfo.h b/kdeui/kwindowinfo.h new file mode 100644 index 000000000..c419a41d3 --- /dev/null +++ b/kdeui/kwindowinfo.h @@ -0,0 +1,145 @@ +// -*- c++ -*- + +/* + * copyright : (C) 2001-2002 by Richard Moore + * License : This file is released under the terms of the LGPL, version 2. + * email : rich@kde.org + */ + +#ifndef KWINDOWINFO_H +#define KWINDOWINFO_H + +#include <qobject.h> +#include <qpixmap.h> +#include <qstring.h> + +#include <kdelibs_export.h> + +/** + * Displays messages in the window icon and title. The message is usually + * transient with the original title and icon being restored automatically + * after a specified time. The simplest use displays a text message in the + * window title: + * \code + * KWindowInfo::showMessage( this, i18n("Message Body") ); + * \endcode + * This more complex example changes the window icon, as well as + * displaying the text. In addition, this example overrides the + * default timeout to ensure the message is only displayed for 1 + * second. + * \code + * QPixmap px; + * px.load( "lo16-app-logtracker.png" ); + * KWindowInfo::showMessage( this, i18n("Message Body"), px, 1000 ); + * \endcode + * If the parent window inherits KSystemTray then KWindowInfo changes the + * pixmap and tooltip of the system window to display the message. + * + * @author Richard Moore, rich@kde.org + * @since 3.1 +*/ +class KDEUI_EXPORT KWindowInfo : public QObject +{ + Q_OBJECT + +public: + /** + * Creates a KWindowInfo with the specified parent. + */ + KWindowInfo( QWidget *parent, const char *name=0 ); + + /** + * Cleans up. + */ + virtual ~KWindowInfo(); + + /** + * Returns true iff the object should delete itself when it resets. + */ + bool autoDelete() const { return autoDel; } + + /** + * Set to true if you want the object to delete itself when the message + * timeout occurs. + */ + void setAutoDelete( bool enable ) { autoDel = enable; } + + /** + * Utility method to display a title bar message for the specified + * window. + */ + static void showMessage( QWidget *window, const QString &text, int timeout = -1 ); + + /** + * Utility method to display a title bar message and icon for the + * specified window. + */ + static void showMessage( QWidget *window, const QString &text, + const QPixmap &pix, int timeout = -1 ); + +public slots: + /** + * Shows the specified text in the window title. + */ + void message( const QString &text ); + + /** + * Shows the specified text in the window title, and sets the window icon. + */ + void message( const QString &text, const QPixmap &pix ); + + /** + * Shows the specified text in the window title for the specified time. + */ + void message( const QString &text, int timeout ); + + /** + * Shows the specified icon and text in the window title and WM + * icon, for the specified time. The time is a delay specified in + * milliseconds, or one of the two special values. The special + * values are -1 which means the default timeout should be used, + * and 0 which means the message is permanent. + */ + void message( const QString &text, const QPixmap &pix, int timeout ); + + /** + * Shows the specified text in the window title with no timeout. + */ + void permanent( const QString &text ); + + /** + * Shows the specified text and icon in the window title with no timeout. + */ + void permanent( const QString &text, const QPixmap &pix ); + +protected: + /** + * Displays the message in the titlebar/icon. + */ + virtual void display( const QString &text, const QPixmap &pix ); + +protected slots: + /** + * Saves the window title and icon. + */ + virtual void save(); + + /** + * Resets the window title and icon to the saved values. If + * auto-delete is enabled then the object is deleted. + */ + virtual void restore(); + +private: + QWidget *win; + QPixmap oldIcon; + QPixmap oldMiniIcon; + QString oldText; + bool autoDel; + + /* @internal */ + class Private *d; +}; + +#endif // KWINDOWINFO_H + |