Warning, /libraries/kije/examples/lukin/Main.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 2.15 0002 import Qt.labs.folderlistmodel 2.15 0003 import QtQuick.Controls 2.15 as QQC2 0004 import QtQuick.Layouts 1.12 0005 import org.kde.kirigami 2.12 as Kirigami 0006 import org.kde.kije 1.0 as Kije 0007 0008 Kije.ApplicationWindow { 0009 id: appy 0010 title: "Lukin" 0011 0012 toolbar { 0013 defaultActions: ["left", "right", "path", "up"] 0014 potentialActions: [ 0015 Kije.Action { 0016 identifier: "left" 0017 text: "Back" 0018 displayName: "Go Backwards" 0019 enabled: appy.backStack.length > 0 0020 defaultShortcut: "Ctrl+A" 0021 0022 onTriggered: appy.clickBack() 0023 }, 0024 Kije.Action { 0025 identifier: "right" 0026 text: "Forward" 0027 displayName: "Go Forwards" 0028 enabled: appy.forwardStack.length > 0 0029 defaultShortcut: "Ctrl+D" 0030 0031 onTriggered: appy.clickForward() 0032 }, 0033 Kije.Action { 0034 identifier: "up" 0035 text: "Up" 0036 displayName: "Go Up" 0037 defaultShortcut: "Ctrl+W" 0038 0039 onTriggered: appy.clickGoTo(folderModel.parentFolder) 0040 }, 0041 Kije.Action { 0042 identifier: "path" 0043 displayName: "Path Bar" 0044 displayComponent: QQC2.Frame { 0045 Layout.fillWidth: true 0046 0047 RowLayout { 0048 Repeater { 0049 model: (folderModel.folder + "").split("//")[1].split("/") 0050 QQC2.Button { 0051 text: modelData 0052 onClicked: { 0053 appy.clickGoTo("file://" + (folderModel.folder + "").split("//")[1].split("/").slice(0, index+1).join("/")) 0054 } 0055 } 0056 } 0057 } 0058 } 0059 } 0060 ] 0061 } 0062 0063 property var backStack: [] 0064 property var forwardStack: [] 0065 0066 onSaveState: (obj) => { 0067 obj["backStack"] = this.backStack 0068 obj["forwardStack"] = this.forwardStack 0069 obj["location"] = folderModel.folder 0070 } 0071 onRestoreState: (obj) => { 0072 this.backStack = obj["backStack"] || [] 0073 this.forwardStack = obj["forwardStack"] || [] 0074 if (obj["location"]) { 0075 folderModel.folder = obj["location"] 0076 } 0077 } 0078 0079 function clickGoTo(folder) { 0080 backStack = backStack.concat([folderModel.folder]) 0081 forwardStack = [] 0082 folderModel.folder = folder 0083 } 0084 function clickBack() { 0085 let item = backStack 0086 let goTo = item.pop() 0087 0088 backStack = item 0089 forwardStack = forwardStack.concat([goTo]) 0090 folderModel.folder = goTo 0091 } 0092 function clickForward() { 0093 let item = forwardStack 0094 let goTo = item.pop() 0095 0096 forwardStack = item 0097 backStack = backStack.concat([goTo]) 0098 0099 folderModel.folder = goTo 0100 } 0101 0102 stack.initialItem: Item { 0103 GridView { 0104 anchors { 0105 fill: parent 0106 margins: Kirigami.Units.largeSpacing 0107 } 0108 model: FolderListModel { 0109 id: folderModel 0110 0111 showDirsFirst: true 0112 } 0113 0114 delegate: Item { 0115 implicitWidth: Kirigami.Units.gridUnit * 5 0116 implicitHeight: Kirigami.Units.gridUnit * 5 0117 ColumnLayout { 0118 anchors { 0119 verticalCenter: parent.verticalCenter 0120 left: parent.left 0121 right: parent.right 0122 } 0123 Kirigami.Icon { 0124 source: fileIsDir ? "system-file-manager" : "text-x-katefilelist" 0125 0126 Layout.preferredHeight: Kirigami.Units.iconSizes.large 0127 Layout.preferredWidth: Layout.preferredHeight 0128 Layout.alignment: Qt.AlignHCenter 0129 } 0130 QQC2.Label { 0131 text: fileBaseName 0132 horizontalAlignment: Text.AlignHCenter 0133 wrapMode: Text.Wrap 0134 elide: Text.ElideRight 0135 maximumLineCount: 2 0136 0137 Layout.fillWidth: true 0138 } 0139 } 0140 MouseArea { 0141 anchors.fill: parent 0142 onClicked: { 0143 if (fileIsDir) { 0144 appy.clickGoTo(filePath) 0145 } else { 0146 Qt.openUrlExternally(filePath) 0147 } 0148 } 0149 } 0150 } 0151 } 0152 } 0153 0154 }