builds fixes
This commit is contained in:
+214
-11
@@ -48,6 +48,30 @@ Dialog {
|
||||
buildsDialog.refreshStatus()
|
||||
}
|
||||
|
||||
// Удаление необратимо и уносит с собой архив сборки, поэтому сначала
|
||||
// спрашиваем. Индекс запоминаем здесь: к моменту ответа строка списка под
|
||||
// курсором может быть уже другой.
|
||||
function askRemove(index) {
|
||||
const info = buildsDialog.backend.customBuildRemovalInfo(index)
|
||||
if (!info || info.name === undefined)
|
||||
return
|
||||
removeConfirm.buildIndex = index
|
||||
removeConfirm.buildName = info.name
|
||||
removeConfirm.hasArchive = info.hasArchive === true
|
||||
removeConfirm.active = info.active === true
|
||||
removeConfirm.lastOne = info.lastOne === true
|
||||
removeConfirm.open()
|
||||
}
|
||||
|
||||
function performRemove(index) {
|
||||
buildsDialog.backend.removeCustomBuild(index)
|
||||
const left = buildsDialog.backend.customBuildNames.length
|
||||
if (left === 0)
|
||||
buildsDialog.editIndex = -1
|
||||
else
|
||||
buildsDialog.selectBuild(Math.min(index, left - 1))
|
||||
}
|
||||
|
||||
function commit(fields) {
|
||||
if (buildsDialog.loading || buildsDialog.editIndex < 0)
|
||||
return
|
||||
@@ -76,6 +100,157 @@ Dialog {
|
||||
}
|
||||
}
|
||||
|
||||
Dialog {
|
||||
id: removeConfirm
|
||||
|
||||
property int buildIndex: -1
|
||||
property string buildName: ""
|
||||
property bool hasArchive: false
|
||||
property bool active: false
|
||||
property bool lastOne: false
|
||||
|
||||
modal: true
|
||||
padding: 0
|
||||
width: 420
|
||||
parent: buildsDialog.parent
|
||||
x: (buildsDialog.parent.width - width) / 2
|
||||
y: (buildsDialog.parent.height - height) / 2
|
||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||
|
||||
background: Rectangle {
|
||||
color: "#1e1e1e"
|
||||
radius: 10
|
||||
border.color: "#cc6666"
|
||||
border.width: 1
|
||||
}
|
||||
|
||||
header: Item {
|
||||
implicitHeight: 52
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: qsTr("Удалить сборку?")
|
||||
color: "#ffffff"
|
||||
font.pixelSize: 17
|
||||
font.bold: true
|
||||
}
|
||||
Rectangle {
|
||||
anchors.bottom: parent.bottom
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: "#333333"
|
||||
}
|
||||
}
|
||||
|
||||
contentItem: Column {
|
||||
spacing: 10
|
||||
topPadding: 18
|
||||
bottomPadding: 18
|
||||
|
||||
Text {
|
||||
x: 20
|
||||
width: parent.width - 40
|
||||
wrapMode: Text.Wrap
|
||||
color: "#ffffff"
|
||||
font.pixelSize: 13
|
||||
text: qsTr("Сборка «%1» будет удалена без возможности восстановления.")
|
||||
.arg(removeConfirm.buildName)
|
||||
}
|
||||
|
||||
Text {
|
||||
x: 20
|
||||
width: parent.width - 40
|
||||
visible: removeConfirm.hasArchive
|
||||
wrapMode: Text.Wrap
|
||||
color: "#cc6666"
|
||||
font.pixelSize: 12
|
||||
text: qsTr("Вместе с ней удалится её архив: моды, конфиги и миры этой сборки восстановить будет нельзя.")
|
||||
}
|
||||
|
||||
Text {
|
||||
x: 20
|
||||
width: parent.width - 40
|
||||
visible: removeConfirm.active && !removeConfirm.lastOne
|
||||
wrapMode: Text.Wrap
|
||||
color: "#cc6666"
|
||||
font.pixelSize: 12
|
||||
text: qsTr("Сборка сейчас активна: содержимое .minecraft принадлежит ей и будет очищено, а на его место развернётся следующая сборка.")
|
||||
}
|
||||
|
||||
Text {
|
||||
x: 20
|
||||
width: parent.width - 40
|
||||
visible: removeConfirm.lastOne
|
||||
wrapMode: Text.Wrap
|
||||
color: "#888888"
|
||||
font.pixelSize: 12
|
||||
text: qsTr("Это последняя сборка. Содержимое .minecraft останется на месте.")
|
||||
}
|
||||
}
|
||||
|
||||
footer: Item {
|
||||
implicitHeight: 60
|
||||
Rectangle {
|
||||
anchors.top: parent.top
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: "#333333"
|
||||
}
|
||||
Row {
|
||||
anchors.centerIn: parent
|
||||
spacing: 12
|
||||
|
||||
Button {
|
||||
text: qsTr("Отмена")
|
||||
width: 130; 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: removeConfirm.close()
|
||||
}
|
||||
|
||||
Button {
|
||||
text: qsTr("Удалить")
|
||||
width: 130; height: 36
|
||||
contentItem: Text {
|
||||
text: parent.text
|
||||
color: "#ffffff"
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
background: Rectangle {
|
||||
color: parent.pressed ? "#8a3a3a" : "#663333"
|
||||
radius: 6
|
||||
border.color: "#cc6666"
|
||||
border.width: 1
|
||||
}
|
||||
onClicked: {
|
||||
const index = removeConfirm.buildIndex
|
||||
removeConfirm.close()
|
||||
buildsDialog.performRemove(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onClosed: removeConfirm.buildIndex = -1
|
||||
}
|
||||
|
||||
VersionPickerDialog {
|
||||
id: versionPicker
|
||||
backend: buildsDialog.backend
|
||||
parent: buildsDialog.parent
|
||||
x: (buildsDialog.parent.width - width) / 2
|
||||
y: (buildsDialog.parent.height - height) / 2
|
||||
onVersionChosen: (versionId) => bdMinecraft.selectedId = versionId
|
||||
}
|
||||
|
||||
// Установка версии или модлоадера меняет комплектность сборки — строка
|
||||
// состояния должна это заметить, не дожидаясь переоткрытия окна.
|
||||
Connections {
|
||||
@@ -176,14 +351,7 @@ Dialog {
|
||||
anchors.fill: parent
|
||||
anchors.margins: -6
|
||||
hoverEnabled: true
|
||||
onClicked: {
|
||||
buildsDialog.backend.removeCustomBuild(buildRow.index)
|
||||
const left = buildsDialog.backend.customBuildNames.length
|
||||
if (left === 0)
|
||||
buildsDialog.editIndex = -1
|
||||
else
|
||||
buildsDialog.selectBuild(Math.min(buildRow.index, left - 1))
|
||||
}
|
||||
onClicked: buildsDialog.askRemove(buildRow.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,11 +444,46 @@ Dialog {
|
||||
font.pixelSize: 11
|
||||
}
|
||||
|
||||
VersionCatalogCombo {
|
||||
// Само поле только показывает выбор: версий около тысячи, и
|
||||
// разбираться в них удобнее в отдельном окне с категориями.
|
||||
Rectangle {
|
||||
id: bdMinecraft
|
||||
property string selectedId: ""
|
||||
|
||||
width: parent.width
|
||||
catalog: buildsDialog.backend.versionCatalog
|
||||
onAboutToOpen: buildsDialog.backend.refreshVersionCatalog()
|
||||
height: 36
|
||||
radius: 6
|
||||
color: "#2a2a2a"
|
||||
border.color: versionFieldArea.containsMouse ? "#91B315" : "#444444"
|
||||
border.width: 1
|
||||
|
||||
Text {
|
||||
anchors.fill: parent
|
||||
leftPadding: 10
|
||||
rightPadding: 110
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
color: bdMinecraft.selectedId === "" ? "#666666" : "#ffffff"
|
||||
text: bdMinecraft.selectedId === "" ? qsTr("Выберите версию")
|
||||
: bdMinecraft.selectedId
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: qsTr("Выбрать…")
|
||||
color: "#91B315"
|
||||
font.pixelSize: 12
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: versionFieldArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: versionPicker.openFor(bdMinecraft.selectedId)
|
||||
}
|
||||
|
||||
onSelectedIdChanged: buildsDialog.commit({"minecraftVersion":
|
||||
bdMinecraft.selectedId})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user