[kde-doc-english] KDE/kdebase/workspace/plasma/applets/systemtray [POSSIBLY UNSAFE]
Joshua Levesque
guitarist198 at yahoo.com
Sun Jan 18 05:39:53 CET 2009
SVN commit 912723 by jleves:
Configuration dialog for turning off notifications in the panel via system tray
GUI: Added Notification page to system tray configuration dialog
M +28 -0 core/manager.cpp
M +10 -0 core/manager.h [POSSIBLY UNSAFE: system]
M +50 -0 ui/applet.cpp
--- trunk/KDE/kdebase/workspace/plasma/applets/systemtray/core/manager.cpp #912722:912723
@@ -52,6 +52,7 @@
}
void setupProtocol(Protocol *protocol);
+ void unsetProtocol(Protocol *protocol);
Manager *q;
QList<Task*> tasks;
@@ -106,6 +107,15 @@
}
}
+void Manager::unregisterNotificationProtocol()
+{
+ if (d->notificationProtocol) {
+ d->unsetProtocol(d->notificationProtocol);
+ delete d->notificationProtocol;
+ d->notificationProtocol = 0;
+ }
+}
+
void Manager::addNotification(Notification* notification)
{
connect(notification, SIGNAL(destroyed(SystemTray::Notification*)),
@@ -137,6 +147,15 @@
}
}
+void Manager::unregisterJobProtocol()
+{
+ if (d->jobProtocol) {
+ d->unsetProtocol(d->jobProtocol);
+ delete d->jobProtocol;
+ d->jobProtocol = 0;
+ }
+}
+
void Manager::Private::setupProtocol(Protocol *protocol)
{
connect(protocol, SIGNAL(jobCreated(SystemTray::Job*)), q, SLOT(addJob(SystemTray::Job*)));
@@ -146,6 +165,15 @@
protocol->init();
}
+void Manager::Private::unsetProtocol(Protocol *protocol)
+{
+ disconnect(protocol, SIGNAL(jobCreated(SystemTray::Job*)), q, SLOT(addJob(SystemTray::Job*)));
+ disconnect(protocol, SIGNAL(taskCreated(SystemTray::Task*)), q, SLOT(addTask(SystemTray::Task*)));
+ disconnect(protocol, SIGNAL(notificationCreated(SystemTray::Notification*)),
+ q, SLOT(addNotification(SystemTray::Notification*)));
+ protocol->init();
+}
+
void Manager::addJob(Job *job)
{
connect(job, SIGNAL(destroyed(SystemTray::Job*)), this, SLOT(removeJob(SystemTray::Job*)));
--- trunk/KDE/kdebase/workspace/plasma/applets/systemtray/core/manager.h #912722:912723
@@ -69,6 +69,16 @@
**/
void registerNotificationProtocol();
+ /**
+ * Removes the Job progress info from the applet's notification system
+ **/
+ void unregisterJobProtocol();
+
+ /**
+ * Removes the notifications from the applet's notification system
+ **/
+ void unregisterNotificationProtocol();
+
signals:
/**
* Emitted when a new task has been added
--- trunk/KDE/kdebase/workspace/plasma/applets/systemtray/ui/applet.cpp #912722:912723
@@ -27,8 +27,11 @@
#include <QtGui/QApplication>
#include <QtGui/QGraphicsLayout>
+#include <QtGui/QVBoxLayout>
#include <QtGui/QIcon>
+#include <QtGui/QLabel>
#include <QtGui/QListWidget>
+#include <QtGui/QCheckBox>
#include <QtGui/QPainter>
#include <KActionSelector>
@@ -59,6 +62,7 @@
: q(q),
taskArea(0),
configInterface(0),
+ notificationInterface(0),
background(0),
extenderTask(0)
{
@@ -85,6 +89,9 @@
TaskArea *taskArea;
QPointer<KActionSelector> configInterface;
+ QPointer<QWidget> notificationInterface;
+ QCheckBox *showNotifications;
+ QCheckBox *showJobs;
Plasma::FrameSvg *background;
SystemTray::ExtenderTask *extenderTask;
@@ -325,10 +332,29 @@
d->configInterface->setSelectedLabel(i18n("Hidden icons:"));
d->configInterface->setShowUpDownButtons(false);
+ KConfigGroup globalCg = globalConfig();
+ d->notificationInterface = new QWidget();
+
+ QLabel *description = new QLabel(i18n("Select the types of application feedback that should "
+ "be integrated with the system tray:"), d->notificationInterface);
+ description->setWordWrap(true);
+ d->showJobs = new QCheckBox(i18n("Show Jobs"), d->notificationInterface);
+ d->showJobs->setChecked(globalCg.readEntry("ShowJobs", true));
+ d->showNotifications = new QCheckBox(i18n("Show Notifications"), d->notificationInterface);
+ d->showNotifications->setChecked(globalCg.readEntry("ShowNotifications", true));
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(description);
+ layout->addWidget(d->showJobs);
+ layout->addWidget(d->showNotifications);
+ layout->addStretch();
+ d->notificationInterface->setLayout(layout);
+
connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
parent->addPage(d->configInterface, i18n("Auto Hide"));
+ parent->addPage(d->notificationInterface, i18n("Notifications"));
}
QListWidget *visibleList = d->configInterface->availableListWidget();
@@ -371,6 +397,30 @@
KConfigGroup cg = config();
cg.writeEntry("hidden", hiddenTypes);
+ KConfigGroup globalCg = globalConfig();
+ globalCg.writeEntry("ShowJobs", d->showJobs->isChecked());
+ globalCg.writeEntry("ShowNotifications", d->showNotifications->isChecked());
+
+ if (d->showJobs->isChecked()) {
+ Private::s_manager->registerJobProtocol();
+ connect(Private::s_manager, SIGNAL(jobAdded(SystemTray::Job*)),
+ this, SLOT(addJob(SystemTray::Job*)));
+ } else {
+ Private::s_manager->unregisterJobProtocol();
+ disconnect(Private::s_manager, SIGNAL(jobAdded(SystemTray::Job*)),
+ this, SLOT(addJob(SystemTray::Job*)));
+ }
+
+ if (d->showNotifications->isChecked()) {
+ Private::s_manager->registerNotificationProtocol();
+ connect(Private::s_manager, SIGNAL(notificationAdded(SystemTray::Notification*)),
+ this, SLOT(addNotification(SystemTray::Notification*)));
+ } else {
+ Private::s_manager->unregisterNotificationProtocol();
+ disconnect(Private::s_manager, SIGNAL(notificationAdded(SystemTray::Notification*)),
+ this, SLOT(addNotification(SystemTray::Notification*)));
+ }
+
emit configNeedsSaving();
}
More information about the kde-doc-english
mailing list