Skip to content

Commit

Permalink
fix: Batch renaming, "Renaming" option, shortcut key Enter not effective
Browse files Browse the repository at this point in the history
Add the enter key to renameBar for processing

Log: Batch renaming, "Renaming" option, shortcut key Enter not effective
Bug: https://pms.uniontech.com/bug-view-260431.html
  • Loading branch information
liyigang1 committed Jun 25, 2024
1 parent f3cb44b commit 3b827af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <QPushButton>
#include <QLineEdit>
#include <QStackedWidget>
#include <QApplication>
#include <QKeyEvent>

DFMBASE_USE_NAMESPACE
using namespace dfmplugin_workspace;
Expand Down Expand Up @@ -265,6 +267,8 @@ void RenameBar::hideRenameBar()
{
setVisible(false);
reset();
if (parentWidget())
parentWidget()->setFocus();
}

void RenameBar::initConnect()
Expand Down Expand Up @@ -302,3 +306,17 @@ QList<QUrl> RenameBar::getSelectFiles()

return {};
}


void dfmplugin_workspace::RenameBar::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
if (qApp->focusObject() == d->renameBtn
&& d->renameBtn->focusPolicy() == Qt::FocusPolicy::TabFocus)
emit clickRenameButton();
if (qApp->focusObject() == std::get<0>(d->buttonsArea)
&& std::get<0>(d->buttonsArea)->focusPolicy() == Qt::FocusPolicy::TabFocus)
emit clickCancelButton();
}
return QFrame::keyPressEvent(event);
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ private slots:
private:
QSharedPointer<RenameBarPrivate> d { nullptr };
Q_DECLARE_PRIVATE_D(d, RenameBar)

// QWidget interface
protected:
void keyPressEvent(QKeyEvent *event);
};

}
Expand Down

0 comments on commit 3b827af

Please sign in to comment.