mirror of
https://github.com/tnodir/fort
synced 2024-11-15 03:46:13 +00:00
UI: AutoUpdateManager: Sync "fileName" field too
This commit is contained in:
parent
dc51ebef1f
commit
b7e5b6ab89
@ -28,7 +28,7 @@ void AutoUpdateManager::setFlags(Flags v)
|
||||
{
|
||||
if (m_flags != v) {
|
||||
m_flags = v;
|
||||
emit flagsChanged(v);
|
||||
emit flagsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,6 +39,14 @@ void AutoUpdateManager::setFlag(Flag v, bool on)
|
||||
setFlags(flags);
|
||||
}
|
||||
|
||||
void AutoUpdateManager::setFileName(const QString &v)
|
||||
{
|
||||
if (m_fileName != v) {
|
||||
m_fileName = v;
|
||||
emit fileNameChanged();
|
||||
}
|
||||
}
|
||||
|
||||
int AutoUpdateManager::bytesReceived() const
|
||||
{
|
||||
return downloader() ? downloader()->buffer().size() : m_downloadSize;
|
||||
@ -119,7 +127,7 @@ void AutoUpdateManager::setupByTaskInfo(TaskInfoUpdateChecker *taskInfo)
|
||||
const QFileInfo fi(installerPath());
|
||||
const bool downloaded = (fi.exists() && fi.size() == m_downloadSize);
|
||||
|
||||
qCDebug(LC) << "Check download:" << taskInfo->version() << "downloaded:" << downloaded;
|
||||
qCDebug(LC) << "Check:" << taskInfo->version() << "downloaded:" << downloaded;
|
||||
|
||||
setIsDownloaded(downloaded);
|
||||
}
|
||||
@ -157,8 +165,10 @@ bool AutoUpdateManager::runInstaller()
|
||||
const QString installerPath = this->installerPath();
|
||||
const QStringList args = installerArgs(settings);
|
||||
|
||||
if (!QProcess::startDetached(installerPath, args))
|
||||
if (!QProcess::startDetached(installerPath, args)) {
|
||||
qCDebug(LC) << "Run Installer error:" << installerPath << args;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (settings->hasService()) {
|
||||
emit restartClients(installerPath);
|
||||
|
@ -40,6 +40,9 @@ public:
|
||||
bool isDownloading() const { return testFlag(IsDownloading); }
|
||||
void setIsDownloading(bool on) { setFlag(IsDownloading, on); }
|
||||
|
||||
QString fileName() const { return m_fileName; }
|
||||
void setFileName(const QString &v);
|
||||
|
||||
virtual int bytesReceived() const;
|
||||
|
||||
void setUp() override;
|
||||
@ -51,8 +54,9 @@ public slots:
|
||||
bool runInstaller();
|
||||
|
||||
signals:
|
||||
void flagsChanged(AutoUpdateManager::Flags flags);
|
||||
void flagsChanged();
|
||||
void bytesReceivedChanged(int size);
|
||||
void fileNameChanged();
|
||||
|
||||
void restartClients(const QString &installerPath);
|
||||
|
||||
@ -61,6 +65,8 @@ protected:
|
||||
|
||||
void setupDownloader() override;
|
||||
|
||||
QString installerPath() const { return m_updatePath + m_fileName; }
|
||||
|
||||
protected slots:
|
||||
void downloadFinished(const QByteArray &data, bool success) override;
|
||||
|
||||
@ -71,8 +77,6 @@ private:
|
||||
|
||||
bool saveInstaller(const QByteArray &fileData);
|
||||
|
||||
QString installerPath() const { return m_updatePath + m_fileName; }
|
||||
|
||||
static QStringList installerArgs(FortSettings *settings);
|
||||
|
||||
private:
|
||||
|
@ -11,8 +11,8 @@ inline bool processAutoUpdateManager_updateState(
|
||||
AutoUpdateManager *autoUpdateManager, const ProcessCommandArgs &p)
|
||||
{
|
||||
if (auto aum = qobject_cast<AutoUpdateManagerRpc *>(autoUpdateManager)) {
|
||||
aum->updateState(
|
||||
AutoUpdateManager::Flags(p.args.value(0).toInt()), p.args.value(1).toInt());
|
||||
aum->updateState(AutoUpdateManager::Flags(p.args.value(0).toInt()), p.args.value(1).toInt(),
|
||||
p.args.value(2).toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -68,10 +68,12 @@ void AutoUpdateManagerRpc::setBytesReceived(int v)
|
||||
}
|
||||
}
|
||||
|
||||
void AutoUpdateManagerRpc::updateState(AutoUpdateManager::Flags flags, int bytesReceived)
|
||||
void AutoUpdateManagerRpc::updateState(
|
||||
AutoUpdateManager::Flags flags, int bytesReceived, const QString &fileName)
|
||||
{
|
||||
setFlags(flags);
|
||||
setBytesReceived(bytesReceived);
|
||||
setFileName(fileName);
|
||||
}
|
||||
|
||||
QVariantList AutoUpdateManagerRpc::updateState_args()
|
||||
@ -80,8 +82,9 @@ QVariantList AutoUpdateManagerRpc::updateState_args()
|
||||
|
||||
const auto flags = autoUpdateManager->flags();
|
||||
const auto bytesReceived = autoUpdateManager->bytesReceived();
|
||||
const auto fileName = autoUpdateManager->fileName();
|
||||
|
||||
return { int(flags), bytesReceived };
|
||||
return { int(flags), bytesReceived, fileName };
|
||||
}
|
||||
|
||||
bool AutoUpdateManagerRpc::processInitClient(ControlWorker *w)
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
int bytesReceived() const override { return m_bytesReceived; }
|
||||
void setBytesReceived(int v);
|
||||
|
||||
void updateState(AutoUpdateManager::Flags flags, int bytesReceived);
|
||||
void updateState(AutoUpdateManager::Flags flags, int bytesReceived, const QString &fileName);
|
||||
|
||||
static QVariantList updateState_args();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user