summaryrefslogtreecommitdiff
path: root/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/Notepad/NotepadSettings.qml
blob: 9265ddf845a2db32d9925ec6a9f091fdc49e1857 (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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
pragma ComponentBehavior: Bound
import QtQuick
import qs.Common
import qs.Widgets

Item {
    id: root

    property bool isVisible: false
    property var cachedFontFamilies: []
    property var cachedMonoFamilies: []
    property bool fontsEnumerated: false

    signal settingsRequested
    signal findRequested

    function enumerateFonts() {
        var fonts = ["Default"];
        var availableFonts = Qt.fontFamilies();
        var rootFamilies = [];
        var seenFamilies = new Set();
        for (var i = 0; i < availableFonts.length; i++) {
            var fontName = availableFonts[i];
            if (fontName.startsWith("."))
                continue;
            if (fontName === Theme.defaultFontFamily)
                continue;
            var rootName = fontName.replace(/ (Thin|Extra Light|Light|Regular|Medium|Semi Bold|Demi Bold|Bold|Extra Bold|Black|Heavy)$/i, "").replace(/ (Italic|Oblique|Condensed|Extended|Narrow|Wide)$/i, "").replace(/ (UI|Display|Text|Mono|Sans|Serif)$/i, function (match, suffix) {
                return match;
            }).trim();
            if (!seenFamilies.has(rootName) && rootName !== "") {
                seenFamilies.add(rootName);
                rootFamilies.push(rootName);
            }
        }
        cachedFontFamilies = fonts.concat(rootFamilies.sort());
        var monoFonts = ["Default"];
        var monoFamilies = [];
        var seenMonoFamilies = new Set();
        for (var j = 0; j < availableFonts.length; j++) {
            var fontName2 = availableFonts[j];
            if (fontName2.startsWith("."))
                continue;
            if (fontName2 === SettingsData.defaultMonoFontFamily)
                continue;
            var lowerName = fontName2.toLowerCase();
            if (lowerName.includes("mono") || lowerName.includes("code") || lowerName.includes("console") || lowerName.includes("terminal") || lowerName.includes("courier") || lowerName.includes("dejavu sans mono") || lowerName.includes("jetbrains") || lowerName.includes("fira") || lowerName.includes("hack") || lowerName.includes("source code") || lowerName.includes("ubuntu mono") || lowerName.includes("cascadia")) {
                var rootName2 = fontName2.replace(/ (Thin|Extra Light|Light|Regular|Medium|Semi Bold|Demi Bold|Bold|Extra Bold|Black|Heavy)$/i, "").replace(/ (Italic|Oblique|Condensed|Extended|Narrow|Wide)$/i, "").trim();
                if (!seenMonoFamilies.has(rootName2) && rootName2 !== "") {
                    seenMonoFamilies.add(rootName2);
                    monoFamilies.push(rootName2);
                }
            }
        }
        cachedMonoFamilies = monoFonts.concat(monoFamilies.sort());
        fontsEnumerated = true;
    }

    Component.onCompleted: {
        if (!fontsEnumerated) {
            enumerateFonts();
        }
    }

    MouseArea {
        anchors.fill: parent
        visible: root.isVisible
        onClicked: root.settingsRequested()
        z: 50
    }

    Rectangle {
        id: settingsMenu
        visible: root.isVisible
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.verticalCenter: parent.verticalCenter
        width: 360
        height: settingsColumn.implicitHeight + Theme.spacingXL * 2
        radius: Theme.cornerRadius
        color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, Theme.notepadTransparency)
        border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
        border.width: 1
        z: 100

        Rectangle {
            anchors.fill: parent
            anchors.topMargin: 4
            anchors.leftMargin: 2
            anchors.rightMargin: -2
            anchors.bottomMargin: -4
            radius: parent.radius
            color: Qt.rgba(0, 0, 0, 0.15)
            z: parent.z - 1
        }

        Column {
            id: settingsColumn
            width: parent.width - Theme.spacingXL * 2
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.top: parent.top
            anchors.topMargin: Theme.spacingXL
            spacing: Theme.spacingS

            Rectangle {
                width: parent.width
                height: 36
                color: "transparent"

                StyledText {
                    anchors.left: parent.left
                    anchors.leftMargin: -Theme.spacingXS
                    anchors.verticalCenter: parent.verticalCenter
                    text: I18n.tr("Notepad Font Settings")
                    font.pixelSize: Theme.fontSizeMedium
                    font.weight: Font.Medium
                    color: Theme.surfaceText
                }
            }

            Rectangle {
                width: parent.width
                height: 1
                color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
            }

            DankToggle {
                anchors.left: parent.left
                anchors.leftMargin: -Theme.spacingM
                width: parent.width + Theme.spacingM
                text: I18n.tr("Use Monospace Font")
                description: "Toggle fonts"
                checked: SettingsData.notepadUseMonospace
                onToggled: checked => {
                    SettingsData.notepadUseMonospace = checked;
                }
            }

            DankToggle {
                anchors.left: parent.left
                anchors.leftMargin: -Theme.spacingM
                width: parent.width + Theme.spacingM
                text: I18n.tr("Show Line Numbers")
                description: "Display line numbers in editor"
                checked: SettingsData.notepadShowLineNumbers
                onToggled: checked => {
                    SettingsData.notepadShowLineNumbers = checked;
                }
            }

            StyledRect {
                width: parent.width
                height: 60
                radius: Theme.cornerRadius
                color: "transparent"

                StateLayer {
                    anchors.fill: parent
                    anchors.leftMargin: -Theme.spacingM
                    width: parent.width + Theme.spacingM
                    stateColor: Theme.primary
                    cornerRadius: parent.radius
                    onClicked: root.findRequested()
                }

                Row {
                    anchors.left: parent.left
                    anchors.leftMargin: -Theme.spacingM
                    anchors.right: parent.right
                    anchors.rightMargin: Theme.spacingM
                    anchors.verticalCenter: parent.verticalCenter
                    spacing: Theme.spacingM

                    DankIcon {
                        name: "search"
                        size: Theme.iconSize - 2
                        color: Theme.primary
                        anchors.verticalCenter: parent.verticalCenter
                    }

                    Column {
                        anchors.verticalCenter: parent.verticalCenter
                        spacing: Theme.spacingXS

                        StyledText {
                            text: I18n.tr("Find in Text")
                            font.pixelSize: Theme.fontSizeMedium
                            font.weight: Font.Medium
                            color: Theme.surfaceText
                        }

                        StyledText {
                            text: I18n.tr("Open search bar to find text")
                            font.pixelSize: Theme.fontSizeSmall
                            color: Theme.surfaceVariantText
                        }
                    }
                }
            }

            Rectangle {
                width: parent.width
                height: visible ? (fontDropdown.height + Theme.spacingS) : 0
                color: "transparent"
                visible: !SettingsData.notepadUseMonospace

                DankDropdown {
                    id: fontDropdown
                    anchors.left: parent.left
                    anchors.leftMargin: -Theme.spacingM
                    width: parent.width + Theme.spacingM
                    text: I18n.tr("Font Family")
                    options: cachedFontFamilies
                    currentValue: {
                        if (!SettingsData.notepadFontFamily || SettingsData.notepadFontFamily === "")
                            return "Default (Global)";
                        else
                            return SettingsData.notepadFontFamily;
                    }
                    enableFuzzySearch: true
                    onValueChanged: value => {
                        if (value && (value.startsWith("Default") || value === "Default (Global)")) {
                            SettingsData.notepadFontFamily = "";
                        } else {
                            SettingsData.notepadFontFamily = value;
                        }
                    }
                }
            }

            Rectangle {
                width: parent.width
                height: fontSizeRow.height + Theme.spacingS
                color: "transparent"

                Row {
                    id: fontSizeRow
                    width: parent.width
                    spacing: Theme.spacingS

                    Column {
                        width: parent.width - fontSizeControls.width - Theme.spacingM
                        spacing: Theme.spacingXS

                        StyledText {
                            text: I18n.tr("Font Size")
                            font.pixelSize: Theme.fontSizeSmall
                            font.weight: Font.Medium
                            color: Theme.surfaceText
                        }

                        StyledText {
                            text: SettingsData.notepadFontSize + "px"
                            font.pixelSize: Theme.fontSizeSmall
                            color: Theme.surfaceVariantText
                            width: parent.width
                        }
                    }

                    Row {
                        id: fontSizeControls
                        spacing: Theme.spacingS
                        anchors.verticalCenter: parent.verticalCenter

                        DankActionButton {
                            buttonSize: 32
                            iconName: "remove"
                            iconSize: Theme.iconSizeSmall
                            enabled: SettingsData.notepadFontSize > 8
                            backgroundColor: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.5)
                            iconColor: Theme.surfaceText
                            onClicked: {
                                var newSize = Math.max(8, SettingsData.notepadFontSize - 1);
                                SettingsData.notepadFontSize = newSize;
                            }
                        }

                        Rectangle {
                            width: 60
                            height: 32
                            radius: Theme.cornerRadius
                            color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.3)
                            border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
                            border.width: 1

                            StyledText {
                                anchors.centerIn: parent
                                text: SettingsData.notepadFontSize + "px"
                                font.pixelSize: Theme.fontSizeSmall
                                font.weight: Font.Medium
                                color: Theme.surfaceText
                            }
                        }

                        DankActionButton {
                            buttonSize: 32
                            iconName: "add"
                            iconSize: Theme.iconSizeSmall
                            enabled: SettingsData.notepadFontSize < 48
                            backgroundColor: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.5)
                            iconColor: Theme.surfaceText
                            onClicked: {
                                var newSize = Math.min(48, SettingsData.notepadFontSize + 1);
                                SettingsData.notepadFontSize = newSize;
                            }
                        }
                    }
                }
            }

            Rectangle {
                width: parent.width
                height: transparencySliderColumn.height + Theme.spacingS
                color: "transparent"

                Column {
                    id: transparencySliderColumn
                    width: parent.width
                    spacing: Theme.spacingS

                    DankToggle {
                        anchors.left: parent.left
                        anchors.leftMargin: -Theme.spacingM
                        width: parent.width + Theme.spacingM
                        text: I18n.tr("Custom Transparency")
                        description: "Override global transparency for Notepad"
                        checked: SettingsData.notepadTransparencyOverride >= 0
                        onToggled: checked => {
                            if (checked) {
                                SettingsData.notepadTransparencyOverride = SettingsData.notepadLastCustomTransparency;
                            } else {
                                SettingsData.notepadTransparencyOverride = -1;
                            }
                        }
                    }

                    DankSlider {
                        anchors.left: parent.left
                        anchors.leftMargin: -Theme.spacingM
                        width: parent.width + Theme.spacingM
                        height: 24
                        visible: SettingsData.notepadTransparencyOverride >= 0
                        value: Math.round((SettingsData.notepadTransparencyOverride >= 0 ? SettingsData.notepadTransparencyOverride : SettingsData.popupTransparency) * 100)
                        minimum: 0
                        maximum: 100
                        unit: ""
                        showValue: true
                        wheelEnabled: false
                        onSliderValueChanged: newValue => {
                            if (SettingsData.notepadTransparencyOverride >= 0) {
                                SettingsData.notepadTransparencyOverride = newValue / 100;
                            }
                        }
                    }
                }
            }

            StyledText {
                width: parent.width
                text: SettingsData.notepadUseMonospace ? "Using global monospace font from Settings → Personalization" : "Global fonts can be configured in Settings → Personalization"
                font.pixelSize: Theme.fontSizeSmall
                color: Theme.surfaceTextMedium
                wrapMode: Text.WordWrap
                opacity: 0.8
            }
        }
    }
}