From 38cc55ea09a87e67128ce4c2d1624a8732a742e5 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 16 Dec 2009 22:06:24 +0000 Subject: [PATCH] - Add hover effect of labels/categories to animate drag'n drop --- src/Icons/oxygen/folder-documents.png | Bin 0 -> 409 bytes src/icons.qrc | 1 + src/transferlistfilterswidget.h | 44 ++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/Icons/oxygen/folder-documents.png diff --git a/src/Icons/oxygen/folder-documents.png b/src/Icons/oxygen/folder-documents.png new file mode 100644 index 0000000000000000000000000000000000000000..cb457a538f5ebf2db2b49ba94880fecef834a186 GIT binary patch literal 409 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf2?p zUk71ECym(^Ktah8*NBqf{Irtt#G+J&^73-M%)IR4U z`1`~#|K0lNbdD~*lHU`a%>B*cdNS`73s1rf!*kZ<6_v7o?u7s2%*|c1Q1JbuA4Lr8 zY`mX^_WrY87sWoK^~VREmn&M5B!U#$7advi;`V(ej>$}X8VO5oE@^mlO*onH*!=z5 zH+NO;cu|+Zc(Ahj{1OKaZEvy1YfM|ZOe6XPTGC8jySUtI=n!zaDroY$=S|?%4vu3r z{ulOD9=6E{6EizHD?`vt@!Qq|-F_-92b2D>K97mM^iiU>6c~&Qp00i_>zopr09%Bq Aj{pDw literal 0 HcmV?d00001 diff --git a/src/icons.qrc b/src/icons.qrc index 98a761a33..0706af43d 100644 --- a/src/icons.qrc +++ b/src/icons.qrc @@ -166,6 +166,7 @@ Icons/oxygen/network-server.png Icons/oxygen/folder.png Icons/oxygen/urlseed.png + Icons/oxygen/folder-documents.png Icons/oxygen/edit-cut.png Icons/oxygen/unsubscribe.png Icons/oxygen/feed-subscribe.png diff --git a/src/transferlistfilterswidget.h b/src/transferlistfilterswidget.h index 9bdfdae31..a7478d68e 100644 --- a/src/transferlistfilterswidget.h +++ b/src/transferlistfilterswidget.h @@ -47,8 +47,12 @@ class LabelFiltersList: public QListWidget { Q_OBJECT +private: + QListWidgetItem *itemHover; + public: - LabelFiltersList(QWidget *parent): QListWidget(parent){ + LabelFiltersList(QWidget *parent): QListWidget(parent) { + itemHover = 0; // Accept drop setAcceptDrops(true); } @@ -57,12 +61,24 @@ signals: void torrentDropped(int label_row); protected: - void dragMoveEvent(QDragMoveEvent* event) { + void dragMoveEvent(QDragMoveEvent *event) { //qDebug("filters, dragmoveevent"); if(itemAt(event->pos()) && row(itemAt(event->pos())) > 0) { //qDebug("Name: %s", itemAt(event->pos())->text().toLocal8Bit().data()); + if(itemHover) { + if(itemHover != itemAt(event->pos())) { + setItemHover(false); + itemHover = itemAt(event->pos()); + setItemHover(true); + } + } else { + itemHover = itemAt(event->pos()); + setItemHover(true); + } event->acceptProposedAction(); } else { + if(itemHover) + setItemHover(false); event->ignore(); } } @@ -73,6 +89,29 @@ protected: emit torrentDropped(row(itemAt(event->pos()))); } event->ignore(); + setItemHover(false); + // Select current item again + currentItem()->setSelected(true); + } + + void dragLeaveEvent(QDragLeaveEvent*) { + if(itemHover) + setItemHover(false); + // Select current item again + currentItem()->setSelected(true); + } + + void setItemHover(bool hover) { + Q_ASSERT(itemHover); + if(hover) { + itemHover->setData(Qt::DecorationRole, QIcon(":/Icons/oxygen/folder-documents.png")); + itemHover->setSelected(true); + //setCurrentItem(itemHover); + } else { + itemHover->setData(Qt::DecorationRole, QIcon(":/Icons/oxygen/folder.png")); + //itemHover->setSelected(false); + itemHover = 0; + } } }; @@ -144,6 +183,7 @@ public: newLabel->setData(Qt::DecorationRole, QIcon(":/Icons/oxygen/folder.png")); } labelFilters->selectionModel()->select(labelFilters->model()->index(0,0), QItemSelectionModel::Select); + labelFilters->setCurrentItem(labelFilters->item(0)); // Label menu labelFilters->setContextMenuPolicy(Qt::CustomContextMenu); connect(labelFilters, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showLabelMenu(QPoint)));