Skip to content

Commit

Permalink
fix: clear desktop selection when collection view gets focus
Browse files Browse the repository at this point in the history
- add selection clearing in CanvasView's focusOutEvent
- add selection clearing in CollectionView's focusOutEvent

log: When switching focus between desktop and collection view, clear previous selection
to avoid showing multiple highlighted items across different views.

bug: https://pms.uniontech.com/bug-view-300259.htm
  • Loading branch information
dengzhongyuan365-dev committed Jan 22, 2025
1 parent 1c22ade commit febe263
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/plugins/desktop/ddplugin-canvas/view/canvasview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ void CanvasView::focusOutEvent(QFocusEvent *event)
{
d->dodgeOper->stopDelayDodge();
d->dodgeOper->updatePrepareDodgeValue(event);

if (selectionModel())
selectionModel()->clearSelection();

QAbstractItemView::focusOutEvent(event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,14 @@ QPixmap CollectionViewPrivate::polymerizePixmap(QModelIndexList indexs) const
return pixmap;
}

void CollectionView::focusOutEvent(QFocusEvent *event)
{
if (selectionModel())
selectionModel()->clearSelection();

QAbstractItemView::focusOutEvent(event);
}

bool CollectionViewPrivate::checkClientMimeData(QDragEnterEvent *event) const
{
if (DFileDragClient::checkMimeData(event->mimeData())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ protected Q_SLOTS:
void dragLeaveEvent(QDragLeaveEvent *event) override;
void dropEvent(QDropEvent *event) override;
void focusInEvent(QFocusEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;

void scrollContentsBy(int dx, int dy) override;

Expand Down

0 comments on commit febe263

Please sign in to comment.