Commit 43e6d63e authored by Marco Martin's avatar Marco Martin
Browse files

a simple file browser ui

a file browser ui shown when no files are passed to commandline,
just lists files from ~/Documents
parent 9c9a928e
......@@ -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
}
}
}
}
}
......
/*
* 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;
}
}
}
}
}
......@@ -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;
}
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment