On Wednesday 14 January 2009, Aaron J. Seigo wrote:
> On Wednesday 14 January 2009, Marco Martin wrote:
> > On Tuesday 13 January 2009, Aaron J. Seigo wrote:
> > > this would probably mean creating a small Plasma::Message class or
> > > (even re- using Plasma::ToolTipContent perhaps?) and allow plasmoids to
> > > queue such messages with the Applet class. the Applet class would then
> > > display it in a "plasma" way (what does that mean? i don't know for
> > > sure, but we can work that out together; perhaps an overlay on the
> > > plasmoid itself if it is big enough, perhaps a tooltip type thing,
> > > perhaps a notification in the system tray,...?)
> >
> > hmm woudn't this mean duplicating knotify in a similar-but-not-quite way?
>
> it's not meant as a replacement for notifications, but rather a widget
> appropriate replacement for dialog boxes ...
>
> good example is folderview when it can't load the folder (doesn't exist,
> network down, whatever). that functionality should be available to all
> widgets.
>
> the weather widget in kdrevew uses a KMessagBox right now, because it's
> easy to do, but that causes all sorts of problems: it doesn't look Plasma
> and it blocks mouse interaction with the rest of the desktop.
>
> it'll also give us a nice simple bit of API to give scripters.

could be something like the stuff attached, not really sure if it should have 
also other buttons like a yes/no/cancel and be syncronous like dialog.exec()?

Cheers,
Marco Martin

Index: applet.h
===================================================================
--- applet.h	(revision 910984)
+++ applet.h	(working copy)
@@ -729,6 +729,8 @@
          */
         void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString());
 
+        void message(const QString &icon, const QString &message);
+
         /**
          * Reimplement this method so provide a configuration interface,
          * parented to the supplied widget. Ownership of the widgets is passed
Index: applet.cpp
===================================================================
--- applet.cpp	(revision 910984)
+++ applet.cpp	(working copy)
@@ -880,6 +880,46 @@
     d->messageOverlay->show();
 }
 
+void Applet::message(const QString &icon, const QString &message)
+{
+    d->createMessageOverlay();
+    QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(d->messageOverlay);
+    mainLayout->setOrientation(Qt::Vertical);
+    mainLayout->setContentsMargins(10, 10, 10, 10);
+
+    QGraphicsLinearLayout *messageLayout = new QGraphicsLinearLayout();
+    messageLayout->setOrientation(Qt::Horizontal);
+
+    QGraphicsLinearLayout *buttonLayout = new QGraphicsLinearLayout();
+    buttonLayout->setOrientation(Qt::Horizontal);
+
+    mainLayout->addItem(messageLayout);
+    mainLayout->addItem(buttonLayout);
+
+    IconWidget *messageIcon = new IconWidget(this);
+    Label *messageText = new Label(this);
+    messageText->nativeWidget()->setWordWrap(true);
+
+    messageLayout->addItem(messageIcon);
+    messageLayout->addItem(messageText);
+
+    messageIcon->setIcon(KIcon(icon));
+    messageText->setText(message);
+
+
+    buttonLayout->addStretch();
+    PushButton *ok = new PushButton(this);
+    ok->setText(i18n("Ok"));
+    //FIXME: QGL brokeness++
+    ok->setMinimumHeight(23);
+    buttonLayout->addItem(ok);
+    buttonLayout->addStretch();
+
+    connect(ok, SIGNAL(clicked()), this, SLOT(destroyMessageOverlay()));
+    d->messageOverlay->show();
+
+}
+
 void Applet::flushPendingConstraintsEvents()
 {
     if (d->pendingConstraints == NoConstraint) {
@@ -935,7 +975,7 @@
     if (c & Plasma::SizeConstraint) {
         if (d->messageOverlay) {
             d->messageOverlay->setGeometry(QRectF(QPointF(0, 0), geometry().size()));
-
+/*
             QGraphicsItem *button = 0;
             QList<QGraphicsItem*> children = d->messageOverlay->QGraphicsItem::children();
 
@@ -947,7 +987,7 @@
                 QSizeF s = button->boundingRect().size();
                 button->setPos(d->messageOverlay->boundingRect().width() / 2 - s.width() / 2,
                         d->messageOverlay->boundingRect().height() / 2 - s.height() / 2);
-            }
+            }*/
         }
 
         if (d->busyWidget && d->busyWidget->isVisible()) {
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to