diff --git a/CMakeLists.txt b/CMakeLists.txt index df8001f..d183154 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,9 +37,12 @@ qt_add_qml_module(apparchpack SOURCES cpp/utils/utils.hpp cpp/utils/utils.cpp + cpp/updatemanager/updatemanager.hpp + cpp/updatemanager/updatemanager.cpp ) target_include_directories(apparchpack PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/cpp/utils) +target_include_directories(apparchpack PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/cpp/updatemanager) target_link_libraries(apparchpack PRIVATE Qt6::Quick) diff --git a/Main.qml b/Main.qml index 3d5c116..a53a44a 100644 --- a/Main.qml +++ b/Main.qml @@ -25,6 +25,7 @@ ApplicationWindow { id: mainLayout anchors.fill: parent anchors.margins: Theme.baseMargins + anchors.bottomMargin: Theme.baseMargins + consoleBar.height spacing: Theme.baseSpacing RowLayout { @@ -68,11 +69,6 @@ ApplicationWindow { id: pgDelete } } - - Item { - id: plug - implicitHeight: 20 - } } readonly property string consoleTitle: tabs.currentIndex === 0 ? "Консоль обновления" : tabs.currentIndex === 1 ? "Консоль установки" : "Консоль удаления" @@ -83,6 +79,11 @@ ApplicationWindow { // ? (UpdateManager.isInstalling ? "установка..." : "") // : (UpdateManager.isRemoving ? "удаление..." : "") + readonly property var consoleLog: "" + // readonly property var consoleLog: tabs.currentIndex === 0 ? UpdateManager.updateLog + // : tabs.currentIndex === 1 ? UpdateManager.installLog + // : UpdateManager.removalLog + Components.ConsoleBar { id: consoleBar title: root.consoleTitle @@ -96,5 +97,7 @@ ApplicationWindow { anchors.bottom: consoleBar.top consoleOpen: root.consoleOpen status: root.consoleStatus + title: root.consoleTitle + consoleLogData: root.consoleLogData } } diff --git a/cpp/updatemanager/updatemanager.cpp b/cpp/updatemanager/updatemanager.cpp new file mode 100644 index 0000000..0a90353 --- /dev/null +++ b/cpp/updatemanager/updatemanager.cpp @@ -0,0 +1,16 @@ +#include "updatemanager.hpp" + +UpdateManager::UpdateManager(QObject* parent) : QObject{parent} +{ +} + +bool UpdateManager::isChecking() const +{ + return m_isChecking; +} + +int UpdateManager::packageCount() const +{ + int count = 0; + return count; +} diff --git a/cpp/updatemanager/updatemanager.hpp b/cpp/updatemanager/updatemanager.hpp new file mode 100644 index 0000000..cff246e --- /dev/null +++ b/cpp/updatemanager/updatemanager.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +class UpdateManager : public QObject +{ + Q_OBJECT + QML_ELEMENT + QML_SINGLETON + + Q_PROPERTY(bool isChecking READ isChecking NOTIFY isCheckingChanged) + Q_PROPERTY(int packageCount READ packageCount NOTIFY packageCountChanged) + + public: + explicit UpdateManager(QObject* parent = nullptr); + + public: + bool isChecking() const; + int packageCount() const; + + signals: + void isCheckingChanged(); + void packageCountChanged(); + + private: + QProcess m_process; + + private: + bool m_isChecking = false; + bool m_isUpdating = false; +}; + diff --git a/qml/buttons/SettingsBtn.qml b/qml/buttons/SettingsBtn.qml index 0f572ce..412c6d8 100644 --- a/qml/buttons/SettingsBtn.qml +++ b/qml/buttons/SettingsBtn.qml @@ -1,5 +1,3 @@ -pragma ComponentBehavior: Bound - import QtQuick import QtQuick.Controls import "../components" as Components diff --git a/qml/components/console/ConsolePanel.qml b/qml/components/console/ConsolePanel.qml index 820c17c..da2aaac 100644 --- a/qml/components/console/ConsolePanel.qml +++ b/qml/components/console/ConsolePanel.qml @@ -1,3 +1,5 @@ +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Layouts @@ -14,6 +16,7 @@ Rectangle { property string title: "" property string status: "" + property var consoleLogData: "" property int consoleHeight: 320 property bool consoleOpen: false @@ -66,6 +69,37 @@ Rectangle { Item { Layout.fillWidth: true Layout.fillHeight: true + + // ListView { + // id: logView + // clip: true + // spacing: 2 + // model: root.consoleLogData + // onModelChanged: positionViewAtEnd() + // onCountChanged: positionViewAtEnd() + // + // ScrollBar.vertical: ScrollBar { + // policy: ScrollBar.AsNeeded + // width: 6 + // } + // + // delegate: Text { + // width: logView.width + // text: modelData + // color: "#a6adc8" + // font.family: "monospace" + // font.pixelSize: 11 + // wrapMode: Text.WrapAnywhere + // } + // } + + Text { + anchors.centerIn: parent + text: "Логи отсутствуют" + color: "#585b70" + font.pixelSize: 12 + visible: root.consoleLogData.length === 0 + } } } }