Files
archpack/Main.qml

130 lines
3.6 KiB
QML

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import "qml/components" as Components
import "qml/pages" as Pages
import "qml/buttons" as Buttons
ApplicationWindow {
id: root
title: "Arch Linux Updater"
width: 740
height: 960
minimumWidth: 740
minimumHeight: 560
maximumWidth: 1080
maximumHeight: 1460
visible: true
color: Theme.color1
property string packageManager: "yay"
property string sessionPassword: ""
property bool consoleOpen: false
Component.onCompleted: UpdateManager.checkUpdates()
ColumnLayout {
id: mainLayout
anchors.fill: parent
anchors.margins: Theme.baseMargins
anchors.bottomMargin: Theme.baseMargins + consoleBar.height
spacing: Theme.baseSpacing
RowLayout {
id: headerLayout
Layout.maximumWidth: Number.POSITIVE_INFINITY
Components.Title {
id: title
Layout.maximumWidth: Number.POSITIVE_INFINITY
Layout.alignment: Qt.AlignBottom
isChecking: UpdateManager.isChecking
packageCount: UpdateManager.packageCount
}
Buttons.SettingsBtn {
id: settingsButton
Layout.alignment: Qt.AlignBottom
}
}
Components.Line { id: line }
Components.Tabs {
id: tabs
parentWidth: mainLayout.width
}
StackLayout {
id: pages
Layout.fillWidth: true
Layout.fillHeight: true
currentIndex: tabs.currentIndex
Pages.UpdatePg {
id: pgUpdate
packageCount: UpdateManager.packageCount
isChecking: UpdateManager.isChecking
isUpdating: UpdateManager.isUpdating
isInstalling: UpdateManager.isInstalling
packages: UpdateManager.packages
onUpdateRequested: {
root.requestPrivileged("update", "")
}
}
Pages.InstallPg {
id: pgInstall
}
Pages.DeletePg {
id: pgDelete
}
}
}
readonly property string consoleTitle: tabs.currentIndex === 0 ? "Консоль обновления" : tabs.currentIndex === 1 ? "Консоль установки" : "Консоль удаления"
readonly property string consoleStatus: Utils.statusConsole(tabs.currentIndex, UpdateManager.isUpdating, UpdateManager.isInstalling, UpdateManager.isRemoving)
// readonly property var consoleLog: tabs.currentIndex === 0 ? UpdateManager.updateLog
// : tabs.currentIndex === 1 ? UpdateManager.installLog
// : UpdateManager.removalLog
Components.ConsoleBar {
id: consoleBar
title: root.consoleTitle
consoleOpen: root.consoleOpen
status: root.consoleStatus
onToggled: root.consoleOpen = !root.consoleOpen
}
// Components.ConsolePanel {
// id: consolePanel
// anchors.bottom: consoleBar.top
// consoleOpen: root.consoleOpen
// status: root.consoleStatus
// title: root.consoleTitle
// consoleLogData: root.consoleLogData
// }
function requestPrivileged(action, packageName) {
if (root.sessionPassword !== "") {
root.runPrivileged(action, packageName, root.sessionPassword)
return
}
console.log("requestPrivileged")
// passwordDialog.action = action
// passwordDialog.packageName = packageName
// passwordDialog.open()
}
function runPrivileged(action, packageName, password) {
console.log("runPrivileged")
// if (action == "update") UpdateManager.update(password, root.packageManager)
// else if (action === "install") UpdateManager.installPackage(packageName, password)
// else UpdateManager.removePackage(packageName, password)
}
}