Improve behavior when using ProgramUpdater class

This is mainly to avoid involving of `sender()` function.
This commit is contained in:
Chocobo1 2021-01-25 15:49:29 +08:00
parent 5c819f7242
commit 88d695f7af
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
4 changed files with 90 additions and 79 deletions

View file

@ -1,5 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2021 Mike Tzou (Chocobo1)
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
@ -29,6 +30,8 @@
#pragma once
#include <QObject>
#include <QString>
#include <QUrl>
namespace Net
{
@ -41,18 +44,19 @@ class ProgramUpdater final : public QObject
Q_DISABLE_COPY(ProgramUpdater)
public:
explicit ProgramUpdater(QObject *parent = nullptr, bool invokedByUser = false);
using QObject::QObject;
void checkForUpdates() const;
void updateProgram() const;
QString getNewVersion() const;
bool updateProgram() const;
signals:
void updateCheckFinished(bool updateAvailable, const QString &version, bool invokedByUser);
void updateCheckFinished();
private slots:
void rssDownloadFinished(const Net::DownloadResult &result);
private:
QString m_updateUrl;
const bool m_invokedByUser;
QString m_newVersion;
QUrl m_updateURL;
};