diff --git a/mobile/app/package/contents/ui/MainView.qml b/mobile/app/package/contents/ui/MainView.qml index 38510698a..68ddccd05 100644 --- a/mobile/app/package/contents/ui/MainView.qml +++ b/mobile/app/package/contents/ui/MainView.qml @@ -1,66 +1,66 @@ /* * 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 QtQuick.Controls 1.3 +import QtQuick.Controls 2.3 as QQC2 import org.kde.okular 2.0 as Okular import org.kde.kirigami 2.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 } - ProgressBar { + QQC2.ProgressBar { id: bar z: 99 visible: applicationWindow().controlsVisible height: Kirigami.Units.smallSpacing anchors { left: parent.left right: parent.right bottom: parent.bottom } value: documentItem.pageCount != 0 ? ((documentItem.currentPage+1) / documentItem.pageCount) : 0 } } diff --git a/mobile/app/package/contents/ui/OkularDrawer.qml b/mobile/app/package/contents/ui/OkularDrawer.qml index 0ea448cda..7bb8ade69 100644 --- a/mobile/app/package/contents/ui/OkularDrawer.qml +++ b/mobile/app/package/contents/ui/OkularDrawer.qml @@ -1,114 +1,114 @@ /* * 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 QtQuick.Controls 2.5 +import QtQuick.Controls 2.5 as QQC2 import org.kde.kirigami 2.0 as Kirigami import org.kde.okular 2.0 as Okular Kirigami.OverlayDrawer { edge: Qt.RightEdge contentItem: Item { id: browserFrame implicitWidth: Kirigami.Units.gridUnit * 45 implicitHeight: implicitWidth state: "Hidden" - StackView { + QQC2.StackView { id: pageStack anchors { left: parent.left top: parent.top right: parent.right bottom: tabsToolbar.top } clip: true } Connections { target: documentItem onUrlChanged: thumbnailsButton.checked = true; } - ToolBar { + QQC2.ToolBar { id: tabsToolbar height: mainTabBar.height anchors { top: undefined bottom: browserFrame.bottom left: parent.left right: parent.right } Component.onCompleted: thumbnailsButton.checked = true; Item { width: parent.width height: childrenRect.height Row { id: mainTabBar spacing: 0 anchors.horizontalCenter: parent.horizontalCenter width: Math.min(parent.width, implicitWidth) - ButtonGroup { id: tabPositionGroup } - ToolButton { + QQC2.ButtonGroup { id: tabPositionGroup } + QQC2.ToolButton { id: thumbnailsButton text: tabsToolbar.width > Kirigami.Units.gridUnit * 30 ? i18n("Thumbnails") : "" icon.name: "view-preview" checkable: true flat: false onCheckedChanged: { if (checked) { pageStack.replace(Qt.createComponent("Thumbnails.qml")) } } - ButtonGroup.group: tabPositionGroup + QQC2.ButtonGroup.group: tabPositionGroup } - ToolButton { + QQC2.ToolButton { id: tocButton enabled: documentItem.tableOfContents.count > 0 text: tabsToolbar.width > Kirigami.Units.gridUnit * 30 ? i18n("Table of contents") : "" icon.name: "view-table-of-contents-ltr" checkable: true flat: false onCheckedChanged: { if (checked) { pageStack.replace(Qt.createComponent("TableOfContents.qml")) } } - ButtonGroup.group: tabPositionGroup + QQC2.ButtonGroup.group: tabPositionGroup } - ToolButton { + QQC2.ToolButton { id: bookmarksButton enabled: documentItem.bookmarkedPages.length > 0 text: tabsToolbar.width > Kirigami.Units.gridUnit * 30 ? i18n("Bookmarks") : "" icon.name: "bookmarks-organize" checkable: true flat: false onCheckedChanged: { if (checked) { pageStack.replace(Qt.createComponent("Bookmarks.qml")) } } - ButtonGroup.group: tabPositionGroup + QQC2.ButtonGroup.group: tabPositionGroup } } } } } } diff --git a/mobile/app/package/contents/ui/TableOfContents.qml b/mobile/app/package/contents/ui/TableOfContents.qml index eab539a32..f46bb6e04 100644 --- a/mobile/app/package/contents/ui/TableOfContents.qml +++ b/mobile/app/package/contents/ui/TableOfContents.qml @@ -1,72 +1,71 @@ /* * 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 QtQuick.Controls 1.3 import QtQuick.Controls 2.0 as QQC2 import org.kde.kirigami 2.0 as Kirigami Kirigami.Page { id: root leftPadding: 0 topPadding: 0 rightPadding: 0 bottomPadding: 0 property alias contentY: flickable.contentY property alias contentHeight: flickable.contentHeight QQC2.ToolBar { id: toolBarContent width: root.width height: searchField.height - QQC2.TextField { + TextField { id: searchField anchors.centerIn: parent } } - ScrollView { + QQC2.ScrollView { anchors { left: parent.left top: toolBarContent.bottom right: parent.right bottom: parent.bottom } Flickable { id: flickable anchors.fill: parent contentWidth: width contentHeight: treeView.height Column { id: treeView width: flickable.width Repeater { model: VisualDataModel { id: tocModel model: documentItem.tableOfContents delegate: TreeDelegate { sourceModel: tocModel width: treeView.width } } } } } } } diff --git a/mobile/app/package/contents/ui/Thumbnails.qml b/mobile/app/package/contents/ui/Thumbnails.qml index c0f275cd4..e8e57df3e 100644 --- a/mobile/app/package/contents/ui/Thumbnails.qml +++ b/mobile/app/package/contents/ui/Thumbnails.qml @@ -1,45 +1,45 @@ /* * 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 QtQuick.Controls 2.0 +import QtQuick.Controls 2.0 as QQC2 import org.kde.kirigami 2.0 as Kirigami ThumbnailsBase { id: root model: documentItem.matchingPages - ToolBar { + QQC2.ToolBar { id: toolBarContent width: root.width height: searchField.height - TextField { + QQC2.TextField { id: searchField anchors.fill: parent enabled: documentItem ? documentItem.supportsSearching : false onTextChanged: { if (text.length > 2) { documentItem.searchText(text); } else { documentItem.resetSearch(); } } } } } diff --git a/mobile/app/package/contents/ui/ThumbnailsBase.qml b/mobile/app/package/contents/ui/ThumbnailsBase.qml index 67ec94173..4244c10c9 100644 --- a/mobile/app/package/contents/ui/ThumbnailsBase.qml +++ b/mobile/app/package/contents/ui/ThumbnailsBase.qml @@ -1,122 +1,122 @@ /* * 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 QtQuick.Controls 1.3 +import QtQuick.Controls 2.3 as QQC2 import QtGraphicalEffects 1.0 import org.kde.okular 2.0 as Okular import org.kde.kirigami 2.0 as Kirigami Kirigami.Page { id: root leftPadding: 0 topPadding: 0 rightPadding: 0 bottomPadding: 0 property alias resultsContentY: resultsGrid.contentY property alias resultsContentHeight: resultsGrid.contentHeight property alias model: resultsGrid.model signal pageClicked(int pageNumber) property Item view: resultsGrid - ScrollView { + QQC2.ScrollView { anchors { fill: parent topMargin: Kirigami.Units.gridUnit * 2 } - Label { + QQC2.Label { anchors.centerIn: parent visible: model.length == 0 text: i18n("No results found.") } GridView { id: resultsGrid anchors.fill: parent cellWidth: Math.floor(width / Math.floor(width / (Kirigami.Units.gridUnit * 8))) cellHeight: Math.floor(cellWidth * 1.6) delegate: Item { id: delegate width: resultsGrid.cellWidth height: resultsGrid.cellHeight property bool current: documentItem.currentPage == modelData onCurrentChanged: { if (current) { resultsGrid.currentIndex = index } } Rectangle { anchors.centerIn: parent width: thumbnail.width + Kirigami.Units.smallSpacing * 2 //FIXME: why bindings with thumbnail.height doesn't work? height: thumbnail.height + Kirigami.Units.smallSpacing * 2 Okular.ThumbnailItem { id: thumbnail x: Kirigami.Units.smallSpacing y: Kirigami.Units.smallSpacing document: documentItem pageNumber: modelData width: delegate.width - Kirigami.Units.smallSpacing * 2 - Kirigami.Units.gridUnit //value repeated to avoid binding loops height: Math.round(width / (implicitWidth/implicitHeight)) Rectangle { width: childrenRect.width height: childrenRect.height color: Kirigami.Theme.backgroundColor radius: width smooth: true anchors { bottom: parent.bottom right: parent.right } - Label { + QQC2.Label { text: modelData + 1 } } } MouseArea { anchors.fill: parent onClicked: { resultsGrid.currentIndex = index documentItem.currentPage = modelData contextDrawer.drawerOpen = false root.pageClicked(modelData) } } } layer.enabled: true layer.effect: DropShadow { horizontalOffset: 0 verticalOffset: 0 radius: Math.ceil(Kirigami.Units.gridUnit * 0.8) samples: 32 color: Qt.rgba(0, 0, 0, 0.5) } } 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 d1c1b3464..97e2e60a1 100644 --- a/mobile/app/package/contents/ui/TreeDelegate.qml +++ b/mobile/app/package/contents/ui/TreeDelegate.qml @@ -1,108 +1,108 @@ /* * 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 QtQuick.Controls 2.0 +import QtQuick.Controls 2.0 as QQC2 import org.kde.kirigami 2.0 as Kirigami Column { id: treeDelegate property variant sourceModel property int rowIndex: index width: parent.width property bool matches: display.toLowerCase().indexOf(searchField.text.toLowerCase()) !== -1 MouseArea { id: delegateArea width: parent.width height: matches ? label.height : 0 opacity: matches ? 1 : 0 Behavior on opacity { NumberAnimation { duration: 250 } } onClicked: { documentItem.currentPage = page-1 contextDrawer.drawerOpen = false } Kirigami.Icon { id: icon source: decoration width: Kirigami.Units.iconSizes.small height: width anchors.verticalCenter: parent.verticalCenter x: Kirigami.Units.largeSpacing } - Label { + QQC2.Label { id: label text: display verticalAlignment: Text.AlignBottom anchors.left: icon.right } //there isn't a sane way to do a dotted line in QML Rectangle { color: Kirigami.Theme.textColor opacity: 0.3 height: 1 anchors { bottom: parent.bottom left: label.right right: pageNumber.left } } - Label { + QQC2.Label { id: pageNumber text: pageLabel ? pageLabel : page anchors.right: parent.right verticalAlignment: Text.AlignBottom anchors.rightMargin: Kirigami.Units.largeSpacing } } Column { id: col x: 20 width: parent.width - 20 property variant model: childrenModel Repeater { id: rep model: VisualDataModel { id: childrenModel model: documentItem.tableOfContents } } } onParentChanged: { if (treeDelegate.parent && treeDelegate.parent.model) { sourceModel = treeDelegate.parent.model } childrenModel.rootIndex = sourceModel.modelIndex(index) if (model.hasModelChildren) { childrenModel.delegate = Qt.createComponent("TreeDelegate.qml") } } } diff --git a/mobile/components/DocumentView.qml b/mobile/components/DocumentView.qml index 5008128f0..d7f3daf2f 100644 --- a/mobile/components/DocumentView.qml +++ b/mobile/components/DocumentView.qml @@ -1,292 +1,292 @@ /* * Copyright 2015 by 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.2 -import QtQuick.Controls 1.2 as QtControls +import QtQuick.Controls 2.2 as QQC2 import org.kde.okular 2.0 import "./private" /** * A touchscreen optimized view for a document * * It supports changing pages by a swipe gesture, pinch zoom * and flicking to scroll around */ -QtControls.ScrollView { +QQC2.ScrollView { id: root property DocumentItem document property PageItem page: mouseArea.currPageDelegate.pageItem signal clicked //NOTE: on some themes it tries to set the flickable to interactive //but we need it always non interactive as we need to manage //dragging by ourselves Component.onCompleted: flick.interactive = false Flickable { id: flick interactive: false onWidthChanged: resizeTimer.restart() onHeightChanged: resizeTimer.restart() Component.onCompleted: { flick.contentWidth = flick.width flick.contentHeight = flick.width / mouseArea.currPageDelegate.pageRatio } Connections { target: root.document onUrlChanged: resizeTimer.restart() } Timer { id: resizeTimer interval: 250 onTriggered: { flick.contentWidth = flick.width flick.contentHeight = flick.width / mouseArea.currPageDelegate.pageRatio } } PinchArea { width: flick.contentWidth height: flick.contentHeight property real initialWidth property real initialHeight onPinchStarted: { initialWidth = mouseArea.currPageDelegate.implicitWidth * mouseArea.currPageDelegate.scaleFactor initialHeight = mouseArea.currPageDelegate.implicitHeight * mouseArea.currPageDelegate.scaleFactor } onPinchUpdated: { // adjust content pos due to drag flick.contentX += pinch.previousCenter.x - pinch.center.x flick.contentY += pinch.previousCenter.y - pinch.center.y // resize content //use the scale property during pinch, for speed reasons if (initialHeight * pinch.scale > flick.height && initialHeight * pinch.scale < flick.height * 3) { mouseArea.scale = pinch.scale; } resizeTimer.stop(); flick.returnToBounds(); } onPinchFinished: { flick.resizeContent(Math.max(flick.width+1, initialWidth * mouseArea.scale), Math.max(flick.height, initialHeight * mouseArea.scale), pinch.center); mouseArea.scale = 1; resizeTimer.stop() flick.returnToBounds(); } MouseArea { id: mouseArea width: parent.width height: parent.height property real oldMouseX property real oldMouseY property real startMouseX property real startMouseY property bool incrementing: true property Item currPageDelegate: page1 property Item prevPageDelegate: page2 property Item nextPageDelegate: page3 onPressed: { var pos = mapToItem(flick, mouse.x, mouse.y); startMouseX = oldMouseX = pos.x; startMouseY = oldMouseY = pos.y; } onPositionChanged: { var pos = mapToItem(flick, mouse.x, mouse.y); flick.contentY = Math.max(0, Math.min(flick.contentHeight - flick.height, flick.contentY - (pos.y - oldMouseY))); if ((pos.x - oldMouseX > 0 && flick.atXBeginning) || (pos.x - oldMouseX < 0 && flick.atXEnd)) { currPageDelegate.x += pos.x - oldMouseX; mouseArea.incrementing = currPageDelegate.x <= 0; } else { flick.contentX = Math.max(0, Math.min(flick.contentWidth - flick.width, flick.contentX - (pos.x - oldMouseX))); } oldMouseX = pos.x; oldMouseY = pos.y; } onReleased: { if (root.document.currentPage > 0 && currPageDelegate.x > width/6) { switchAnimation.running = true; } else if (root.document.currentPage < document.pageCount-1 && currPageDelegate.x < -width/6) { switchAnimation.running = true; } else { resetAnim.running = true; } } onCanceled: { resetAnim.running = true; } onDoubleClicked: { flick.contentWidth = flick.width flick.contentHeight = flick.width / mouseArea.currPageDelegate.pageRatio } onClicked: { var pos = mapToItem(flick, mouse.x, mouse.y); if (Math.abs(startMouseX - pos.x) < 20 && Math.abs(startMouseY - pos.y) < 20) { root.clicked(); } } onWheel: { if (wheel.modifiers & Qt.ControlModifier) { //generate factors between 0.8 and 1.2 var factor = (((wheel.angleDelta.y / 120)+1) / 5 )+ 0.8; var newWidth = flick.contentWidth * factor; var newHeight = flick.contentHeight * factor; if (newWidth < flick.width || newHeight < flick.height || newHeight > flick.height * 3) { return; } flick.resizeContent(newWidth, newHeight, Qt.point(wheel.x, wheel.y)); flick.returnToBounds(); resizeTimer.stop(); } else { flick.contentY = Math.min(flick.contentHeight-flick.height, Math.max(0, flick.contentY - wheel.angleDelta.y)); } } PageView { id: page1 document: root.document z: 2 } PageView { id: page2 document: root.document z: 1 } PageView { id: page3 document: root.document z: 0 } Binding { target: mouseArea.currPageDelegate property: "pageNumber" value: root.document.currentPage } Binding { target: mouseArea.currPageDelegate property: "visible" value: true } Binding { target: mouseArea.prevPageDelegate property: "pageNumber" value: root.document.currentPage - 1 } Binding { target: mouseArea.prevPageDelegate property: "visible" value: !mouseArea.incrementing && root.document.currentPage > 0 } Binding { target: mouseArea.nextPageDelegate property: "pageNumber" value: root.document.currentPage + 1 } Binding { target: mouseArea.nextPageDelegate property: "visible" value: mouseArea.incrementing && root.document.currentPage < document.pageCount-1 } SequentialAnimation { id: switchAnimation ParallelAnimation { NumberAnimation { target: flick properties: "contentY" to: 0 easing.type: Easing.InQuad //hardcoded number, we would need units from kirigami //which cannot depend from here duration: 250 } NumberAnimation { target: mouseArea.currPageDelegate properties: "x" to: mouseArea.incrementing ? -mouseArea.currPageDelegate.width : mouseArea.currPageDelegate.width easing.type: Easing.InQuad //hardcoded number, we would need units from kirigami //which cannot depend from here duration: 250 } } ScriptAction { script: { mouseArea.currPageDelegate.z = 0; mouseArea.prevPageDelegate.z = 1; mouseArea.nextPageDelegate.z = 2; } } ScriptAction { script: { mouseArea.currPageDelegate.x = 0 var oldCur = mouseArea.currPageDelegate; var oldPrev = mouseArea.prevPageDelegate; var oldNext = mouseArea.nextPageDelegate; if (mouseArea.incrementing) { root.document.currentPage++; mouseArea.currPageDelegate = oldNext; mouseArea.prevPageDelegate = oldCur; mouseArea. nextPageDelegate = oldPrev; } else { root.document.currentPage--; mouseArea.currPageDelegate = oldPrev; mouseArea.nextPageDelegate = oldCur; mouseArea.prevPageDelegate = oldNext; } mouseArea.currPageDelegate.z = 2; mouseArea.prevPageDelegate.z = 1; mouseArea.nextPageDelegate.z = 0; } } } NumberAnimation { id: resetAnim target: mouseArea.currPageDelegate properties: "x" to: 0 easing.type: Easing.InQuad duration: 250 } } } } }