2023-04-09 05:35:35 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-02-15 11:54:35 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
ToolBar {
|
|
|
|
id: bar
|
|
|
|
width: parent.width
|
|
|
|
RowLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
ToolButton {
|
|
|
|
icon.source: AppPath + "/image/modmaker/back"
|
|
|
|
onClicked: mainStack.pop();
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
2023-06-04 11:31:44 +00:00
|
|
|
Label {
|
|
|
|
text: qsTr("Package Manager")
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
ToolButton {
|
|
|
|
icon.source: AppPath + "/image/modmaker/menu"
|
|
|
|
onClicked: menu.open()
|
|
|
|
|
|
|
|
Menu {
|
|
|
|
id: menu
|
|
|
|
y: bar.height
|
|
|
|
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Enable All")
|
|
|
|
onTriggered: {
|
|
|
|
for (let i = 0; i < packageModel.count; i++) {
|
2023-06-09 09:23:02 +00:00
|
|
|
const name = packageModel.get(i).pkgName;
|
2023-06-04 11:31:44 +00:00
|
|
|
Pacman.enablePack(name);
|
|
|
|
}
|
|
|
|
updatePackageList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Disable All")
|
|
|
|
onTriggered: {
|
|
|
|
for (let i = 0; i < packageModel.count; i++) {
|
2023-06-09 09:23:02 +00:00
|
|
|
const name = packageModel.get(i).pkgName;
|
2023-06-04 11:31:44 +00:00
|
|
|
Pacman.disablePack(name);
|
|
|
|
}
|
|
|
|
updatePackageList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Upgrade All")
|
|
|
|
onTriggered: {
|
|
|
|
for (let i = 0; i < packageModel.count; i++) {
|
2023-06-09 09:23:02 +00:00
|
|
|
const name = packageModel.get(i).pkgName;
|
2023-06-04 11:31:44 +00:00
|
|
|
Pacman.upgradePack(name);
|
|
|
|
}
|
|
|
|
updatePackageList();
|
|
|
|
}
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
Rectangle {
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height - bar.height - urlInstaller.height
|
|
|
|
anchors.top: bar.bottom
|
|
|
|
color: "snow"
|
|
|
|
opacity: 0.75
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: packageList
|
|
|
|
anchors.fill: parent
|
|
|
|
model: ListModel {
|
|
|
|
id: packageModel
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
2023-06-04 11:31:44 +00:00
|
|
|
delegate: ItemDelegate {
|
|
|
|
width: root.width
|
|
|
|
height: 64
|
2023-02-15 11:54:35 +00:00
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 8
|
2023-02-15 11:54:35 +00:00
|
|
|
Text {
|
2023-06-04 11:31:44 +00:00
|
|
|
text: "<b>" + pkgName + "</b> (" + pkgVersion + ")"
|
|
|
|
font.pixelSize: 18
|
|
|
|
textFormat: Text.RichText
|
|
|
|
color: pkgEnabled === "1" ? "black" : "grey"
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
|
|
|
Text {
|
2023-06-04 11:31:44 +00:00
|
|
|
text: pkgURL
|
|
|
|
color: pkgEnabled === "1" ? "black" : "grey"
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
2023-06-04 11:31:44 +00:00
|
|
|
}
|
2023-02-15 11:54:35 +00:00
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
Button {
|
|
|
|
id: enableBtn
|
|
|
|
text: pkgEnabled === "0" ? qsTr("Enable") : qsTr("Disable")
|
|
|
|
anchors.right: upgradeBtn.left
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
onClicked: {
|
|
|
|
if (pkgEnabled === "0") {
|
|
|
|
Pacman.enablePack(pkgName);
|
|
|
|
} else {
|
|
|
|
Pacman.disablePack(pkgName);
|
|
|
|
}
|
|
|
|
updatePackageList();
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
Button {
|
|
|
|
id: upgradeBtn
|
|
|
|
text: qsTr("Upgrade")
|
|
|
|
anchors.right: delBtn.left
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
onClicked: {
|
|
|
|
Pacman.upgradePack(pkgName);
|
|
|
|
updatePackageList();
|
|
|
|
}
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
2023-06-04 11:31:44 +00:00
|
|
|
|
|
|
|
Button {
|
|
|
|
id: delBtn
|
|
|
|
text: qsTr("Remove")
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
onClicked: {
|
|
|
|
Pacman.removePack(pkgName);
|
|
|
|
updatePackageList();
|
|
|
|
}
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
2023-06-04 11:31:44 +00:00
|
|
|
|
2023-02-15 11:54:35 +00:00
|
|
|
onClicked: {
|
2023-06-04 11:31:44 +00:00
|
|
|
Backend.copyToClipboard(pkgURL);
|
|
|
|
toast.show(qsTr("Copied %1.").arg(pkgURL));
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
Rectangle {
|
|
|
|
id: urlInstaller
|
|
|
|
width: parent.width
|
|
|
|
height: childrenRect.height
|
|
|
|
color: "snow"
|
|
|
|
opacity: 0.75
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
width: parent.width
|
|
|
|
TextField {
|
|
|
|
id: urlEdit
|
|
|
|
Layout.fillWidth: true
|
|
|
|
clip: true
|
|
|
|
}
|
2023-02-15 11:54:35 +00:00
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
Button {
|
|
|
|
text: qsTr("Install From URL")
|
|
|
|
enabled: urlEdit.text !== ""
|
|
|
|
onClicked: {
|
2023-06-09 09:23:02 +00:00
|
|
|
const url = urlEdit.text;
|
2023-06-04 11:31:44 +00:00
|
|
|
mainWindow.busy = true;
|
|
|
|
Pacman.downloadNewPack(url, true);
|
|
|
|
}
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function updatePackageList() {
|
|
|
|
packageModel.clear();
|
2023-06-09 09:23:02 +00:00
|
|
|
const data = JSON.parse(Pacman.listPackages());
|
2023-02-15 11:54:35 +00:00
|
|
|
data.forEach(e => packageModel.append({
|
|
|
|
pkgName: e.name,
|
|
|
|
pkgURL: e.url,
|
|
|
|
pkgVersion: e.hash.substring(0, 8),
|
|
|
|
pkgEnabled: e.enabled
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
function downloadComplete() {
|
2023-06-09 09:23:02 +00:00
|
|
|
const idx = packageList.currentIndex;
|
2023-02-15 11:54:35 +00:00
|
|
|
updatePackageList();
|
|
|
|
packageList.currentIndex = idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
updatePackageList();
|
|
|
|
}
|
|
|
|
}
|