Skip to content

Commit

Permalink
fix: When batch modifying file names, deselecting the file will resul…
Browse files Browse the repository at this point in the history
…t in renaming failure

When the selected file is empty, cancel renamba

Log: When batch modifying file names, deselecting the file will result in renaming failure
Bug: https://pms.uniontech.com/bug-view-259905.html
  • Loading branch information
liyigang1 committed Jun 25, 2024
1 parent 10f3f51 commit 5017b6d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,8 @@ void FileView::onSelectionChanged(const QItemSelection &selected, const QItemSel
{
delayUpdateStatusBar();

emit selectUrlChanged(selectedUrlList());

quint64 winId = WorkspaceHelper::instance()->windowId(this);
WorkspaceEventCaller::sendViewSelectionChanged(winId, selected, deselected);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public slots:
Q_SIGNALS:
void reqOpenNewWindow(const QList<QUrl> &urls);
void viewStateChanged();
void selectUrlChanged(const QList<QUrl> &urls);

private slots:
void loadViewState(const QUrl &url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class RenameBarPrivate : public QObject
DTuple<QPushButton *, QPushButton *, QHBoxLayout *, QFrame *> buttonsArea {};

DSuggestButton *renameBtn { nullptr };
bool connectInitOnce { false };

public slots:
void onRenamePatternChanged(const int &index) noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@ void RenameBar::storeUrlList(const QList<QUrl> &list) noexcept
d->urlList = list;
}

void RenameBar::setVisible(bool visible)
{
Q_D(RenameBar);
if (!d->connectInitOnce) {
auto widget = qobject_cast<WorkspaceWidget *>(parentWidget());
if (widget) {
auto view = dynamic_cast<FileView *>(widget->currentView());
if (view)
{
d->connectInitOnce = true;
QObject::connect(view, &FileView::selectUrlChanged, this, &RenameBar::onSelectUrlChanged);
}
}
}
return QFrame::setVisible(visible);
}

void RenameBar::onVisibleChanged(bool value) noexcept
{
Q_D(RenameBar);
Expand Down Expand Up @@ -271,6 +288,15 @@ void RenameBar::hideRenameBar()
parentWidget()->setFocus();
}

void RenameBar::onSelectUrlChanged(const QList<QUrl> &urls)
{
if (!isVisible())
return;

if (urls.isEmpty())
emit clickCancelButton();
}

void RenameBar::initConnect()
{
Q_D(RenameBar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class RenameBar : public QFrame

void storeUrlList(const QList<QUrl> &list) noexcept;

public Q_SLOTS:
void setVisible(bool visible) override;

signals:
void requestReplaceOperator();
void clickCancelButton();
Expand All @@ -43,6 +46,7 @@ private slots:
void onCustomOperatorSNNumberChanged();
void eventDispatcher();
void hideRenameBar();
void onSelectUrlChanged(const QList<QUrl> &urls);

// QWidget interface
protected:
Expand Down

0 comments on commit 5017b6d

Please sign in to comment.