196 lines
5.5 KiB
QML
196 lines
5.5 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
|
|
import "qml/dialogs" as Dialogs
|
|
|
|
// test new gitcast
|
|
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 bool consoleOpen: false
|
|
|
|
Component.onCompleted: ProcessManager.checkUpdates()
|
|
|
|
function requestUpdate() {
|
|
if (ProcessManager.passwordEmpty())
|
|
{
|
|
passwordDialog.action = "update"
|
|
passwordDialog.packageName = ""
|
|
passwordDialog.open()
|
|
return
|
|
}
|
|
ProcessManager.update()
|
|
}
|
|
|
|
function requestInstall(name) {
|
|
if (ProcessManager.passwordEmpty())
|
|
{
|
|
passwordDialog.action = "install"
|
|
passwordDialog.packageName = name
|
|
passwordDialog.open()
|
|
return
|
|
}
|
|
ProcessManager.install(name)
|
|
}
|
|
|
|
function requestRemove(name) {
|
|
if (ProcessManager.passwordEmpty())
|
|
{
|
|
passwordDialog.action = "remove"
|
|
passwordDialog.packageName = name
|
|
passwordDialog.open()
|
|
return
|
|
}
|
|
ProcessManager.removePackage(name)
|
|
}
|
|
|
|
Connections {
|
|
target: ProcessManager
|
|
function onStatus_changed() {
|
|
if (ProcessManager.status === ProcessManager.Status.Updating
|
|
|| ProcessManager.status === ProcessManager.Status.Installing
|
|
|| ProcessManager.status === ProcessManager.Status.Removing)
|
|
root.consoleOpen = true
|
|
}
|
|
|
|
function onPasswordAccepted() {
|
|
passwordDialog.checking = false;
|
|
if (!passwordDialog.visible) return;
|
|
passwordDialog.accept();
|
|
if (passwordDialog.action === "install")
|
|
ProcessManager.install(passwordDialog.packageName)
|
|
else if (passwordDialog.action === "remove")
|
|
ProcessManager.removePackage(passwordDialog.packageName)
|
|
else
|
|
ProcessManager.update()
|
|
}
|
|
|
|
function onPasswordRejected(reason) {
|
|
passwordDialog.checking = false;
|
|
if (!passwordDialog.visible) return;
|
|
passwordDialog.errorText = reason;
|
|
}
|
|
}
|
|
|
|
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
|
|
status: ProcessManager.status
|
|
packageCount: ProcessManager.packageCount
|
|
}
|
|
|
|
Buttons.SettingsBtn {
|
|
id: settingsButton
|
|
Layout.alignment: Qt.AlignTop
|
|
}
|
|
}
|
|
|
|
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: ProcessManager.packageCount
|
|
visiblePreLoader: ProcessManager.status === ProcessManager.Status.Checking
|
|
status: ProcessManager.status
|
|
packages: ProcessManager.packages
|
|
onUpdate: root.requestUpdate()
|
|
}
|
|
|
|
Pages.InstallPg {
|
|
id: pgInstall
|
|
searchResults: ProcessManager.searchResults
|
|
searching: ProcessManager.searching
|
|
searchError: ProcessManager.searchError
|
|
busy: ProcessManager.status !== ProcessManager.Status.Null
|
|
installing: ProcessManager.status === ProcessManager.Status.Installing
|
|
installingPackage: ProcessManager.installingPackage
|
|
onSearchRequested: (query) => ProcessManager.searchPackages(query)
|
|
onInstallRequested: (name) => root.requestInstall(name)
|
|
}
|
|
|
|
Pages.DeletePg {
|
|
id: pgDelete
|
|
installedPackages: ProcessManager.installedPackages
|
|
loadingInstalled: ProcessManager.loadingInstalled
|
|
installedError: ProcessManager.installedError
|
|
busy: ProcessManager.status !== ProcessManager.Status.Null
|
|
removing: ProcessManager.status === ProcessManager.Status.Removing
|
|
removingPackage: ProcessManager.removingPackage
|
|
onReloadRequested: ProcessManager.loadInstalledPackages()
|
|
onFilterRequested: (query) => ProcessManager.filterInstalledPackages(query)
|
|
onRemoveRequested: (name) => {
|
|
removeDialog.packageName = name
|
|
removeDialog.open()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
readonly property string consoleTitle: tabs.currentIndex === 0 ? "Консоль обновления" : tabs.currentIndex === 1 ? "Консоль установки" : "Консоль удаления"
|
|
readonly property string consoleStatus: Utils.statusConsole(ProcessManager.status)
|
|
readonly property var consoleLog: ProcessManager.updateLog
|
|
|
|
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.consoleLog
|
|
}
|
|
|
|
Dialogs.PasswordDialog {
|
|
id: passwordDialog
|
|
onPasswordSubmitted: (password) => ProcessManager.checkPassword(password)
|
|
}
|
|
|
|
Dialogs.RemoveDialog {
|
|
id: removeDialog
|
|
onConfirmed: root.requestRemove(removeDialog.packageName)
|
|
}
|
|
}
|