Browse Source

- Add hover effect of labels/categories to animate drag'n drop

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
38cc55ea09
  1. BIN
      src/Icons/oxygen/folder-documents.png
  2. 1
      src/icons.qrc
  3. 44
      src/transferlistfilterswidget.h

BIN
src/Icons/oxygen/folder-documents.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 409 B

1
src/icons.qrc

@ -166,6 +166,7 @@
<file>Icons/oxygen/network-server.png</file> <file>Icons/oxygen/network-server.png</file>
<file>Icons/oxygen/folder.png</file> <file>Icons/oxygen/folder.png</file>
<file>Icons/oxygen/urlseed.png</file> <file>Icons/oxygen/urlseed.png</file>
<file>Icons/oxygen/folder-documents.png</file>
<file>Icons/oxygen/edit-cut.png</file> <file>Icons/oxygen/edit-cut.png</file>
<file>Icons/oxygen/unsubscribe.png</file> <file>Icons/oxygen/unsubscribe.png</file>
<file>Icons/oxygen/feed-subscribe.png</file> <file>Icons/oxygen/feed-subscribe.png</file>

44
src/transferlistfilterswidget.h

@ -47,8 +47,12 @@
class LabelFiltersList: public QListWidget { class LabelFiltersList: public QListWidget {
Q_OBJECT Q_OBJECT
private:
QListWidgetItem *itemHover;
public: public:
LabelFiltersList(QWidget *parent): QListWidget(parent){ LabelFiltersList(QWidget *parent): QListWidget(parent) {
itemHover = 0;
// Accept drop // Accept drop
setAcceptDrops(true); setAcceptDrops(true);
} }
@ -57,12 +61,24 @@ signals:
void torrentDropped(int label_row); void torrentDropped(int label_row);
protected: protected:
void dragMoveEvent(QDragMoveEvent* event) { void dragMoveEvent(QDragMoveEvent *event) {
//qDebug("filters, dragmoveevent"); //qDebug("filters, dragmoveevent");
if(itemAt(event->pos()) && row(itemAt(event->pos())) > 0) { if(itemAt(event->pos()) && row(itemAt(event->pos())) > 0) {
//qDebug("Name: %s", itemAt(event->pos())->text().toLocal8Bit().data()); //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(); event->acceptProposedAction();
} else { } else {
if(itemHover)
setItemHover(false);
event->ignore(); event->ignore();
} }
} }
@ -73,6 +89,29 @@ protected:
emit torrentDropped(row(itemAt(event->pos()))); emit torrentDropped(row(itemAt(event->pos())));
} }
event->ignore(); 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")); newLabel->setData(Qt::DecorationRole, QIcon(":/Icons/oxygen/folder.png"));
} }
labelFilters->selectionModel()->select(labelFilters->model()->index(0,0), QItemSelectionModel::Select); labelFilters->selectionModel()->select(labelFilters->model()->index(0,0), QItemSelectionModel::Select);
labelFilters->setCurrentItem(labelFilters->item(0));
// Label menu // Label menu
labelFilters->setContextMenuPolicy(Qt::CustomContextMenu); labelFilters->setContextMenuPolicy(Qt::CustomContextMenu);
connect(labelFilters, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showLabelMenu(QPoint))); connect(labelFilters, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showLabelMenu(QPoint)));

Loading…
Cancel
Save