added editing for profiles\versions

This commit is contained in:
2026-06-16 12:16:59 +03:00
parent bbbed6aa89
commit 966cd46049
5 changed files with 393 additions and 4 deletions
+345 -2
View File
@@ -190,7 +190,7 @@ Window {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
leftPadding: 8
rightPadding: 36
rightPadding: 62
}
background: Rectangle {
color: (profileBox.currentIndex === profileItem.index || profileItem.hovered)
@@ -202,6 +202,28 @@ Window {
profileBox.popup.close()
}
// ── Карандаш — видна при наведении на строку ────
Image {
id: profilePencil
width: 16; height: 16
anchors.right: profileTrash.left
anchors.rightMargin: 12
anchors.verticalCenter: parent.verticalCenter
visible: profileItem.hovered
opacity: profilePencilArea.containsMouse ? 1.0 : 0.7
source: "images/Pencil.svg"
sourceSize.width: 16; sourceSize.height: 16
fillMode: Image.PreserveAspectFit
MouseArea {
id: profilePencilArea
anchors.fill: parent
anchors.margins: -6
hoverEnabled: true
onClicked: editProfileDialog.openFor(profileItem.index)
}
}
// ── Корзина — видна при наведении на строку ─────
Image {
id: profileTrash
@@ -354,7 +376,7 @@ Window {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
leftPadding: 8
rightPadding: 36
rightPadding: 62
}
background: Rectangle {
color: (versionBox.currentIndex === versionItem.index || versionItem.hovered)
@@ -366,6 +388,28 @@ Window {
versionBox.popup.close()
}
// ── Карандаш — видна при наведении на строку ────
Image {
id: versionPencil
width: 16; height: 16
anchors.right: versionTrash.left
anchors.rightMargin: 12
anchors.verticalCenter: parent.verticalCenter
visible: versionItem.hovered
opacity: versionPencilArea.containsMouse ? 1.0 : 0.7
source: "images/Pencil.svg"
sourceSize.width: 16; sourceSize.height: 16
fillMode: Image.PreserveAspectFit
MouseArea {
id: versionPencilArea
anchors.fill: parent
anchors.margins: -6
hoverEnabled: true
onClicked: editVersionDialog.openFor(versionItem.index)
}
}
// ── Корзина — видна при наведении на строку ─────
Image {
id: versionTrash
@@ -680,4 +724,303 @@ Window {
verName.text = ""; verServer.text = ""
}
}
// ── Edit Profile Dialog ────────────────────────────────────────────────
// Идентичен диалогу создания, но с предзаполненными данными выбранного
// профиля. По нажатию ОК данные перезаписываются под тем же индексом.
Dialog {
id: editProfileDialog
modal: true
width: 320
x: (window.width - width) / 2
y: (window.height - height) / 2
padding: 0
property int editIndex: -1
function openFor(index) {
const data = backend.profileAt(index)
editIndex = index
epName.text = data.name || ""
epLogin.text = data.login || ""
epPassword.text = data.password || ""
profileBox.popup.close()
open()
}
background: Rectangle {
color: "#1e1e1e"
radius: 10
border.color: "#91B315"
border.width: 1
}
header: Item {
implicitHeight: 52
Text {
anchors.centerIn: parent
text: "Редактирование профиля"
color: "#ffffff"
font.pixelSize: 17
font.bold: true
}
Rectangle {
anchors.bottom: parent.bottom
width: parent.width
height: 1
color: "#333333"
}
}
contentItem: Column {
spacing: 12
topPadding: 20
bottomPadding: 20
TextField {
id: epName
x: 20
width: parent.width - 40
placeholderText: "Имя профиля"
color: "#ffffff"
placeholderTextColor: "#666666"
background: Rectangle {
color: "#2a2a2a"
radius: 6
border.color: epName.activeFocus ? "#91B315" : "#444444"
border.width: 1
}
}
TextField {
id: epLogin
x: 20
width: parent.width - 40
placeholderText: "Логин"
color: "#ffffff"
placeholderTextColor: "#666666"
background: Rectangle {
color: "#2a2a2a"
radius: 6
border.color: epLogin.activeFocus ? "#91B315" : "#444444"
border.width: 1
}
}
TextField {
id: epPassword
x: 20
width: parent.width - 40
placeholderText: "Пароль"
echoMode: TextInput.Password
color: "#ffffff"
placeholderTextColor: "#666666"
background: Rectangle {
color: "#2a2a2a"
radius: 6
border.color: epPassword.activeFocus ? "#91B315" : "#444444"
border.width: 1
}
}
}
footer: Item {
implicitHeight: 60
Rectangle {
anchors.top: parent.top
width: parent.width
height: 1
color: "#333333"
}
Row {
anchors.centerIn: parent
spacing: 12
Button {
text: "Отмена"
width: 110; height: 36
contentItem: Text {
text: parent.text
color: "#ffffff"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
background: Rectangle {
color: parent.pressed ? "#444444" : "#333333"
radius: 6
}
onClicked: editProfileDialog.reject()
}
Button {
text: "ОК"
width: 110; height: 36
contentItem: Text {
text: parent.text
color: "#ffffff"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
background: Rectangle {
color: parent.pressed ? "#6a8510" : "#91B315"
radius: 6
}
onClicked: editProfileDialog.accept()
}
}
}
onAccepted: {
const name = epName.text.trim()
if (editIndex >= 0 && name !== "")
backend.updateProfile(editIndex, name, epLogin.text.trim(), epPassword.text)
editIndex = -1
epName.text = ""; epLogin.text = ""; epPassword.text = ""
}
onRejected: {
editIndex = -1
epName.text = ""; epLogin.text = ""; epPassword.text = ""
}
}
// ── Edit Version Dialog ────────────────────────────────────────────────
// Идентичен диалогу создания, но с предзаполненными данными выбранной
// версии. По нажатию ОК данные перезаписываются под тем же индексом.
Dialog {
id: editVersionDialog
modal: true
width: 320
x: (window.width - width) / 2
y: (window.height - height) / 2
padding: 0
property int editIndex: -1
function openFor(index) {
const data = backend.versionAt(index)
editIndex = index
evName.text = data.name || ""
evServer.text = data.serverUrl || ""
versionBox.popup.close()
open()
}
background: Rectangle {
color: "#1e1e1e"
radius: 10
border.color: "#91B315"
border.width: 1
}
header: Item {
implicitHeight: 52
Text {
anchors.centerIn: parent
text: "Редактирование версии"
color: "#ffffff"
font.pixelSize: 17
font.bold: true
}
Rectangle {
anchors.bottom: parent.bottom
width: parent.width
height: 1
color: "#333333"
}
}
contentItem: Column {
spacing: 12
topPadding: 20
bottomPadding: 20
TextField {
id: evName
x: 20
width: parent.width - 40
placeholderText: "Название версии"
color: "#ffffff"
placeholderTextColor: "#666666"
background: Rectangle {
color: "#2a2a2a"
radius: 6
border.color: evName.activeFocus ? "#91B315" : "#444444"
border.width: 1
}
}
TextField {
id: evServer
x: 20
width: parent.width - 40
placeholderText: "URL сервера загрузки"
color: "#ffffff"
placeholderTextColor: "#666666"
background: Rectangle {
color: "#2a2a2a"
radius: 6
border.color: evServer.activeFocus ? "#91B315" : "#444444"
border.width: 1
}
}
}
footer: Item {
implicitHeight: 60
Rectangle {
anchors.top: parent.top
width: parent.width
height: 1
color: "#333333"
}
Row {
anchors.centerIn: parent
spacing: 12
Button {
text: "Отмена"
width: 110; height: 36
contentItem: Text {
text: parent.text
color: "#ffffff"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
background: Rectangle {
color: parent.pressed ? "#444444" : "#333333"
radius: 6
}
onClicked: editVersionDialog.reject()
}
Button {
text: "ОК"
width: 110; height: 36
contentItem: Text {
text: parent.text
color: "#ffffff"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
background: Rectangle {
color: parent.pressed ? "#6a8510" : "#91B315"
radius: 6
}
onClicked: editVersionDialog.accept()
}
}
}
onAccepted: {
const name = evName.text.trim()
if (editIndex >= 0 && name !== "")
backend.updateVersion(editIndex, name, evServer.text.trim())
editIndex = -1
evName.text = ""; evServer.text = ""
}
onRejected: {
editIndex = -1
evName.text = ""; evServer.text = ""
}
}
}