improve menu behavior and appearance

pull/1/head
Michail Vourlakos 8 years ago
parent 83e0a7564a
commit f4201a8a71

@ -81,8 +81,12 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen)
QAction *lockWidgetsAction = containment()->actions()->action("lock widgets");
containment()->actions()->removeAction(lockWidgetsAction);
//FIX: hide and not delete in order to disable a nasty behavior from
//ContainmentInterface. If only one action exists for containment the
//this action is triggered directly
QAction *addWidgetsAction = containment()->actions()->action("add widgets");
containment()->actions()->removeAction(addWidgetsAction);
addWidgetsAction->setVisible(false);
//containment()->actions()->removeAction(addWidgetsAction);
}, Qt::DirectConnection);
}

@ -607,6 +607,27 @@ PlasmaComponents.ContextMenu {
Component.onCompleted: configureAction = plasmoid.action("configure")
}
PlasmaComponents.MenuItem {
separator: true
}
PlasmaComponents.MenuItem {
id: closeWindowItem
visible: (visualParent && visualParent.m.IsLauncher !== true && visualParent.m.IsStartup !== true)
enabled: visualParent && visualParent.m.IsClosable === true
text: i18n("Close")
icon: "window-close"
onClicked: tasksModel.requestClose(visualParent.modelIndex())
}
PlasmaComponents.MenuItem {
separator: true
}
PlasmaComponents.MenuItem {
id: containmentMenuItem
@ -626,16 +647,32 @@ PlasmaComponents.ContextMenu {
var actionList = nowDockPanel.containmentActions();
if (actionList.length > 1) {
var visibleActions=0;
for (var i=0; i<actionList.length; ++i){
console.log(i);
if (actionList[i].visible) {
visibleActions++;
}
}
if (visibleActions > 1) {
for (var i=0; i<actionList.length; ++i){
var item = menu.newMenuItem(containmentSubMenu);
item.visible = false;
item.action = actionList[i];
containmentSubMenu.addMenuItem(item,containmentMenuItem);
}
} else if (actionList.length === 1){
var item = menu.newMenuItem(menu);
item.action = actionList[0];
} else if (visibleActions === 1){
for (var i=0; i<actionList.length; ++i){
if (actionList[i].visible){
var item = menu.newMenuItem(menu);
item.action = actionList[i];
}
}
}
if (visibleActions <= 1) {
containmentMenuItem.visible = false;
}
}
@ -644,20 +681,5 @@ PlasmaComponents.ContextMenu {
}
}
PlasmaComponents.MenuItem {
separator: true
}
PlasmaComponents.MenuItem {
id: closeWindowItem
visible: (visualParent && visualParent.m.IsLauncher !== true && visualParent.m.IsStartup !== true)
enabled: visualParent && visualParent.m.IsClosable === true
text: i18n("Close")
icon: "window-close"
onClicked: tasksModel.requestClose(visualParent.modelIndex())
}
}

Loading…
Cancel
Save