[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/plasma/applets/quicklaunch
From: Lukas Appelhans <l.appelhans () gmx ! de>
Date: 2009-05-11 16:29:43
Message-ID: 1242059383.385319.16950.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 966617 by lappelhans:
-Make icons being rearrangeable, patch by Shafqat Bhuiyan, thank you
very much!
-Fix crash when dropping something on an existing icon...
CCMAIL:priomsrb@gmail.com
BUG:181612
M +36 -4 quicklaunchApplet.cpp
--- trunk/KDE/kdebase/workspace/plasma/applets/quicklaunch/quicklaunchApplet.cpp #966616:966617
@@ -397,9 +397,42 @@
bool QuicklaunchApplet::eventFilter(QObject * object, QEvent * event)
{
- Q_UNUSED(object)
+ if (event->type() == QEvent::GraphicsSceneMousePress) {
+ m_mousePressPos = static_cast<QGraphicsSceneMouseEvent*>(event)->pos();
+ }
+
+ if (event->type() == QEvent::GraphicsSceneMouseMove) {
+ QuicklaunchIcon * icon = qobject_cast<QuicklaunchIcon*>(object);
+ if (m_icons.contains(icon)) {
+ QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent*>(event);
+ int dragDistance = (mouseEvent->pos() - m_mousePressPos).toPoint().manhattanLength();
+ if (dragDistance >= QApplication::startDragDistance()) {
+ int numberOfPreviousIcons = m_icons.count();
+ QMimeData *mimeData = new QMimeData();
+ mimeData->setData("text/uri-list", icon->url().url().toAscii());
+ mimeData->setText(mimeData->text());
+
+ QDrag *drag = new QDrag(mouseEvent->widget());
+ drag->setMimeData(mimeData);
+ drag->setPixmap(icon->icon().pixmap(m_iconSize, m_iconSize));
+
+ Qt::DropAction dropAction = drag->exec();
+
+ // If the current number of icons is more than the previous amount then
+ // it means that the icon was re-arranged and not dragged outside the applet
+ // Therefore we remove the previous icon
+ if (dropAction == Qt::MoveAction && m_icons.count() > numberOfPreviousIcons) {
+ m_icons.removeAll(icon);
+ icon->hide();
+ icon->deleteLater();
+ performUiRefactor();
+ }
+ }
+ }
+ }
+
if (event->type() == QEvent::GraphicsSceneDrop) {
- dropApp(static_cast<QGraphicsSceneDragDropEvent*>(event),true);
+ dropApp(static_cast<QGraphicsSceneDragDropEvent*>(event), object == m_dialogWidget);
return true;
}
@@ -420,8 +453,7 @@
void QuicklaunchApplet::dropEvent(QGraphicsSceneDragDropEvent *event)
{
- kDebug()<< "I am in dropEvent";
- dropApp(static_cast<QGraphicsSceneDragDropEvent*>(event),false);
+ dropApp(static_cast<QGraphicsSceneDragDropEvent*>(event),false);
}
void QuicklaunchApplet::addProgram(int index, const QString &url)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic