context:add actions in context menu dynamically

pull/22/head
Michail Vourlakos 4 years ago
parent 496b86e796
commit a7e8cf4542

@ -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,

@ -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;

Loading…
Cancel
Save