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
|
implicitHeight: 600
|
||||||
color: Colours.palette.m3surface
|
color: Colours.palette.m3surface
|
||||||
|
|
||||||
|
onAccepted: visible = false
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,16 @@ Item {
|
||||||
clip: true
|
clip: true
|
||||||
focus: true
|
focus: true
|
||||||
currentIndex: -1
|
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 {
|
model: FolderListModel {
|
||||||
showDirsFirst: true
|
showDirsFirst: true
|
||||||
|
|
@ -87,13 +96,11 @@ Item {
|
||||||
implicitHeight: nonAnimHeight
|
implicitHeight: nonAnimHeight
|
||||||
|
|
||||||
radius: Appearance.rounding.normal
|
radius: Appearance.rounding.normal
|
||||||
color: view.currentItem === item ? Colours.palette.m3primary : "transparent"
|
color: GridView.isCurrentItem ? Colours.palette.m3surfaceContainerHighest : "transparent"
|
||||||
z: view.currentItem === item || implicitHeight !== nonAnimHeight ? 1 : 0
|
z: GridView.isCurrentItem || implicitHeight !== nonAnimHeight ? 1 : 0
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
StateLayer {
|
StateLayer {
|
||||||
color: view.currentItem === item ? Colours.palette.m3onPrimary : Colours.palette.m3onSurface
|
|
||||||
|
|
||||||
onDoubleClicked: {
|
onDoubleClicked: {
|
||||||
if (item.fileIsDir)
|
if (item.fileIsDir)
|
||||||
root.dialog.cwd.push(item.fileName);
|
root.dialog.cwd.push(item.fileName);
|
||||||
|
|
@ -115,7 +122,17 @@ Item {
|
||||||
|
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
implicitSize: Sizes.itemWidth - Appearance.padding.normal * 2
|
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: {
|
onStatusChanged: {
|
||||||
if (status === Image.Error)
|
if (status === Image.Error)
|
||||||
source = Quickshell.iconPath("error");
|
source = Quickshell.iconPath("error");
|
||||||
|
|
@ -144,9 +161,8 @@ Item {
|
||||||
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
text: item.fileName
|
text: item.fileName
|
||||||
color: view.currentItem === item ? Colours.palette.m3onPrimary : Colours.palette.m3onSurface
|
elide: item.GridView.isCurrentItem ? Text.ElideNone : Text.ElideRight
|
||||||
elide: view.currentItem === item ? Text.ElideNone : Text.ElideRight
|
wrapMode: item.GridView.isCurrentItem ? Text.WrapAtWordBoundaryOrAnywhere : Text.NoWrap
|
||||||
wrapMode: view.currentItem === item ? Text.WrapAtWordBoundaryOrAnywhere : Text.NoWrap
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on implicitHeight {
|
Behavior on implicitHeight {
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,7 @@ StyledRect {
|
||||||
required property string modelData
|
required property string modelData
|
||||||
readonly property bool selected: modelData === root.dialog.cwd[root.dialog.cwd.length - 1]
|
readonly property bool selected: modelData === root.dialog.cwd[root.dialog.cwd.length - 1]
|
||||||
|
|
||||||
anchors.left: parent.left
|
Layout.fillWidth: true
|
||||||
anchors.right: parent.right
|
|
||||||
implicitHeight: placeInner.implicitHeight + Appearance.padding.normal * 2
|
implicitHeight: placeInner.implicitHeight + Appearance.padding.normal * 2
|
||||||
|
|
||||||
radius: Appearance.rounding.full
|
radius: Appearance.rounding.full
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@ pragma Singleton
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
property int itemWidth: 100
|
property int itemWidth: 103
|
||||||
property int sidebarWidth: 200
|
property int sidebarWidth: 200
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue