← Back to team overview

ayatana-commits team mailing list archive

[Branch ~agateau/plasma-widget-message-indicator/trunk] Rev 111: Show an explanation message when clicking on the widget if no indicator app are

 

------------------------------------------------------------
revno: 111
committer: Aurelien Gateau <aurelien.gateau@xxxxxxxxxxxxx>
branch nick: plasma-widget-message-indicator
timestamp: Fri 2010-02-12 11:46:57 +0100
message:
  Show an explanation message when clicking on the widget if no indicator app are
  running.
modified:
  src/message-indicator.cpp
  src/message-indicator.h


--
lp:plasma-widget-message-indicator
https://code.launchpad.net/~agateau/plasma-widget-message-indicator/trunk

Your team ayatana-commits is subscribed to branch lp:plasma-widget-message-indicator.
To unsubscribe from this branch go to https://code.launchpad.net/~agateau/plasma-widget-message-indicator/trunk/+edit-subscription.
=== modified file 'src/message-indicator.cpp'
--- src/message-indicator.cpp	2010-02-09 10:34:28 +0000
+++ src/message-indicator.cpp	2010-02-12 10:46:57 +0000
@@ -13,6 +13,7 @@
 
 // Qt
 #include <QGraphicsLinearLayout>
+#include <QLabel>
 #include <QLayout>
 #include <QRegExp>
 
@@ -32,6 +33,8 @@
 static const char* NO_NEW_STUFF_ICON = "mail-unread";
 static const char* NEW_STUFF_ICON = "mail-unread-new";
 
+static const char* MI_URL = "https://wiki.kubuntu.org/KarmicKoala/ConfigureIndicators";;
+
 K_EXPORT_PLASMA_APPLET(message-indicator, MessageIndicator)
 
 
@@ -39,17 +42,38 @@
 : Plasma::PopupApplet(parent, args)
 , mListener(0)
 , mSourceModel(0)
-, mView(new ExpandedTreeView())
+, mStack(new QWidget)
+, mView(new ExpandedTreeView(mStack))
+, mNoIndicatorLabel(new QLabel(mStack))
 , mIconWidget(new Plasma::IconWidget(this))
 {
     setBackgroundHints(StandardBackground);
     setAspectRatioMode(Plasma::Square);
+
+    mNoIndicatorLabel->setText(i18n(
+        "<p>The Message Indicator widget helps you keep track of incoming messages in a non-intrusive way.</p>"
+        "<p>To take advantage of it, you need to enable support for Message Indicator in your application."
+        " Applications with support for Message Indicator include:</p>"
+        "<ul>"
+        "<li>Kopete</li>"
+        "<li>Konversation</li>"
+        "<li>Quassel</li>"
+        "<li>KMail</li>"
+        "</ul>"
+        "<p>For more information visit the <a href='%1'>Message Indicator wiki page</a>.</p>",
+        MI_URL
+        ));
+    mNoIndicatorLabel->setWordWrap(true);
+    mNoIndicatorLabel->setOpenExternalLinks(true);
+    mCurrentWidget = mNoIndicatorLabel;
+
+    setWidget(mStack);
+    updateIconState();
 }
 
 MessageIndicator::~MessageIndicator()
 {
     removeInterestOnServers();
-    delete mView;
 }
 
 void MessageIndicator::init()
@@ -142,11 +166,6 @@
     widget()->setPalette(pal);
 }
 
-QWidget* MessageIndicator::widget()
-{
-    return mView;
-}
-
 void MessageIndicator::toolTipAboutToShow()
 {
     Plasma::ToolTipContent toolTip;
@@ -163,16 +182,18 @@
 
 void MessageIndicator::adjustViewSize()
 {
-    QSize sh = widget()->sizeHint();
+    QSize sh = mCurrentWidget->sizeHint();
+    mCurrentWidget->resize(sh);
 
     QWidget* dialog = widget()->parentWidget();
     if (!dialog) {
+        kWarning() << "No parentWidget for applet widget()!";
         return;
     }
     int left, top, right, bottom;
     dialog->getContentsMargins(&left, &top, &right, &bottom);
 
-    dialog->setFixedSize(sh.width() + left + right, sh.height() + top + bottom);
+    dialog->resize(sh.width() + left + right, sh.height() + top + bottom);
 
     // Hack: Plasma::Dialog only emits dialogResized() if its content is a
     // QGraphicsWidget. Emit it ourself to ensure the dialog is correctly
@@ -241,12 +262,17 @@
 
 void MessageIndicator::updateIconState()
 {
-    if (mSourceModel->rowCount() == 0) {
+    if (!mSourceModel || mSourceModel->rowCount() == 0) {
+        mView->hide();
+        mNoIndicatorLabel->show();
+        mCurrentWidget = mNoIndicatorLabel;
         hidePopup();
-        mIconWidget->setEnabled(false);
     } else {
-        mIconWidget->setEnabled(true);
+        mView->show();
+        mNoIndicatorLabel->hide();
+        mCurrentWidget = mView;
     }
+    adjustViewSize();
 }
 
 void MessageIndicator::slotServerAdded(QIndicate::Listener::Server* server)

=== modified file 'src/message-indicator.h'
--- src/message-indicator.h	2010-01-15 10:26:42 +0000
+++ src/message-indicator.h	2010-02-12 10:46:57 +0000
@@ -23,6 +23,8 @@
 // Local
 #include <listenermodel.h>
 
+class QLabel;
+
 class MessageIndicator : public Plasma::PopupApplet
 {
 Q_OBJECT
@@ -32,8 +34,6 @@
 
     virtual void init();
 
-    virtual QWidget* widget();
-
 public Q_SLOTS:
     void toolTipAboutToShow();
 
@@ -52,7 +52,10 @@
 private:
     QIndicate::Listener* mListener;
     ListenerModel* mSourceModel;
+    QWidget* mStack;
     QTreeView* mView;
+    QLabel* mNoIndicatorLabel;
+    QWidget* mCurrentWidget;
     Plasma::IconWidget* mIconWidget;
 
     void initIcon();