2021-03-29 01:51:34 -07:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
2021-03-16 00:02:20 -07:00
|
|
|
import QtGraphicalEffects 1.0
|
2021-03-29 01:51:34 -07:00
|
|
|
|
2021-03-16 00:02:20 -07:00
|
|
|
import Cutefish.FileManager 1.0
|
2021-03-29 01:51:34 -07:00
|
|
|
import MeuiKit 1.0 as Meui
|
2021-03-16 00:02:20 -07:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: control
|
|
|
|
|
|
|
|
property string url: ""
|
|
|
|
|
2021-03-29 01:51:34 -07:00
|
|
|
signal itemClicked(string path)
|
|
|
|
signal editorAccepted(string path)
|
2021-03-16 00:02:20 -07:00
|
|
|
|
|
|
|
ListView {
|
2021-03-29 01:51:34 -07:00
|
|
|
id: _pathView
|
2021-03-16 00:02:20 -07:00
|
|
|
anchors.fill: parent
|
2021-03-29 01:51:34 -07:00
|
|
|
model: _pathBarModel
|
2021-03-16 00:02:20 -07:00
|
|
|
orientation: Qt.Horizontal
|
|
|
|
layoutDirection: Qt.LeftToRight
|
|
|
|
clip: true
|
|
|
|
|
2021-03-29 01:51:34 -07:00
|
|
|
leftMargin: 3
|
|
|
|
rightMargin: 3
|
2021-03-16 00:02:20 -07:00
|
|
|
spacing: Meui.Units.smallSpacing
|
|
|
|
|
|
|
|
onCountChanged: {
|
2021-03-29 01:51:34 -07:00
|
|
|
_pathView.currentIndex = _pathView.count - 1
|
|
|
|
_pathView.positionViewAtEnd()
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
color: Meui.Theme.backgroundColor
|
|
|
|
radius: Meui.Theme.smallRadius
|
|
|
|
z: -1
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
acceptedButtons: Qt.LeftButton
|
|
|
|
onClicked: openEditor()
|
|
|
|
z: -1
|
2021-03-16 00:02:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
delegate: MouseArea {
|
2021-03-29 01:51:34 -07:00
|
|
|
id: _item
|
|
|
|
height: ListView.view.height
|
|
|
|
width: _name.width + Meui.Units.largeSpacing
|
|
|
|
z: -1
|
2021-03-16 00:02:20 -07:00
|
|
|
|
2021-03-29 01:51:34 -07:00
|
|
|
property bool selected: index === _pathView.count - 1
|
2021-03-16 00:02:20 -07:00
|
|
|
|
2021-03-29 01:51:34 -07:00
|
|
|
onClicked: control.itemClicked(model.path)
|
2021-03-16 00:02:20 -07:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
2021-03-29 01:51:34 -07:00
|
|
|
anchors.topMargin: 2
|
|
|
|
anchors.bottomMargin: 2
|
2021-03-16 00:02:20 -07:00
|
|
|
color: Meui.Theme.highlightColor
|
|
|
|
radius: Meui.Theme.smallRadius
|
|
|
|
visible: selected
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
2021-03-29 01:51:34 -07:00
|
|
|
id: _name
|
|
|
|
text: model.name
|
|
|
|
color: selected ? Meui.Theme.highlightedTextColor : Meui.Theme.textColor
|
2021-03-16 00:02:20 -07:00
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TextField {
|
2021-03-29 01:51:34 -07:00
|
|
|
id: _pathEditor
|
|
|
|
anchors.fill: parent
|
2021-03-16 00:02:20 -07:00
|
|
|
visible: false
|
|
|
|
selectByMouse: true
|
|
|
|
inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhNoAutoUppercase
|
|
|
|
|
|
|
|
text: control.url
|
|
|
|
|
2021-04-04 22:01:49 -07:00
|
|
|
background: Rectangle {
|
|
|
|
radius: Meui.Theme.smallRadius
|
|
|
|
}
|
|
|
|
|
2021-03-16 00:02:20 -07:00
|
|
|
onAccepted: {
|
2021-03-29 01:51:34 -07:00
|
|
|
control.editorAccepted(text)
|
2021-03-16 00:02:20 -07:00
|
|
|
closeEditor()
|
|
|
|
}
|
|
|
|
|
|
|
|
Keys.onPressed: {
|
|
|
|
if (event.key === Qt.Key_Escape)
|
|
|
|
focus = false
|
|
|
|
}
|
|
|
|
|
|
|
|
onActiveFocusChanged: {
|
|
|
|
if (!activeFocus) {
|
|
|
|
closeEditor()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-29 01:51:34 -07:00
|
|
|
PathBarModel {
|
|
|
|
id: _pathBarModel
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateUrl(url) {
|
|
|
|
control.url = url
|
|
|
|
_pathBarModel.url = url
|
2021-03-16 00:02:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function openEditor() {
|
2021-03-29 01:51:34 -07:00
|
|
|
_pathEditor.text = control.url
|
|
|
|
_pathEditor.visible = true
|
|
|
|
_pathEditor.forceActiveFocus()
|
|
|
|
_pathEditor.selectAll()
|
|
|
|
_pathView.visible = false
|
|
|
|
}
|
|
|
|
|
|
|
|
function closeEditor() {
|
|
|
|
_pathEditor.visible = false
|
|
|
|
_pathView.visible = true
|
2021-03-16 00:02:20 -07:00
|
|
|
}
|
|
|
|
}
|