[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Kicker/Taskbar: Mouseover effect
From: Stefan Nikolaus <stefan.nikolaus () kdemail ! net>
Date: 2005-04-16 16:14:46
Message-ID: 200504161814.46904.stefan.nikolaus () kdemail ! net
[Download RAW message or body]
Hi,
if we already have that nifty mouse over effect, why not use them for the task
buttons? Attached a patch which displays the effect. It shows the (full)
title, the app's icon and the desktop the task is on.
Comments?
Bye,
Stefan
["taskbar-mouseover-1.patch" (text/x-diff)]
Index: taskcontainer.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/taskbar/taskcontainer.cpp,v
retrieving revision 1.116
diff -u -p -b -r1.116 taskcontainer.cpp
--- taskcontainer.cpp 15 Apr 2005 23:38:01 -0000 1.116
+++ taskcontainer.cpp 16 Apr 2005 16:11:24 -0000
@@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE
#include <qbitmap.h>
#include <qcolor.h>
+#include <qcursor.h>
#include <qimage.h>
#include <qpainter.h>
#include <qpixmap.h>
@@ -41,6 +42,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE
#include <kiconloader.h>
#include <kimageeffect.h>
+#include "global.h"
+#include "kickerSettings.h"
+#include "kickertip.h"
#include "taskmanager.h"
#include "taskbarsettings.h"
#include "tasklmbmenu.h"
@@ -162,18 +166,6 @@ void TaskContainer::iconChanged()
QToolButton::update();
}
-void TaskContainer::update()
-{
- QString tooltip = "<qt>" + QStyleSheet::escape(name()) + "</qt>";
- if (QToolTip::textFor(this) != tooltip)
- {
- QToolTip::remove(this);
- QToolTip::add(this, tooltip);
- }
-
- QToolButton::update();
-}
-
void TaskContainer::setLastActivated()
{
for ( Task* t = m_filteredTasks.first(); t ; t = m_filteredTasks.next() )
@@ -738,6 +730,8 @@ void TaskContainer::mousePressEvent( QMo
return;
}
+ KickerTip::the()->untipFor(this);
+
if (e->button() == LeftButton)
{
m_dragStartPos = e->pos();
@@ -1118,6 +1112,60 @@ void TaskContainer::dragLeaveEvent( QDra
QToolButton::dragLeaveEvent( e );
}
+void TaskContainer::enterEvent(QEvent* e)
+{
+ QToolTip::remove(this);
+
+ if (!KickerSettings::showMouseOverEffects())
+ {
+ QString tooltip = "<qt>" + QStyleSheet::escape(name()) + "</qt>";
+ QToolTip::add(this, tooltip);
+ QToolButton::enterEvent(e);
+ return;
+ }
+
+ if (!KickerTip::tippingEnabled())
+ {
+ QToolButton::enterEvent(e);
+ return;
+ }
+
+ if (!mouseGrabber() &&
+ !QApplication::activePopupWidget() &&
+ !KickerTip::the()->isTippingFor(this))
+ {
+ KickerTip::the()->tipFor(this);
+
+ if (KickerTip::the()->isVisible())
+ {
+ showMouseOver();
+ }
+ else
+ {
+ // delay if it isn't shown to avoid false starts
+ // e.g. when the user quickly zooms their mouse over
+ // a button then out of kicker
+ QTimer::singleShot(250, this, SLOT(showMouseOver()));
+ }
+
+ return;
+ }
+
+ QToolButton::enterEvent(e);
+}
+
+void TaskContainer::leaveEvent(QEvent* e)
+{
+ if (KickerTip::tippingEnabled() &&
+ KickerTip::the()->isTippingFor(this) &&
+ KickerTip::the()->isVisible())
+ {
+ QTimer::singleShot(200, this, SLOT(hideMouseOver()));
+ }
+
+ QToolButton::leaveEvent(e);
+}
+
void TaskContainer::dragSwitch()
{
if ( m_filteredTasks.count() < 1 )
@@ -1274,3 +1322,55 @@ void TaskContainer::settingsChanged()
updateFilteredTaskList();
update();
}
+
+void TaskContainer::showMouseOver()
+{
+ if (!KickerTip::the()->isTippingFor(this))
+ {
+ return;
+ }
+
+ if (!rect().contains(mapFromGlobal(QCursor::pos())))
+ {
+ KickerTip::the()->untipFor(this);
+ return;
+ }
+
+ //try to guess the icon from the classhint
+ QPixmap pixmap = KGlobal::iconLoader()->loadIcon(sid.lower(),
+ KIcon::Panel,
+ KIcon::SizeHuge,
+ KIcon::DefaultState,
+ 0, true);
+
+ // try to load icon via net_wm
+ if (pixmap.isNull())
+ {
+ pixmap = KWin::icon(tasks.first()->window(),
+ KIcon::SizeHuge,
+ KIcon::SizeHuge,
+ true);
+ }
+
+ // Collect all desktops the tasks are on. Sort naturally.
+ QMap<int, QString> desktopMap;
+ for (Task *t = m_filteredTasks.first(); t; t = m_filteredTasks.next())
+ {
+ desktopMap.insert(t->desktop(),
+ TaskManager::the()->desktopName(t->desktop()));
+ }
+ QStringList desktopNames = desktopMap.values();
+
+ KickerTip::the()->display(this->name(), desktopNames.join( ", " ), pixmap);
+
+ QPoint p = KickerLib::popupPosition(KPanelApplet::Up,
+ KickerTip::the(),
+ this);
+ KickerTip::the()->move(p);
+ KickerTip::the()->show();
+}
+
+void TaskContainer::hideMouseOver()
+{
+ KickerTip::the()->untipFor(this);
+}
Index: taskcontainer.h
===================================================================
RCS file: /home/kde/kdebase/kicker/taskbar/taskcontainer.h,v
retrieving revision 1.42
diff -u -p -b -r1.42 taskcontainer.h
--- taskcontainer.h 15 Apr 2005 23:38:01 -0000 1.42
+++ taskcontainer.h 16 Apr 2005 16:11:24 -0000
@@ -86,6 +86,8 @@ protected:
void mouseMoveEvent(QMouseEvent*);
void dragEnterEvent(QDragEnterEvent*);
void dragLeaveEvent(QDragLeaveEvent*);
+ void enterEvent(QEvent*);
+ void leaveEvent(QEvent*);
bool startDrag(const QPoint& pos);
void stopTimers();
@@ -100,11 +102,12 @@ protected slots:
void attentionTimerFired();
void slotClicked();
void dragSwitch();
- void update();
void iconChanged();
void setLastActivated();
void taskChanged();
void showMe();
+ void showMouseOver();
+ void hideMouseOver();
private:
void checkAttention( const Task* changed_task = NULL );
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic