Commit 3413d873 authored by Xuetian Weng's avatar Xuetian Weng
Browse files

kimpanel: use visualParent to correctly position the popup menu

parent d28deb6f
......@@ -1233,7 +1233,7 @@ ibus_panel_impanel_update_lookup_table (IBusPanelService *panel,
gint orientation = ibus_lookup_table_get_orientation(lookup_table);
if (orientation == IBUS_ORIENTATION_HORIZONTAL) {
orientation = 2;
orientation = 2;
} else if (orientation == IBUS_ORIENTATION_VERTICAL) {
orientation = 1;
} else {
......
......@@ -20,7 +20,9 @@
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.plasmoid 2.0
Item {
id: root
......@@ -33,8 +35,8 @@ Item {
onActionListChanged: refreshMenu();
function open(x, y) {
menu.open();
function open() {
menu.openRelative();
}
function refreshMenu() {
......@@ -66,6 +68,18 @@ Item {
PlasmaComponents.ContextMenu {
visualParent: root.visualParent
placement: {
if (plasmoid.location == PlasmaCore.Types.LeftEdge) {
return PlasmaCore.Types.RightPosedTopAlignedPopup;
} else if (plasmoid.location == PlasmaCore.Types.TopEdge) {
return PlasmaCore.Types.BottomPosedLeftAlignedPopup;
} else if (plasmoid.location == PlasmaCore.Types.RightEdge) {
return PlasmaCore.Types.LeftPosedTopAlignedPopup;
} else {
return PlasmaCore.Types.TopPosedLeftAlignedPopup;
}
}
}
}
......
......@@ -20,7 +20,9 @@
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.plasmoid 2.0
Item {
id: root
......@@ -32,7 +34,7 @@ Item {
function open(item, actionItem) {
visualParent = item;
refreshMenu(actionItem);
menu.open();
menu.openRelative();
}
function refreshMenu(actionItem) {
......@@ -76,6 +78,18 @@ Item {
property Item separator: separatorItem
property QtObject showMenu: subShowMenu
placement: {
if (plasmoid.location == PlasmaCore.Types.LeftEdge) {
return PlasmaCore.Types.RightPosedTopAlignedPopup;
} else if (plasmoid.location == PlasmaCore.Types.TopEdge) {
return PlasmaCore.Types.BottomPosedLeftAlignedPopup;
} else if (plasmoid.location == PlasmaCore.Types.RightEdge) {
return PlasmaCore.Types.LeftPosedTopAlignedPopup;
} else {
return PlasmaCore.Types.TopPosedLeftAlignedPopup;
}
}
PlasmaComponents.MenuItem {
id: showItem
visible: separatorItem.visible
......
......@@ -70,7 +70,10 @@ Item {
hint: model.hint
onTriggered : {
if (button == Qt.LeftButton) {
clickHandler(model.key)
clickHandler(model.key);
// clickHandler will trigger the menu, but we have to wait for
// the menu data. So we have to set the visual parent ahead.
actionMenu.visualParent = statusIcon;
} else {
contextMenu.open(statusIcon, {key: model.key, label: model.label});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment