add updatemanager base funciton
This commit is contained in:
24
Main.qml
24
Main.qml
@@ -72,14 +72,8 @@ ApplicationWindow {
|
||||
}
|
||||
|
||||
readonly property string consoleTitle: tabs.currentIndex === 0 ? "Консоль обновления" : tabs.currentIndex === 1 ? "Консоль установки" : "Консоль удаления"
|
||||
readonly property string consoleStatus: "in develop"
|
||||
// readonly property string consoleStatus: tabs.currentIndex === 0
|
||||
// ? (UpdateManager.isUpdating ? "обновление..." : "")
|
||||
// : tabBar.currentIndex === 1
|
||||
// ? (UpdateManager.isInstalling ? "установка..." : "")
|
||||
// : (UpdateManager.isRemoving ? "удаление..." : "")
|
||||
readonly property string consoleStatus: Utils.statusConsole(tabs.currentIndex, UpdateManager.isUpdating, UpdateManager.isInstalling, UpdateManager.isRemoving)
|
||||
|
||||
readonly property var consoleLog: ""
|
||||
// readonly property var consoleLog: tabs.currentIndex === 0 ? UpdateManager.updateLog
|
||||
// : tabs.currentIndex === 1 ? UpdateManager.installLog
|
||||
// : UpdateManager.removalLog
|
||||
@@ -92,12 +86,12 @@ ApplicationWindow {
|
||||
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
|
||||
}
|
||||
// Components.ConsolePanel {
|
||||
// id: consolePanel
|
||||
// anchors.bottom: consoleBar.top
|
||||
// consoleOpen: root.consoleOpen
|
||||
// status: root.consoleStatus
|
||||
// title: root.consoleTitle
|
||||
// consoleLogData: root.consoleLogData
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -4,13 +4,28 @@ UpdateManager::UpdateManager(QObject* parent) : QObject{parent}
|
||||
{
|
||||
}
|
||||
|
||||
bool UpdateManager::isChecking() const
|
||||
{
|
||||
return m_isChecking;
|
||||
}
|
||||
|
||||
int UpdateManager::packageCount() const
|
||||
{
|
||||
int count = 0;
|
||||
return count;
|
||||
}
|
||||
|
||||
bool UpdateManager::isChecking() const
|
||||
{
|
||||
return m_isChecking;
|
||||
}
|
||||
|
||||
bool UpdateManager::isUpdating() const
|
||||
{
|
||||
return m_isUpdating;
|
||||
}
|
||||
|
||||
bool UpdateManager::isInstalling() const
|
||||
{
|
||||
return m_isInstalling;
|
||||
}
|
||||
|
||||
bool UpdateManager::isRemoving() const
|
||||
{
|
||||
return m_isRemoving;
|
||||
}
|
||||
|
||||
@@ -15,19 +15,21 @@ class UpdateManager : public QObject
|
||||
QML_ELEMENT
|
||||
QML_SINGLETON
|
||||
|
||||
Q_PROPERTY(bool isChecking READ isChecking NOTIFY isCheckingChanged)
|
||||
Q_PROPERTY(int packageCount READ packageCount NOTIFY packageCountChanged)
|
||||
Q_PROPERTY(bool isChecking READ isChecking NOTIFY isCheckingChanged)
|
||||
Q_PROPERTY(bool isUpdating READ isUpdating NOTIFY isUpdatingChanged)
|
||||
Q_PROPERTY(bool isInstalling READ isInstalling NOTIFY isInstallingChanged)
|
||||
Q_PROPERTY(bool isRemoving READ isRemoving NOTIFY isRemovingChanged)
|
||||
|
||||
public:
|
||||
explicit UpdateManager(QObject* parent = nullptr);
|
||||
|
||||
public:
|
||||
bool isChecking() const;
|
||||
int packageCount() const;
|
||||
|
||||
signals:
|
||||
void isCheckingChanged();
|
||||
void packageCountChanged();
|
||||
bool isChecking() const;
|
||||
bool isUpdating() const;
|
||||
bool isInstalling() const;
|
||||
bool isRemoving() const;
|
||||
|
||||
private:
|
||||
QProcess m_process;
|
||||
@@ -35,5 +37,14 @@ class UpdateManager : public QObject
|
||||
private:
|
||||
bool m_isChecking = false;
|
||||
bool m_isUpdating = false;
|
||||
bool m_isInstalling = false;
|
||||
bool m_isRemoving = false;
|
||||
|
||||
signals:
|
||||
void packageCountChanged();
|
||||
void isCheckingChanged();
|
||||
void isUpdatingChanged();
|
||||
void isInstallingChanged();
|
||||
void isRemovingChanged();
|
||||
};
|
||||
|
||||
|
||||
@@ -12,7 +12,15 @@ QString Utils::declensionLabel(int count)
|
||||
else if (n % 10 >= 2 && n % 10 <= 4) suffix = QStringLiteral("пакета");
|
||||
else suffix = QStringLiteral("пакетов");
|
||||
|
||||
|
||||
return QString::number(count) + " " + suffix;
|
||||
}
|
||||
|
||||
QString Utils::statusConsole(int status, bool updating, bool installing, bool removing)
|
||||
{
|
||||
QString res;
|
||||
if (status == 0 && updating) res = "обновление...";
|
||||
if (status == 1 && installing) res = "установка...";
|
||||
if (status == 2 && removing) res = "удаление...";
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -14,5 +14,6 @@ class Utils : public QObject
|
||||
explicit Utils(QObject *parent = nullptr);
|
||||
|
||||
Q_INVOKABLE static QString declensionLabel(int count);
|
||||
Q_INVOKABLE static QString statusConsole(int status, bool updating, bool installing, bool removing);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user