fix update manager finished
This commit is contained in:
4
Main.qml
4
Main.qml
@@ -6,7 +6,6 @@ import "qml/components" as Components
|
|||||||
import "qml/pages" as Pages
|
import "qml/pages" as Pages
|
||||||
import "qml/buttons" as Buttons
|
import "qml/buttons" as Buttons
|
||||||
import "qml/dialogs" as Dialogs
|
import "qml/dialogs" as Dialogs
|
||||||
import archpack
|
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
id: root
|
id: root
|
||||||
@@ -20,7 +19,6 @@ ApplicationWindow {
|
|||||||
visible: true
|
visible: true
|
||||||
color: Theme.color1
|
color: Theme.color1
|
||||||
|
|
||||||
property string packageManager: "yay"
|
|
||||||
property bool consoleOpen: false
|
property bool consoleOpen: false
|
||||||
|
|
||||||
Component.onCompleted: ProcessManager.checkUpdates()
|
Component.onCompleted: ProcessManager.checkUpdates()
|
||||||
@@ -97,7 +95,7 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
readonly property string consoleTitle: tabs.currentIndex === 0 ? "Консоль обновления" : tabs.currentIndex === 1 ? "Консоль установки" : "Консоль удаления"
|
readonly property string consoleTitle: tabs.currentIndex === 0 ? "Консоль обновления" : tabs.currentIndex === 1 ? "Консоль установки" : "Консоль удаления"
|
||||||
readonly property string consoleStatus: Utils.statusConsole(tabs.currentIndex, ProcessManager.status)
|
readonly property string consoleStatus: Utils.statusConsole(ProcessManager.status)
|
||||||
readonly property var consoleLog: tabs.currentIndex === 0 ? ProcessManager.updateLog : []
|
readonly property var consoleLog: tabs.currentIndex === 0 ? ProcessManager.updateLog : []
|
||||||
// readonly property var consoleLog: tabs.currentIndex === 0 ? ProcessManager.updateLog : tabs.currentIndex === 1 ? UpdateManager.installLog : UpdateManager.removalLog
|
// readonly property var consoleLog: tabs.currentIndex === 0 ? ProcessManager.updateLog : tabs.currentIndex === 1 ? UpdateManager.installLog : UpdateManager.removalLog
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
UpdateManager::UpdateManager(QObject* parent)
|
UpdateManager::UpdateManager(QObject* parent)
|
||||||
{
|
{
|
||||||
|
m_process.setProcessChannelMode(QProcess::MergedChannels);
|
||||||
connect(&m_process, &QProcess::readyReadStandardOutput, this, &UpdateManager::on_update_ready_read);
|
connect(&m_process, &QProcess::readyReadStandardOutput, this, &UpdateManager::on_update_ready_read);
|
||||||
connect(&m_process, &QProcess::finished, this, &UpdateManager::on_process_finished);
|
connect(&m_process, &QProcess::finished, this, &UpdateManager::on_process_finished);
|
||||||
connect(&m_process, &QProcess::errorOccurred, this, &UpdateManager::on_process_error);
|
connect(&m_process, &QProcess::errorOccurred, this, &UpdateManager::on_process_error);
|
||||||
@@ -17,6 +18,8 @@ void UpdateManager::set_package_manager(const QString& pm)
|
|||||||
void UpdateManager::on_update_ready_read()
|
void UpdateManager::on_update_ready_read()
|
||||||
{
|
{
|
||||||
const QByteArray chunk = m_process.readAllStandardOutput();
|
const QByteArray chunk = m_process.readAllStandardOutput();
|
||||||
|
// m_tail += chunk;
|
||||||
|
// if (m_tail.size() > 8192) m_tail = m_tail.right(8192);
|
||||||
emit append_update_log(chunk);
|
emit append_update_log(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,6 +53,7 @@ void UpdateManager::yay(const QString& askpass)
|
|||||||
if (program.isEmpty())
|
if (program.isEmpty())
|
||||||
{
|
{
|
||||||
emit add_log_line("cannot update: " + m_package_manager);
|
emit add_log_line("cannot update: " + m_package_manager);
|
||||||
|
emit finished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +78,7 @@ void UpdateManager::pacman(const QString& askpass)
|
|||||||
if (sudo.isEmpty() || program.isEmpty())
|
if (sudo.isEmpty() || program.isEmpty())
|
||||||
{
|
{
|
||||||
emit add_log_line("cannot update:" + m_package_manager + " or sudo not found");
|
emit add_log_line("cannot update:" + m_package_manager + " or sudo not found");
|
||||||
|
emit finished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ QString Utils::declensionLabel(int count)
|
|||||||
return QString::number(count) + " " + suffix;
|
return QString::number(count) + " " + suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Utils::statusConsole(int index, int status)
|
QString Utils::statusConsole(int status)
|
||||||
{
|
{
|
||||||
QString res = "";
|
QString res = "";
|
||||||
if (index == 0 && status == static_cast<int>(ProcessManager::Status::Updating)) res = "обновление...";
|
if (status == static_cast<int>(ProcessManager::Status::Updating)) res = "обновление...";
|
||||||
if (index == 1 && status == static_cast<int>(ProcessManager::Status::Installing)) res = "установка...";
|
if (status == static_cast<int>(ProcessManager::Status::Installing)) res = "установка...";
|
||||||
if (index == 2 && status == static_cast<int>(ProcessManager::Status::Removing)) res = "удаление...";
|
if (status == static_cast<int>(ProcessManager::Status::Removing)) res = "удаление...";
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ class Utils : public QObject
|
|||||||
explicit Utils(QObject *parent = nullptr);
|
explicit Utils(QObject *parent = nullptr);
|
||||||
|
|
||||||
Q_INVOKABLE static QString declensionLabel(int count);
|
Q_INVOKABLE static QString declensionLabel(int count);
|
||||||
Q_INVOKABLE static QString statusConsole(int index, int status);
|
Q_INVOKABLE static QString statusConsole(int status);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user