1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-10 21:18:19 +03:00

context:add actions in context menu dynamically

This commit is contained in:
Michail Vourlakos 2021-06-10 09:04:56 +03:00
parent 496b86e796
commit a7e8cf4542
2 changed files with 17 additions and 11 deletions

View File

@ -27,6 +27,16 @@ static const char QUITLATTEACTION[] = "_quit_latte";
static const char SECTIONACTION[]= "_latte_section";
static const char SEPARATOR1ACTION[] = "_separator1";
static QStringList ACTIONSEDITORDER = {LAYOUTSACTION,
PREFERENCESACTION,
QUITLATTEACTION,
SEPARATOR1ACTION,
ADDWIDGETSACTION,
ADDVIEWACTION,
MOVEVIEWACTION,
EXPORTVIEWTEMPLATEACTION,
REMOVEVIEWACTION};
static QStringList ACTIONSALWAYSVISIBLE = {LAYOUTSACTION,
PREFERENCESACTION,
QUITLATTEACTION,

View File

@ -217,18 +217,11 @@ QList<QAction *> Menu::contextualActions()
QList<QAction *> actions;
actions << m_actions[Latte::Data::ContextMenu::SECTIONACTION];
//actions << m_actions[Latte::Data::ContextMenu::PRINTACTION];
actions << m_actions[Latte::Data::ContextMenu::LAYOUTSACTION];
actions << m_actions[Latte::Data::ContextMenu::PREFERENCESACTION];
actions << m_actions[Latte::Data::ContextMenu::QUITLATTEACTION];
actions << m_actions[Latte::Data::ContextMenu::SEPARATOR1ACTION];
actions << m_actions[Latte::Data::ContextMenu::ADDWIDGETSACTION];
actions << m_actions[Latte::Data::ContextMenu::ADDVIEWACTION];
actions << m_actions[Latte::Data::ContextMenu::MOVEVIEWACTION];
actions << m_actions[Latte::Data::ContextMenu::EXPORTVIEWTEMPLATEACTION];
actions << m_actions[Latte::Data::ContextMenu::PRINTACTION];
for(int i=0; i<Latte::Data::ContextMenu::ACTIONSEDITORDER.count(); ++i) {
actions << m_actions[Latte::Data::ContextMenu::ACTIONSEDITORDER[i]];
}
actions << m_actions[Latte::Data::ContextMenu::EDITVIEWACTION];
actions << m_actions[Latte::Data::ContextMenu::REMOVEVIEWACTION];
m_data.clear();
m_viewTemplates.clear();
@ -289,6 +282,9 @@ void Menu::updateVisibleActions()
for(auto actionName: m_actions.keys()) {
if (Latte::Data::ContextMenu::ACTIONSSPECIAL.contains(actionName)) {
continue;
} else if (Latte::Data::ContextMenu::ACTIONSALWAYSHIDDEN.contains(actionName)) {
m_actions[actionName]->setVisible(false);
continue;
}
bool isvisible = m_actionsAlwaysShown.contains(actionName) || configuring;