summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Martin <notmart@gmail.com>2015-07-21 17:00:45 (GMT)
committerMarco Martin <notmart@gmail.com>2015-07-21 17:00:45 (GMT)
commit43e6d63e9621c618f77367d3d6bd3828db42c118 (patch)
tree1dba0a14531c55680825ba718b9f245814e46e76
parent9c9a928e12bf42943d0b3a83712654c6d5ccb82a (diff)
a simple file browser ui
a file browser ui shown when no files are passed to commandline, just lists files from ~/Documents
-rw-r--r--active/app/package/contents/ui/Browser.qml33
-rw-r--r--active/app/package/contents/ui/Documents.qml106
-rw-r--r--active/app/package/contents/ui/main.qml5
3 files changed, 126 insertions, 18 deletions
diff --git a/active/app/package/contents/ui/Browser.qml b/active/app/package/contents/ui/Browser.qml
index 1cdea18..be4c955 100644
--- a/active/app/package/contents/ui/Browser.qml
+++ b/active/app/package/contents/ui/Browser.qml
@@ -145,10 +145,10 @@ MobileComponents.OverlayDrawer {
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)
@@ -172,7 +172,7 @@ MobileComponents.OverlayDrawer {
left: parent.left
top: mainToolBar.bottom
right: parent.right
- bottom: parent.bottom
+ bottom: tabsToolbar.top
}
clip: true
toolBar: mainToolBar
@@ -184,24 +184,17 @@ MobileComponents.OverlayDrawer {
target: pageStack.currentPage
onContentYChanged: {
-
- if (pageStack.currentPage.contentHeight <= pageStack.height ||
- (scrollConnection.oldContentY < pageStack.currentPage.contentY &&
- pageStack.currentPage.contentY > 0)) {
- tabsToolbar.y = tabsToolbar.parent.height - tabsToolbar.height
- } else {
- tabsToolbar.y = tabsToolbar.parent.height
- }
scrollConnection.oldContentY = pageStack.currentPage.contentY
}
}
PlasmaComponents.ToolBar {
id: tabsToolbar
- y: parent.height
+ y: parent.height - tabsToolbar.height*5
+ height: mainTabBar.height
anchors {
top: undefined
- bottom: undefined
+ bottom: browserFrame.bottom
left: parent.left
right: parent.right
}
@@ -211,6 +204,17 @@ MobileComponents.OverlayDrawer {
PlasmaComponents.TabBar {
id: mainTabBar
anchors.horizontalCenter: parent.horizontalCenter
+ width: Math.min(parent.width, implicitWidth)
+ tabPosition: Qt.BottomEdge
+ PlasmaComponents.TabButton {
+ id: documentsButton
+ text: i18n("Documents")
+ onCheckedChanged: {
+ if (checked) {
+ pageStack.replace(Qt.createComponent("Documents.qml"))
+ }
+ }
+ }
PlasmaComponents.TabButton {
id: thumbnailsButton
text: i18n("Thumbnails")
@@ -242,11 +246,6 @@ MobileComponents.OverlayDrawer {
}
}
}
- Behavior on y {
- NumberAnimation {
- duration: 250
- }
- }
}
}
}
diff --git a/active/app/package/contents/ui/Documents.qml b/active/app/package/contents/ui/Documents.qml
new file mode 100644
index 0000000..4902c0e
--- /dev/null
+++ b/active/app/package/contents/ui/Documents.qml
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2015 Marco Martin <mart@kde.org>
+ *
+ * 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 Qt.labs.folderlistmodel 2.1
+
+PlasmaComponents.Page {
+ id: root
+ anchors.fill: parent
+ property Item view: filesView
+ property alias contentY: filesView.contentY
+ property alias contentHeight: filesView.contentHeight
+ property alias model: filesView.model
+
+ tools: Item {
+ id: toolBarContent
+ width: root.width
+ height: searchField.height
+ MobileComponents.ViewSearch {
+ id: searchField
+ enabled: documentItem.supportsSearch
+ anchors.centerIn: parent
+ busy: documentItem.searchInProgress
+ onSearchQueryChanged: {
+ if (searchQuery.length > 2) {
+ filterModel.filterRegExp = ".*" + searchQuery + ".*";
+ } else {
+ filterModel.filterRegExp = "";
+ }
+ }
+ }
+ }
+
+ PlasmaExtras.ScrollArea {
+ anchors.fill: parent
+ GridView {
+ id: filesView
+ anchors.fill: parent
+ cellWidth: units.gridUnit * 5
+ cellHeight: units.gridUnit * 5
+ model: PlasmaCore.SortFilterModel {
+ id: filterModel
+ filterRole: "fileName"
+ sourceModel: FolderListModel {
+ id: folderModel
+ folder: userPaths.documents
+ nameFilters: ["*.pdf", "*.txt", "*.chm", "*.epub"]
+ showDirs: false
+ }
+ }
+
+ 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"
+ }
+ PlasmaComponents.Label {
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: icon.bottom
+ bottom: parent.bottom
+ }
+ text: model.fileName
+ horizontalAlignment: Text.AlignHCenter
+ wrapMode: Text.WordWrap
+ elide: Text.ElideRight
+ }
+ onClicked: {
+ documentItem.path = model.filePath;
+ resourceBrowser.open = false;
+ mainTabBar.currentTab = thumbnailsButton;
+ }
+ }
+ }
+ }
+}
diff --git a/active/app/package/contents/ui/main.qml b/active/app/package/contents/ui/main.qml
index 0a776b7..37ae5f5 100644
--- a/active/app/package/contents/ui/main.qml
+++ b/active/app/package/contents/ui/main.qml
@@ -59,7 +59,10 @@ ApplicationWindow {
documentItem.path = commandlineArguments[0]
}
- mainStack.push(Qt.createComponent("Browser.qml"))
+ var browser = mainStack.push(Qt.createComponent("Browser.qml"))
+ if (commandlineArguments.length == 0) {
+ browser.open = true;
+ }
}
}
}