summaryrefslogtreecommitdiff
path: root/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modals/FileBrowser/FileBrowserSortMenu.qml
blob: e1886f9f0bc2501db06d859b8fc259fa8bbbd51b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import QtQuick
import qs.Common
import qs.Widgets

StyledRect {
    id: sortMenu

    property string sortBy: "name"
    property bool sortAscending: true

    signal sortBySelected(string value)
    signal sortOrderSelected(bool ascending)

    width: 200
    height: sortColumn.height + Theme.spacingM * 2
    color: Theme.surfaceContainer
    radius: Theme.cornerRadius
    border.color: Theme.outlineMedium
    border.width: 1
    visible: false
    z: 100

    Column {
        id: sortColumn
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.top: parent.top
        anchors.margins: Theme.spacingM
        spacing: Theme.spacingXS

        StyledText {
            text: "Sort By"
            font.pixelSize: Theme.fontSizeSmall
            color: Theme.surfaceTextMedium
            font.weight: Font.Medium
        }

        Repeater {
            model: [{
                    "name": "Name",
                    "value": "name"
                }, {
                    "name": "Size",
                    "value": "size"
                }, {
                    "name": "Modified",
                    "value": "modified"
                }, {
                    "name": "Type",
                    "value": "type"
                }]

            StyledRect {
                width: sortColumn?.width ?? 0
                height: 32
                radius: Theme.cornerRadius
                color: sortMouseArea.containsMouse ? Theme.surfaceVariant : (sortBy === modelData?.value ? Theme.surfacePressed : "transparent")

                Row {
                    anchors.fill: parent
                    anchors.leftMargin: Theme.spacingS
                    spacing: Theme.spacingS

                    DankIcon {
                        name: sortBy === modelData?.value ? "check" : ""
                        size: Theme.iconSizeSmall
                        color: Theme.primary
                        anchors.verticalCenter: parent.verticalCenter
                        visible: sortBy === modelData?.value
                    }

                    StyledText {
                        text: modelData?.name ?? ""
                        font.pixelSize: Theme.fontSizeMedium
                        color: sortBy === modelData?.value ? Theme.primary : Theme.surfaceText
                        anchors.verticalCenter: parent.verticalCenter
                    }
                }

                MouseArea {
                    id: sortMouseArea
                    anchors.fill: parent
                    hoverEnabled: true
                    cursorShape: Qt.PointingHandCursor
                    onClicked: {
                        sortMenu.sortBySelected(modelData?.value ?? "name")
                        sortMenu.visible = false
                    }
                }
            }
        }

        StyledRect {
            width: sortColumn.width
            height: 1
            color: Theme.outline
        }

        StyledText {
            text: "Order"
            font.pixelSize: Theme.fontSizeSmall
            color: Theme.surfaceTextMedium
            font.weight: Font.Medium
            topPadding: Theme.spacingXS
        }

        StyledRect {
            width: sortColumn?.width ?? 0
            height: 32
            radius: Theme.cornerRadius
            color: ascMouseArea.containsMouse ? Theme.surfaceVariant : (sortAscending ? Theme.surfacePressed : "transparent")

            Row {
                anchors.fill: parent
                anchors.leftMargin: Theme.spacingS
                spacing: Theme.spacingS

                DankIcon {
                    name: "arrow_upward"
                    size: Theme.iconSizeSmall
                    color: sortAscending ? Theme.primary : Theme.surfaceText
                    anchors.verticalCenter: parent.verticalCenter
                }

                StyledText {
                    text: "Ascending"
                    font.pixelSize: Theme.fontSizeMedium
                    color: sortAscending ? Theme.primary : Theme.surfaceText
                    anchors.verticalCenter: parent.verticalCenter
                }
            }

            MouseArea {
                id: ascMouseArea
                anchors.fill: parent
                hoverEnabled: true
                cursorShape: Qt.PointingHandCursor
                onClicked: {
                    sortMenu.sortOrderSelected(true)
                    sortMenu.visible = false
                }
            }
        }

        StyledRect {
            width: sortColumn?.width ?? 0
            height: 32
            radius: Theme.cornerRadius
            color: descMouseArea.containsMouse ? Theme.surfaceVariant : (!sortAscending ? Theme.surfacePressed : "transparent")

            Row {
                anchors.fill: parent
                anchors.leftMargin: Theme.spacingS
                spacing: Theme.spacingS

                DankIcon {
                    name: "arrow_downward"
                    size: Theme.iconSizeSmall
                    color: !sortAscending ? Theme.primary : Theme.surfaceText
                    anchors.verticalCenter: parent.verticalCenter
                }

                StyledText {
                    text: "Descending"
                    font.pixelSize: Theme.fontSizeMedium
                    color: !sortAscending ? Theme.primary : Theme.surfaceText
                    anchors.verticalCenter: parent.verticalCenter
                }
            }

            MouseArea {
                id: descMouseArea
                anchors.fill: parent
                hoverEnabled: true
                cursorShape: Qt.PointingHandCursor
                onClicked: {
                    sortMenu.sortOrderSelected(false)
                    sortMenu.visible = false
                }
            }
        }
    }
}