add update logic
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QVariantList>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTimer>
|
||||
|
||||
class UpdateManager : public QObject
|
||||
{
|
||||
@@ -15,14 +17,29 @@ class UpdateManager : public QObject
|
||||
QProcess m_process;
|
||||
|
||||
public:
|
||||
void check_update();
|
||||
void yay(const QString& password);
|
||||
void pacman(const QString& password);
|
||||
|
||||
private:
|
||||
void on_process_finished(int exitCode, QProcess::ExitStatus status);
|
||||
void on_process_error(QProcess::ProcessError error);
|
||||
QProcessEnvironment update_environment(const QString& askpass) const;
|
||||
void add_log_line(const QString& line);
|
||||
void append_update_output(const QByteArray& chunk);
|
||||
void stop_update(bool success, const QString& reason);
|
||||
|
||||
private:
|
||||
QString m_package_manager = "yay";
|
||||
std::unique_ptr<QTemporaryDir> m_askpass_dir;
|
||||
QByteArray m_update_output;
|
||||
QStringList m_update_log;
|
||||
bool m_update_timedout = false;
|
||||
QString m_update_log_buffer;
|
||||
|
||||
signals:
|
||||
void finished(bool ok, QString reason = "");
|
||||
void packages_ready(QVariantList packages);
|
||||
void update_log_changed();
|
||||
void set_updating_flag(bool updated, bool updating);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user