Commit 9ca92183 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Make it possible to support exclusive action groups

Summary:
We need to find away to import 2.3 if available otherwise modelData.Controls.ActionGroup returns null.

CCBUG: 391144

Reviewers: #kirigami, mart

Reviewed By: #kirigami, mart

Subscribers: mart, plasma-devel

Tags: #kirigami

Differential Revision: https://phabricator.kde.org/D10892
parent a3fdaf43
......@@ -64,6 +64,13 @@ if (NOT STATIC_LIBRARY)
add_dependencies(kirigamiplugin copy)
install(DIRECTORY controls/ DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/kirigami.2)
if(Qt5Qml_VERSION VERSION_GREATER 5.10)
install(FILES controls/private/ActionMenuItemQt510.qml DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/kirigami.2/private
RENAME ActionMenuItem.qml)
else()
install(FILES controls/private/ActionMenuItemQt59.qml DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/kirigami.2/private
RENAME ActionMenuItem.qml)
endif()
if (PLASMA_ENABLED)
install(DIRECTORY styles/Plasma DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/kirigami.2/styles)
......
/*
* Copyright 2018 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.3
import QtQuick.Controls 2.1 as Controls
Controls.MenuItem {
id: menuItem
property QtObject ourAction
text: ourAction.text
visible: ourAction.visible
enabled: ourAction.enabled
checkable: ourAction.checkable
checked: ourAction.checked
onTriggered: {
ourAction.trigger()
}
readonly property var ourMenu: theMenu.submenuComponent ? theMenu.submenuComponent.createObject(menuItem, { actions: ourAction.children }) : null
}
/*
* Copyright 2018 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.3
import QtQuick.Controls 2.3 as Controls
ActionMenuItemBase
{
icon.name: ourAction.iconName
autoExclusive: ourAction.Controls.ActionGroup && ourAction.Controls.ActionGroup.group.exclusive
}
/*
* Copyright 2018 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
ActionMenuItemBase
{
}
......@@ -18,7 +18,7 @@
*/
import QtQuick 2.3
import QtQuick.Controls 2.0 as Controls
import QtQuick.Controls 2.1 as Controls
Controls.Menu
{
......@@ -29,20 +29,8 @@ Controls.Menu
Repeater {
id: actionsRepeater
delegate: Controls.MenuItem {
id: menuItem
text: model.text
// TODO: enable when we depend on Qt 5.10
// icon.name: model.iconName
visible: model.visible
enabled: modelData.enabled
checkable: modelData.checkable
checked: modelData.checked
onTriggered: {
modelData.trigger()
}
readonly property var ourMenu: theMenu.submenuComponent ? theMenu.submenuComponent.createObject(menuItem, { actions: modelData.children }) : null
delegate: ActionMenuItem {
ourAction: modelData
}
}
}
......@@ -19,7 +19,7 @@
*/
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Controls 2.3 as QQC2
import org.kde.kirigami 2.2 as Kirigami
Kirigami.ApplicationWindow
......@@ -29,27 +29,30 @@ Kirigami.ApplicationWindow
header: Kirigami.ToolBarApplicationHeader {}
pageStack.initialPage: Kirigami.Page {
Button {
QQC2.Button {
text: "button"
onClicked: menu.popup()
Menu {
QQC2.Menu {
id: menu
MenuItem { text: "xxx" }
MenuItem { text: "xxx" }
MenuItem {
QQC2.MenuItem { text: "xxx" }
QQC2.MenuItem { text: "xxx" }
QQC2.MenuItem {
text: "yyy"
Menu {
MenuItem { text: "yyy" }
QQC2.Menu {
QQC2.MenuItem { text: "yyy" }
}
}
}
}
QQC2.ActionGroup {
id: group
}
contextualActions: [
Kirigami.Action {
text: "fua"
text: "submenus"
icon.name: "kalgebra"
Kirigami.Action { text: "xxx"; onTriggered: console.log("xxx") }
......@@ -62,6 +65,28 @@ Kirigami.ApplicationWindow
Kirigami.Action { text: "yyy" }
Kirigami.Action { text: "yyy" }
}
},
Kirigami.Action {
id: optionsAction
text: "Options"
icon.name: "kate"
Kirigami.Action {
QQC2.ActionGroup.group: group
text: "A"
checkable: true
checked: true
}
Kirigami.Action {
QQC2.ActionGroup.group: group
text: "B"
checkable: true
}
Kirigami.Action {
QQC2.ActionGroup.group: group
text: "C"
checkable: true
}
}
]
}
......
Supports Markdown
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