on xenial help sign in
MenuItemFactory: use a ButtonMenu and activate the item on button clicks
932f026Marco Trevisan (Treviño)
qml/Panel/Indicators/MenuItemFactory.qml+3−9
@@ -1002,7 +1002,7 @@ Item {
1002 Component {
1002 Component {
1003 id: buttonSectionMenu;
1003 id: buttonSectionMenu;
1004
1004
1005− Menus.StandardMenu {
1005+ Menus.ButtonMenu {
1006 objectName: "buttonSectionMenu"
1006 objectName: "buttonSectionMenu"
1007 property QtObject menuData: null
1007 property QtObject menuData: null
1008 property var menuModel: menuFactory.menuModel
1008 property var menuModel: menuFactory.menuModel
@@ -1014,6 +1014,7 @@ Item {
1014 highlightWhenPressed: false
1014 highlightWhenPressed: false
1015 text: menuData && menuData.label || ""
1015 text: menuData && menuData.label || ""
1016 foregroundColor: theme.palette.normal.backgroundText
1016 foregroundColor: theme.palette.normal.backgroundText
1017+ buttonText: getExtendedProperty(extendedData, "xCanonicalExtraLabel", "")
1017
1018
1018 onMenuModelChanged: {
1019 onMenuModelChanged: {
1019 loadAttributes();
1020 loadAttributes();
@@ -1026,14 +1027,7 @@ Item {
1026 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-extra-label': 'string'});
1027 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-extra-label': 'string'});
1027 }
1028 }
1028
1029
1029− slots: Button {
1030− objectName: "buttonSectionMenuControl"
1031− text: getExtendedProperty(extendedData, "xCanonicalExtraLabel", "")
1032−
1033− onClicked: {
1034− menuModel.activate(menuIndex);
1030+ onButtonClicked: menuModel.activate(menuIndex);
1035− }
1036− }
1037 }
1031 }
1038 }
1032 }
1039
1033
tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml+1−3
@@ -556,9 +556,7 @@ Item {
556 compare(loader.item.iconSource, data.icon, "Icon does not match data");
556 compare(loader.item.iconSource, data.icon, "Icon does not match data");
557 compare(loader.item.enabled, data.enabled, "Enabled does not match data");
557 compare(loader.item.enabled, data.enabled, "Enabled does not match data");
558
558
559− var button = findChild(loader.item, "buttonSectionMenuControl");
560− verify(button !== null);
561− compare(button.text, data.buttonText, "Button text does not match data");
559+ compare(loader.item.buttonText, data.buttonText, "Button text does not match data");
562 }
560 }
563
561
564 function test_create_wifiSection_data() {
562 function test_create_wifiSection_data() {