summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Martin <notmart@gmail.com>2015-12-01 16:28:49 (GMT)
committerMarco Martin <notmart@gmail.com>2015-12-01 16:29:16 (GMT)
commit2b4486a00de34cf0102997db8bb88462d4959de6 (patch)
treeb93e98c76c1c892848036f28454662b0e8317f66
parent9b749abbc02f852ca6c66e84392084f7777ac850 (diff)
adapt to new components API
-rw-r--r--mobile/app/package/contents/ui/Browser.qml14
-rw-r--r--mobile/app/package/contents/ui/Documents.qml32
-rw-r--r--mobile/app/package/contents/ui/ThumbnailsBase.qml2
-rw-r--r--mobile/app/package/contents/ui/TreeDelegate.qml2
-rw-r--r--mobile/app/package/contents/ui/main.qml100
-rw-r--r--mobile/components/DocumentView.qml6
6 files changed, 59 insertions, 97 deletions
diff --git a/mobile/app/package/contents/ui/Browser.qml b/mobile/app/package/contents/ui/Browser.qml
index 2f74350..873a1c0 100644
--- a/mobile/app/package/contents/ui/Browser.qml
+++ b/mobile/app/package/contents/ui/Browser.qml
@@ -31,8 +31,10 @@ MobileComponents.SplitDrawer {
anchors.fill: parent
visible: true
- property alias splitDrawerOpen: splitDrawer.open
- property alias overlayDrawerOpen: resourceBrowser.open
+ 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
@@ -40,14 +42,14 @@ MobileComponents.SplitDrawer {
pageArea.page.bookmarked = bookmarked
}
- drawer: Documents {
- implicitWidth: splitDrawer.width/4 * 3
+ contentItem: Documents {
+ implicitWidth: units.gridUnit * 25
}
MobileComponents.OverlayDrawer {
id: resourceBrowser
anchors.fill: parent
- visible: true
+ edge: Qt.RightEdge
Okular.DocumentView {
id: pageArea
@@ -66,7 +68,7 @@ MobileComponents.SplitDrawer {
onBookmarkedChanged: splitDrawer.bookmarked = pageArea.page.bookmarked
}
- drawer: Item {
+ contentItem: Item {
id: browserFrame
anchors.fill: parent
state: "Hidden"
diff --git a/mobile/app/package/contents/ui/Documents.qml b/mobile/app/package/contents/ui/Documents.qml
index a36aad8..a3cfc65 100644
--- a/mobile/app/package/contents/ui/Documents.qml
+++ b/mobile/app/package/contents/ui/Documents.qml
@@ -24,9 +24,10 @@ import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
import Qt.labs.folderlistmodel 2.1
-PlasmaComponents.Page {
+MobileComponents.Page {
id: root
anchors.fill: parent
+ color: theme.viewBackgroundColor
visible: true
property Item view: filesView
property alias contentY: filesView.contentY
@@ -52,11 +53,10 @@ PlasmaComponents.Page {
PlasmaExtras.ScrollArea {
anchors.fill: parent
- GridView {
+ ListView {
id: filesView
anchors.fill: parent
- cellWidth: units.gridUnit * 5
- cellHeight: units.gridUnit * 5
+
model: PlasmaCore.SortFilterModel {
id: filterModel
filterRole: "fileName"
@@ -68,27 +68,9 @@ PlasmaComponents.Page {
}
}
- delegate: MouseArea {
- width: filesView.cellWidth
- height: filesView.cellHeight
- PlasmaCore.IconItem {
- id: icon
- width: units.gridUnit * 3
- height: width
- anchors {
- top: parent.top
- horizontalCenter: parent.horizontalCenter
- }
- //TODO: proper icons
- source: "application-epub+zip"
- }
+ delegate: MobileComponents.ListItem {
+ enabled: true
PlasmaComponents.Label {
- anchors {
- left: parent.left
- right: parent.right
- top: icon.bottom
- bottom: parent.bottom
- }
text: model.fileName
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
@@ -96,7 +78,7 @@ PlasmaComponents.Page {
}
onClicked: {
documentItem.path = model.filePath;
- splitDrawer.open = false;
+ globalDrawer.opened = false;
mainTabBar.currentTab = thumbnailsButton;
}
}
diff --git a/mobile/app/package/contents/ui/ThumbnailsBase.qml b/mobile/app/package/contents/ui/ThumbnailsBase.qml
index 0c0f738..c4345a7 100644
--- a/mobile/app/package/contents/ui/ThumbnailsBase.qml
+++ b/mobile/app/package/contents/ui/ThumbnailsBase.qml
@@ -91,7 +91,7 @@ PlasmaComponents.Page {
resultsGrid.currentIndex = index
documentItem.currentPage = modelData
- resourceBrowser.open = false
+ contextDrawer.opened = false
root.pageClicked(modelData)
}
}
diff --git a/mobile/app/package/contents/ui/TreeDelegate.qml b/mobile/app/package/contents/ui/TreeDelegate.qml
index 714a859..966410f 100644
--- a/mobile/app/package/contents/ui/TreeDelegate.qml
+++ b/mobile/app/package/contents/ui/TreeDelegate.qml
@@ -46,7 +46,7 @@ Column {
onClicked: {
documentItem.currentPage = page-1
- resourceBrowser.open = false
+ contextDrawer.opened = false
}
QIconItem {
diff --git a/mobile/app/package/contents/ui/main.qml b/mobile/app/package/contents/ui/main.qml
index 9d65b31..b91ad71 100644
--- a/mobile/app/package/contents/ui/main.qml
+++ b/mobile/app/package/contents/ui/main.qml
@@ -22,78 +22,39 @@ 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
-ApplicationWindow {
+MobileComponents.ApplicationWindow {
id: fileBrowserRoot
objectName: "fileBrowserRoot"
visible: true
- width: 360
- height: 360
-
/*TODO: port ResourceInstance
PlasmaExtras.ResourceInstance {
id: resourceInstance
uri: documentItem.path
}*/
- statusBar: PlasmaComponents.ToolBar {
- id: toolbar
- tools: PlasmaComponents.ToolBarLayout {
- //TODO: those buttons should support drag to open the menus as well
- PlasmaComponents.ToolButton {
- id: openButton
- iconSource: "document-open"
- checkable: true
- onCheckedChanged: {
- mainStack.currentPage.splitDrawerOpen = checked
- if (checked) {
- mainStack.currentPage.overlayDrawerOpen = false;
- }
- }
- }
- PlasmaComponents.ToolButton {
- id: bookmarkButton
- iconSource: "bookmarks-organize"
- checkable: true
- onCheckedChanged: {
- mainStack.currentPage.bookmarked = checked
- }
- }
- PlasmaComponents.ToolButton {
- id: exploreButton
- iconSource: "view-list-icons"
- checkable: true
- onCheckedChanged: {
- mainStack.currentPage.overlayDrawerOpen = checked
- if (checked) {
- mainStack.currentPage.splitDrawerOpen = false;
- }
- }
- }
+ globalDrawer: MobileComponents.OverlayDrawer {
+ edge: Qt.LeftEdge
+ contentItem: Documents {
+ implicitWidth: units.gridUnit * 20
}
- Connections {
- target: mainStack.currentPage
- onSplitDrawerOpenChanged: {
- openButton.checked = mainStack.currentPage.splitDrawerOpen;
- }
- onOverlayDrawerOpenChanged: {
- exploreButton.checked = mainStack.currentPage.overlayDrawerOpen;
- }
- onBookmarkedChanged: {
- bookmarkButton.checked = mainStack.currentPage.bookmarked
- }
- }
- PlasmaComponents.ProgressBar {
- id: bar
- anchors {
- left: parent.left
- right: parent.right
- bottom: parent.top
- }
- height: units.smallSpacing
- value: documentItem.pageCount != 0 ? (documentItem.currentPage / documentItem.pageCount) : 0
+ }
+ contextDrawer: OkularDrawer {}
+ actionButton.iconSource: "bookmarks-organize"
+ actionButton.checkable: true
+ actionButton.onCheckedChanged: pageArea.page.bookmarked = actionButton.checked;
+ PlasmaComponents.ProgressBar {
+ id: bar
+ z: 99
+ anchors {
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
}
+ height: units.smallSpacing
+ value: documentItem.pageCount != 0 ? (documentItem.currentPage / documentItem.pageCount) : 0
}
Okular.DocumentItem {
@@ -103,9 +64,21 @@ ApplicationWindow {
}
}
- PlasmaComponents.PageStack {
- id: mainStack
- clip: false
+ Okular.DocumentView {
+ 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
}
//FIXME: this is due to global vars being binded after the parse is done, do the 2 steps parsing
@@ -117,9 +90,8 @@ ApplicationWindow {
documentItem.path = commandlineArguments[0]
}
- var browser = mainStack.push(Qt.createComponent("Browser.qml"))
if (commandlineArguments.length == 0) {
- browser.open = true;
+ globalDrawer.opened = true;
}
}
}
diff --git a/mobile/components/DocumentView.qml b/mobile/components/DocumentView.qml
index 117c6be..4efbadd 100644
--- a/mobile/components/DocumentView.qml
+++ b/mobile/components/DocumentView.qml
@@ -32,6 +32,7 @@ QtControls.ScrollView {
id: root
property DocumentItem document
property PageItem page: mouseArea.currPageDelegate.pageItem
+ signal clicked
onWidthChanged: resizeTimer.restart()
onHeightChanged: resizeTimer.restart()
@@ -138,6 +139,11 @@ QtControls.ScrollView {
flick.contentWidth = flick.width
flick.contentHeight = flick.width / mouseArea.currPageDelegate.pageRatio
}
+ onClicked: {
+ if (Math.abs(currPageDelegate.x) < 20) {
+ root.clicked();
+ }
+ }
PageView {
id: page1