KDEUI
kstatusnotifieritem.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright 2009 by Marco Martin <notmart@gmail.com> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License (LGPL) as published by the Free Software Foundation; 00007 either version 2 of the License, or (at your option) any later 00008 version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef KSTATUSNOTIFIERITEM_H 00022 #define KSTATUSNOTIFIERITEM_H 00023 00024 #include <QtCore/QObject> 00025 #include <QtCore/QString> 00026 #include <QtDBus/QDBusArgument> 00027 #include <QtCore/QPoint> 00028 00029 #include "kdeui_export.h" 00030 00031 class KActionCollection; 00032 class KMenu; 00033 class QMovie; 00034 00035 00036 class KStatusNotifierItemPrivate; 00037 00072 class KDEUI_EXPORT KStatusNotifierItem : public QObject 00073 { 00074 Q_OBJECT 00075 00076 Q_ENUMS(ItemStatus) 00077 Q_ENUMS(ItemCategory) 00078 Q_PROPERTY( ItemCategory category READ category WRITE setCategory ) 00079 Q_PROPERTY( QString title READ title WRITE setTitle ) 00080 Q_PROPERTY( ItemStatus status READ status WRITE setStatus ) 00081 Q_PROPERTY( QString iconName READ iconName WRITE setIconByName ) 00082 Q_PROPERTY( QString overlayIconName READ overlayIconName WRITE setOverlayIconByName ) 00083 Q_PROPERTY( QString attentionIconName READ attentionIconName WRITE setAttentionIconByName ) 00084 Q_PROPERTY( QString toolTipIconName READ toolTipIconName WRITE setToolTipIconByName ) 00085 Q_PROPERTY( QString toolTipTitle READ toolTipTitle WRITE setToolTipTitle ) 00086 Q_PROPERTY( QString toolTipSubTitle READ toolTipSubTitle WRITE setToolTipSubTitle ) 00087 00088 friend class KStatusNotifierItemDBus; 00089 friend class KStatusNotifierItemPrivate; 00090 public: 00095 enum ItemStatus { 00097 Passive = 1, 00100 Active = 2, 00103 NeedsAttention = 3 00104 }; 00105 00110 enum ItemCategory { 00112 ApplicationStatus = 1, 00115 Communications = 2, 00119 SystemServices = 3, 00121 Hardware = 4, 00122 Reserved = 129 00123 }; 00124 00133 explicit KStatusNotifierItem(QObject *parent = 0); 00134 00153 explicit KStatusNotifierItem(const QString &id, QObject *parent = 0); 00154 00155 ~KStatusNotifierItem(); 00156 00163 QString id() const; 00164 00170 void setCategory(const ItemCategory category); 00171 00175 ItemCategory category() const; 00176 00180 void setTitle(const QString &title); 00181 00185 QString title() const; 00186 00190 void setStatus(const ItemStatus status); 00191 00195 ItemStatus status() const; 00196 00197 //Main icon related functions 00204 void setIconByName(const QString &name); 00205 00210 QString iconName() const; 00211 00217 void setIconByPixmap(const QIcon &icon); 00218 00222 QIcon iconPixmap() const; 00223 00229 void setOverlayIconByName(const QString &name); 00230 00234 QString overlayIconName() const; 00235 00243 void setOverlayIconByPixmap(const QIcon &icon); 00244 00248 QIcon overlayIconPixmap() const; 00249 00250 //Requesting attention icon 00251 00259 void setAttentionIconByName(const QString &name); 00260 00266 QString attentionIconName() const; 00267 00274 void setAttentionIconByPixmap(const QIcon &icon); 00275 00279 QIcon attentionIconPixmap() const; 00280 00285 void setAttentionMovieByName(const QString &name); 00286 00291 QString attentionMovieName() const; 00292 00293 00294 //ToolTip handling 00303 void setToolTip(const QString &iconName, const QString &title, const QString &subTitle); 00304 00309 void setToolTip(const QIcon &icon, const QString &title, const QString &subTitle); 00310 00316 void setToolTipIconByName(const QString &name); 00317 00322 QString toolTipIconName() const; 00323 00330 void setToolTipIconByPixmap(const QIcon &icon); 00331 00335 QIcon toolTipIconPixmap() const; 00336 00340 void setToolTipTitle(const QString &title); 00341 00345 QString toolTipTitle() const; 00346 00350 void setToolTipSubTitle(const QString &subTitle); 00351 00355 QString toolTipSubTitle() const; 00356 00364 void setContextMenu(KMenu *menu); 00365 00369 KMenu *contextMenu() const; 00370 00381 void setAssociatedWidget(QWidget *parent); 00382 00386 QWidget *associatedWidget() const; 00387 00391 KActionCollection *actionCollection() const; 00392 00396 void setStandardActionsEnabled(bool enabled); 00397 00401 bool standardActionsEnabled() const; 00402 00411 void showMessage(const QString &title, const QString &message, const QString &icon, int timeout = 10000); 00412 00413 00414 public Q_SLOTS: 00415 00422 virtual void activate(const QPoint &pos = QPoint()); 00423 00424 Q_SIGNALS: 00432 void scrollRequested(int delta, Qt::Orientation orientation); 00433 00443 void activateRequested(bool active, const QPoint &pos); 00444 00453 void secondaryActivateRequested(const QPoint &pos); 00454 00455 protected: 00456 bool eventFilter(QObject *watched, QEvent *event); 00457 00458 private: 00459 KStatusNotifierItemPrivate *const d; 00460 00461 Q_PRIVATE_SLOT(d, void serviceChange(const QString& name, 00462 const QString& oldOwner, 00463 const QString& newOwner)) 00464 Q_PRIVATE_SLOT(d, void checkForRegisteredHosts()) 00465 Q_PRIVATE_SLOT(d, void registerToDaemon()) 00466 Q_PRIVATE_SLOT(d, void contextMenuAboutToShow()) 00467 Q_PRIVATE_SLOT(d, void maybeQuit()) 00468 Q_PRIVATE_SLOT(d, void minimizeRestore()) 00469 Q_PRIVATE_SLOT(d, void hideMenu()) 00470 Q_PRIVATE_SLOT(d, void legacyWheelEvent(int)) 00471 Q_PRIVATE_SLOT(d, void legacyActivated(QSystemTrayIcon::ActivationReason)) 00472 }; 00473 00474 #endif
KDE 4.6 API Reference