Skip to content

Commit

Permalink
refactor: optimize hidden files toggle logic
Browse files Browse the repository at this point in the history
1. Refactor toggleHiddenFiles() implementation to use Application generic attribute
2. Remove redundant view operations when toggling hidden files
3. Fix code format for case statements

Log: The changes simplify the hidden files toggle mechanism by directly operating on
the Application level attribute instead of manipulating view components. This
provides a more maintainable and cleaner approach.
  • Loading branch information
Johnson-zs committed Dec 13, 2024
1 parent ae541d8 commit 4a3b094
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void ShortcutHelper::initRenameProcessTimer()
renameProcessTimer->setSingleShot(true);
renameProcessTimer->setInterval(500);

connect(renameProcessTimer, &QTimer::timeout, this, [ = ]{
connect(renameProcessTimer, &QTimer::timeout, this, [=] {
if (enterTriggerFlag) {
enterTriggerFlag = false;

Expand Down Expand Up @@ -177,13 +177,11 @@ bool ShortcutHelper::processKeyPressEvent(QKeyEvent *event)
openAction(view->selectedUrlList());
return true;
}
case Qt::Key_D:
{
case Qt::Key_D: {
moveToTrash();
return true;
}
case Qt::Key_Y:
{
case Qt::Key_Y: {
// redo
redoFiles();
return true;
Expand Down Expand Up @@ -332,12 +330,8 @@ void ShortcutHelper::touchFolder()

void ShortcutHelper::toggleHiddenFiles()
{
// Todo(yanghao)
// Todo(yanghao): preSelectionUrls
// d->preSelectionUrls = urls;
view->itemDelegate()->hideAllIIndexWidget();
view->clearSelection();
view->model()->toggleHiddenFiles();
bool isShowedHiddenFiles = Application::instance()->genericAttribute(Application::kShowedHiddenFiles).toBool();
Application::instance()->setGenericAttribute(Application::kShowedHiddenFiles, !isShowedHiddenFiles);
}

void ShortcutHelper::showFilesProperty()
Expand Down

0 comments on commit 4a3b094

Please sign in to comment.