on xenial help sign in
MenuItemFactory: use a ButtonMenu and activate the item on button clicks
commit932f026bb86aea68da451b22404e5e1b02af1c35 authorMarco Trevisan (Treviño) <mail@3v1n0.net> dateWed 26 Oct 2016, 23:01 (10 years ago) parent3dd8231
2 files changed+4−12
qml/Panel/Indicators/MenuItemFactory.qml+3−9 tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml+1−3
qml/Panel/Indicators/MenuItemFactory.qml+3−9
@@ -1002,7 +1002,7 @@ Item {
10021002 Component {
10031003 id: buttonSectionMenu;
10041004
1005− Menus.StandardMenu {
1005+ Menus.ButtonMenu {
10061006 objectName: "buttonSectionMenu"
10071007 property QtObject menuData: null
10081008 property var menuModel: menuFactory.menuModel
@@ -1014,6 +1014,7 @@ Item {
10141014 highlightWhenPressed: false
10151015 text: menuData && menuData.label || ""
10161016 foregroundColor: theme.palette.normal.backgroundText
1017+ buttonText: getExtendedProperty(extendedData, "xCanonicalExtraLabel", "")
10171018
10181019 onMenuModelChanged: {
10191020 loadAttributes();
@@ -1026,14 +1027,7 @@ Item {
10261027 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-extra-label': 'string'});
10271028 }
10281029
1029− slots: Button {
1030− objectName: "buttonSectionMenuControl"
1031− text: getExtendedProperty(extendedData, "xCanonicalExtraLabel", "")
1032−
1033− onClicked: {
1034− menuModel.activate(menuIndex);
1035− }
1036− }
1030+ onButtonClicked: menuModel.activate(menuIndex);
10371031 }
10381032 }
10391033
tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml+1−3
@@ -556,9 +556,7 @@ Item {
556556 compare(loader.item.iconSource, data.icon, "Icon does not match data");
557557 compare(loader.item.enabled, data.enabled, "Enabled does not match data");
558558
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");
562560 }
563561
564562 function test_create_wifiSection_data() {