106 lines
2.8 KiB
QML
106 lines
2.8 KiB
QML
import QtQuick 2.0
|
|
import Sailfish.Silica 1.0
|
|
import EQL5 1.0
|
|
|
|
Page {
|
|
id: files
|
|
objectName: "filesPage"
|
|
allowedOrientations: Orientation.All
|
|
|
|
SilicaListView {
|
|
id: listView
|
|
anchors.fill: parent
|
|
|
|
header: PageHeader {
|
|
title: qsTr("Files")
|
|
}
|
|
|
|
model: fileListModel
|
|
|
|
section {
|
|
property: 'section'
|
|
|
|
delegate: SectionHeader {
|
|
text: section == "recentf" ? qsTr("Recent files") : section
|
|
height: Theme.itemSizeExtraSmall
|
|
}
|
|
}
|
|
|
|
delegate: ListItem {
|
|
id: fileItem
|
|
|
|
anchors {
|
|
left: parent.left
|
|
right: parent.right
|
|
}
|
|
contentHeight: Theme.itemSizeSmall
|
|
|
|
Label {
|
|
text: section == "recentf" ? directory + filename : filename
|
|
elide: Text.ElideMiddle
|
|
width: parent.width - Theme.horizontalPageMargin * 2
|
|
font.pixelSize: Theme.fontSizeMedium
|
|
anchors {
|
|
top: parent.top
|
|
left: parent.left
|
|
leftMargin: Theme.horizontalPageMargin
|
|
rightMargin: Theme.horizontalPageMargin
|
|
centerIn: parent
|
|
}
|
|
}
|
|
|
|
onClicked: openEditor(directory, filename)
|
|
|
|
menu: ContextMenu {
|
|
MenuItem {
|
|
visible: section == "recentf"
|
|
text: qsTr("Remove from list")
|
|
onClicked: {
|
|
remorse.execute(fileItem, "", function () {
|
|
console.log("Remove file from list: " + filename)
|
|
})
|
|
}
|
|
}
|
|
|
|
MenuItem {
|
|
text: qsTr("Delete file")
|
|
onClicked: {
|
|
remorse.execute(fileItem, "", function () {
|
|
console.log("Delete file: " + filename)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
ViewPlaceholder {
|
|
id: placeholder
|
|
enabled: listView.count == 0
|
|
text: qsTr("Pull down to open a file")
|
|
}
|
|
|
|
PullDownMenu {
|
|
MenuItem {
|
|
text: qsTr("Settings")
|
|
}
|
|
|
|
MenuItem {
|
|
text: qsTr("Open file")
|
|
}
|
|
|
|
MenuItem {
|
|
text: qsTr("New file")
|
|
}
|
|
}
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
if (Lisp.call("cockpit:show-welcome-screen-p"))
|
|
openFile(Lisp.call("cockpit:data-path"), "welcome.org")
|
|
}
|
|
|
|
function openEditor(directory, filename) {
|
|
var filepath = directory + filename
|
|
pageStack.push(Qt.resolvedUrl("Editor.qml"), {filepath: filepath, filename: filename})
|
|
}
|
|
}
|