mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-26 19:26:59 +03:00
- Add hover effect of labels/categories to animate drag'n drop
This commit is contained in:
parent
5d60295db3
commit
38cc55ea09
3 changed files with 43 additions and 2 deletions
BIN
src/Icons/oxygen/folder-documents.png
Normal file
BIN
src/Icons/oxygen/folder-documents.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 409 B |
|
@ -166,6 +166,7 @@
|
|||
<file>Icons/oxygen/network-server.png</file>
|
||||
<file>Icons/oxygen/folder.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/unsubscribe.png</file>
|
||||
<file>Icons/oxygen/feed-subscribe.png</file>
|
||||
|
|
|
@ -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)));
|
||||
|
|
Loading…
Reference in a new issue