Skip to content

Commit

Permalink
fix: [menu]view mode menu issue
Browse files Browse the repository at this point in the history
add tree view mode action in empty area menu.

Log: fix menu issue
Bug: https://pms.uniontech.com/bug-view-239753.html
  • Loading branch information
Lighto-Ku authored and max-lvs committed Jan 15, 2024
1 parent b04954b commit 31baa4e
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <dfm-base/dfm_menu_defines.h>
#include <dfm-base/dfm_global_defines.h>
#include <dfm-base/dfm_event_defines.h>
#include <dfm-base/base/configs/dconfig/dconfigmanager.h>

#include <dfm-framework/dpf.h>

Expand Down Expand Up @@ -39,6 +40,7 @@ SortAndDisplayMenuScene::SortAndDisplayMenuScene(QObject *parent)
// 显示子菜单
d->predicateName[ActionID::kDisplayIcon] = tr("Icon");
d->predicateName[ActionID::kDisplayList] = tr("List");
d->predicateName[ActionID::kDisplayTree] = tr("Tree");
}

SortAndDisplayMenuScene::~SortAndDisplayMenuScene()
Expand Down Expand Up @@ -103,6 +105,12 @@ bool SortAndDisplayMenuScene::triggered(QAction *action)
dpfSignalDispatcher->publish(DFMBASE_NAMESPACE::kSwitchViewMode, d->windowId, int(Global::ViewMode::kListMode));
return true;
}

// display as tree
if (actionId == ActionID::kDisplayTree) {
dpfSignalDispatcher->publish(DFMBASE_NAMESPACE::kSwitchViewMode, d->windowId, int(Global::ViewMode::kTreeMode));
return true;
}
}

// sort by
Expand Down Expand Up @@ -197,6 +205,13 @@ QMenu *SortAndDisplayMenuScenePrivate::addDisplayAsActions(QMenu *menu)
predicateAction[ActionID::kDisplayList] = tempAction;
tempAction->setProperty(ActionPropertyKey::kActionID, QString(ActionID::kDisplayList));

if (DConfigManager::instance()->value(kViewDConfName, kTreeViewEnable, true).toBool()) {
tempAction = subMenu->addAction(predicateName.value(ActionID::kDisplayTree));
tempAction->setCheckable(true);
predicateAction[ActionID::kDisplayTree] = tempAction;
tempAction->setProperty(ActionPropertyKey::kActionID, QString(ActionID::kDisplayTree));
}

return subMenu;
}

Expand Down Expand Up @@ -239,6 +254,9 @@ void SortAndDisplayMenuScenePrivate::updateEmptyAreaActionState()
case Global::ViewMode::kListMode:
predicateAction[ActionID::kDisplayList]->setChecked(true);
break;
case Global::ViewMode::kTreeMode:
predicateAction[ActionID::kDisplayTree]->setChecked(true);
break;
default:
break;
}
Expand Down

0 comments on commit 31baa4e

Please sign in to comment.