From a2be5c161d6c94349037311d42114ee553e45395 Mon Sep 17 00:00:00 2001 From: chatlanin Date: Sun, 15 Nov 2026 11:08:05 +0300 Subject: [PATCH] add package list in update page --- CMakeLists.txt | 11 +- Main.qml | 3 +- qml/{components => }/console/ConsoleBar.qml | 0 qml/{components => }/console/ConsolePanel.qml | 6 +- qml/lists/PackageList.qml | 106 ++++++++++++++++++ qml/{components => }/pages/DeletePg.qml | 0 qml/{components => }/pages/InstallPg.qml | 0 qml/{components => }/pages/UpdatePg.qml | 13 ++- qml/style/Theme.qml | 1 + 9 files changed, 128 insertions(+), 12 deletions(-) rename qml/{components => }/console/ConsoleBar.qml (100%) rename qml/{components => }/console/ConsolePanel.qml (96%) create mode 100644 qml/lists/PackageList.qml rename qml/{components => }/pages/DeletePg.qml (100%) rename qml/{components => }/pages/InstallPg.qml (100%) rename qml/{components => }/pages/UpdatePg.qml (70%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f7bdc3..3900a06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,11 +30,12 @@ qt_add_qml_module(apparchpack qml/components/Tabs.qml qml/components/PreLoader.qml qml/components/SettingsMenu.qml - qml/components/pages/UpdatePg.qml - qml/components/pages/InstallPg.qml - qml/components/pages/DeletePg.qml - qml/components/console/ConsoleBar.qml - qml/components/console/ConsolePanel.qml + qml/pages/UpdatePg.qml + qml/pages/InstallPg.qml + qml/pages/DeletePg.qml + qml/console/ConsoleBar.qml + qml/console/ConsolePanel.qml + qml/lists/PackageList.qml SOURCES cpp/utils/utils.hpp cpp/utils/utils.cpp diff --git a/Main.qml b/Main.qml index 59ebb79..1218153 100644 --- a/Main.qml +++ b/Main.qml @@ -3,7 +3,7 @@ import QtQuick.Controls import QtQuick.Layouts import "qml/components" as Components -import "qml/components/pages" as Pages +import "qml/pages" as Pages import "qml/buttons" as Buttons ApplicationWindow { @@ -68,6 +68,7 @@ ApplicationWindow { isChecking: UpdateManager.isChecking isUpdating: UpdateManager.isUpdating isInstalling: UpdateManager.isInstalling + packages: UpdateManager.packages onUpdateRequested: { root.requestPrivileged("update", "") } diff --git a/qml/components/console/ConsoleBar.qml b/qml/console/ConsoleBar.qml similarity index 100% rename from qml/components/console/ConsoleBar.qml rename to qml/console/ConsoleBar.qml diff --git a/qml/components/console/ConsolePanel.qml b/qml/console/ConsolePanel.qml similarity index 96% rename from qml/components/console/ConsolePanel.qml rename to qml/console/ConsolePanel.qml index da2aaac..5496964 100644 --- a/qml/components/console/ConsolePanel.qml +++ b/qml/console/ConsolePanel.qml @@ -1,5 +1,3 @@ -pragma ComponentBehavior: Bound - import QtQuick import QtQuick.Layouts @@ -86,7 +84,7 @@ Rectangle { // delegate: Text { // width: logView.width // text: modelData - // color: "#a6adc8" + // color: Theme.color3 // font.family: "monospace" // font.pixelSize: 11 // wrapMode: Text.WrapAnywhere @@ -96,7 +94,7 @@ Rectangle { Text { anchors.centerIn: parent text: "Логи отсутствуют" - color: "#585b70" + color: Theme.color12 font.pixelSize: 12 visible: root.consoleLogData.length === 0 } diff --git a/qml/lists/PackageList.qml b/qml/lists/PackageList.qml new file mode 100644 index 0000000..42cc86a --- /dev/null +++ b/qml/lists/PackageList.qml @@ -0,0 +1,106 @@ +pragma ComponentBehavior: Bound + +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import archpack + +Item { + id: root + + property int packageCount: 0 + property bool isChecking: false + property var packages: [] + + ListView { + id: listView + anchors.fill: parent + // свойство, которое обрезает всё содержимое списка по его границам. Без него элементы списка (делегаты) могут визуально «вылезать» за пределы ListView, наезжая на другие элементы интерфейса. + clip: true + spacing: 2 + model: root.packages + + ScrollBar.vertical: ScrollBar { + policy: ScrollBar.AsNeeded + width: 6 + } + + delegate: Rectangle { + id: delegate + width: listView.width + height: 32 + radius: 7 + color: modelData.updating ? "#313244" : "transparent" + + // из-зи предупреждение qmllint + required property var modelData + + Behavior on color { ColorAnimation { duration: 300 } } + + RowLayout { + anchors.fill: parent + anchors.leftMargin: 8 + anchors.rightMargin: 8 + spacing: 8 + + Text { + text: delegate.modelData.name + font.pixelSize: 13 + font.family: "monospace" + color: delegate.modelData.updated ? Theme.color2 : delegate.modelData.updating ? Theme.color7 : Theme.color3 + Layout.fillWidth: true + + Behavior on color { ColorAnimation { duration: 300 } } + } + + Text { + text: delegate.modelData.version + font.pixelSize: 11 + color: Theme.color12 + visible: delegate.modelData.version !== "" + } + + Text { + text: "○" + font.pixelSize: 16 + font.bold: true + color: Theme.color4 + horizontalAlignment: Text.AlignHCenter + Layout.preferredWidth: 18 + Layout.alignment: Qt.AlignVCenter + visible: !delegate.modelData.updating && !delegate.modelData.updated + } + + Text { + text: "⟳" + font.pixelSize: 14 + color: Theme.color7 + horizontalAlignment: Text.AlignHCenter + Layout.preferredWidth: 18 + Layout.alignment: Qt.AlignVCenter + visible: delegate.modelData.updating + + RotationAnimation on rotation { + running: delegate.modelData.updating + loops: Animation.Infinite + from: 0 + to: 360 + duration: 1000 + } + } + + Text { + text: "✓" + font.pixelSize: 16 + font.bold: true + color: Theme.color13 + horizontalAlignment: Text.AlignHCenter + Layout.preferredWidth: 18 + Layout.alignment: Qt.AlignVCenter + visible: delegate.modelData.updated && !delegate.modelData.updating + } + } + } + } +} + diff --git a/qml/components/pages/DeletePg.qml b/qml/pages/DeletePg.qml similarity index 100% rename from qml/components/pages/DeletePg.qml rename to qml/pages/DeletePg.qml diff --git a/qml/components/pages/InstallPg.qml b/qml/pages/InstallPg.qml similarity index 100% rename from qml/components/pages/InstallPg.qml rename to qml/pages/InstallPg.qml diff --git a/qml/components/pages/UpdatePg.qml b/qml/pages/UpdatePg.qml similarity index 70% rename from qml/components/pages/UpdatePg.qml rename to qml/pages/UpdatePg.qml index 26d2058..77a67d6 100644 --- a/qml/components/pages/UpdatePg.qml +++ b/qml/pages/UpdatePg.qml @@ -1,7 +1,8 @@ import QtQuick import QtQuick.Layouts -import "../../buttons" as Buttons -import "../../components" as Components +import "../buttons" as Buttons +import "../components" as Components +import "../lists" as Lists Item { id: root @@ -10,6 +11,7 @@ Item { property bool isChecking: true property bool isUpdating: false property bool isInstalling: false + property var packages: [] signal updateRequested() ColumnLayout { @@ -20,6 +22,13 @@ Item { Layout.fillWidth: true Layout.fillHeight: true + Lists.PackageList { + anchors.fill: parent + packages: root.packages + packageCount: root.packageCount + isChecking: root.isChecking + } + Components.PreLoader { visible: root.isChecking anchors.fill: parent diff --git a/qml/style/Theme.qml b/qml/style/Theme.qml index 227c5d7..79f6be3 100644 --- a/qml/style/Theme.qml +++ b/qml/style/Theme.qml @@ -16,6 +16,7 @@ QtObject { readonly property color color10: "#8CAAEE" readonly property color color11: "#6f8fd8" readonly property color color12: "#585b70" + readonly property color color13: "#a6e3a1" readonly property int fontSize: 12 readonly property int fontTitleSize: 20