[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/plasma/applets/systray-refactor
From: Jason Stubbs <jasonbstubbs () gmail ! com>
Date: 2008-10-05 5:22:06
Message-ID: 1223184126.267030.14738.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 867969 by jstubbs:
Support saving and restoring of detached notifications again.
Icon saving and restoring is _not_ supported.
M +0 -3 TODO
M +6 -7 ui/applet.cpp
M +1 -0 ui/applet.h
M +42 -15 ui/notificationwidget.cpp
M +1 -0 ui/notificationwidget.h
--- trunk/playground/base/plasma/applets/systray-refactor/TODO #867968:867969
@@ -1,6 +1,3 @@
-* Detached notifications don't close.
- - Also re-add support for saving/restoring detached notifications
-
* Style fixes
- Friendly Qt/KDE headers
- <x.h> plasma headers
--- trunk/playground/base/plasma/applets/systray-refactor/ui/applet.cpp \
#867968:867969 @@ -257,14 +257,7 @@
{
Plasma::ExtenderItem *extenderItem = new Plasma::ExtenderItem(extender());
extenderItem->setWidget(new NotificationWidget(notification, extenderItem));
- extenderItem->setIcon("preferences-desktop-notification");
- if (!notification->summary().isEmpty()) {
- extenderItem->setTitle(notification->summary());
- } else {
- extenderItem->setTitle(i18n("Notification from %1", \
notification->applicationName()));
- }
-
connect(extenderItem, SIGNAL(destroyed()),
this, SLOT(hidePopupIfEmpty()));
@@ -272,6 +265,12 @@
}
+void Applet::initExtenderItem(Plasma::ExtenderItem *extenderItem)
+{
+ extenderItem->setWidget(new NotificationWidget(0, extenderItem));
+}
+
+
void Applet::hidePopupIfEmpty()
{
if (extender()->items().isEmpty()) {
--- trunk/playground/base/plasma/applets/systray-refactor/ui/applet.h #867968:867969
@@ -50,6 +50,7 @@
protected:
void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, \
const QRect &contentsRect); void createConfigurationInterface(KConfigDialog \
*parent); + void initExtenderItem(Plasma::ExtenderItem *extenderItem);
private slots:
void configAccepted();
--- trunk/playground/base/plasma/applets/systray-refactor/ui/notificationwidget.cpp \
#867968:867969 @@ -65,25 +65,32 @@
};
-NotificationWidget::NotificationWidget(SystemTray::Notification *notification, \
Plasma::ExtenderItem *parent)
- : QGraphicsWidget(parent),
+NotificationWidget::NotificationWidget(SystemTray::Notification *notification, \
Plasma::ExtenderItem *extenderItem) + : QGraphicsWidget(extenderItem),
d(new Private())
{
+ extenderItem->setIcon("preferences-desktop-notification");
setMinimumSize(QSizeF(275, desiredMinimumHeight()));
-
- d->notification = notification;
d->textWidget = new NotifyTextItem(this);
- connect(notification, SIGNAL(changed()),
- this, SLOT(updateNotification()));
- connect(notification, SIGNAL(destroyed()),
- this, SLOT(destroy()));
- connect(d->textWidget, SIGNAL(actionInvoked(const QString&)),
- this, SLOT(checkAction(const QString&)));
- connect(parent->extender(), SIGNAL(itemDetached(Plasma::ExtenderItem*)),
- this, SLOT(removeCloseActionIfSelf(Plasma::ExtenderItem*)));
+ if (notification) {
+ d->notification = notification;
- updateNotification();
+ connect(notification, SIGNAL(changed()),
+ this, SLOT(updateNotification()));
+ connect(notification, SIGNAL(destroyed()),
+ this, SLOT(destroy()));
+ connect(d->textWidget, SIGNAL(actionInvoked(const QString&)),
+ this, SLOT(checkAction(const QString&)));
+ connect(extenderItem->extender(), \
SIGNAL(itemDetached(Plasma::ExtenderItem*)), + this, \
SLOT(removeCloseActionIfSelf(Plasma::ExtenderItem*))); +
+ updateNotification();
+ } else {
+ setTextFields(extenderItem->config().readEntry("applicationName", ""),
+ extenderItem->config().readEntry("summary", ""),
+ extenderItem->config().readEntry("message", ""));
+ }
}
@@ -95,9 +102,15 @@
void NotificationWidget::updateNotification()
{
+ Plasma::ExtenderItem *extenderItem = \
dynamic_cast<Plasma::ExtenderItem*>(parentWidget()); +
+ extenderItem->config().writeEntry("applicationName", \
d->notification->applicationName()); + \
extenderItem->config().writeEntry("summary", d->notification->summary()); + \
extenderItem->config().writeEntry("message", d->notification->message()); +
+ setTextFields(d->notification->applicationName(), d->notification->summary(), \
d->notification->message()); d->applicationIcon = \
KIcon(d->notification->applicationIcon());
- d->textWidget->setBody(d->notification->message());
if (!d->notification->actions().isEmpty() || !d->destroyOnClose) {
d->textWidget->setActions(d->notification->actions(), \
d->notification->actionOrder()); } else {
@@ -112,6 +125,20 @@
}
+void NotificationWidget::setTextFields(const QString &applicationName, const QString \
&summary, const QString &message) +{
+ Plasma::ExtenderItem *extenderItem = \
dynamic_cast<Plasma::ExtenderItem*>(parentWidget()); +
+ if (!summary.isEmpty()) {
+ extenderItem->setTitle(summary);
+ } else {
+ extenderItem->setTitle(i18n("Notification from %1", applicationName));
+ }
+
+ d->textWidget->setBody(message);
+}
+
+
void NotificationWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem \
*option, QWidget *widget) {
Q_UNUSED(option);
@@ -146,7 +173,7 @@
{
Plasma::ExtenderItem *extenderItem = dynamic_cast<Plasma::ExtenderItem \
*>(parentItem());
- if (d->destroyOnClose && extenderItem) {
+ if (d->destroyOnClose) {
extenderItem->destroy();
} else {
d->textWidget->clearActions();
--- trunk/playground/base/plasma/applets/systray-refactor/ui/notificationwidget.h \
#867968:867969 @@ -65,6 +65,7 @@
private:
void resizeEvent(QGraphicsSceneResizeEvent *event);
void updateLayout(const QSizeF &newSize);
+ void setTextFields(const QString &applicationName, const QString &summary, const \
QString &message);
private:
class Private;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic