ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #00029
[Branch ~agateau/plasma-indicatordisplay/trunk] Rev 68: Added tooltip and ensured we do not show an empty popup if no application is running.
------------------------------------------------------------
revno: 68
committer: Aurelien Gateau <aurelien.gateau@xxxxxxxxxxxxx>
branch nick: plasma-indicatordisplay
timestamp: Tue 2009-09-01 15:34:44 +0200
message:
Added tooltip and ensured we do not show an empty popup if no application is running.
modified:
src/indicatordisplay.cpp
src/indicatordisplay.h
--
lp:plasma-indicatordisplay
https://code.launchpad.net/~agateau/plasma-indicatordisplay/trunk
Your team ayatana-commits is subscribed to branch lp:plasma-indicatordisplay.
To unsubscribe from this branch go to https://code.launchpad.net/~agateau/plasma-indicatordisplay/trunk/+edit-subscription.
=== modified file 'src/indicatordisplay.cpp'
--- src/indicatordisplay.cpp 2009-08-11 10:32:01 +0000
+++ src/indicatordisplay.cpp 2009-09-01 13:34:44 +0000
@@ -20,6 +20,7 @@
#include <KIcon>
#include <Plasma/IconWidget>
#include <Plasma/Theme>
+#include <Plasma/ToolTipManager>
// Local
#include "delegate.h"
@@ -53,7 +54,7 @@
void IndicatorDisplay::init()
{
- initIcon();
+ Plasma::ToolTipManager::self()->registerWidget(this);
mListener = new QIndicate::Listener(this);
connect(mListener,
SIGNAL(serverAdded(QIndicate::Listener::Server*, const QString&)),
@@ -63,6 +64,7 @@
initSourceModel();
initFilterModel();
initView();
+ initIcon();
}
void IndicatorDisplay::initIcon()
@@ -77,6 +79,7 @@
connect(mIconWidget, SIGNAL(clicked()), SLOT(togglePopup()));
updateIcon(false /* no new stuff */);
+ updateIconState();
}
void IndicatorDisplay::initSourceModel()
@@ -146,6 +149,20 @@
return mView;
}
+void IndicatorDisplay::toolTipAboutToShow()
+{
+ Plasma::ToolTipContent toolTip;
+ toolTip.setImage(mIconWidget->icon());
+ toolTip.setMainText(i18n("Indicator Display"));
+ int appCount = mSourceModel->rowCount();
+ if (appCount == 0) {
+ toolTip.setSubText(i18n("No applications running"));
+ } else {
+ toolTip.setSubText(i18np("One application running", "%1 applications running", appCount));
+ }
+ Plasma::ToolTipManager::self()->setContent(this, toolTip);
+}
+
void IndicatorDisplay::adjustViewSize()
{
QSize sh = mView->sizeHint();
@@ -188,7 +205,8 @@
void IndicatorDisplay::slotRowsChanged(const QModelIndex& parent)
{
if (!parent.isValid()) {
- // A new server has been added, we don't care about this
+ // A server has been added or removed
+ updateIconState();
return;
}
@@ -214,6 +232,16 @@
mIconWidget->setIcon(newStuff ? NEW_STUFF_ICON : NO_NEW_STUFF_ICON);
}
+void IndicatorDisplay::updateIconState()
+{
+ if (mSourceModel->rowCount() == 0) {
+ hidePopup();
+ mIconWidget->setEnabled(false);
+ } else {
+ mIconWidget->setEnabled(true);
+ }
+}
+
void IndicatorDisplay::slotServerAdded(QIndicate::Listener::Server* server)
{
mListener->setInterest(server, QIndicate::InterestServerDisplay, true);
=== modified file 'src/indicatordisplay.h'
--- src/indicatordisplay.h 2009-08-10 16:04:49 +0000
+++ src/indicatordisplay.h 2009-09-01 13:34:44 +0000
@@ -35,6 +35,9 @@
virtual QWidget* widget();
+public Q_SLOTS:
+ void toolTipAboutToShow();
+
protected:
virtual void popupEvent(bool show);
@@ -58,6 +61,7 @@
void initFilterModel();
void initView();
void updateIcon(bool newStuff);
+ void updateIconState();
};
#endif /* INDICATORDISPLAY_H */