From bb687f7f8bf97c02bbcda1066ad2d6f5a3542ed5 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 7 Jan 2016 06:59:33 -0800 Subject: [PATCH] Remove plasma mobile components, pull from upstream at build time This prevents us from constantly having to worry about keeping them in sync. Signed-off-by: Dirk Hohndel --- .gitignore | 1 + packaging/android/build.sh | 45 +- qt-mobile/qml/mobile-resources.qrc | 1 - .../qml/mobilecomponents/ActionGroup.qml | 27 - .../mobilecomponents/ApplicationWindow.qml | 99 ---- .../qml/mobilecomponents/BasicListItem.qml | 52 -- .../qml/mobilecomponents/ContextDrawer.qml | 89 --- .../qml/mobilecomponents/GlobalDrawer.qml | 183 ------- qt-mobile/qml/mobilecomponents/Heading.qml | 74 --- qt-mobile/qml/mobilecomponents/Icon.qml | 48 -- qt-mobile/qml/mobilecomponents/IconGrid.qml | 238 -------- qt-mobile/qml/mobilecomponents/Label.qml | 59 -- qt-mobile/qml/mobilecomponents/ListItem.qml | 129 ----- .../mobilecomponents/ListItemWithActions.qml | 292 ---------- .../qml/mobilecomponents/OverlayDrawer.qml | 377 ------------- qt-mobile/qml/mobilecomponents/Page.qml | 53 -- qt-mobile/qml/mobilecomponents/PageRow.qml | 513 ------------------ .../qml/mobilecomponents/SplitDrawer.qml | 234 -------- qt-mobile/qml/mobilecomponents/Theme.qml | 62 --- qt-mobile/qml/mobilecomponents/Units.qml | 101 ---- .../mobilecomponents/icons/dialog-cancel.svg | 122 ----- .../icons/distribute-horizontal-x.svg | 102 ---- .../mobilecomponents/icons/document-edit.svg | 93 ---- .../mobilecomponents/icons/document-save.svg | 108 ---- .../qml/mobilecomponents/icons/go-next.svg | 76 --- .../mobilecomponents/icons/go-previous.svg | 127 ----- .../icons/view-readermode.svg | 110 ---- .../private/AbstractDrawer.qml | 47 -- .../mobilecomponents/private/ActionButton.qml | 192 ------- .../private/ActionButtonArrow.qml | 56 -- .../qml/mobilecomponents/private/PageStack.js | 243 --------- qt-mobile/qml/mobilecomponents/private/qmldir | 3 - qt-mobile/qml/mobilecomponents/qmldir | 21 - scripts/build.sh | 49 ++ 34 files changed, 94 insertions(+), 3932 deletions(-) delete mode 100644 qt-mobile/qml/mobilecomponents/ActionGroup.qml delete mode 100644 qt-mobile/qml/mobilecomponents/ApplicationWindow.qml delete mode 100644 qt-mobile/qml/mobilecomponents/BasicListItem.qml delete mode 100644 qt-mobile/qml/mobilecomponents/ContextDrawer.qml delete mode 100644 qt-mobile/qml/mobilecomponents/GlobalDrawer.qml delete mode 100644 qt-mobile/qml/mobilecomponents/Heading.qml delete mode 100644 qt-mobile/qml/mobilecomponents/Icon.qml delete mode 100644 qt-mobile/qml/mobilecomponents/IconGrid.qml delete mode 100644 qt-mobile/qml/mobilecomponents/Label.qml delete mode 100644 qt-mobile/qml/mobilecomponents/ListItem.qml delete mode 100644 qt-mobile/qml/mobilecomponents/ListItemWithActions.qml delete mode 100644 qt-mobile/qml/mobilecomponents/OverlayDrawer.qml delete mode 100644 qt-mobile/qml/mobilecomponents/Page.qml delete mode 100644 qt-mobile/qml/mobilecomponents/PageRow.qml delete mode 100644 qt-mobile/qml/mobilecomponents/SplitDrawer.qml delete mode 100644 qt-mobile/qml/mobilecomponents/Theme.qml delete mode 100644 qt-mobile/qml/mobilecomponents/Units.qml delete mode 100644 qt-mobile/qml/mobilecomponents/icons/dialog-cancel.svg delete mode 100644 qt-mobile/qml/mobilecomponents/icons/distribute-horizontal-x.svg delete mode 100644 qt-mobile/qml/mobilecomponents/icons/document-edit.svg delete mode 100644 qt-mobile/qml/mobilecomponents/icons/document-save.svg delete mode 100644 qt-mobile/qml/mobilecomponents/icons/go-next.svg delete mode 100644 qt-mobile/qml/mobilecomponents/icons/go-previous.svg delete mode 100644 qt-mobile/qml/mobilecomponents/icons/view-readermode.svg delete mode 100644 qt-mobile/qml/mobilecomponents/private/AbstractDrawer.qml delete mode 100644 qt-mobile/qml/mobilecomponents/private/ActionButton.qml delete mode 100644 qt-mobile/qml/mobilecomponents/private/ActionButtonArrow.qml delete mode 100644 qt-mobile/qml/mobilecomponents/private/PageStack.js delete mode 100644 qt-mobile/qml/mobilecomponents/private/qmldir delete mode 100644 qt-mobile/qml/mobilecomponents/qmldir diff --git a/.gitignore b/.gitignore index 4f21f1172..35af50390 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ Subsurface.app .DS_Store !android/**/*.xml build* +qt-mobile/qml/mobilecomponents diff --git a/packaging/android/build.sh b/packaging/android/build.sh index 1069d93b1..51ea947aa 100644 --- a/packaging/android/build.sh +++ b/packaging/android/build.sh @@ -288,6 +288,48 @@ if [ "$SUBSURFACE_DESKTOP" = "ON" ] ; then else SUBSURFACE_MOBILE="ON" fi + +if [ "$SUBSURFACE_MOBILE" = "ON" ] ; then + # now bring in the latest Plasma-mobile mobile components plus a couple of icons that we need + # first, get the latest from upstream + # yes, this is a bit overkill as we clone a lot of stuff for just a few files, but this way + # we stop having to manually merge our code with upstream all the time + # as we get closer to shipping a production version we'll likely check out specific tags + # or SHAs from upstream + if [ ! -d plasma-mobile ] ; then + git clone git://github.com/KDE/plasma-mobile + fi + pushd plasma-mobile + git pull + popd + if [ ! -d breeze-icons ] ; then + git clone git://anongit.kde.org/breeze-icons + fi + pushd breeze-icons + git pull + popd + + # now copy the components and a couple of icons into plae + MC=$SUBSURFACE_SOURCE/qt-mobile/qml/mobilecomponents + PMMC=plasma-mobile/components/mobilecomponents + BREEZE=breeze-icons + + rm -rf $MC + mkdir -p $MC/icons + cp -R $PMMC/qml/* $MC/ + cp $PMMC/fallbacktheme/*qml $MC/ + + cp $BREEZE/icons/actions/24/dialog-cancel.svg $MC/icons + cp $BREEZE/icons/actions/24/distribute-horizontal-x.svg $MC/icons + cp $BREEZE/icons/actions/24/document-edit.svg $MC/icons + cp $BREEZE/icons/actions/24/document-save.svg $MC/icons + cp $BREEZE/icons/actions/24/go-next.svg $MC/icons + cp $BREEZE/icons/actions/24/go-previous.svg $MC/icons + cp $BREEZE/icons/actions/16/view-readermode.svg $MC/icons + + echo org.kde.plasma.mobilecomponents synced from upstream +fi + if [ ! -z "$SUBSURFACE_MOBILE" ] ; then mkdir -p subsurface-mobile-build-$ARCH cd subsurface-mobile-build-$ARCH @@ -298,7 +340,7 @@ else cd subsurface-build-$ARCH fi -# somehting in the qt-android-cmake-thingies mangles your path, so thats why we need to hard-code ant and pkg-config here. +# something in the qt-android-cmake-thingies mangles your path, so thats why we need to hard-code ant and pkg-config here. if [ $PLATFORM = Darwin ] ; then ANT=/usr/local/bin/ant FTDI=OFF @@ -306,6 +348,7 @@ else ANT=/usr/bin/ant FTDI=ON fi + PKGCONF=$(which pkg-config) cmake $MOBILE_CMAKE \ -DQT_ANDROID_ANT=${ANT} \ diff --git a/qt-mobile/qml/mobile-resources.qrc b/qt-mobile/qml/mobile-resources.qrc index b6393fc91..cde0d42cf 100644 --- a/qt-mobile/qml/mobile-resources.qrc +++ b/qt-mobile/qml/mobile-resources.qrc @@ -38,7 +38,6 @@ mobilecomponents/private/ActionButtonArrow.qml mobilecomponents/private/AbstractDrawer.qml mobilecomponents/private/PageStack.js - mobilecomponents/private/qmldir mobilecomponents/icons/go-next.svg mobilecomponents/icons/go-previous.svg mobilecomponents/icons/distribute-horizontal-x.svg diff --git a/qt-mobile/qml/mobilecomponents/ActionGroup.qml b/qt-mobile/qml/mobilecomponents/ActionGroup.qml deleted file mode 100644 index ba057f58f..000000000 --- a/qt-mobile/qml/mobilecomponents/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/qt-mobile/qml/mobilecomponents/ApplicationWindow.qml b/qt-mobile/qml/mobilecomponents/ApplicationWindow.qml deleted file mode 100644 index c57afb6da..000000000 --- a/qt-mobile/qml/mobilecomponents/ApplicationWindow.qml +++ /dev/null @@ -1,99 +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 "private" -import org.kde.plasma.mobilecomponents 0.2 - -/** - * 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 and 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 - - function showPassiveNotification(message, timeout, actionText, callBack) { - if (!__actionButton.__passiveNotification) { - var component = Qt.createComponent("private/PassiveNotification.qml"); - __actionButton.__passiveNotification = component.createObject(contentItem.parent); - } - - __actionButton.__passiveNotification.showNotification(message, timeout, actionText, callBack); - } - - PageRow { - id: __pageStack - anchors { - fill: parent - bottomMargin: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0 - } - focus: true - Keys.onReleased: { - if (event.key == Qt.Key_Back && stackView.depth > 1) { - stackView.pop(); - event.accepted = true; - } - } - } - - property AbstractDrawer globalDrawer - property AbstractDrawer contextDrawer - - onGlobalDrawerChanged: { - globalDrawer.parent = contentItem.parent; - } - onContextDrawerChanged: { - contextDrawer.parent = contentItem.parent; - } - - width: Units.gridUnit * 25 - height: Units.gridUnit * 30 - - property alias actionButton: __actionButton - ActionButton { - id: __actionButton - //put it there just to make it not accessible bu users - property Item __passiveNotification - z: 9999 - anchors.bottom: parent.bottom - x: parent.width/2 - width/2 - iconSource: "distribute-horizontal-x" - - visible: root.globalDrawer || root.contextDrawer - } -} diff --git a/qt-mobile/qml/mobilecomponents/BasicListItem.qml b/qt-mobile/qml/mobilecomponents/BasicListItem.qml deleted file mode 100644 index fe5b79ed6..000000000 --- a/qt-mobile/qml/mobilecomponents/BasicListItem.qml +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2010 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 2.010-1301, USA. - */ - -import QtQuick 2.1 -import QtQuick.Layouts 1.2 -import org.kde.plasma.mobilecomponents 0.2 - -/** - * An item delegate for the primitive ListView component. - * - * It's intended to make all listviews look coherent. - * - * @inherit QtQuick.Item - */ -ListItem { - id: listItem - - property string label - property var icon - - RowLayout { - height: implicitHeight + Units.smallSpacing * 2 - anchors { - left: parent.left - margins: Units.largeSpacing - } - Icon { - Layout.minimumHeight: Units.iconSizes.smallMedium - Layout.minimumWidth: height - source: listItem.icon - } - Label { - text: listItem.label - } - } -} diff --git a/qt-mobile/qml/mobilecomponents/ContextDrawer.qml b/qt-mobile/qml/mobilecomponents/ContextDrawer.qml deleted file mode 100644 index 088399721..000000000 --- a/qt-mobile/qml/mobilecomponents/ContextDrawer.qml +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.2 -import QtQuick.Controls 1.0 as QtControls -import org.kde.plasma.mobilecomponents 0.2 - -OverlayDrawer { - id: root - - property string title: typeof i18n !== "undefined" ? i18n("Actions") : "Actions" - - //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 var actions: pageStack.lastVisiblePage ? pageStack.lastVisiblePage.contextualActions : null - enabled: menu.count > 0 - edge: Qt.RightEdge - - contentItem: QtControls.ScrollView { - implicitWidth: Units.gridUnit * 20 - ListView { - id: menu - interactive: contentHeight > height - model: { - if (typeof root.actions == "undefined") { - return null; - } - if (root.actions.length == 0) { - return null; - } else { - return root.actions[0].text !== undefined && - root.actions[0].trigger !== undefined ? - root.actions : - root.actions[0]; - } - } - topMargin: menu.height - menu.contentHeight - header: Item { - height: heading.height - width: menu.width - Heading { - id: heading - anchors { - left: parent.left - right: parent.right - margins: Units.largeSpacing - } - elide: Text.ElideRight - level: 2 - text: root.title - } - } - delegate: BasicListItem { - checked: modelData.checked - icon: modelData.iconName - label: model ? model.text : modelData.text - enabled: model ? model.enabled : modelData.enabled - opacity: enabled ? 1.0 : 0.6 - 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") - } - root.opened = false; - } - } - } - } -} diff --git a/qt-mobile/qml/mobilecomponents/GlobalDrawer.qml b/qt-mobile/qml/mobilecomponents/GlobalDrawer.qml deleted file mode 100644 index afe304166..000000000 --- a/qt-mobile/qml/mobilecomponents/GlobalDrawer.qml +++ /dev/null @@ -1,183 +0,0 @@ -/* - * 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.2 -import QtGraphicalEffects 1.0 -import org.kde.plasma.mobilecomponents 0.2 - -OverlayDrawer { - id: root - edge: Qt.LeftEdge - - default property alias content: mainContent.data - - property alias title: heading.text - property alias titleIcon: headingIcon.source - property alias bannerImageSource: bannerImage.source - property list actions - - contentItem: ColumnLayout { - id: mainColumn - anchors.fill: parent - spacing: 0 - implicitWidth: Units.gridUnit * 12 - - Image { - id: bannerImage - Layout.fillWidth: true - - Layout.preferredWidth: title.implicitWidth - Layout.preferredHeight: bannerImageSource != "" ? Math.max(title.implicitHeight, Math.floor(width / (sourceSize.width/sourceSize.height))) : title.implicitHeight - Layout.minimumHeight: Math.max(headingIcon.height, heading.height) + Units.smallSpacing * 2 - - fillMode: Image.PreserveAspectCrop - asynchronous: true - - anchors { - left: parent.left - right: parent.right - top: parent.top - } - - LinearGradient { - anchors { - left: parent.left - right: parent.right - top: parent.top - } - visible: bannerImageSource != "" - height: title.height * 1.3 - start: Qt.point(0, 0) - end: Qt.point(0, height) - gradient: Gradient { - GradientStop { - position: 0.0 - color: Qt.rgba(0, 0, 0, 0.8) - } - GradientStop { - position: 1.0 - color: "transparent" - } - } - } - - RowLayout { - id: title - anchors { - left: parent.left - top: parent.top - margins: Units.smallSpacing * 2 - } - Icon { - id: headingIcon - Layout.minimumWidth: Units.iconSizes.large - Layout.minimumHeight: width - } - Heading { - id: heading - level: 1 - color: bannerImageSource != "" ? "white" : Theme.textColor - } - Item { - height: 1 - Layout.minimumWidth: heading.height - } - } - } - - Rectangle { - color: Theme.textColor - opacity: 0.2 - Layout.fillWidth: true - Layout.minimumHeight: 1 - } - - StackView { - id: pageRow - Layout.fillWidth: true - Layout.fillHeight: true - initialItem: menuComponent - } - - ColumnLayout { - id: mainContent - Layout.alignment: Qt.AlignHCenter - Layout.minimumWidth: parent.width - Units.smallSpacing*2 - Layout.maximumWidth: Layout.minimumWidth - Layout.fillWidth: false - Layout.fillHeight: true - visible: children.length > 0 - } - Item { - Layout.minimumWidth: Units.smallSpacing - Layout.minimumHeight: Units.smallSpacing - } - - Component { - id: menuComponent - ListView { - id: optionMenu - clip: true - - model: actions - property int level: 0 - - interactive: contentHeight > height - - footer: BasicListItem { - visible: level > 0 - enabled: true - icon: "go-previous" - label: typeof i18n !== "undefined" ? i18n("Back") : "Back" - onClicked: pageRow.pop() - } - delegate: BasicListItem { - enabled: true - checked: modelData.checked - icon: modelData.iconName - label: modelData.text - - Icon { - anchors { - top: parent.top - bottom: parent.bottom - right: parent.right - } - width: height - source: "go-next" - visible: modelData.children != undefined - } - - onClicked: { - if (modelData.children) { - pageRow.push(menuComponent, {"model": modelData.children, "level": level + 1}); - } else { - modelData.trigger(); - pageRow.pop(pageRow.initialPage); - root.opened = false; - } - } - } - } - } - } -} - diff --git a/qt-mobile/qml/mobilecomponents/Heading.qml b/qt-mobile/qml/mobilecomponents/Heading.qml deleted file mode 100644 index db69645eb..000000000 --- a/qt-mobile/qml/mobilecomponents/Heading.qml +++ /dev/null @@ -1,74 +0,0 @@ -/* -* Copyright 2012 by Sebastian Kügler -* -* 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 2.010-1301, USA. -*/ - -import QtQuick 2.0 -import org.kde.plasma.mobilecomponents 0.2 - -/** - * A heading label used for subsections of texts. - * - * The characteristics of the text will be automatically set according to the - * plasma Theme. Use this components for section titles or headings in your UI, - * for example page or section titles. - * - * Example usage: - * - * @code - * import org.kde.plasma.mobilecomponents 0.2 as MobileComponents - * [...] - * Column { - * MobileComponents.Heading { text: "Apples in the sunlight"; level: 2 } - * [...] - * } - * @endcode - * - * The most important property is "text", which applies to the text property of - * Label. See PlasmaComponents Label and primitive QML Text element API for - * additional properties, methods and signals. - */ -Label { - id: heading - - /** - * The level determines how big the section header is display, values - * between 1 (big) and 5 (small) are accepted - */ - property int level: 1 - - property int step: 2 - - height: Math.round(paintedHeight * 1.2) - font.pointSize: headerPointSize(level) - font.weight: Font.Light - wrapMode: Text.WordWrap - opacity: 0.8 - - function headerPointSize(l) { - var n = Theme.defaultFont.pointSize; - var s; - if (l > 4) { - s = n - } else if (l < 2) { - s = n + (5*step) - } else { - s = n + ((5-level)*2) - } - return s; - } -} diff --git a/qt-mobile/qml/mobilecomponents/Icon.qml b/qt-mobile/qml/mobilecomponents/Icon.qml deleted file mode 100644 index 150c181e6..000000000 --- a/qt-mobile/qml/mobilecomponents/Icon.qml +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.0 -import QtGraphicalEffects 1.0 -import org.kde.plasma.mobilecomponents 0.2 - -Item { - id: root - property string source - property alias smooth: image.smooth - property bool active: false - property bool valid: image.status == Image.Ready - - implicitWidth: image.source != "" ? Units.iconSizes.smallMedium : 0 - implicitHeight: image.source != "" ? Units.iconSizes.smallMedium : 0 - - Image { - id: image - anchors.fill: parent - source: root.source != "" ? (root.source.indexOf(".") === -1 ? "icons/" + root.source + ".svg" : root.source) : root.source - sourceSize.width: root.width - sourceSize.height: root.height - } - /* // FIXME: This causes black squares on some GLES drivers, notably on Adreno hardware - GammaAdjust { - anchors.fill: image - source: image - gamma: root.active ? 3.0 : 1 - } - */ -} diff --git a/qt-mobile/qml/mobilecomponents/IconGrid.qml b/qt-mobile/qml/mobilecomponents/IconGrid.qml deleted file mode 100644 index 1a6acbc1d..000000000 --- a/qt-mobile/qml/mobilecomponents/IconGrid.qml +++ /dev/null @@ -1,238 +0,0 @@ -/* - Copyright 2010 Marco Martin - - This library 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 of the License, or (at your option) any later version. - - This library 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 library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -import QtQuick 2.1 -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.mobilecomponents 0.2 -import org.kde.plasma.mobilecomponents.private 0.2 - -Item { - id: main - - property Component delegate - property QtObject model - - property int pageSize: Math.floor(iconView.width / main.delegateWidth) * Math.floor(iconView.height / main.delegateHeight) - property int delegateWidth: Units.iconSizes.huge + Units.gridUnit * 2 - property int delegateHeight: Units.iconSizes.huge + Units.gridUnit * 2 - property alias currentPage: iconView.currentIndex - property int pagesCount: Math.ceil(model.count / pageSize) - property int count: model.count - property alias contentX: iconView.contentX - clip: true - - function positionViewAtIndex(index) - { - iconView.positionViewAtIndex(index / pageSize, ListView.Beginning) - } - - Timer { - id: resizeTimer - running: true - interval: 100 - onTriggered: { - main.pageSize = Math.floor(iconView.width / main.delegateWidth) * Math.floor(iconView.height / main.delegateHeight) - if (iconView.currentItem) { - iconView.currentItem.width = iconView.width - iconView.currentItem.height = iconView.height - } - } - } - - ListView { - id: iconView - objectName: "iconView" - pressDelay: 200 - cacheBuffer: Units.gridUnit * 8 - highlightMoveDuration: Units.shortDuration - anchors.fill: parent - onWidthChanged: resizeTimer.restart() - onHeightChanged: resizeTimer.restart() - - model: main.model ? Math.ceil(main.model.count/main.pageSize) : 0 - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem - boundsBehavior: Flickable.DragOverBounds - - signal clicked(string url) - - delegate: Component { - Item { - id: delegatePage - //Explicitly *not* bind the properties for performance reasons - Component.onCompleted: { - width = iconView.width - height = iconView.height - //iconView.cacheBuffer = iconView.width - } - - Flow { - id: iconFlow - width: iconRepeater.suggestedWidth - - anchors { - horizontalCenter: parent.horizontalCenter - top: parent.top - bottom: parent.bottom - } - property int orientation: ListView.Horizontal - - PagedProxyModel { - id: pagedProxyModel - sourceModel: main.model - currentPage: model.index - pageSize: main.pageSize - } - Repeater { - id: iconRepeater - model: pagedProxyModel - property int columns: Math.min(count, Math.floor(delegatePage.width / main.delegateWidth)) - property int suggestedWidth: main.delegateWidth * columns - //property int suggestedHeight: main.delegateHeight*Math.floor(count/columns) - - delegate: main.delegate - } - } - } - } - } - - - Loader { - id: scrollArea - visible: main.model && Math.ceil(main.model.count/main.pageSize) > 1 - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - height: Math.max(16, iconView.height - Math.floor(iconView.height / delegateHeight) * delegateHeight) - - property int pageCount: main.model ? Math.ceil(main.model.count/main.pageSize) : 0 - - sourceComponent: pageCount > 1 ? ((pageCount * 20 > width) ? scrollDotComponent : dotsRow) : undefined - function setViewIndex(index) - { - //animate only if near - if (Math.abs(iconView.currentIndex - index) > 1) { - iconView.positionViewAtIndex(index, ListView.Beginning) - } else { - iconView.currentIndex = index - } - } - Component { - id: scrollDotComponent - MouseArea { - anchors.fill: parent - property int pendingIndex: 0 - Rectangle { - id: barRectangle - color: Theme.textColor - height: 4 - radius: 2 - anchors { - left: parent.left - right: parent.right - verticalCenter: parent.verticalCenter - leftMargin: (parent.width / pageCount / 2) - rightMargin: (parent.width / pageCount / 2) - } - } - Rectangle { - color: Theme.textColor - height: 8 - width: height - radius: 4 - anchors.verticalCenter: parent.verticalCenter - x: parent.width / (pageCount / (iconView.currentIndex+1)) - (parent.width / pageCount / 2) - 4 - Behavior on x { - NumberAnimation { - duration: Units.shortDuration - easing.type: Easing.InOutQuad - } - } - } - function setViewIndexFromMouse(x) - { - pendingIndex = Math.min(pageCount, - Math.round(pageCount / (barRectangle.width / Math.max(x - barRectangle.x, 1)))) - viewPositionTimer.restart() - } - onPressed: setViewIndexFromMouse(mouse.x) - onPositionChanged: setViewIndexFromMouse(mouse.x) - - Timer { - id: viewPositionTimer - interval: 200 - onTriggered: setViewIndex(pendingIndex) - } - } - } - Component { - id: dotsRow - - Item { - Row { - anchors.centerIn: parent - spacing: units.gridUnit - - Repeater { - model: scrollArea.pageCount - - - Rectangle { - width: 6 - height: 6 - scale: iconView.currentIndex == index ? 1.5 : 1 - radius: 5 - smooth: true - opacity: iconView.currentIndex == index ? 0.8: 0.4 - color: Theme.textColor - - Behavior on scale { - NumberAnimation { - duration: units.shortDuration - easing.type: Easing.InOutQuad - } - } - Behavior on opacity { - NumberAnimation { - duration: units.shortDuration - easing.type: Easing.InOutQuad - } - } - - MouseArea { - anchors { - fill: parent - margins: Units.gridUnit / 2 - } - - onClicked: { - setViewIndex(index) - } - } - } - } - } - } - } - } -} diff --git a/qt-mobile/qml/mobilecomponents/Label.qml b/qt-mobile/qml/mobilecomponents/Label.qml deleted file mode 100644 index bf27078b7..000000000 --- a/qt-mobile/qml/mobilecomponents/Label.qml +++ /dev/null @@ -1,59 +0,0 @@ -/* -* Copyright (C) 2011 by 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 2.010-1301, USA. -*/ - -import QtQuick 2.1 -import org.kde.plasma.mobilecomponents 0.2 - -/** - * This is a label which uses the plasma Theme. - * - * The characteristics of the text will be automatically set according to the - * plasma Theme. If you need a more customized text item use the Text component - * from QtQuick. - * - * You can use all elements of the QML Text component, in particular the "text" - * property to define the label text. - * - * @inherit QtQuick.Text - */ -Text { - id: root - - height: Math.round(Math.max(paintedHeight, Units.gridUnit * 1.6)) - verticalAlignment: lineCount > 1 ? Text.AlignTop : Text.AlignVCenter - - activeFocusOnTab: false - renderType: Text.NativeRendering - - font.capitalization: Theme.defaultFont.capitalization - font.family: Theme.defaultFont.family - font.italic: Theme.defaultFont.italic - font.letterSpacing: Theme.defaultFont.letterSpacing - font.pointSize: Theme.defaultFont.pointSize - font.strikeout: Theme.defaultFont.strikeout - font.underline: Theme.defaultFont.underline - font.weight: Theme.defaultFont.weight - font.wordSpacing: Theme.defaultFont.wordSpacing - color: Theme.textColor - - opacity: enabled? 1 : 0.6 - - Accessible.role: Accessible.StaticText - Accessible.name: text -} diff --git a/qt-mobile/qml/mobilecomponents/ListItem.qml b/qt-mobile/qml/mobilecomponents/ListItem.qml deleted file mode 100644 index 042ba2cbc..000000000 --- a/qt-mobile/qml/mobilecomponents/ListItem.qml +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2010 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 2.010-1301, USA. - */ - -import QtQuick 2.1 -import org.kde.plasma.mobilecomponents 0.2 - -/** - * An item delegate for the primitive ListView component. - * - * It's intended to make all listviews look coherent. - * - * @inherit QtQuick.Item - */ -Item { - id: listItem - default property alias content: paddingItem.data - - /** - * type:bool Holds if the item emits signals related to mouse interaction. - * - * The default value is false. - */ - property alias enabled: itemMouse.enabled - //item has been clicked or pressed+hold - - /** - * This signal is emitted when there is a click. - * - * This is disabled by default, set enabled to true to use it. - * @see enabled - */ - signal clicked - - - /** - * The user pressed the item with the mouse and didn't release it for a - * certain amount of time. - * - * This is disabled by default, set enabled to true to use it. - * @see enabled - */ - signal pressAndHold - - /** - * If true makes the list item look as checked or pressed. It has to be set - * from the code, it won't change by itself. - */ - //plasma extension - //always look pressed? - property bool checked: false - - /** - * If true the item will be a delegate for a section, so will look like a - * "title" for the otems under it. - */ - //is this to be used as section delegate? - property bool sectionDelegate: false - - /** - * True if the list item contains mouse - */ - property alias containsMouse: itemMouse.containsMouse - - width: parent ? parent.width : childrenRect.width - height: paddingItem.childrenRect.height + Units.smallSpacing*2 - - property int implicitHeight: paddingItem.childrenRect.height + Units.smallSpacing*2 - - - MouseArea { - id: itemMouse - property bool changeBackgroundOnPress: !listItem.checked && !listItem.sectionDelegate - anchors.fill: parent - enabled: false - hoverEnabled: true - - onClicked: listItem.clicked() - onPressAndHold: listItem.pressAndHold() - - Rectangle { - id : background - color: listItem.checked || (itemMouse.pressed && itemMouse.changeBackgroundOnPress) ? Theme.highlightColor : Theme.viewBackgroundColor - - anchors.fill: parent - visible: listItem.ListView.view ? listItem.ListView.view.highlight === null : true - opacity: itemMouse.containsMouse && !itemMouse.pressed ? 0.5 : 1 - Behavior on color { - ColorAnimation { duration: Units.longDuration } - } - Behavior on opacity { NumberAnimation { duration: Units.longDuration } } - } - Item { - id: paddingItem - anchors { - fill: parent - margins: Units.smallSpacing - } - } - } - - Rectangle { - color: Theme.textColor - opacity: 0.2 - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - height: 1 - } - - Accessible.role: Accessible.ListItem -} diff --git a/qt-mobile/qml/mobilecomponents/ListItemWithActions.qml b/qt-mobile/qml/mobilecomponents/ListItemWithActions.qml deleted file mode 100644 index 5fd62319d..000000000 --- a/qt-mobile/qml/mobilecomponents/ListItemWithActions.qml +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright 2010 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 2.010-1301, USA. - */ - -import QtQuick 2.1 -import QtQuick.Layouts 1.2 -import QtQuick.Controls 1.0 -import org.kde.plasma.mobilecomponents 0.2 -import QtGraphicalEffects 1.0 - -/** - * An item delegate for the primitive ListView component. - * - * It's intended to make all listviews look coherent. - * - * @inherit QtQuick.Item - */ -Item { - id: listItem - default property alias content: paddingItem.data - - /** - * type:bool Holds if the item emits signals related to mouse interaction. - * - * The default value is false. - */ - property alias enabled: itemMouse.enabled - //item has been clicked or pressed+hold - - /** - * This signal is emitted when there is a click. - * - * This is disabled by default, set enabled to true to use it. - * @see enabled - */ - signal clicked - - /** - * The user pressed the item with the mouse and didn't release it for a - * certain amount of time. - * - * This is disabled by default, set enabled to true to use it. - * @see enabled - */ - signal pressAndHold - - /** - * If true makes the list item look as checked or pressed. It has to be set - * from the code, it won't change by itself. - */ - //plasma extension - //always look pressed? - property bool checked: false - - /** - * If true the item will be a delegate for a section, so will look like a - * "title" for the otems under it. - */ - //is this to be used as section delegate? - property bool sectionDelegate: false - - /** - * True if the list item contains mouse - */ - property alias containsMouse: itemMouse.containsMouse - - /** - * 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 - } - - width: parent ? parent.width : childrenRect.width - height: paddingItem.childrenRect.height + Units.smallSpacing * 2 - - property int implicitHeight: paddingItem.childrenRect.height + Units.smallSpacing * 2 - - - Rectangle { - id: shadowHolder - color: Theme.backgroundColor - x: itemMouse.x + itemMouse.width - width: parent.width - height: parent.height - } - InnerShadow { - anchors.fill: shadowHolder - radius: Units.smallSpacing * 2 - samples: 16 - horizontalOffset: verticalOffset - verticalOffset: Units.smallSpacing / 2 - color: Qt.rgba(0, 0, 0, 0.3) - source: shadowHolder - } - - MouseArea { - anchors.fill: parent - drag { - target: itemMouse - axis: Drag.XAxis - maximumX: 0 - } - onClicked: itemMouse.x = 0; - onPressed: handleArea.mouseDown(mouse); - onPositionChanged: handleArea.positionChanged(mouse); - onReleased: handleArea.released(mouse); - } - RowLayout { - anchors { - right: parent.right - verticalCenter: parent.verticalCenter - rightMargin: y - } - height: Math.min( parent.height / 1.5, Units.iconSizes.medium) - property bool exclusive: false - property Item checkedButton - spacing: Units.largeSpacing - Repeater { - model: { - if (listItem.actions.length == 0) { - return null; - } else { - return listItem.actions[0].text !== undefined && - listItem.actions[0].trigger !== undefined ? - listItem.actions : - listItem.actions[0]; - } - } - delegate: Icon { - Layout.fillHeight: true - Layout.minimumWidth: height - source: modelData.iconName - MouseArea { - anchors { - fill: parent - margins: -Units.smallSpacing - } - 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") - } - itemMouse.x = 0; - } - } - } - } - } - - - MouseArea { - id: itemMouse - property bool changeBackgroundOnPress: !listItem.checked && !listItem.sectionDelegate - width: parent.width - height: parent.height - enabled: false - hoverEnabled: true - - onClicked: listItem.clicked() - onPressAndHold: listItem.pressAndHold() - - Behavior on x { - NumberAnimation { - duration: Units.longDuration - easing.type: Easing.InOutQuad - } - } - - Rectangle { - id : item - color: listItem.checked || (itemMouse.pressed && itemMouse.changeBackgroundOnPress) ? Theme.highlightColor : Theme.viewBackgroundColor - anchors.fill: parent - - visible: listItem.ListView.view ? listItem.ListView.view.highlight === null : true - Behavior on color { - ColorAnimation { duration: Units.longDuration } - } - - Item { - id: paddingItem - anchors { - fill: parent - margins: Units.smallSpacing - } - } - - Timer { - id: speedSampler - interval: 100 - repeat: true - property real speed - property real oldItemMouseX - onTriggered: { - speed = itemMouse.x - oldItemMouseX; - oldItemMouseX = itemMouse.x; - } - onRunningChanged: { - if (running) { - speed = 0; - } else { - speed = itemMouse.x - oldItemMouseX; - } - oldItemMouseX = itemMouse.x; - } - } - MouseArea { - id: handleArea - width: Units.iconSizes.smallMedium - height: width - preventStealing: true - anchors { - right: parent.right - verticalCenter: parent.verticalCenter - rightMargin: y - } - drag { - target: itemMouse - axis: Drag.XAxis - maximumX: 0 - minimumX: -listItem.width - } - function mouseDown(mouse) { - speedSampler.speed = 0; - speedSampler.running = true; - } - onPressed: mouseDown(mouse); - onCanceled: speedSampler.running = false; - onReleased: { - speedSampler.running = false; - - if (speedSampler.speed < -Units.gridUnit * 3) { - itemMouse.x = -itemMouse.width + width * 2; - } else if (speedSampler.speed > Units.gridUnit * 3 || itemMouse.x > -itemMouse.width/3) { - itemMouse.x = 0; - } else { - itemMouse.x = -itemMouse.width + width * 2; - } - } - onClicked: { - if (itemMouse.x < -itemMouse.width/2) { - itemMouse.x = 0; - } else { - itemMouse.x = -itemMouse.width + width * 2 - } - } - Icon { - anchors.fill: parent - source: "application-menu" - } - } - } - } - - - Rectangle { - color: Theme.textColor - opacity: 0.2 - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - height: 1 - } - - Accessible.role: Accessible.ListItem -} diff --git a/qt-mobile/qml/mobilecomponents/OverlayDrawer.qml b/qt-mobile/qml/mobilecomponents/OverlayDrawer.qml deleted file mode 100644 index 061a9f490..000000000 --- a/qt-mobile/qml/mobilecomponents/OverlayDrawer.qml +++ /dev/null @@ -1,377 +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 QtGraphicalEffects 1.0 -import org.kde.plasma.mobilecomponents 0.2 -import "private" - -/**Documented API - -Imports: - QtQuick 2.1 - -Description: - Overlay Drawers are used to expose additional UI elements needed for - small secondary tasks for which the main UI elements are not needed. - For example in Okular Active, an Overlay Drawer is used to display - thumbnails of all pages within a document along with a search field. - This is used for the distinct task of navigating to another page. - -Properties: - bool opened: - If true the drawer is open showing the contents of the "drawer" - component. - - Item page: - It's the default property. it's the main content of the drawer page, - the part that is always shown - - Item contentItem: - It's the part that can be pulled in and out, will act as a sidebar. -**/ -AbstractDrawer { - id: root - anchors.fill: parent - z: 9999 - - default property alias page: mainPage.data - property Item contentItem - property alias opened: mainFlickable.open - property int edge: Qt.LeftEdge - property real position: 0 - onPositionChanged: { - if (!mainFlickable.flicking && !mainFlickable.dragging && !mainAnim.running) { - switch (root.edge) { - case Qt.RightEdge: - mainFlickable.contentX = drawerPage.width * position; - break; - case Qt.LeftEdge: - mainFlickable.contentX = drawerPage.width * (1-position); - break; - case Qt.BottomEdge: - mainFlickable.contentY = drawerPage.height * position; - break; - } - } - } - onContentItemChanged: { - contentItem.parent = drawerPage - contentItem.anchors.fill = drawerPage - } - - - function open () { - mainAnim.to = 0; - switch (root.edge) { - case Qt.RightEdge: - mainAnim.to = drawerPage.width; - break; - case Qt.BottomEdge: - mainAnim.to = drawerPage.height; - break; - case Qt.LeftEdge: - case Qt.TopEdge: - default: - mainAnim.to = 0; - break; - } - mainAnim.running = true; - mainFlickable.open = true; - } - function close () { - switch (root.edge) { - case Qt.RightEdge: - case Qt.BottomEdge: - mainAnim.to = 0; - break; - case Qt.LeftEdge: - mainAnim.to = drawerPage.width; - break; - case Qt.TopEdge: - mainAnim.to = drawerPage.height; - break; - } - mainAnim.running = true; - mainFlickable.open = false; - } - - Item { - id: mainPage - anchors.fill: parent - onChildrenChanged: mainPage.children[0].anchors.fill = mainPage - } - - Rectangle { - anchors.fill: parent - color: "black" - opacity: 0.6 * mainFlickable.internalPosition - } - - - NumberAnimation { - id: mainAnim - target: mainFlickable - properties: (root.edge == Qt.RightEdge || root.edge == Qt.LeftEdge) ? "contentX" : "contentY" - duration: Units.longDuration - easing.type: Easing.InOutQuad - } - - MouseArea { - id: edgeMouse - anchors { - right: root.edge == Qt.LeftEdge ? undefined : parent.right - left: root.edge == Qt.RightEdge ? undefined : parent.left - top: root.edge == Qt.BottomEdge ? undefined : parent.top - bottom: root.edge == Qt.TopEdge ? undefined : parent.bottom - } - z: 99 - width: Units.smallSpacing * 2 - height: Units.smallSpacing * 2 - property int startMouseX - property real oldMouseX - property int startMouseY - property real oldMouseY - property bool startDragging: false - - onPressed: { - if (drawerPage.children.length == 0) { - mouse.accepted = false; - return; - } - - speedSampler.restart(); - mouse.accepted = true; - oldMouseX = startMouseX = mouse.x; - oldMouseY = startMouseY = mouse.y; - startDragging = false; - } - - onPositionChanged: { - if (!root.contentItem) { - mouse.accepted = false; - return; - } - - if (Math.abs(mouse.x - startMouseX) > root.width / 5 || - Math.abs(mouse.y - startMouseY) > root.height / 5) { - startDragging = true; - } - if (startDragging) { - switch (root.edge) { - case Qt.RightEdge: - mainFlickable.contentX = Math.min(mainItem.width - root.width, mainFlickable.contentX + oldMouseX - mouse.x); - break; - case Qt.LeftEdge: - mainFlickable.contentX = Math.max(0, mainFlickable.contentX + oldMouseX - mouse.x); - break; - case Qt.BottomEdge: - mainFlickable.contentY = Math.min(mainItem.height - root.height, mainFlickable.contentY + oldMouseY - mouse.y); - break; - case Qt.TopEdge: - mainFlickable.contentY = Math.max(0, mainFlickable.contentY + oldMouseY - mouse.y); - break; - } - } - oldMouseX = mouse.x; - oldMouseY = mouse.y; - } - onReleased: { - speedSampler.running = false; - if (speedSampler.speed != 0) { - if (root.edge == Qt.RightEdge || root.edge == Qt.LeftEdge) { - mainFlickable.flick(speedSampler.speed, 0); - } else { - mainFlickable.flick(0, speedSampler.speed); - } - } else { - if (mainFlickable.internalPosition > 0.5) { - root.open(); - } else { - root.close(); - } - } - } - } - - Timer { - id: speedSampler - interval: 100 - repeat: true - property real speed - property real oldContentX - property real oldContentY - onTriggered: { - if (root.edge == Qt.RightEdge || root.edge == Qt.LeftEdge) { - speed = (mainFlickable.contentX - oldContentX) * 10; - oldContentX = mainFlickable.contentX; - } else { - speed = (mainFlickable.contentY - oldContentY) * 10; - oldContentY = mainFlickable.contentY; - } - } - onRunningChanged: { - if (running) { - speed = 0; - oldContentX = mainFlickable.contentX; - oldContentY = mainFlickable.contentY; - } else { - if (root.edge == Qt.RightEdge || root.edge == Qt.LeftEdge) { - speed = (oldContentX - mainFlickable.contentX) * 10; - } else { - speed = (oldContentY - mainFlickable.contentY) * 10; - } - } - } - } - - MouseArea { - id: mainMouseArea - anchors.fill: parent - drag.filterChildren: true - onClicked: { - if ((root.edge == Qt.LeftEdge && mouse.x < drawerPage.width) || - (root.edge == Qt.RightEdge && mouse.x > drawerPage.x) || - (root.edge == Qt.TopEdge && mouse.y < drawerPage.height) || - (root.edge == Qt.BottomEdge && mouse.y > drawerPage.y)) { - return; - } - root.clicked(); - root.close(); - } - enabled: (root.edge == Qt.LeftEdge && !mainFlickable.atXEnd) || - (root.edge == Qt.RightEdge && !mainFlickable.atXBeginning) || - (root.edge == Qt.TopEdge && !mainFlickable.atYEnd) || - (root.edge == Qt.BottomEdge && !mainFlickable.atYBeginning) || - mainFlickable.moving - - Flickable { - id: mainFlickable - property bool open - anchors.fill: parent - - onOpenChanged: { - if (open) { - root.open(); - } else { - root.close(); - } - } - enabled: parent.enabled - flickableDirection: root.edge == Qt.LeftEdge || root.edge == Qt.RightEdge ? Flickable.HorizontalFlick : Flickable.VerticalFlick - contentWidth: mainItem.width - contentHeight: mainItem.height - boundsBehavior: Flickable.StopAtBounds - property real internalPosition: { - switch (root.edge) { - case Qt.RightEdge: - return mainFlickable.contentX/drawerPage.width; - case Qt.LeftEdge: - return 1 - (mainFlickable.contentX/drawerPage.width); - case Qt.BottomEdge: - return mainFlickable.contentY/drawerPage.height; - case Qt.TopEdge: - return 1 - (mainFlickable.contentY/drawerPage.height); - } - } - onInternalPositionChanged: { - root.position = internalPosition; - } - - onFlickingChanged: { - if (!flicking) { - if (internalPosition > 0.5) { - root.open(); - } else { - root.close(); - } - } - } - onMovingChanged: { - if (!moving) { - flickingChanged(); - } - } - - Item { - id: mainItem - width: root.width + ((root.edge == Qt.RightEdge || root.edge == Qt.LeftEdge) ? drawerPage.width : 0) - height: root.height + ((root.edge == Qt.TopEdge || root.edge == Qt.BottomEdge) ? drawerPage.height : 0) - onWidthChanged: { - if (root.edge == Qt.LeftEdge) { - mainFlickable.contentX = drawerPage.width; - } - } - onHeightChanged: { - if (root.edge == Qt.TopEdge) { - mainFlickable.contentY = drawerPage.Height; - } - } - - Rectangle { - id: drawerPage - anchors { - left: root.edge != Qt.RightEdge ? parent.left : undefined - right: root.edge != Qt.LeftEdge ? parent.right : undefined - top: root.edge != Qt.BottomEdge ? parent.top : undefined - bottom: root.edge != Qt.TopEdge ? parent.bottom : undefined - } - color: Theme.viewBackgroundColor - clip: true - width: root.contentItem ? Math.min(root.contentItem.implicitWidth, root.width - Units.gridUnit * 2) : 0 - height: root.contentItem ? Math.min(root.contentItem.implicitHeight, root.height - Units.gridUnit * 2) : 0 - } - LinearGradient { - width: Units.gridUnit/2 - height: Units.gridUnit/2 - anchors { - right: root.edge == Qt.RightEdge ? drawerPage.left : (root.edge == Qt.LeftEdge ? undefined : parent.right) - left: root.edge == Qt.LeftEdge ? drawerPage.right : (root.edge == Qt.RightEdge ? undefined : parent.left) - top: root.edge == Qt.TopEdge ? drawerPage.bottom : (root.edge == Qt.BottomEdge ? undefined : parent.top) - bottom: root.edge == Qt.BottomEdge ? drawerPage.top : (root.edge == Qt.TopEdge ? undefined : parent.bottom) - } - - opacity: root.position == 0 ? 0 : 1 - start: Qt.point(0, 0) - end: (root.edge == Qt.RightEdge || root.edge == Qt.LeftEdge) ? Qt.point(Units.gridUnit/2, 0) : Qt.point(0, Units.gridUnit/2) - gradient: Gradient { - GradientStop { - position: 0.0 - color: root.edge == Qt.LeftEdge ? Qt.rgba(0, 0, 0, 0.3) : "transparent" - } - GradientStop { - position: root.edge == Qt.LeftEdge ? 0.3 : 0.7 - color: Qt.rgba(0, 0, 0, 0.15) - } - GradientStop { - position: 1.0 - color: root.edge == Qt.LeftEdge ? "transparent" : Qt.rgba(0, 0, 0, 0.3) - } - } - Behavior on opacity { - NumberAnimation { - duration: Units.longDuration - easing.type: Easing.InOutQuad - } - } - } - } - } - } -} diff --git a/qt-mobile/qml/mobilecomponents/Page.qml b/qt-mobile/qml/mobilecomponents/Page.qml deleted file mode 100644 index 9220357e6..000000000 --- a/qt-mobile/qml/mobilecomponents/Page.qml +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.2 -import org.kde.plasma.mobilecomponents 0.2 -import "private" - -Rectangle { - 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 contextual actions for the page: - * an easy way to assign actions in the right sliding panel - */ - property list contextualActions - - - Layout.fillWidth: true - color: "transparent" -} diff --git a/qt-mobile/qml/mobilecomponents/PageRow.qml b/qt-mobile/qml/mobilecomponents/PageRow.qml deleted file mode 100644 index b69b39c8f..000000000 --- a/qt-mobile/qml/mobilecomponents/PageRow.qml +++ /dev/null @@ -1,513 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Marco Martin -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Components project. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Controls 1.0 -import QtQuick.Layouts 1.2 -import org.kde.plasma.mobilecomponents 0.2 - -import "private/PageStack.js" as Engine - -Item { - id: actualRoot - - width: parent ? parent.width : 0 - height: parent ? parent.height : 0 - - - property int depth: Engine.getDepth() - property Item currentPage: null - property Item lastVisiblePage: currentPage - property ToolBar toolBar - property variant initialPage - //A column is wide enough for 30 characters - property int columnWidth: Math.round(parent.width/(Units.gridUnit*30)) > 0 ? parent.width/Math.round(parent.width/(Units.gridUnit*30)) : width - property alias clip: scrollArea.clip - - // Indicates whether there is an ongoing page transition. - property bool busy: internal.ongoingTransitionCount > 0 - - // Pushes a page on the stack. - // The page can be defined as a component, item or string. - // If an item is used then the page will get re-parented. - // If a string is used then it is interpreted as a url that is used to load a page component. - // - // The page can also be given as an array of pages. In this case all those pages will be pushed - // onto the stack. The items in the stack can be components, items or strings just like for single - // pages. Additionally an object can be used, which specifies a page and an optional properties - // property. This can be used to push multiple pages while still giving each of them properties. - // When an array is used the transition animation will only be to the last page. - // - // The properties argument is optional and allows defining a map of properties to set on the page. - // If the immediate argument is true then no transition animation is performed. - // Returns the page instance. - function push(page, properties, immediate) - { - pop(lastVisiblePage, true); - scrollAnimation.running = false; - var item = Engine.push(page, properties, false, immediate) - scrollToLevel(depth) - return item - } - - // Pops a page off the stack. - // If page is specified then the stack is unwound to that page, to unwind to the first page specify - // page as null. If the immediate argument is true then no transition animation is performed. - // Returns the page instance that was popped off the stack. - function pop(page, immediate) - { - scrollToLevel(depth-1); - return Engine.pop(page, immediate); - } - - // Replaces a page on the stack. - // See push() for details. - function replace(page, properties, immediate) - { - pop(lastVisiblePage, true); - scrollAnimation.running = false; - var item = Engine.push(page, properties, true, immediate); - scrollToLevel(depth) - return item - } - - // Clears the page stack. - function clear() - { - return Engine.clear(); - } - - // Iterates through all pages (top to bottom) and invokes the specified function. - // If the specified function returns true the search stops and the find function - // returns the page that the iteration stopped at. If the search doesn't result - // in any page being found then null is returned. - function find(func) - { - return Engine.find(func); - } - - // Scroll the view to have the page of the given level as first item - function scrollToLevel(level) - { - if (level < 0 || level > depth || root.width < width) { - return - } - - var firstLevel = Math.max(0, level - mainFlickable.width/columnWidth + 1); - scrollAnimation.to = Math.max(0, Math.min(Math.max(0, columnWidth * (firstLevel - 1)), mainFlickable.contentWidth)); - scrollAnimation.running = true; - } - - SequentialAnimation { - id: scrollAnimation - property alias to: actualScrollAnimation.to - NumberAnimation { - id: actualScrollAnimation - target: mainFlickable - properties: "contentX" - duration: internal.transitionDuration - easing.type: Easing.InOutQuad - } - ScriptAction { - script: { - //At startup sometimes the contentX is NaN for an instant - if (isNaN(mainFlickable.contentX)) { - return; - } - - actualRoot.lastVisiblePage = root.children[Math.floor((mainFlickable.contentX + mainFlickable.width - 1)/columnWidth)].page; - if (!actualRoot.lastVisiblePage) { - actualRoot.lastVisiblePage = actualRoot.currentPage; - } - } - } - } - - // Called when the page stack visibility changes. - onVisibleChanged: { - if (currentPage) { - if (visible) - currentPage.visible = currentPage.parent.visible = true; - } - } - - onInitialPageChanged: { - if (!internal.completed) { - return - } - - if (initialPage) { - if (depth == 0) { - push(initialPage, null, true) - } else if (depth == 1) { - replace(initialPage, null, true) - } else { - console.log("Cannot update PageStack.initialPage") - } - } - } - - onWidthChanged: { - var firstLevel = Math.max(0, depth - mainFlickable.width/columnWidth + 1); - mainFlickable.contentX = Math.max(0, Math.min(Math.max(0, columnWidth * (firstLevel - 1)), mainFlickable.contentWidth)); - } - Component.onCompleted: { - internal.completed = true - if (initialPage && depth == 0) - push(initialPage, null, true) - } - - QtObject { - id: internal - - // The number of ongoing transitions. - property int ongoingTransitionCount: 0 - - //FIXME: there should be a way to access to theh without storing it in an ugly way - property bool completed: false - - // Duration of transition animation (in ms) - property int transitionDuration: Units.longDuration - } - - ScrollView { - id: scrollArea - anchors.fill: parent - Flickable { - id: mainFlickable - anchors.fill: parent - interactive: root.width > width - boundsBehavior: Flickable.StopAtBounds - contentWidth: root.width - contentHeight: height - Row { - id: root - spacing: -Units.gridUnit * 8 - width: Math.max((depth-1+children[children.length-1].takenColumns) * columnWidth, childrenRect.width - Units.gridUnit * 8) - - height: parent.height - Behavior on width { - NumberAnimation { - duration: internal.transitionDuration - easing.type: Easing.InOutQuad - } - } - } - onMovementEnded: { - scrollToLevel(Math.round(contentX/columnWidth)+1) - } - onFlickEnded: { - movementEnded(); - } - } - } - - // Component for page containers. - Component { - id: containerComponent - - Item { - id: container - - implicitWidth: actualContainer.width + Units.gridUnit * 8 - width: implicitWidth - height: parent ? parent.height : 0 - - x: 0 - - // The actual parent of page: page will anchor to that - property Item pageParent: actualContainer - - property int pageDepth: 0 - Component.onCompleted: { - pageDepth = Engine.getDepth() + 1 - container.z = -Engine.getDepth() - } - - // The states correspond to the different possible positions of the container. - state: "Hidden" - - // The page held by this container. - property Item page: null - - // The owner of the page. - property Item owner: null - - // The width of the longer stack dimension - property int stackWidth: Math.max(actualRoot.width, actualRoot.height) - - - // Flag that indicates the container should be cleaned up after the transition has ended. - property bool cleanupAfterTransition: false - - // Flag that indicates if page transition animation is running - property bool transitionAnimationRunning: false - - // State to be set after previous state change animation has finished - property string pendingState: "none" - - //how many columns take the page? - property alias takenColumns: actualContainer.takenColumns - - // Ensures that transition finish actions are executed - // in case the object is destroyed before reaching the - // end state of an ongoing transition - Component.onDestruction: { - if (transitionAnimationRunning) - transitionEnded(); - } - - Item { - id: actualContainer - - anchors { - top: parent.top - bottom: parent.bottom - right: parent.right - rightMargin: Units.gridUnit * 8 - } - - property int takenColumns: { - if (container.page && container.page.Layout && container.page.Layout.fillWidth) { - return Math.max(1, Math.round(actualRoot.width/columnWidth)-(container.x > 0 ? 1: 0)); - } else { - return Math.max(1, Math.round(container.page ? container.page.implicitWidth/columnWidth : 1)); - } - } - - width: (container.pageDepth >= actualRoot.depth ? Math.min(actualRoot.width, takenColumns*columnWidth) : columnWidth) - } - - Rectangle { - anchors { - top: parent.top - bottom: parent.bottom - right: actualContainer.right - } - width: 1 - color: Theme.textColor - opacity: 0.3 - visible: container.pageDepth < actualRoot.depth - } - - // Sets pending state as current if state change is delayed - onTransitionAnimationRunningChanged: { - if (!transitionAnimationRunning && pendingState != "none") { - state = pendingState; - pendingState = "none"; - } - } - - // Handles state change depening on transition animation status - function setState(newState) - { - if (transitionAnimationRunning) - pendingState = newState; - else - state = newState; - } - - // Performs a push enter transition. - function pushEnter(immediate, orientationChanges) - { - if (!immediate) { - setState("Right"); - } - setState(""); - page.visible = true; - } - - // Performs a push exit transition. - function pushExit(replace, immediate, orientationChanges) - { - if (replace) { - setState(immediate ? "Hidden" : "Left"); - } - - if (replace) { - if (immediate) - cleanup(); - else - cleanupAfterTransition = true; - } - } - - // Performs a pop enter transition. - function popEnter(immediate, orientationChanges) - { - setState(""); - page.visible = true; - } - - // Performs a pop exit transition. - function popExit(immediate, orientationChanges) - { - setState(immediate ? "Hidden" : "Left"); - - if (immediate) - cleanup(); - else - cleanupAfterTransition = true; - } - - // Called when a transition has started. - function transitionStarted() - { - container.clip = true - transitionAnimationRunning = true; - internal.ongoingTransitionCount++; - } - - // Called when a transition has ended. - function transitionEnded() - { - container.clip = false - if (state != "") - state = "Hidden"; - - internal.ongoingTransitionCount--; - transitionAnimationRunning = false; - - if (cleanupAfterTransition) { - cleanup(); - } - } - - states: [ - // Explicit properties for default state. - State { - name: "" - PropertyChanges { target: container; visible: true; opacity: 1 } - PropertyChanges { target: container; width: container.implicitWidth} - }, - // Start state for pop entry, end state for push exit. - State { - name: "Left" - PropertyChanges { target: container; opacity: 0 } - PropertyChanges { target: container; width: Units.gridUnit * 8} - }, - // Start state for push entry, end state for pop exit. - State { - name: "Right" - PropertyChanges { target: container; opacity: 0 } - PropertyChanges { target: container; width: Units.gridUnit * 8} - }, - // Inactive state. - State { - name: "Hidden" - PropertyChanges { target: container; visible: false } - PropertyChanges { target: container; width: container.implicitWidth} - } - ] - - transitions: [ - // Push exit transition - Transition { - from: ""; to: "Left" - SequentialAnimation { - ScriptAction { script: transitionStarted() } - ParallelAnimation { - PropertyAnimation { properties: "width"; easing.type: Easing.InQuad; duration: internal.transitionDuration } - PropertyAnimation { properties: "opacity"; easing.type: Easing.InQuad; duration: internal.transitionDuration } - } - ScriptAction { script: transitionEnded() } - } - }, - // Pop entry transition - Transition { - from: "Left"; to: "" - SequentialAnimation { - ScriptAction { script: transitionStarted() } - ParallelAnimation { - PropertyAnimation { properties: "width"; easing.type: Easing.OutQuad; duration: internal.transitionDuration } - PropertyAnimation { properties: "opacity"; easing.type: Easing.InQuad; duration: internal.transitionDuration } - } - ScriptAction { script: transitionEnded() } - } - }, - // Pop exit transition - Transition { - from: ""; to: "Right" - SequentialAnimation { - ScriptAction { script: transitionStarted() } - ParallelAnimation { - PropertyAnimation { properties: "width"; easing.type: Easing.InQuad; duration: internal.transitionDuration } - PropertyAnimation { properties: "opacity"; easing.type: Easing.InQuad; duration: internal.transitionDuration } - } - // Workaround for transition animation bug causing ghost view with page pop transition animation - // TODO: Root cause still unknown - PropertyAnimation {} - ScriptAction { script: transitionEnded() } - } - }, - // Push entry transition - Transition { - from: "Right"; to: "" - SequentialAnimation { - ScriptAction { script: transitionStarted() } - ParallelAnimation { - PropertyAnimation { properties: "width"; easing.type: Easing.OutQuad; duration: internal.transitionDuration } - PropertyAnimation { properties: "opacity"; easing.type: Easing.InQuad; duration: internal.transitionDuration } - } - ScriptAction { script: transitionEnded() } - } - } - ] - - // Cleans up the container and then destroys it. - function cleanup() - { - if (page != null) { - if (owner != container) { - // container is not the owner of the page - re-parent back to original owner - page.visible = false; - page.anchors.fill = undefined - page.parent = owner; - } - } - container.parent = null; - container.visible = false; - destroy(); - } - } - } -} diff --git a/qt-mobile/qml/mobilecomponents/SplitDrawer.qml b/qt-mobile/qml/mobilecomponents/SplitDrawer.qml deleted file mode 100644 index 813eae10c..000000000 --- a/qt-mobile/qml/mobilecomponents/SplitDrawer.qml +++ /dev/null @@ -1,234 +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 QtGraphicalEffects 1.0 -import org.kde.plasma.mobilecomponents 0.2 -import "private" - -/**Documented API -Inherits: - Item - -Imports: - QtQuick 2.1 - -Description: - Split Drawers are used to expose additional UI elements which are optional and can be used in conjunction with the main UI elements. For example the Resource Browser uses a Split Drawer to select different kinds of filters for the main view. - -Properties: - bool open: - If true the drawer is open showing the contents of the "drawer" component. - - Item page: - It's the default property. it's the main content of the drawer page, the part that is always shown - - Item drawer: - It's the part that can be pulled in and out, will act as a sidebar. - - int visibleDrawerWidth: the width of the visible portion of the drawer: it updates while dragging or animating -**/ -AbstractDrawer { - id: root - anchors { - fill: parent - } - visible: true - - default property alias page: mainPage.data - property Item contentItem - property alias opened: sidebar.open - property int visibleDrawerWidth: browserFrame.x - - Component.onCompleted: { - mainPage.width = browserFrame.width - } - - onContentItemChanged: contentItem.parent = drawerPage - MouseArea { - id: mouseEventListener - z: 200 - drag.filterChildren: true - //drag.target: browserFrame - property int startMouseX - property int oldMouseX - property int startBrowserFrameX - property bool toggle: false - property string startState - - anchors.fill: parent - - onPressed: { - if (drawerPage.children.length == 0 || (browserFrame.state == "Closed" && mouse.x > Units.gridUnit) || - mouse.x < browserFrame.x) { - mouse.accepted = false; - return; - } - - toggle = true; - startBrowserFrameX = browserFrame.x; - oldMouseX = startMouseX = mouse.x; - startState = browserFrame.state; - browserFrame.state = "Dragging"; - browserFrame.x = startBrowserFrameX; - } - - onPositionChanged: { - browserFrame.x = Math.max(0, browserFrame.x + mouse.x - oldMouseX); - oldMouseX = mouse.x; - if (Math.abs(mouse.x - startMouseX) > Units.gridUnit * 2) { - toggle = false; - } - } - - onReleased: { - if (toggle) { - browserFrame.state = startState == "Open" ? "Closed" : "Open" - } else if (browserFrame.x < sidebar.width / 2) { - browserFrame.state = "Closed"; - } else { - browserFrame.state = "Open"; - } - } - onClicked: root.clicked() - } - - Rectangle { - id: browserFrame - z: 100 - color: Theme.backgroundColor - state: "Closed" - onStateChanged: sidebar.open = (state != "Closed") - - anchors { - top: parent.top - bottom: parent.bottom - } - width: root.width; - - Item { - id: mainPage - onChildrenChanged: mainPage.children[0].anchors.fill = mainPage - - anchors.fill: parent - } - - Rectangle { - anchors.fill: parent - color: "black" - opacity: Math.min(0.4, 0.4 * (browserFrame.x / sidebar.width)) - } - LinearGradient { - width: Units.gridUnit/2 - anchors { - right: parent.left - top: parent.top - bottom: parent.bottom - rightMargin: -1 - } - start: Qt.point(0, 0) - end: Qt.point(Units.gridUnit/2, 0) - gradient: Gradient { - GradientStop { - position: 0.0 - color: "transparent" - } - GradientStop { - position: 0.7 - color: Qt.rgba(0, 0, 0, 0.15) - } - GradientStop { - position: 1.0 - color: Qt.rgba(0, 0, 0, 0.3) - } - } - } - - states: [ - State { - name: "Open" - PropertyChanges { - target: browserFrame - x: sidebar.width - } - - }, - State { - name: "Dragging" - PropertyChanges { - target: browserFrame - x: mouseEventListener.startBrowserFrameX - } - }, - State { - name: "Closed" - PropertyChanges { - target: browserFrame - x: 0 - } - } - ] - - transitions: [ - Transition { - //Exclude Dragging - to: "Open,Closed,Hidden" - NumberAnimation { - properties: "x" - duration: Units.longDuration - easing.type: Easing.InOutQuad - } - } - ] - } - - - Item { - id: sidebar - - property bool open: false - onOpenChanged: { - if (drawerPage.children.length == 0) { - return; - } - - if (open) { - browserFrame.state = "Open"; - } else { - browserFrame.state = "Closed"; - } - } - - width: Math.min(parent.width/4*3, Math.max(root.contentItem ? root.contentItem.implicitWidth : 0, parent.width/4)) - - anchors { - left: parent.left - top: parent.top - bottom: parent.bottom - } - - Item { - id: drawerPage - anchors.fill: parent - clip: false - onChildrenChanged: drawerPage.children[0].anchors.fill = drawerPage - } - } -} - diff --git a/qt-mobile/qml/mobilecomponents/Theme.qml b/qt-mobile/qml/mobilecomponents/Theme.qml deleted file mode 100644 index 402caedb6..000000000 --- a/qt-mobile/qml/mobilecomponents/Theme.qml +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.4 - -pragma Singleton - -/*! - \qmltype Theme - \inqmlmodule Material 0.1 - - \brief Provides access to standard colors that follow the Material Design specification. - - See \l {http://www.google.com/design/spec/style/color.html#color-ui-color-application} for - details about choosing a color scheme for your application. - */ -QtObject { - id: theme - - property color textColor: Qt.rgba(0,0,0, 0.54) - - property color highlightColor: "#2196F3" - property color backgroundColor: "#eff0f1" - property color linkColor: "#2196F3" - property color visitedLinkColor: "#2196F3" - - property color buttonTextColor: Qt.rgba(0,0,0, 0.54) - property color buttonBackgroundColor: "#eff0f1" - property color buttonHoverColor: "#2196F3" - property color buttonFocusColor: "#2196F3" - - property color viewTextColor: Qt.rgba(0,0,0, 0.54) - property color viewBackgroundColor: "#fcfcfc" - property color viewHoverColor: "#2196F3" - property color viewFocusColor: "#2196F3" - - property color complementaryTextColor: "#f3f3f3" - property color complementaryBackgroundColor: Qt.rgba(0,0,0, 0.54) - property color complementaryHoverColor: "#2196F3" - property color complementaryFocusColor: "#2196F3" - - property font defaultFont: fontMetrics.font - - property variant fontMetrics: TextMetrics {} - -} diff --git a/qt-mobile/qml/mobilecomponents/Units.qml b/qt-mobile/qml/mobilecomponents/Units.qml deleted file mode 100644 index 8b5032a71..000000000 --- a/qt-mobile/qml/mobilecomponents/Units.qml +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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.4 -import QtQuick.Window 2.2 - -pragma Singleton - - -QtObject { - id: units - - /** - * The fundamental unit of space that should be used for sizes, expressed in pixels. - * Given the screen has an accurate DPI settings, it corresponds to a width of - * the capital letter M - */ - property int gridUnit: fontMetrics.height - - /** - * units.iconSizes provides access to platform-dependent icon sizing - * - * The icon sizes provided are normalized for different DPI, so icons - * will scale depending on the DPI. - * - * Icon sizes from KIconLoader, adjusted to devicePixelRatio: - * * small - * * smallMedium - * * medium - * * large - * * huge - * * enormous - * - * Not devicePixelRation-adjusted:: - * * desktop - */ - property QtObject iconSizes: QtObject { - property int small: 16 * devicePixelRatio - property int smallMedium: 22 * devicePixelRatio - property int medium: 32 * devicePixelRatio - property int large: 48 * devicePixelRatio - property int huge: 64 * devicePixelRatio - property int enormous: 128 * devicePixelRatio - } - - /** - * units.smallSpacing is the amount of spacing that should be used around smaller UI elements, - * for example as spacing in Columns. Internally, this size depends on the size of - * the default font as rendered on the screen, so it takes user-configured font size and DPI - * into account. - */ - property int smallSpacing: gridUnit/4 - - /** - * units.largeSpacing is the amount of spacing that should be used inside bigger UI elements, - * for example between an icon and the corresponding text. Internally, this size depends on - * the size of the default font as rendered on the screen, so it takes user-configured font - * size and DPI into account. - */ - property int largeSpacing: gridUnit - - /** - * The ratio between physical and device-independent pixels. This value does not depend on the \ - * size of the configured font. If you want to take font sizes into account when scaling elements, - * use theme.mSize(theme.defaultFont), units.smallSpacing and units.largeSpacing. - * The devicePixelRatio follows the definition of "device independent pixel" by Microsoft. - */ - property real devicePixelRatio: fontMetrics.height / fontMetrics.font.pointSize - - /** - * units.longDuration should be used for longer, screen-covering animations, for opening and - * closing of dialogs and other "not too small" animations - */ - property int longDuration: 250 - - /** - * units.shortDuration should be used for short animations, such as accentuating a UI event, - * hover events, etc.. - */ - property int shortDuration: 150 - - property variant fontMetrics: TextMetrics { - text: "M" - } -} diff --git a/qt-mobile/qml/mobilecomponents/icons/dialog-cancel.svg b/qt-mobile/qml/mobilecomponents/icons/dialog-cancel.svg deleted file mode 100644 index a2b022a9d..000000000 --- a/qt-mobile/qml/mobilecomponents/icons/dialog-cancel.svg +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - diff --git a/qt-mobile/qml/mobilecomponents/icons/distribute-horizontal-x.svg b/qt-mobile/qml/mobilecomponents/icons/distribute-horizontal-x.svg deleted file mode 100644 index 1a14480d7..000000000 --- a/qt-mobile/qml/mobilecomponents/icons/distribute-horizontal-x.svg +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/qt-mobile/qml/mobilecomponents/icons/document-edit.svg b/qt-mobile/qml/mobilecomponents/icons/document-edit.svg deleted file mode 100644 index 805446a72..000000000 --- a/qt-mobile/qml/mobilecomponents/icons/document-edit.svg +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/qt-mobile/qml/mobilecomponents/icons/document-save.svg b/qt-mobile/qml/mobilecomponents/icons/document-save.svg deleted file mode 100644 index f400f3a9e..000000000 --- a/qt-mobile/qml/mobilecomponents/icons/document-save.svg +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - diff --git a/qt-mobile/qml/mobilecomponents/icons/go-next.svg b/qt-mobile/qml/mobilecomponents/icons/go-next.svg deleted file mode 100644 index fe4e783de..000000000 --- a/qt-mobile/qml/mobilecomponents/icons/go-next.svg +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - diff --git a/qt-mobile/qml/mobilecomponents/icons/go-previous.svg b/qt-mobile/qml/mobilecomponents/icons/go-previous.svg deleted file mode 100644 index 743ff18e2..000000000 --- a/qt-mobile/qml/mobilecomponents/icons/go-previous.svg +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - diff --git a/qt-mobile/qml/mobilecomponents/icons/view-readermode.svg b/qt-mobile/qml/mobilecomponents/icons/view-readermode.svg deleted file mode 100644 index c24c574a5..000000000 --- a/qt-mobile/qml/mobilecomponents/icons/view-readermode.svg +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/qt-mobile/qml/mobilecomponents/private/AbstractDrawer.qml b/qt-mobile/qml/mobilecomponents/private/AbstractDrawer.qml deleted file mode 100644 index db662509c..000000000 --- a/qt-mobile/qml/mobilecomponents/private/AbstractDrawer.qml +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 QtGraphicalEffects 1.0 -import org.kde.plasma.mobilecomponents 0.2 - -//TODO: This will become a QQC2 Drawer -//providing just a dummy api for now -Item { - id: root - anchors.fill: parent - z: 9999 - - default property alias page: mainPage.data - property Item contentItem - property bool opened - property int edge: Qt.LeftEdge - property real position: 0 - - function open () { } - function close () { } - signal clicked - - Item { - id: mainPage - anchors.fill: parent - onChildrenChanged: mainPage.children[0].anchors.fill = mainPage - } -} - diff --git a/qt-mobile/qml/mobilecomponents/private/ActionButton.qml b/qt-mobile/qml/mobilecomponents/private/ActionButton.qml deleted file mode 100644 index c6963c285..000000000 --- a/qt-mobile/qml/mobilecomponents/private/ActionButton.qml +++ /dev/null @@ -1,192 +0,0 @@ -/* - * 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.2 -import QtGraphicalEffects 1.0 -import org.kde.plasma.mobilecomponents 0.2 - -MouseArea { - id: button - property alias iconSource: icon.source - property bool checkable: false - property bool checked: false - //either Action or QAction should work here - property QtObject action - Layout.minimumWidth: Units.iconSizes.medium - Layout.maximumWidth: Layout.minimumWidth - implicitWidth: Units.iconSizes.medium - implicitHeight: width - drag { - target: button - axis: Drag.XAxis - minimumX: parent.width/2 - width/2 - (contextDrawer && contextDrawer.enabled ? contextDrawer.contentItem.width : 0) - maximumX: parent.width/2 - width/2 + (globalDrawer && globalDrawer.enabled ? globalDrawer.contentItem.width : 0) - } - function toggleVisibility() { - showAnimation.running = false; - if (translateTransform.y < button.height) { - showAnimation.to = button.height; - } else { - showAnimation.to = 0; - } - showAnimation.running = true; - } - - transform: Translate { - id: translateTransform - } - property var downTimestamp; - property int startX - onPressed: { - downTimestamp = (new Date()).getTime(); - startX = button.x - } - onReleased: { - //pixel/second - var speed = ((button.x - startX) / ((new Date()).getTime() - downTimestamp) * 1000); - - //project where it would be a full second in the future - if (globalDrawer && x + speed > Math.min(parent.width/4*3, parent.width/2 + globalDrawer.contentItem.width/2)) { - globalDrawer.open(); - contextDrawer.close(); - } else if (contextDrawer && x + speed < Math.max(parent.width/4, parent.width/2 - contextDrawer.contentItem.width/2)) { - if (contextDrawer) { - contextDrawer.open(); - } - if (globalDrawer) { - globalDrawer.close(); - } - } else { - if (globalDrawer) { - globalDrawer.close(); - } - if (contextDrawer) { - contextDrawer.close(); - } - } - } - onClicked: { - if (checkable) { - checked = !checked; - } - - //if an action has been assigned, trigger it - if (button.action && button.action.trigger) { - button.action.trigger(); - } - } - Connections { - target: globalDrawer - onPositionChanged: { - if (!button.pressed) { - button.x = globalDrawer.contentItem.width * globalDrawer.position + button.parent.width/2 - button.width/2; - } - } - } - Connections { - target: contextDrawer - onPositionChanged: { - if (!button.pressed) { - button.x = button.parent.width/2 - button.width/2 - contextDrawer.contentItem.width * contextDrawer.position; - } - } - } - Connections { - target: button.parent - onWidthChanged: button.x = button.parent.width/2 - button.width/2 - } - onXChanged: { - if (button.pressed) { - if (globalDrawer) { - globalDrawer.position = Math.min(1, Math.max(0, (x - button.parent.width/2 + button.width/2)/globalDrawer.contentItem.width)); - } - if (contextDrawer) { - contextDrawer.position = Math.min(1, Math.max(0, (button.parent.width/2 - button.width/2 - x)/contextDrawer.contentItem.width)); - } - } - } - - NumberAnimation { - id: showAnimation - target: translateTransform - properties: "y" - duration: Units.longDuration - easing.type: Easing.InOutQuad - } - Item { - id: background - anchors { - fill: parent - leftMargin: -Units.gridUnit - rightMargin: -Units.gridUnit - } - Rectangle { - radius: width/2 - anchors.centerIn: parent - height: parent.height - Units.smallSpacing*2 - width: height - color: button.pressed || button.checked ? Theme.highlightColor : Theme.backgroundColor - Icon { - id: icon - anchors { - fill: parent - margins: Units.smallSpacing - } - } - ActionButtonArrow { - anchors { - right: parent.left - rightMargin: Units.smallSpacing - } - visible: contextDrawer && contextDrawer.enabled - inverted: true - } - ActionButtonArrow { - anchors { - left: parent.right - leftMargin: Units.smallSpacing - } - visible: globalDrawer && globalDrawer.enabled - } - Behavior on color { - ColorAnimation { - duration: Units.longDuration - easing.type: Easing.InOutQuad - } - } - Behavior on x { - NumberAnimation { - duration: Units.longDuration - easing.type: Easing.InOutQuad - } - } - } - } - DropShadow { - anchors.fill: background - horizontalOffset: 0 - verticalOffset: Units.smallSpacing/3 - radius: Units.gridUnit / 3.5 - samples: 16 - color: button.pressed ? "transparent" : Qt.rgba(0, 0, 0, 0.5) - source: background - } -} - diff --git a/qt-mobile/qml/mobilecomponents/private/ActionButtonArrow.qml b/qt-mobile/qml/mobilecomponents/private/ActionButtonArrow.qml deleted file mode 100644 index 7b585452b..000000000 --- a/qt-mobile/qml/mobilecomponents/private/ActionButtonArrow.qml +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.2 -import QtGraphicalEffects 1.0 -import org.kde.plasma.mobilecomponents 0.2 - -Canvas { - id: canvas - width: Units.gridUnit - height: width - property bool inverted - property color color: parent.color - anchors.verticalCenter: parent.verticalCenter - - onColorChanged: requestPaint() - - onPaint: { - var ctx = canvas.getContext("2d"); - ctx.fillStyle = canvas.color; - ctx.beginPath(); - if (inverted) { - ctx.moveTo(canvas.width, 0); - ctx.bezierCurveTo(canvas.width-canvas.width/8, 0, - canvas.width-canvas.width/8, canvas.height, - canvas.width, canvas.height); - ctx.lineTo(0, canvas.height/2); - } else { - ctx.moveTo(0, 0); - ctx.bezierCurveTo(canvas.width/8, 0, - canvas.width/8, canvas.height, - 0, canvas.height); - ctx.lineTo(canvas.width, canvas.height/2); - //ctx.lineTo(0, canvas.height); - } - ctx.fill(); - } -} - diff --git a/qt-mobile/qml/mobilecomponents/private/PageStack.js b/qt-mobile/qml/mobilecomponents/private/PageStack.js deleted file mode 100644 index 8986956b0..000000000 --- a/qt-mobile/qml/mobilecomponents/private/PageStack.js +++ /dev/null @@ -1,243 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Components project. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// Page stack. Items are page containers. -var pageStack = []; - -// Page component cache map. Key is page url, value is page component. -var componentCache = {}; - -// Returns the page stack depth. -function getDepth() { - return pageStack.length; -} - -// Pushes a page on the stack. -function push(page, properties, replace, immediate) { - // page order sanity check - if ((!replace && page == currentPage) - || (replace && pageStack.length > 1 - && page == pageStack[pageStack.length - 2].page)) { - throw new Error("Cannot navigate so that the resulting page stack has two consecutive entries of the same page instance."); - } - - // figure out if more than one page is being pushed - var pages; - if (page instanceof Array) { - pages = page; - page = pages.pop(); - if (page.createObject === undefined && page.parent === undefined && typeof page != "string") { - properties = properties || page.properties; - page = page.page; - } - } - - // get the current container - var oldContainer; - if (pageStack.length) { - oldContainer = pageStack[pageStack.length - 1]; - } - - // pop the old container off the stack if this is a replace - if (oldContainer && replace) { - pageStack.pop(); - } - - // push any extra defined pages onto the stack - if (pages) { - var i; - for (i = 0; i < pages.length; i++) { - var tPage = pages[i]; - var tProps; - if (tPage.createObject === undefined && tPage.parent === undefined && typeof tPage != "string") { - tProps = tPage.properties; - tPage = tPage.page; - } - pageStack.push(initPage(tPage, tProps)); - } - } - - // initialize the page - var container = initPage(page, properties); - - // push the page container onto the stack - pageStack.push(container); - - depth = pageStack.length; - currentPage = container.page; - - // perform page transition - //FIXME: this should be in for PageStack, out for PageRow? - //immediate = immediate || !oldContainer; - var orientationChange = false; - if (oldContainer) { - orientationChange = orientationChanges(oldContainer.page, container.page); - oldContainer.pushExit(replace, immediate, orientationChange); - } - - // sync tool bar - var tools = container.page.tools || null; - if (toolBar) { - toolBar.setTools(tools, immediate ? "set" : replace ? "replace" : "push"); - } - - container.pushEnter(immediate, orientationChange); - return container.page; -} - -// Initializes a page and its container. -function initPage(page, properties) { - var container = containerComponent.createObject(root); - - var pageComp; - if (page.createObject) { - // page defined as component - pageComp = page; - } else if (typeof page == "string") { - // page defined as string (a url) - pageComp = componentCache[page]; - if (!pageComp) { - pageComp = componentCache[page] = Qt.createComponent(page); - } - } - if (pageComp) { - if (pageComp.status == Component.Error) { - throw new Error("Error while loading page: " + pageComp.errorString()); - } else { - // instantiate page from component - page = pageComp.createObject(container.pageParent, properties || {}); - } - } else { - // copy properties to the page - for (var prop in properties) { - if (properties.hasOwnProperty(prop)) { - page[prop] = properties[prop]; - } - } - } - - container.page = page; - if (page.parent == null || page.parent == container.pageParent) { - container.owner = container; - } else { - container.owner = page.parent; - } - - // the page has to be reparented if - if (page.parent != container.pageParent) { - page.parent = container.pageParent; - } - - if (page.pageStack !== undefined) { - page.pageStack = root; - } - - page.anchors.fill = container.pageParent - - return container; -} - -// Pops a page off the stack. -function pop(page, immediate) { - // make sure there are enough pages in the stack to pop - if (pageStack.length > 1) { - //unwind to itself means no pop - if (page !== undefined && page == pageStack[pageStack.length - 1].page) { - return - } - // pop the current container off the stack and get the next container - var oldContainer = pageStack.pop(); - var container = pageStack[pageStack.length - 1]; - if (page !== undefined) { - // an unwind target has been specified - pop until we find it - while (page != container.page && pageStack.length > 1) { - pageStack.pop(); - container.popExit(immediate, false); - container = pageStack[pageStack.length - 1]; - } - } - - depth = pageStack.length; - currentPage = container.page; - - // perform page transition - var orientationChange = orientationChanges(oldContainer.page, container.page); - oldContainer.popExit(immediate, orientationChange); - container.popEnter(immediate, orientationChange); - - // sync tool bar - var tools = container.page.tools || null; - if (toolBar) { - toolBar.setTools(tools, immediate ? "set" : "pop"); - } - return oldContainer.page; - } else { - return null; - } -} - -// Checks if the orientation changes between oldPage and newPage -function orientationChanges(oldPage, newPage) { - return newPage.orientationLock != 0 //PlasmaComponents.PageOrientation.Automatic - && newPage.orientationLock != 3//PlasmaComponents.PageOrientation.LockPrevious - && newPage.orientationLock != oldPage.orientationLock -} - -// Clears the page stack. -function clear() { - var container; - while (container = pageStack.pop()) { - container.cleanup(); - } - depth = 0; - currentPage = null; -} - -// Iterates through all pages in the stack (top to bottom) to find a page. -function find(func) { - for (var i = pageStack.length - 1; i >= 0; i--) { - var page = pageStack[i].page; - if (func(page)) { - return page; - } - } - return null; -} - diff --git a/qt-mobile/qml/mobilecomponents/private/qmldir b/qt-mobile/qml/mobilecomponents/private/qmldir deleted file mode 100644 index 35e158210..000000000 --- a/qt-mobile/qml/mobilecomponents/private/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -module org.kde.plasma.mobilecomponents.private -#plugin mobilecomponentsprivateplugin - diff --git a/qt-mobile/qml/mobilecomponents/qmldir b/qt-mobile/qml/mobilecomponents/qmldir deleted file mode 100644 index 999f823ea..000000000 --- a/qt-mobile/qml/mobilecomponents/qmldir +++ /dev/null @@ -1,21 +0,0 @@ -module org.kde.plasma.mobilecomponents -#plugin mobilecomponentsplugin - -singleton Units 0.2 Units.qml -singleton Theme 0.2 Theme.qml - -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 -Icon 0.2 Icon.qml -Label 0.2 Label.qml -Heading 0.2 Heading.qml -ListItem 0.2 ListItem.qml -BasicListItem 0.2 BasicListItem.qml -ListItemWithActions 0.2 ListItemWithActions.qml -RefreshableScrollView 0.2 RefreshableScrollView.qml diff --git a/scripts/build.sh b/scripts/build.sh index 1ea0e3ef0..9db5c983d 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -23,6 +23,11 @@ exec 1> >(tee build.log) 2>&1 SRC=$(pwd) PLATFORM=$(uname) +# to build Subsurface-mobile on the desktop change this to +# SUBSURFACE_EXECUTABLE=MobileExecutable +SUBSURFACE_EXECUTABLE=DesktopExecutable + + if [[ ! -d "subsurface" ]] ; then echo "please start this script from the directory containing the Subsurface source directory" exit 1 @@ -161,6 +166,49 @@ cmake -DCMAKE_BUILD_TYPE=Release \ make -j4 make install +# pull the plasma-mobile components from upstream if building Subsurface-mobile +if [ "$SUBSURFACE_EXECUTABLE" = "MobileExecutable" ] ; then + # now bring in the latest Plasma-mobile mobile components plus a couple of icons that we need + # first, get the latest from upstream + # yes, this is a bit overkill as we clone a lot of stuff for just a few files, but this way + # we stop having to manually merge our code with upstream all the time + # as we get closer to shipping a production version we'll likely check out specific tags + # or SHAs from upstream + cd $SRC + if [ ! -d plasma-mobile ] ; then + git clone git://github.com/KDE/plasma-mobile + fi + pushd plasma-mobile + git pull + popd + if [ ! -d breeze-icons ] ; then + git clone git://anongit.kde.org/breeze-icons + fi + pushd breeze-icons + git pull + popd + + # now copy the components and a couple of icons into plae + MC=$SRC/subsurface/qt-mobile/qml/mobilecomponents + PMMC=plasma-mobile/components/mobilecomponents + BREEZE=breeze-icons + + rm -rf $MC + mkdir -p $MC/icons + cp -R $PMMC/qml/* $MC/ + cp $PMMC/fallbacktheme/*qml $MC/ + + cp $BREEZE/icons/actions/24/dialog-cancel.svg $MC/icons + cp $BREEZE/icons/actions/24/distribute-horizontal-x.svg $MC/icons + cp $BREEZE/icons/actions/24/document-edit.svg $MC/icons + cp $BREEZE/icons/actions/24/document-save.svg $MC/icons + cp $BREEZE/icons/actions/24/go-next.svg $MC/icons + cp $BREEZE/icons/actions/24/go-previous.svg $MC/icons + cp $BREEZE/icons/actions/16/view-readermode.svg $MC/icons + + echo org.kde.plasma.mobilecomponents synced from upstream +fi + # finally, build Subsurface if [ $PLATFORM = Darwin ] ; then @@ -174,6 +222,7 @@ mkdir -p build cd build export CMAKE_PREFIX_PATH=$INSTALL_ROOT/lib/cmake cmake -DCMAKE_BUILD_TYPE=Debug .. \ + -DSUBSURFACE_TARGET_EXECUTABLE=$SUBSURFACE_EXECUTABLE \ -DLIBGIT2_INCLUDE_DIR=$INSTALL_ROOT/include \ -DLIBGIT2_LIBRARIES=$INSTALL_ROOT/lib/libgit2.$SH_LIB_EXT \ -DLIBDIVECOMPUTER_INCLUDE_DIR=$INSTALL_ROOT/include \