diff --git a/mobile/app/package/contents/ui/Documents.qml b/mobile/app/package/contents/ui/Documents.qml index 3f5b402c1..9c6b47d43 100644 --- a/mobile/app/package/contents/ui/Documents.qml +++ b/mobile/app/package/contents/ui/Documents.qml @@ -1,88 +1,89 @@ /* * Copyright 2015 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 org.kde.kirigami 1.0 as Kirigami +import QtQuick.Controls 2.0 as QQC2 +import org.kde.kirigami 2.0 as Kirigami import Qt.labs.folderlistmodel 2.1 Item { id: root anchors.fill: parent property Item view: filesView property alias contentY: filesView.contentY property alias contentHeight: filesView.contentHeight property alias model: filesView.model Item { id: toolBarContent width: root.width height: searchField.height + Kirigami.Units.gridUnit - TextField { + QQC2.TextField { id: searchField anchors.centerIn: parent focus: true } } Kirigami.Label { z: 2 visible: filesView.count == 0 anchors { fill: parent 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 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } ScrollView { anchors { top: toolBarContent.bottom left: parent.left right: parent.right bottom: parent.bottom } ListView { id: filesView anchors.fill: parent model: FolderListModel { id: folderModel folder: userPaths.documents nameFilters: ["*.pdf", "*.txt", "*.chm", "*.epub"] showDirs: false } 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; + globalDrawer.close(); applicationWindow().controlsVisible = false; } } } } } diff --git a/mobile/app/package/contents/ui/MainView.qml b/mobile/app/package/contents/ui/MainView.qml index 8a82231c3..38510698a 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 org.kde.okular 2.0 as Okular -import org.kde.kirigami 1.0 as Kirigami +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 { 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 b20f455c1..05dbb568e 100644 --- a/mobile/app/package/contents/ui/OkularDrawer.qml +++ b/mobile/app/package/contents/ui/OkularDrawer.qml @@ -1,116 +1,118 @@ /* * 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 +//still needed for icons in toolbuttons import QtQuick.Controls 1.3 -import org.kde.kirigami 1.0 as Kirigami +import QtQuick.Controls 2.0 as QQC2 +import org.kde.kirigami 2.0 as Kirigami import org.kde.kquickcontrolsaddons 2.0 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 { id: pageStack anchors { left: parent.left top: parent.top right: parent.right bottom: tabsToolbar.top } clip: true } Connections { target: documentItem - onPathChanged: mainTabBar.currentTab = thumbnailsButton; + onPathChanged: 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) ExclusiveGroup { id: tabPositionGroup } ToolButton { id: thumbnailsButton - text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Thumbnails") : "" + text: tabsToolbar.width > Kirigami.Units.gridUnit * 30 ? i18n("Thumbnails") : "" iconName: "view-preview" checkable: true //Hint for Plasma style property bool flat: false onCheckedChanged: { if (checked) { pageStack.replace(Qt.createComponent("Thumbnails.qml")) } } exclusiveGroup: tabPositionGroup } ToolButton { id: tocButton enabled: documentItem.tableOfContents.count > 0 - text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Table of contents") : "" + text: tabsToolbar.width > Kirigami.Units.gridUnit * 30 ? i18n("Table of contents") : "" iconName: "view-table-of-contents-ltr" checkable: true property bool flat: false onCheckedChanged: { if (checked) { pageStack.replace(Qt.createComponent("TableOfContents.qml")) } } exclusiveGroup: tabPositionGroup } ToolButton { id: bookmarksButton enabled: documentItem.bookmarkedPages.length > 0 - text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Bookmarks") : "" + text: tabsToolbar.width > Kirigami.Units.gridUnit * 30 ? i18n("Bookmarks") : "" iconName: "bookmarks-organize" checkable: true property bool flat: false 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 7b5a5ad8c..eab539a32 100644 --- a/mobile/app/package/contents/ui/TableOfContents.qml +++ b/mobile/app/package/contents/ui/TableOfContents.qml @@ -1,71 +1,72 @@ /* * 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 org.kde.kirigami 1.0 as Kirigami +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 - ToolBar { + QQC2.ToolBar { id: toolBarContent width: root.width height: searchField.height - TextField { + QQC2.TextField { id: searchField anchors.centerIn: parent } } 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 6e6936cb5..58cd91134 100644 --- a/mobile/app/package/contents/ui/Thumbnails.qml +++ b/mobile/app/package/contents/ui/Thumbnails.qml @@ -1,53 +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 QtQuick.Controls 1.3 -import org.kde.kirigami 1.0 as Kirigami +import QtQuick.Controls 2.0 +import org.kde.kirigami 2.0 as Kirigami ThumbnailsBase { id: root model: documentItem.matchingPages ToolBar { id: toolBarContent width: root.width height: searchField.height TextField { id: searchField - enabled: documentItem.supportsSearch + enabled: documentItem ? documentItem.supportsSearch : false anchors.centerIn: parent onTextChanged: { if (text.length > 2) { documentItem.searchText(text); } else { documentItem.resetSearch(); } } } Kirigami.Label { anchors { left: searchField.right verticalCenter: searchField.verticalCenter } visible: documentItem.matchingPages.length == 0 text: i18n("No results found.") } } } diff --git a/mobile/app/package/contents/ui/ThumbnailsBase.qml b/mobile/app/package/contents/ui/ThumbnailsBase.qml index 6abab9ba4..37b1b7b34 100644 --- a/mobile/app/package/contents/ui/ThumbnailsBase.qml +++ b/mobile/app/package/contents/ui/ThumbnailsBase.qml @@ -1,116 +1,116 @@ /* * 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 QtGraphicalEffects 1.0 import org.kde.okular 2.0 as Okular -import org.kde.kirigami 1.0 as Kirigami +import org.kde.kirigami 2.0 as Kirigami 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 signal pageClicked(int pageNumber) property Item view: resultsGrid ScrollView { anchors { fill: parent topMargin: Kirigami.Units.gridUnit * 2 } 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: theme.backgroundColor + color: Kirigami.Theme.backgroundColor radius: width smooth: true anchors { bottom: parent.bottom right: parent.right } Kirigami.Label { text: modelData + 1 } } } MouseArea { anchors.fill: parent onClicked: { resultsGrid.currentIndex = index documentItem.currentPage = modelData contextDrawer.opened = 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 fe77c8f71..13854046c 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 org.kde.kquickcontrolsaddons 2.0 -import org.kde.kirigami 1.0 as Kirigami +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.opened = false } QIconItem { id: icon icon: decoration width: theme.smallIconSize height: width anchors.verticalCenter: parent.verticalCenter x: units.largeSpacing } Kirigami.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: theme.textColor opacity: 0.3 height: 1 anchors { bottom: parent.bottom left: label.right right: pageNumber.left } } Kirigami.Label { id: pageNumber text: pageLabel ? pageLabel : page anchors.right: parent.right verticalAlignment: Text.AlignBottom anchors.rightMargin: 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/app/package/contents/ui/main.qml b/mobile/app/package/contents/ui/main.qml index e030ab14a..45949eab7 100644 --- a/mobile/app/package/contents/ui/main.qml +++ b/mobile/app/package/contents/ui/main.qml @@ -1,72 +1,74 @@ /* * 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 org.kde.okular 2.0 as Okular -import org.kde.kirigami 1.0 as Kirigami +import org.kde.kirigami 2.0 as Kirigami Kirigami.AbstractApplicationWindow { id: fileBrowserRoot objectName: "fileBrowserRoot" visible: true /*TODO: port ResourceInstance PlasmaExtras.ResourceInstance { id: resourceInstance uri: documentItem.path }*/ header: null globalDrawer: Kirigami.OverlayDrawer { edge: Qt.LeftEdge contentItem: Documents { - implicitWidth: units.gridUnit * 20 + implicitWidth: Kirigami.Units.gridUnit * 20 } } - contextDrawer: OkularDrawer {} + contextDrawer: OkularDrawer { + drawerOpen: false + } Okular.DocumentItem { id: documentItem onWindowTitleForDocumentChanged: { fileBrowserRoot.title = windowTitleForDocument } } MainView { id: pageArea anchors.fill: parent document: documentItem } //FIXME: this is due to global vars being binded after the parse is done, do the 2 steps parsing Timer { interval: 100 running: true onTriggered: { if (commandlineArguments.length > 0) { documentItem.path = commandlineArguments[0] } if (commandlineArguments.length == 0) { - globalDrawer.opened = true; + globalDrawer.open(); } } } }