filedialog: add special icons for xdg dirs
This commit is contained in:
parent
abf4bd8e6b
commit
e00d5b124f
4 changed files with 29 additions and 12 deletions
|
|
@ -15,6 +15,8 @@ FloatingWindow {
|
|||
implicitHeight: 600
|
||||
color: Colours.palette.m3surface
|
||||
|
||||
onAccepted: visible = false
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,16 @@ Item {
|
|||
clip: true
|
||||
focus: true
|
||||
currentIndex: -1
|
||||
Keys.onEscapePressed: view.currentIndex = -1
|
||||
Keys.onEscapePressed: currentIndex = -1
|
||||
|
||||
Keys.onReturnPressed: {
|
||||
if (currentItem)
|
||||
root.dialog.accepted(currentItem.filePath);
|
||||
}
|
||||
Keys.onEnterPressed: {
|
||||
if (currentItem)
|
||||
root.dialog.accepted(currentItem.filePath);
|
||||
}
|
||||
|
||||
model: FolderListModel {
|
||||
showDirsFirst: true
|
||||
|
|
@ -87,13 +96,11 @@ Item {
|
|||
implicitHeight: nonAnimHeight
|
||||
|
||||
radius: Appearance.rounding.normal
|
||||
color: view.currentItem === item ? Colours.palette.m3primary : "transparent"
|
||||
z: view.currentItem === item || implicitHeight !== nonAnimHeight ? 1 : 0
|
||||
color: GridView.isCurrentItem ? Colours.palette.m3surfaceContainerHighest : "transparent"
|
||||
z: GridView.isCurrentItem || implicitHeight !== nonAnimHeight ? 1 : 0
|
||||
clip: true
|
||||
|
||||
StateLayer {
|
||||
color: view.currentItem === item ? Colours.palette.m3onPrimary : Colours.palette.m3onSurface
|
||||
|
||||
onDoubleClicked: {
|
||||
if (item.fileIsDir)
|
||||
root.dialog.cwd.push(item.fileName);
|
||||
|
|
@ -115,7 +122,17 @@ Item {
|
|||
|
||||
asynchronous: true
|
||||
implicitSize: Sizes.itemWidth - Appearance.padding.normal * 2
|
||||
source: Quickshell.iconPath(item.fileIsDir ? "inode-directory" : "application-x-zerosize")
|
||||
source: {
|
||||
if (!item.fileIsDir)
|
||||
return Quickshell.iconPath("application-x-zerosize");
|
||||
|
||||
const name = item.fileName;
|
||||
if (root.dialog.cwd.length === 1 && ["Desktop", "Documents", "Downloads", "Music", "Pictures", "Public", "Templates", "Videos"].includes(name))
|
||||
return Quickshell.iconPath(`folder-${name.toLowerCase()}`);
|
||||
|
||||
return Quickshell.iconPath("inode-directory");
|
||||
}
|
||||
|
||||
onStatusChanged: {
|
||||
if (status === Image.Error)
|
||||
source = Quickshell.iconPath("error");
|
||||
|
|
@ -144,9 +161,8 @@ Item {
|
|||
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: item.fileName
|
||||
color: view.currentItem === item ? Colours.palette.m3onPrimary : Colours.palette.m3onSurface
|
||||
elide: view.currentItem === item ? Text.ElideNone : Text.ElideRight
|
||||
wrapMode: view.currentItem === item ? Text.WrapAtWordBoundaryOrAnywhere : Text.NoWrap
|
||||
elide: item.GridView.isCurrentItem ? Text.ElideNone : Text.ElideRight
|
||||
wrapMode: item.GridView.isCurrentItem ? Text.WrapAtWordBoundaryOrAnywhere : Text.NoWrap
|
||||
}
|
||||
|
||||
Behavior on implicitHeight {
|
||||
|
|
|
|||
|
|
@ -46,8 +46,7 @@ StyledRect {
|
|||
required property string modelData
|
||||
readonly property bool selected: modelData === root.dialog.cwd[root.dialog.cwd.length - 1]
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: placeInner.implicitHeight + Appearance.padding.normal * 2
|
||||
|
||||
radius: Appearance.rounding.full
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ pragma Singleton
|
|||
import Quickshell
|
||||
|
||||
Singleton {
|
||||
property int itemWidth: 100
|
||||
property int itemWidth: 103
|
||||
property int sidebarWidth: 200
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue