[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/plasma/applets/quicklaunch
From: Aaron J. Seigo <aseigo () kde ! org>
Date: 2009-03-26 4:21:00
Message-ID: 1238041260.798242.32139.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 944785 by aseigo:
tooltips, patch by Jonathan Thomas
CCMAIL:echidnaman@kubuntu.org
BUG:180702
M +10 -1 quicklaunchApplet.cpp
M +23 -2 quicklaunchIcon.cpp
M +15 -1 quicklaunchIcon.h
--- trunk/KDE/kdebase/workspace/plasma/applets/quicklaunch/quicklaunchApplet.cpp \
#944784:944785 @@ -412,20 +412,29 @@
return;
KUrl appUrl = KUrl(url);
KIcon icon;
+ QString text;
+ QString genericName;
if (appUrl.isLocalFile() && KDesktopFile::isDesktopFile(appUrl.toLocalFile())) {
KDesktopFile *f = new KDesktopFile(appUrl.toLocalFile());
+
+ text = f->readName();
icon = KIcon(f->readIcon());
+ genericName = f->readGenericName();
delete f;
} else {
icon = KIcon(KMimeType::iconNameForUrl(appUrl));
}
+ if (text.isNull()) {
+ text = appUrl.fileName();
+ }
+
if (icon.isNull()) {
icon = KIcon("unknown");
}
- QuicklaunchIcon *container = new QuicklaunchIcon(appUrl, icon, this);
+ QuicklaunchIcon *container = new QuicklaunchIcon(appUrl, text, icon, \
genericName, this); container->installEventFilter(this);
m_icons.insert(index, container);
}
--- trunk/KDE/kdebase/workspace/plasma/applets/quicklaunch/quicklaunchIcon.cpp \
#944784:944785 @@ -26,21 +26,27 @@
#include <KMenu>
#include <KRun>
+#include <Plasma/ToolTipManager>
+
#include "quicklaunchApplet.h"
-QuicklaunchIcon::QuicklaunchIcon(const KUrl & appUrl, const KIcon & icon, \
QuicklaunchApplet *parent) +QuicklaunchIcon::QuicklaunchIcon(const KUrl & appUrl, \
const QString & text, const KIcon & icon, const QString & genericName, \
QuicklaunchApplet *parent) : Plasma::IconWidget(icon, QString(), parent),
m_launcher(parent),
m_appUrl(appUrl),
+ m_text(text),
+ m_genericName(genericName),
m_removeAction(0),
m_iconSize(0)
{
setAcceptDrops(true);
+ Plasma::ToolTipManager::self()->registerWidget(this);
connect(this, SIGNAL(clicked()), SLOT(execute()));
}
QuicklaunchIcon::~QuicklaunchIcon()
{
+ Plasma::ToolTipManager::self()->unregisterWidget(this);
}
KUrl QuicklaunchIcon::url() const
@@ -69,7 +75,7 @@
//rect.setTop((option->rect.height() - m_iconSize) / 2);
//QStyleOptionGraphicsItem opt = *option;
//opt.rect = rect;
- kDebug() << "Paint to:" << rect << "Original rect was:" << option->rect;
+ //kDebug() << "Paint to:" << rect << "Original rect was:" << option->rect;
painter->drawPixmap(rect, icon().pixmap(m_iconSize));
//IconWidget::paint(painter, &opt, widget);
@@ -91,6 +97,21 @@
m.exec(event->screenPos());
}
+void QuicklaunchIcon::toolTipAboutToShow()
+{
+ Plasma::ToolTipContent toolTip;
+ toolTip.setMainText(m_text);
+ toolTip.setSubText(m_genericName);
+ toolTip.setImage(icon().pixmap(m_iconSize));
+
+ Plasma::ToolTipManager::self()->setContent(this, toolTip);
+}
+
+void QuicklaunchIcon::toolTipHidden()
+{
+ Plasma::ToolTipManager::self()->clearContent(this);
+}
+
/*bool QuicklaunchIcon::eventFilter(QObject * object, QEvent * event)
{
if (event->type() != QEvent::GraphicsSceneMouseMove) {
--- trunk/KDE/kdebase/workspace/plasma/applets/quicklaunch/quicklaunchIcon.h \
#944784:944785 @@ -37,9 +37,11 @@
* Constructor
* @param appUrl Url to desktop file
* @param mimetype Icon mimetype
+ * @param text Desktop file name
* @param icon Icon object
+ * @param genericName Desktop file generic name
*/
- QuicklaunchIcon(const KUrl & appUrl, const KIcon & icon, QuicklaunchApplet \
*parent); + QuicklaunchIcon(const KUrl & appUrl, const QString & text, const \
KIcon & icon, const QString & genericName, QuicklaunchApplet *parent);
/**
* Desctructor
@@ -69,6 +71,16 @@
*/
void execute();
+ /**
+ * @internal Sets the tooltip content properly before showing.
+ */
+ void toolTipAboutToShow();
+
+ /**
+ * @internal Clears memory when needed.
+ */
+ void toolTipHidden();
+
protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
//bool eventFilter(QObject * object, QEvent * event);
@@ -77,6 +89,8 @@
private:
QuicklaunchApplet *m_launcher;
KUrl m_appUrl;
+ QString m_text;
+ QString m_genericName;
QAction *m_removeAction;
int m_iconSize;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic