From eb1f73800e83b11e4a5ae93ac069893aa88f0eaa Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 13 May 2016 14:49:08 +0200 Subject: [PATCH] port to kirigami port away from plasma-framework dependencies --- mobile/app/package/contents/ui/Browser.qml | 174 ------------------ mobile/app/package/contents/ui/Documents.qml | 64 +++---- mobile/app/package/contents/ui/MainView.qml | 53 ++++++ .../app/package/contents/ui/OkularDrawer.qml | 68 +++---- .../package/contents/ui/TableOfContents.qml | 26 ++- mobile/app/package/contents/ui/Thumbnails.qml | 12 +- .../package/contents/ui/ThumbnailsBase.qml | 40 ++-- .../app/package/contents/ui/TreeDelegate.qml | 7 +- mobile/app/package/contents/ui/main.qml | 32 +--- 9 files changed, 160 insertions(+), 316 deletions(-) delete mode 100644 mobile/app/package/contents/ui/Browser.qml create mode 100644 mobile/app/package/contents/ui/MainView.qml diff --git a/mobile/app/package/contents/ui/Browser.qml b/mobile/app/package/contents/ui/Browser.qml deleted file mode 100644 index 873a1c0fa..000000000 --- a/mobile/app/package/contents/ui/Browser.qml +++ /dev/null @@ -1,174 +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 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 General Public License for more details - * - * You should have received a copy of the GNU 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 org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.mobilecomponents 0.2 as MobileComponents -import org.kde.kquickcontrolsaddons 2.0 -import org.kde.okular 2.0 as Okular - - -MobileComponents.SplitDrawer { - id: splitDrawer - anchors.fill: parent - visible: true - - property alias splitDrawerOpen: splitDrawer.opened - property alias overlayDrawerOpen: resourceBrowser.opened - property Item globalDrawer: splitDrawer - property Item contextDrawer: resourceDrawer - - //An alias doesn't work - property bool bookmarked: false - onBookmarkedChanged: { - pageArea.page.bookmarked = bookmarked - } - - contentItem: Documents { - implicitWidth: units.gridUnit * 25 - } - - MobileComponents.OverlayDrawer { - id: resourceBrowser - anchors.fill: parent - edge: Qt.RightEdge - - Okular.DocumentView { - id: pageArea - document: documentItem - anchors.fill: parent - - onPageChanged: { - bookmarkConnection.target = page - splitDrawer.bookmarked = page.bookmarked - } - } - //HACK - Connections { - id: bookmarkConnection - target: pageArea.page - onBookmarkedChanged: splitDrawer.bookmarked = pageArea.page.bookmarked - } - - contentItem: Item { - id: browserFrame - anchors.fill: parent - state: "Hidden" - - PlasmaComponents.ToolBar { - id: mainToolBar - - height: units.gridUnit * 2 - y: pageStack.currentPage.contentY <= 0 ? 0 : -height - transform: Translate { - y: Math.max(0, -pageStack.currentPage.contentY) - } - tools: pageStack.currentPage.tools - Behavior on y { - NumberAnimation { - duration: 250 - } - } - anchors { - left: parent.left - right: parent.right - } - } - - - PlasmaComponents.PageStack { - id: pageStack - anchors { - left: parent.left - top: mainToolBar.bottom - right: parent.right - bottom: tabsToolbar.top - } - clip: true - toolBar: mainToolBar - } - - Connections { - id: scrollConnection - property int oldContentY:0 - target: pageStack.currentPage - - onContentYChanged: { - scrollConnection.oldContentY = pageStack.currentPage.contentY - } - } - - PlasmaComponents.ToolBar { - id: tabsToolbar - y: parent.height - tabsToolbar.height*5 - height: mainTabBar.height - anchors { - top: undefined - bottom: browserFrame.bottom - left: parent.left - right: parent.right - } - tools: Item { - width: parent.width - height: childrenRect.height - PlasmaComponents.TabBar { - id: mainTabBar - anchors.horizontalCenter: parent.horizontalCenter - width: Math.min(parent.width, implicitWidth) - tabPosition: Qt.BottomEdge - PlasmaComponents.TabButton { - id: thumbnailsButton - text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Thumbnails") : "" - iconSource: "view-preview" - onCheckedChanged: { - if (checked) { - pageStack.replace(Qt.createComponent("Thumbnails.qml")) - } - } - } - PlasmaComponents.TabButton { - id: tocButton - enabled: documentItem.tableOfContents.count > 0 - text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Table of contents") : "" - iconSource: "view-table-of-contents-ltr" - onCheckedChanged: { - if (checked) { - pageStack.replace(Qt.createComponent("TableOfContents.qml")) - } - } - } - PlasmaComponents.TabButton { - id: bookmarksButton - enabled: documentItem.bookmarkedPages.length > 0 - text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Bookmarks") : "" - iconSource: "bookmarks-organize" - onCheckedChanged: { - if (checked) { - pageStack.replace(Qt.createComponent("Bookmarks.qml")) - } - } - } - } - } - } - } - } -} diff --git a/mobile/app/package/contents/ui/Documents.qml b/mobile/app/package/contents/ui/Documents.qml index d6002e875..f0e4279b2 100644 --- a/mobile/app/package/contents/ui/Documents.qml +++ b/mobile/app/package/contents/ui/Documents.qml @@ -18,45 +18,36 @@ */ import QtQuick 2.1 -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.mobilecomponents 0.2 as MobileComponents +import QtQuick.Controls 1.3 +import org.kde.kirigami 1.0 as Kirigami import Qt.labs.folderlistmodel 2.1 -MobileComponents.Page { +Item { id: root anchors.fill: parent - color: theme.viewBackgroundColor - visible: true + property Item view: filesView property alias contentY: filesView.contentY property alias contentHeight: filesView.contentHeight property alias model: filesView.model - tools: Item { + Item { id: toolBarContent width: root.width - height: searchField.height - PlasmaComponents.TextField { + height: searchField.height + Kirigami.Units.gridUnit + TextField { id: searchField anchors.centerIn: parent - onTextChanged: { - if (text.length > 2) { - filterModel.filterRegExp = ".*" + text + ".*"; - } else { - filterModel.filterRegExp = ""; - } - } + focus: true } } - MobileComponents.Label { + Kirigami.Label { z: 2 visible: filesView.count == 0 anchors { fill: parent - margins: MobileComponents.Units.gridUnit + margins: Kirigami.Units.gridUnit } text: i18n("No Documents found. To start to read, put some files in the Documents folder of your device.") wrapMode: Text.WordWrap @@ -64,31 +55,28 @@ MobileComponents.Page { verticalAlignment: Text.AlignVCenter } - PlasmaExtras.ScrollArea { - anchors.fill: parent + ScrollView { + anchors { + top: toolBarContent.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } ListView { id: filesView anchors.fill: parent - model: PlasmaCore.SortFilterModel { - id: filterModel - filterRole: "fileName" - sourceModel: FolderListModel { - id: folderModel - folder: userPaths.documents - nameFilters: ["*.pdf", "*.txt", "*.chm", "*.epub"] - showDirs: false - } + model: FolderListModel { + id: folderModel + folder: userPaths.documents + nameFilters: ["*.pdf", "*.txt", "*.chm", "*.epub"] + showDirs: false } - delegate: MobileComponents.ListItem { - enabled: true - PlasmaComponents.Label { - text: model.fileName - horizontalAlignment: Text.AlignHCenter - wrapMode: Text.WordWrap - elide: Text.ElideRight - } + delegate: Kirigami.BasicListItem { + label: model.fileName + visible: model.fileName.indexOf(searchField.text) !== -1 + height: visible ? implicitHeight : 0 onClicked: { documentItem.path = model.filePath; globalDrawer.opened = false; diff --git a/mobile/app/package/contents/ui/MainView.qml b/mobile/app/package/contents/ui/MainView.qml new file mode 100644 index 000000000..ec791af53 --- /dev/null +++ b/mobile/app/package/contents/ui/MainView.qml @@ -0,0 +1,53 @@ +/* + * Copyright 2012 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details + * + * You should have received a copy of the GNU 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 org.kde.okular 2.0 as Okular +import org.kde.kirigami 1.0 as Kirigami + +Kirigami.Page { + property alias document: pageArea.document + leftPadding: 0 + topPadding: 0 + rightPadding: 0 + bottomPadding: 0 + + actions.main: Kirigami.Action { + iconName: "bookmarks-organize" + checkable: true + onCheckedChanged: pageArea.page.bookmarked = checked; + } + + Okular.DocumentView { + id: pageArea + anchors.fill: parent + + onPageChanged: { + bookmarkConnection.target = page + actions.main.checked = page.bookmarked + } + onClicked: fileBrowserRoot.controlsVisible = !fileBrowserRoot.controlsVisible + } + + Connections { + id: bookmarkConnection + target: pageArea.page + onBookmarkedChanged: actions.main.checked = pageArea.page.bookmarked + } +} diff --git a/mobile/app/package/contents/ui/OkularDrawer.qml b/mobile/app/package/contents/ui/OkularDrawer.qml index 2fbbd302b..bb2a206a9 100644 --- a/mobile/app/package/contents/ui/OkularDrawer.qml +++ b/mobile/app/package/contents/ui/OkularDrawer.qml @@ -18,68 +18,43 @@ */ import QtQuick 2.1 -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.mobilecomponents 0.2 as MobileComponents +import QtQuick.Controls 1.3 +import org.kde.kirigami 1.0 as Kirigami import org.kde.kquickcontrolsaddons 2.0 import org.kde.okular 2.0 as Okular -MobileComponents.OverlayDrawer { +Kirigami.OverlayDrawer { edge: Qt.RightEdge contentItem: Item { id: browserFrame - implicitWidth: MobileComponents.Units.gridUnit * 25 + implicitWidth: Kirigami.Units.gridUnit * 25 implicitHeight: implicitWidth state: "Hidden" - PlasmaComponents.ToolBar { - id: mainToolBar - - height: units.gridUnit * 2 - y: pageStack.currentPage.contentY <= 0 ? 0 : -height - transform: Translate { - y: Math.max(0, -pageStack.currentPage.contentY) - } - tools: pageStack.currentPage.tools - Behavior on y { - NumberAnimation { - duration: 250 - } - } - anchors { - left: parent.left - right: parent.right - } - } - - - PlasmaComponents.PageStack { + StackView { id: pageStack anchors { left: parent.left - top: mainToolBar.bottom + top: parent.top right: parent.right bottom: tabsToolbar.top } clip: true - toolBar: mainToolBar } Connections { id: scrollConnection property int oldContentY:0 - target: pageStack.currentPage + target: pageStack.currentItem onContentYChanged: { - scrollConnection.oldContentY = pageStack.currentPage.contentY + scrollConnection.oldContentY = pageStack.currentItem.contentY } } - PlasmaComponents.ToolBar { + ToolBar { id: tabsToolbar - y: parent.height - tabsToolbar.height*5 height: mainTabBar.height anchors { top: undefined @@ -87,45 +62,52 @@ MobileComponents.OverlayDrawer { left: parent.left right: parent.right } - tools: Item { + Component.onCompleted: thumbnailsButton.checked = true; + Item { width: parent.width height: childrenRect.height - PlasmaComponents.TabBar { + Row { id: mainTabBar anchors.horizontalCenter: parent.horizontalCenter width: Math.min(parent.width, implicitWidth) - tabPosition: Qt.BottomEdge - PlasmaComponents.TabButton { + ExclusiveGroup { id: tabPositionGroup } + ToolButton { id: thumbnailsButton text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Thumbnails") : "" - iconSource: "view-preview" + iconName: "view-preview" + checkable: true onCheckedChanged: { if (checked) { pageStack.replace(Qt.createComponent("Thumbnails.qml")) } } + exclusiveGroup: tabPositionGroup } - PlasmaComponents.TabButton { + ToolButton { id: tocButton enabled: documentItem.tableOfContents.count > 0 text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Table of contents") : "" - iconSource: "view-table-of-contents-ltr" + iconName: "view-table-of-contents-ltr" + checkable: true onCheckedChanged: { if (checked) { pageStack.replace(Qt.createComponent("TableOfContents.qml")) } } + exclusiveGroup: tabPositionGroup } - PlasmaComponents.TabButton { + ToolButton { id: bookmarksButton enabled: documentItem.bookmarkedPages.length > 0 text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Bookmarks") : "" - iconSource: "bookmarks-organize" + iconName: "bookmarks-organize" + checkable: true onCheckedChanged: { if (checked) { pageStack.replace(Qt.createComponent("Bookmarks.qml")) } } + exclusiveGroup: tabPositionGroup } } } diff --git a/mobile/app/package/contents/ui/TableOfContents.qml b/mobile/app/package/contents/ui/TableOfContents.qml index b5a9bc949..7b5a5ad8c 100644 --- a/mobile/app/package/contents/ui/TableOfContents.qml +++ b/mobile/app/package/contents/ui/TableOfContents.qml @@ -18,28 +18,34 @@ */ import QtQuick 2.1 -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.plasma.mobilecomponents 0.2 as MobileComponents +import QtQuick.Controls 1.3 +import org.kde.kirigami 1.0 as Kirigami -PlasmaComponents.Page { +Kirigami.Page { id: root + leftPadding: 0 + topPadding: 0 + rightPadding: 0 + bottomPadding: 0 property alias contentY: flickable.contentY property alias contentHeight: flickable.contentHeight - tools: Item { + ToolBar { id: toolBarContent width: root.width height: searchField.height - PlasmaComponents.TextField { + TextField { id: searchField - clearButtonShown: true anchors.centerIn: parent } } - PlasmaExtras.ScrollArea { - anchors.fill: parent + ScrollView { + anchors { + left: parent.left + top: toolBarContent.bottom + right: parent.right + bottom: parent.bottom + } Flickable { id: flickable diff --git a/mobile/app/package/contents/ui/Thumbnails.qml b/mobile/app/package/contents/ui/Thumbnails.qml index c3a4f8417..ab443ef0b 100644 --- a/mobile/app/package/contents/ui/Thumbnails.qml +++ b/mobile/app/package/contents/ui/Thumbnails.qml @@ -18,22 +18,20 @@ */ import QtQuick 2.1 -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.mobilecomponents 0.2 as MobileComponents +import QtQuick.Controls 1.3 +import org.kde.kirigami 1.0 as Kirigami ThumbnailsBase { id: root model: documentItem.matchingPages anchors.fill: parent - tools: Item { + ToolBar { id: toolBarContent width: root.width height: searchField.height - PlasmaComponents.TextField { + TextField { id: searchField - clearButtonShown: true enabled: documentItem.supportsSearch anchors.centerIn: parent onTextChanged: { @@ -45,7 +43,7 @@ ThumbnailsBase { } } } - PlasmaComponents.Label { + Kirigami.Label { anchors { left: searchField.right verticalCenter: searchField.verticalCenter diff --git a/mobile/app/package/contents/ui/ThumbnailsBase.qml b/mobile/app/package/contents/ui/ThumbnailsBase.qml index c4345a7d2..c276e3f63 100644 --- a/mobile/app/package/contents/ui/ThumbnailsBase.qml +++ b/mobile/app/package/contents/ui/ThumbnailsBase.qml @@ -18,14 +18,16 @@ */ import QtQuick 2.1 +import QtQuick.Controls 1.3 import org.kde.okular 2.0 as Okular -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.plasma.mobilecomponents 0.2 as MobileComponents +import org.kde.kirigami 1.0 as Kirigami -PlasmaComponents.Page { +Kirigami.Page { id: root + leftPadding: 0 + topPadding: 0 + rightPadding: 0 + bottomPadding: 0 property alias contentY: resultsGrid.contentY property alias contentHeight: resultsGrid.contentHeight property alias model: resultsGrid.model @@ -34,8 +36,11 @@ PlasmaComponents.Page { anchors.fill: parent - PlasmaExtras.ScrollArea { - anchors.fill: parent + ScrollView { + anchors { + fill: parent + topMargin: Kirigami.Units.gridUnit * 2 + } GridView { id: resultsGrid @@ -54,20 +59,18 @@ PlasmaComponents.Page { resultsGrid.currentIndex = index } } - PlasmaCore.FrameSvgItem { + Rectangle { anchors.centerIn: parent - imagePath: "widgets/media-delegate" - prefix: "picture" - width: thumbnail.width + margins.left + margins.right + width: thumbnail.width + Kirigami.Units.smallSpacing * 2 //FIXME: why bindings with thumbnail.height doesn't work? - height: thumbnail.height + margins.top + margins.bottom + height: thumbnail.height + Kirigami.Units.smallSpacing * 2 Okular.ThumbnailItem { id: thumbnail - x: parent.margins.left - y: parent.margins.top + x: Kirigami.Units.smallSpacing + y: Kirigami.Units.smallSpacing document: documentItem pageNumber: modelData - width: delegate.width - parent.margins.left + parent.margins.right - units.gridUnit + width: delegate.width - Kirigami.Units.smallSpacing * 2 - units.gridUnit //value repeated to avoid binding loops height: Math.round(width / (implicitWidth/implicitHeight)) Rectangle { @@ -80,7 +83,7 @@ PlasmaComponents.Page { bottom: parent.bottom right: parent.right } - PlasmaComponents.Label { + Kirigami.Label { text: modelData + 1 } } @@ -97,7 +100,10 @@ PlasmaComponents.Page { } } } - highlight: PlasmaComponents.Highlight {} + highlight: Rectangle { + color: Kirigami.Theme.highlightColor + opacity: 0.4 + } } } } diff --git a/mobile/app/package/contents/ui/TreeDelegate.qml b/mobile/app/package/contents/ui/TreeDelegate.qml index 966410ffc..fe77c8f71 100644 --- a/mobile/app/package/contents/ui/TreeDelegate.qml +++ b/mobile/app/package/contents/ui/TreeDelegate.qml @@ -18,9 +18,8 @@ */ import QtQuick 2.1 -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.kquickcontrolsaddons 2.0 +import org.kde.kirigami 1.0 as Kirigami Column { id: treeDelegate @@ -57,7 +56,7 @@ Column { anchors.verticalCenter: parent.verticalCenter x: units.largeSpacing } - PlasmaComponents.Label { + Kirigami.Label { id: label text: display verticalAlignment: Text.AlignBottom @@ -74,7 +73,7 @@ Column { right: pageNumber.left } } - PlasmaComponents.Label { + Kirigami.Label { id: pageNumber text: pageLabel ? pageLabel : page anchors.right: parent.right diff --git a/mobile/app/package/contents/ui/main.qml b/mobile/app/package/contents/ui/main.qml index b91ad71c1..09410c802 100644 --- a/mobile/app/package/contents/ui/main.qml +++ b/mobile/app/package/contents/ui/main.qml @@ -18,13 +18,11 @@ */ import QtQuick 2.1 -import org.kde.okular 2.0 as Okular import QtQuick.Controls 1.3 -import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.mobilecomponents 0.2 as MobileComponents +import org.kde.okular 2.0 as Okular +import org.kde.kirigami 1.0 as Kirigami -MobileComponents.ApplicationWindow { +Kirigami.AbstractApplicationWindow { id: fileBrowserRoot objectName: "fileBrowserRoot" visible: true @@ -35,17 +33,16 @@ MobileComponents.ApplicationWindow { uri: documentItem.path }*/ - globalDrawer: MobileComponents.OverlayDrawer { + header: null + globalDrawer: Kirigami.OverlayDrawer { edge: Qt.LeftEdge contentItem: Documents { implicitWidth: units.gridUnit * 20 } } contextDrawer: OkularDrawer {} - actionButton.iconSource: "bookmarks-organize" - actionButton.checkable: true - actionButton.onCheckedChanged: pageArea.page.bookmarked = actionButton.checked; - PlasmaComponents.ProgressBar { + + ProgressBar { id: bar z: 99 anchors { @@ -64,21 +61,10 @@ MobileComponents.ApplicationWindow { } } - Okular.DocumentView { + MainView { id: pageArea - document: documentItem anchors.fill: parent - - onPageChanged: { - bookmarkConnection.target = page - actionButton.checked = page.bookmarked - } - onClicked: actionButton.toggleVisibility(); - } - Connections { - id: bookmarkConnection - target: pageArea.page - onBookmarkedChanged: actionButton.checked = page.bookmarked + document: documentItem } //FIXME: this is due to global vars being binded after the parse is done, do the 2 steps parsing