-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFolderViewCreateStackDialog.qml
More file actions
116 lines (99 loc) · 3.16 KB
/
Copy pathFolderViewCreateStackDialog.qml
File metadata and controls
116 lines (99 loc) · 3.16 KB
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
import QtQuick
import QtQuick.Controls
import Quickshell
import qs.Common
import qs.Widgets
import qs.Services
import "./dms-common"
Popup {
id: createStackDialog
width: 260
height: 156
padding: 0
modal: false
focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
x: parent ? Math.round((parent.width - width) / 2) : 0
y: parent ? Math.round((parent.height - height) / 2) : 0
property var selectedPaths: []
property var inputField: null
onOpened: {
Qt.callLater(() => {
if (createStackDialog.inputField) {
createStackDialog.inputField.forceActiveFocus();
createStackDialog.inputField.selectAll();
}
});
}
background: Rectangle {
color: "transparent"
}
contentItem: Rectangle {
color: Theme.surfaceContainer
radius: Theme.cornerRadius
border.color: Theme.withAlpha(Theme.outline, 0.15)
border.width: 1
Column {
anchors.fill: parent
anchors.margins: Theme.spacingM
spacing: Theme.spacingS
StyledText {
text: I18n.tr("Create Stack")
font.bold: true
font.pixelSize: Theme.fontSizeMedium
color: Theme.surfaceText
}
Row {
width: parent.width
spacing: Theme.spacingS
DankTextField {
id: stackNameField
width: parent.width
placeholderText: I18n.tr("Stack name...")
focus: true
onAccepted: createStackDialog.performCreate()
Component.onCompleted: {
createStackDialog.inputField = stackNameField;
}
}
}
Row {
width: parent.width
spacing: Theme.spacingS
layoutDirection: Qt.RightToLeft
DankButton {
text: I18n.tr("Create")
backgroundColor: Theme.primary
textColor: Theme.primaryText
onClicked: createStackDialog.performCreate()
}
DankButton {
text: I18n.tr("Cancel")
backgroundColor: Theme.surfaceContainerHigh
textColor: Theme.surfaceText
onClicked: createStackDialog.close()
}
}
}
}
function showFor(paths) {
createStackDialog.selectedPaths = paths || [];
if (createStackDialog.inputField) {
createStackDialog.inputField.text = "New Stack";
}
createStackDialog.open();
}
function performCreate() {
if (!createStackDialog.inputField) {
createStackDialog.close();
return;
}
const name = createStackDialog.inputField.text.trim();
if (name.length === 0) {
createStackDialog.close();
return;
}
root.createStack(name, createStackDialog.selectedPaths);
createStackDialog.close();
}
}