diff --git a/components/mobilecomponents/ActionGroup.qml b/components/mobilecomponents/ActionGroup.qml new file mode 100644 --- /dev/null +++ b/components/mobilecomponents/ActionGroup.qml @@ -0,0 +1,27 @@ +/* + * Copycontext 2015 Marco Martin + * + * 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.1 +import QtQuick.Controls 1.3 + +Action { + id: root + default property alias children: root.__children + property list __children +} diff --git a/components/mobilecomponents/ApplicationWindow.qml b/components/mobilecomponents/ApplicationWindow.qml new file mode 100644 --- /dev/null +++ b/components/mobilecomponents/ApplicationWindow.qml @@ -0,0 +1,57 @@ +/* + * Copycontext 2015 Marco Martin + * + * 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.1 +import QtQuick.Controls 1.3 +import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.mobilecomponents 0.2 +import org.kde.kquickcontrolsaddons 2.0 +import org.kde.plasma.extras 2.0 as PlasmaExtras + +/** + * A window that provides some basic features needed for all apps + * + * It's usually used as a root QML component for the application. + * It's based around the PageRow component, the application will be + * about pages adding and removal. + */ +ApplicationWindow { + id: root + + /** + * The first page that will be loaded when the application starts + */ + property alias initialPage: __pageStack.initialPage + + /** + * The stack used to allocate the pages nd to manage the transitions + * between them. + * It's using a PageRow, while having the same aPI as PageStack, + * it positions the pages as adjacent columns, with as many columns + * as can fit in the screen. An handheld device would usually have a single + * fullscreen column, a tablet device would have many tiled columns. + */ + property alias pageStack: __pageStack + + PlasmaExtras.PageRow { + id: __pageStack + anchors.fill: parent + } + +} diff --git a/components/mobilecomponents/CMakeLists.txt b/components/mobilecomponents/CMakeLists.txt --- a/components/mobilecomponents/CMakeLists.txt +++ b/components/mobilecomponents/CMakeLists.txt @@ -13,9 +13,6 @@ install(TARGETS mobilecomponentsplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/mobilecomponents) -install(FILES IconGrid.qml DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/mobilecomponents) -install(FILES OverlayDrawer.qml DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/mobilecomponents) -install(FILES SplitDrawer.qml DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/mobilecomponents) +install(DIRECTORY ${PROJECT_SOURCE_DIR} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/mobilecomponents) -install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/mobilecomponents) diff --git a/components/mobilecomponents/ContextDrawer.qml b/components/mobilecomponents/ContextDrawer.qml new file mode 100644 --- /dev/null +++ b/components/mobilecomponents/ContextDrawer.qml @@ -0,0 +1,97 @@ +/* + * Copyright 2015 Marco Martin + * + * 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.1 +import QtQuick.Controls 1.0 as QtControls +import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.extras 2.0 as PlasmaExtras +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.kquickcontrolsaddons 2.0 +import org.kde.plasma.mobilecomponents 0.2 as MobileComponents + +MobileComponents.OverlayDrawer { + id: root + + property string title + + //This can be any type of object that a ListView can accept as model. It expects items compatible with either QAction or QQC Action + property alias actions: internalActions.data + + Item { + id: internalActions + } + + drawer: QtControls.ScrollView { + + ListView { + id: menu + model: { + if (root.actions.length == 0) { + return null; + } else { + return root.actions[0].text !== undefined && + root.actions[0].trigger !== undefined ? + root.actions : + root.actions[0]; + } + } + header: Item { + height: heading.height + PlasmaExtras.Heading { + id: heading + anchors { + left: parent.left + right: parent.right + margins: units.largeSpacing + } + elide: Text.ElideRight + level: 2 + text: root.title + } + } + delegate: PlasmaComponents.ListItem { + enabled: true + Row { + anchors { + left: parent.left + margins: units.largeSpacing + } + PlasmaCore.IconItem { + height: parent.height + width: height + source: modelData.iconName + } + PlasmaComponents.Label { + text: model ? model.text : modelData.text + } + } + onClicked: { + if (modelData && modelData.trigger !== undefined) { + modelData.trigger(); + // assume the model is a list of QAction or Action + } else if (menu.model.length > index) { + menu.model[index].trigger(); + } else { + console.warning("Don't know how to trigger the action") + } + } + } + } + } +} diff --git a/components/mobilecomponents/GlobalDrawer.qml b/components/mobilecomponents/GlobalDrawer.qml new file mode 100644 --- /dev/null +++ b/components/mobilecomponents/GlobalDrawer.qml @@ -0,0 +1,140 @@ +/* + * Copyright 2015 Marco Martin + * + * 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.1 +import QtQuick.Controls 1.0 +import QtQuick.Layouts 1.3 +import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.extras 2.0 as PlasmaExtras +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.kquickcontrolsaddons 2.0 +import org.kde.plasma.mobilecomponents 0.2 as MobileComponents + +MobileComponents.OverlayDrawer { + id: root + inverse: true + + property alias content: mainContent.data + + property alias title: heading.text + property alias titleIcon: headingIcon.source + property list actions + + drawer: ColumnLayout { + id: mainColumn + anchors.fill: parent + implicitWidth: units.gridUnit * 12 + + RowLayout { + Layout.fillWidth: true + anchors { + left: parent.left + } + PlasmaCore.IconItem { + id: headingIcon + height: parent.height + width: height + Layout.minimumWidth: height + } + PlasmaExtras.Heading { + id: heading + level: 1 + } + Item { + height: parent.height + Layout.minimumWidth: height + } + } + + PlasmaExtras.PageRow { + id: pageRow + Layout.fillWidth: true + Layout.fillHeight: true + initialPage: menuComponent + } + + ColumnLayout { + id: mainContent + Layout.fillWidth: true + Layout.fillHeight: true + } + Component { + id: menuComponent + ListView { + id: optionMenu + + model: actions + property int level: 0 + + footer: PlasmaComponents.ListItem { + visible: level > 0 + enabled: true + RowLayout { + anchors { + left: parent.left + } + PlasmaCore.IconItem { + Layout.maximumWidth: height + Layout.fillHeight: true + source: "go-previous" + } + PlasmaComponents.Label { + text: i18n("Back") + } + } + onClicked: pageRow.scrollToLevel(level - 1) + } + delegate: PlasmaComponents.ListItem { + enabled: true + RowLayout { + anchors { + left: parent.left + right: parent.right + } + PlasmaCore.IconItem { + Layout.maximumWidth: height + Layout.fillHeight: true + source: modelData.iconName + } + PlasmaComponents.Label { + Layout.fillWidth: true + text: modelData.text + } + PlasmaCore.IconItem { + Layout.maximumWidth: height + Layout.fillHeight: true + source: "go-next" + visible: modelData.children != undefined + } + } + onClicked: { + if (modelData.children) { + pageRow.pop(optionMenu); + pageRow.push(menuComponent, {"model": modelData.children, "level": level + 1}); + } else { + modelData.trigger(); + pageRow.pop(pageRow.initialPage); + } + } + } + } + } + } +} + diff --git a/components/mobilecomponents/Page.qml b/components/mobilecomponents/Page.qml new file mode 100644 --- /dev/null +++ b/components/mobilecomponents/Page.qml @@ -0,0 +1,122 @@ +/* + * Copyright 2015 Marco Martin + * + * 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.1 +import QtQuick.Layouts 1.3 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents + +Item { + id: root + + /** + * type:PageStack + * The page stack that this page is owned by. + */ + property Item pageStack + + /** + * Defines the toolbar contents for the page. If the page stack is set up + * using a toolbar instance, it automatically shows the currently active + * page's toolbar contents in the toolbar. + * + * The default value is null resulting in the page's toolbar to be + * invisible when the page is active. + */ + property Item tools: null + + /** + * Defines the actions for the page: at most 4 buttons will + * contain the actions at the bottom of the page, if the main + * item of the page is a Flickable or a ScrllArea, it will + * control the visibility of the actions. + */ + property alias actions: internalActions.data + + Item { + id: internalActions + } + + RowLayout { + id: internalButtons + z:99 + anchors.horizontalCenter: parent.horizontalCenter + Layout.fillWidth: false + height: units.iconSizes.large + property Item flickable: { + if (root.children[root.children.length-1]) { + if (root.children[root.children.length-1].contentY) { + return root.children[root.children.length-1]; + } else if (root.children[root.children.length-1].flickableItem) { + return root.children[root.children.length-1].flickableItem; + } + } + return null; + } + Connections { + target: internalButtons.flickable + property real oldContentY: internalButtons.flickable.contentY + onContentYChanged: { + if (internalButtons.flickable.atYBeginning || internalButtons.flickable.atYEnd) { + return; + } + internalButtons.y = Math.max(internalButtons.flickable.height - internalButtons.height, Math.min(internalButtons.flickable.height, internalButtons.y + internalButtons.flickable.contentY - oldContentY)); + oldContentY = internalButtons.flickable.contentY; + } + } + y: parent.height - height + Repeater { + model: { + if (root.actions.length == 0) { + return null; + } else { + return root.actions[0].text !== undefined && + root.actions[0].trigger !== undefined ? + root.actions : + root.actions[0]; + } + } + delegate: PlasmaComponents.ToolButton { + Layout.fillHeight: true + flat: false + iconSource: modelData.iconName + onClicked: { + if (modelData && modelData.trigger !== undefined) { + modelData.trigger(); + // assume the model is a list of QAction or Action + } else if (toolbar.model.length > index) { + toolbar.model[index].trigger(); + } else { + console.log("Don't know how to trigger the action") + } + } + } + } + onChildrenChanged: { + var flexibleFound = false; + for (var i = 0; i < children.length; ++i) { + if (children[i].Layout.fillWidth) { + flexibleFound = true; + break; + } + } + Layout.fillWidth = flexibleFound; + } + } +} diff --git a/components/mobilecomponents/examples/ActionGroup.qml b/components/mobilecomponents/examples/ActionGroup.qml deleted file mode 100644 --- a/components/mobilecomponents/examples/ActionGroup.qml +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copycontext 2015 Marco Martin - * - * 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.1 -import QtQuick.Controls 1.3 - -Action { - id: root - default property alias children: root.__children - property list __children -} diff --git a/components/mobilecomponents/examples/ApplicationWindow.qml b/components/mobilecomponents/examples/ApplicationWindow.qml deleted file mode 100644 --- a/components/mobilecomponents/examples/ApplicationWindow.qml +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copycontext 2015 Marco Martin - * - * 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.1 -import QtQuick.Layouts 1.3 -import QtQuick.Controls 1.3 -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.mobilecomponents 0.2 -import org.kde.kquickcontrolsaddons 2.0 - -ApplicationWindow { - id: root - - property alias initialPage: __pageStack.initialPage - property alias pageStack: __pageStack - - PageRow { - id: __pageStack - anchors.fill: parent - } - -} diff --git a/components/mobilecomponents/examples/ContextDrawer.qml b/components/mobilecomponents/examples/ContextDrawer.qml deleted file mode 100644 --- a/components/mobilecomponents/examples/ContextDrawer.qml +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2012 Marco Martin - * - * 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.1 -import QtQuick.Controls 1.0 as QtControls -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.kquickcontrolsaddons 2.0 -import org.kde.plasma.mobilecomponents 0.2 as MobileComponents - -MobileComponents.OverlayDrawer { - id: root - - property string title - - //This can be any type of object that a ListView can accept as model. It expects items compatible with either QAction or QQC Action - property alias actions: internalActions.data - - Item { - id: internalActions - } - - drawer: QtControls.ScrollView { - - ListView { - id: menu - model: { - if (root.actions.length == 0) { - return null; - } else { - return root.actions[0].text !== undefined && - root.actions[0].trigger !== undefined ? - root.actions : - root.actions[0]; - } - } - header: Item { - height: heading.height - PlasmaExtras.Heading { - id: heading - anchors { - left: parent.left - margins: units.largeSpacing - } - level: 2 - text: root.title - } - } - delegate: PlasmaComponents.ListItem { - enabled: true - Row { - anchors { - left: parent.left - margins: units.largeSpacing - } - PlasmaCore.IconItem { - height: parent.height - width: height - source: modelData.iconName - } - PlasmaComponents.Label { - enabled: true - text: "Menu Item " + model ? model.text : modelData.text - } - } - onClicked: { - if (modelData && modelData.trigger !== undefined) { - modelData.trigger(); - // assume the model is a list of QAction or Action - } else if (menu.model.length > index) { - menu.model[index].trigger(); - } else { - console.log("Don't know how to trigger the action") - } - } - } - } - } -} diff --git a/components/mobilecomponents/examples/ExampleApp.qml b/components/mobilecomponents/examples/ExampleApp.qml --- a/components/mobilecomponents/examples/ExampleApp.qml +++ b/components/mobilecomponents/examples/ExampleApp.qml @@ -26,17 +26,17 @@ import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.core 2.0 as PlasmaCore -ApplicationWindow { +MobileComponents.ApplicationWindow { id: root width: 500 height: 800 - GlobalDrawer { + MobileComponents.GlobalDrawer { title: "Akregator" titleIcon: "akregator" actions: [ - ActionGroup { + MobileComponents.ActionGroup { text: "View" iconName: "view-list-icons" Controls.Action { @@ -49,7 +49,7 @@ text: "action 3" } }, - ActionGroup { + MobileComponents.ActionGroup { text: "Sync" iconName: "folder-sync" Controls.Action { @@ -69,16 +69,16 @@ Layout.minimumWidth: 200 } } - ContextDrawer { - actions: //ListModel {ListElement{text:"AAA"} ListElement{text:"cccc"}} + MobileComponents.ContextDrawer { + actions: [ Controls.Action { - text:"AAA" + text:"Action 1" iconName: "document-decrypt" - onTriggered: print("AAA") + onTriggered: print("Action 1 clicked") }, Controls.Action { - text:"bbb" + text:"Action 2" iconName: "document-share" }] title: "Actions" @@ -89,9 +89,17 @@ //Main app content Component { id: mainPageComponent - Page { + MobileComponents.Page { anchors.fill:parent - actions: [Controls.Action {iconName:"konqueror"; onTriggered: print("AAA")}, Controls.Action {iconName:"go-home"}] + actions: [ + Controls.Action { + iconName:"konqueror" + onTriggered: print("Action triggered") + }, + Controls.Action { + iconName:"go-home" + } + ] PlasmaExtras.ScrollArea { anchors.fill:parent ListView { diff --git a/components/mobilecomponents/examples/GlobalDrawer.qml b/components/mobilecomponents/examples/GlobalDrawer.qml deleted file mode 100644 --- a/components/mobilecomponents/examples/GlobalDrawer.qml +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2012 Marco Martin - * - * 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.1 -import QtQuick.Controls 1.0 -import QtQuick.Layouts 1.3 -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.kquickcontrolsaddons 2.0 -import org.kde.plasma.mobilecomponents 0.2 as MobileComponents - -MobileComponents.OverlayDrawer { - id: root - inverse: true - - property alias content: mainContent.data - - property alias title: heading.text - property alias titleIcon: headingIcon.source - property list actions - - drawer: ColumnLayout { - id: mainColumn - anchors.fill: parent - implicitWidth: units.gridUnit * 12 - - RowLayout { - Layout.fillWidth: true - anchors { - left: parent.left - } - PlasmaCore.IconItem { - id: headingIcon - height: parent.height - width: height - Layout.minimumWidth: height - } - PlasmaExtras.Heading { - id: heading - level: 1 - } - Item { - height: parent.height - Layout.minimumWidth: height - } - } - - PlasmaExtras.PageRow { - id: pageRow - Layout.fillWidth: true - Layout.fillHeight: true - initialPage: menuComponent - } - - ColumnLayout { - id: mainContent - Layout.fillWidth: true - Layout.fillHeight: true - } - Component { - id: menuComponent - ListView { - id: optionMenu - - model: actions - property int level: 0 - - footer: PlasmaComponents.ListItem { - visible: level > 0 - enabled: true - RowLayout { - anchors { - left: parent.left - } - PlasmaCore.IconItem { - Layout.maximumWidth: height - Layout.fillHeight: true - source: "go-previous" - } - PlasmaComponents.Label { - text: i18n("Back") - } - } - onClicked: pageRow.scrollToLevel(level - 1) - } - delegate: PlasmaComponents.ListItem { - enabled: true - RowLayout { - anchors { - left: parent.left - right: parent.right - } - PlasmaCore.IconItem { - Layout.maximumWidth: height - Layout.fillHeight: true - source: modelData.iconName - } - PlasmaComponents.Label { - Layout.fillWidth: true - text: modelData.text - } - PlasmaCore.IconItem { - Layout.maximumWidth: height - Layout.fillHeight: true - source: "go-next" - visible: modelData.children != undefined - } - } - onClicked: { - if (modelData.children) { - pageRow.pop(optionMenu); - pageRow.push(menuComponent, {"model": modelData.children, "level": level + 1}); - } else { - modelData.trigger(); - pageRow.pop(); - } - } - } - } - } - } -} - diff --git a/components/mobilecomponents/examples/Page.qml b/components/mobilecomponents/examples/Page.qml deleted file mode 100644 --- a/components/mobilecomponents/examples/Page.qml +++ /dev/null @@ -1,105 +0,0 @@ - - -import QtQuick 2.1 -import QtQuick.Layouts 1.3 -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.components 2.0 as PlasmaComponents - -Item { - id: root - - /** - * type:PageStack - * The page stack that this page is owned by. - */ - property Item pageStack - - /** - * Defines the toolbar contents for the page. If the page stack is set up - * using a toolbar instance, it automatically shows the currently active - * page's toolbar contents in the toolbar. - * - * The default value is null resulting in the page's toolbar to be - * invisible when the page is active. - */ - property Item tools: null - - /** - * Defines the actions for the page: at most 4 buttons will - * contain the actions at the bottom of the page, if the main - * item of the page is a Flickable or a ScrllArea, it will - * control the visibility of the actions. - */ - property alias actions: internalActions.data - - Item { - id: internalActions - } - - RowLayout { - id: internalButtons - z:99 - anchors.horizontalCenter: parent.horizontalCenter - Layout.fillWidth: false - height: units.iconSizes.large - property Item flickable: { - if (root.children[root.children.length-1]) { - if (root.children[root.children.length-1].contentY) { - return root.children[root.children.length-1]; - } else if (root.children[root.children.length-1].flickableItem) { - return root.children[root.children.length-1].flickableItem; - } - } - return null; - } - Connections { - target: internalButtons.flickable - property real oldContentY: internalButtons.flickable.contentY - onContentYChanged: { - if (internalButtons.flickable.atYBeginning || internalButtons.flickable.atYEnd) { - return; - } - internalButtons.y = Math.max(internalButtons.flickable.height - internalButtons.height, Math.min(internalButtons.flickable.height, internalButtons.y + internalButtons.flickable.contentY - oldContentY)); - oldContentY = internalButtons.flickable.contentY; - } - } - y: parent.height - height - Repeater { - model: { - if (root.actions.length == 0) { - return null; - } else { - return root.actions[0].text !== undefined && - root.actions[0].trigger !== undefined ? - root.actions : - root.actions[0]; - } - } - delegate: PlasmaComponents.ToolButton { - Layout.fillHeight: true - flat: false - iconSource: modelData.iconName - onClicked: { - if (modelData && modelData.trigger !== undefined) { - modelData.trigger(); - // assume the model is a list of QAction or Action - } else if (toolbar.model.length > index) { - toolbar.model[index].trigger(); - } else { - console.log("Don't know how to trigger the action") - } - } - } - } - onChildrenChanged: { - var flexibleFound = false; - for (var i = 0; i < children.length; ++i) { - if (children[i].Layout.fillWidth) { - flexibleFound = true; - break; - } - } - Layout.fillWidth = flexibleFound; - } - } -} diff --git a/components/mobilecomponents/examples/PageRow.qml b/components/mobilecomponents/examples/PageRow.qml deleted file mode 100644 --- a/components/mobilecomponents/examples/PageRow.qml +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copycontext 2015 Marco Martin - * - * 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.1 -import QtQuick.Controls 1.3 -import org.kde.plasma.extras 2.0 as PlasmaExtras - -PlasmaExtras.PageRow { - -} diff --git a/components/mobilecomponents/qmldir b/components/mobilecomponents/qmldir --- a/components/mobilecomponents/qmldir +++ b/components/mobilecomponents/qmldir @@ -3,3 +3,9 @@ IconGrid 0.2 IconGrid.qml OverlayDrawer 0.2 OverlayDrawer.qml SplitDrawer 0.2 SplitDrawer.qml +ActionGroup 0.2 ActionGroup.qml +ApplicationWindow 0.2 ApplicationWindow.qml +ContextDrawer 0.2 ContextDrawer.qml +GlobalDrawer 0.2 GlobalDrawer.qml +Page 0.2 Page.qml +