Applets
extendertask.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "extendertask.h"
00021 #include <fixx11h.h>
00022
00023 #include <QtGui/QWidget>
00024
00025 #include <plasma/popupapplet.h>
00026 #include <plasma/widgets/iconwidget.h>
00027
00028
00029 namespace SystemTray
00030 {
00031
00032 class ExtenderTask::Private
00033 {
00034 public:
00035 Private(Plasma::PopupApplet *systemTray, Task *q)
00036 : q(q),
00037 iconWidget(0),
00038 systemTray(systemTray)
00039 {
00040 }
00041
00042 Task *q;
00043 QString typeId;
00044 QString iconName;
00045 QIcon icon;
00046 Plasma::IconWidget *iconWidget;
00047 Plasma::PopupApplet *systemTray;
00048 };
00049
00050
00051 ExtenderTask::ExtenderTask(Plasma::PopupApplet *systemTray)
00052 : d(new Private(systemTray, this))
00053 {
00054 setOrder(Last);
00055 }
00056
00057
00058 ExtenderTask::~ExtenderTask()
00059 {
00060 emit taskDeleted(d->typeId);
00061 delete d;
00062 }
00063
00064
00065 bool ExtenderTask::isEmbeddable() const
00066 {
00067 return true;
00068 }
00069
00070 bool ExtenderTask::isValid() const
00071 {
00072 return true;
00073 }
00074
00075 bool ExtenderTask::isHideable() const
00076 {
00077 return false;
00078 }
00079
00080 QString ExtenderTask::name() const
00081 {
00082 return i18n("Show or hide notifications and jobs");
00083 }
00084
00085
00086 QString ExtenderTask::typeId() const
00087 {
00088
00089 return "toggle_extender";
00090 }
00091
00092
00093 QIcon ExtenderTask::icon() const
00094 {
00095 return d->icon;
00096 }
00097
00098 void ExtenderTask::setIcon(const QString &icon)
00099 {
00100 d->iconName = icon;
00101 if (d->iconWidget) {
00102 d->iconWidget->setIcon(icon);
00103 }
00104 }
00105
00106 QGraphicsWidget* ExtenderTask::createWidget(Plasma::Applet *host)
00107 {
00108 d->iconWidget = new Plasma::IconWidget(host);
00109 d->iconWidget->setToolTip(i18n("Toggle visibility of notifications and jobs"));
00110 d->iconWidget->setIcon(d->iconName);
00111 d->iconWidget->setMinimumSize(22, 22);
00112 d->iconWidget->setMaximumSize(26, QWIDGETSIZE_MAX);
00113 connect(d->iconWidget, SIGNAL(clicked()), d->systemTray, SLOT(togglePopup()));
00114 return d->iconWidget;
00115 }
00116
00117
00118 }
00119
00120 #include "extendertask.moc"