Skip to content
Snippets Groups Projects
Commit b892be87 authored by akiraohgaki's avatar akiraohgaki
Browse files

Code cleanup

parent a888a67b
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include <QJsonValue> #include <QJsonValue>
#include <QJsonArray> #include <QJsonArray>
#include <QDateTime> #include <QDateTime>
//#include <QThread>
#include "qtlib_file.h" #include "qtlib_file.h"
...@@ -50,7 +49,7 @@ void UpdateHandler::checkAll() ...@@ -50,7 +49,7 @@ void UpdateHandler::checkAll()
if (installType == "bin") { if (installType == "bin") {
#ifdef QTLIB_UNIX #ifdef QTLIB_UNIX
if (filePath.endsWith(".appimage", Qt::CaseInsensitive)) { if (filePath.endsWith(".appimage", Qt::CaseInsensitive)) {
if (AppImageUpdater(itemKey, filePath).checkAppImage()) { if (AppImageUpdater(itemKey, filePath).checkForChanges()) {
updateMethod = "appimageupdate"; updateMethod = "appimageupdate";
} }
//else if (OcsFileUpdater(url).checkFile()) { //else if (OcsFileUpdater(url).checkFile()) {
...@@ -152,15 +151,9 @@ void UpdateHandler::updateAppImage(const QString &itemKey) ...@@ -152,15 +151,9 @@ void UpdateHandler::updateAppImage(const QString &itemKey)
auto installType = installedItem["install_type"].toString(); auto installType = installedItem["install_type"].toString();
auto filePath = configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString() + "/" + filename; auto filePath = configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString() + "/" + filename;
//auto *thread = new QThread(this);
auto *updater = new AppImageUpdater(itemKey, filePath, this); auto *updater = new AppImageUpdater(itemKey, filePath, this);
//updater->moveToThread(thread);
//connect(thread, &QThread::started, updater, &AppImageUpdater::updateAppImage);
connect(updater, &AppImageUpdater::updateProgress, this, &UpdateHandler::updateProgress); connect(updater, &AppImageUpdater::updateProgress, this, &UpdateHandler::updateProgress);
connect(updater, &AppImageUpdater::finished, this, &UpdateHandler::appImageUpdaterFinished); connect(updater, &AppImageUpdater::finished, this, &UpdateHandler::appImageUpdaterFinished);
//connect(updater, &AppImageUpdater::finished, thread, &QThread::quit);
//connect(thread, &QThread::finished, thread, &QThread::deleteLater);
QJsonObject metadata; QJsonObject metadata;
metadata["installed_item_key"] = installedItemKey; metadata["installed_item_key"] = installedItemKey;
...@@ -178,7 +171,6 @@ void UpdateHandler::updateAppImage(const QString &itemKey) ...@@ -178,7 +171,6 @@ void UpdateHandler::updateAppImage(const QString &itemKey)
metadataSet_[itemKey] = metadata; metadataSet_[itemKey] = metadata;
emit updateStarted(itemKey, true); emit updateStarted(itemKey, true);
updater->updateAppImage(); updater->start();
//thread->start();
} }
#endif #endif
...@@ -44,14 +44,14 @@ QString AppImageUpdater::describeAppImage() const ...@@ -44,14 +44,14 @@ QString AppImageUpdater::describeAppImage() const
return QString::fromStdString(description); return QString::fromStdString(description);
} }
bool AppImageUpdater::checkAppImage() const bool AppImageUpdater::checkForChanges() const
{ {
bool updateAvailable = false; bool updateAvailable = false;
updater_->checkForChanges(updateAvailable); updater_->checkForChanges(updateAvailable);
return updateAvailable; return updateAvailable;
} }
void AppImageUpdater::updateAppImage() void AppImageUpdater::start()
{ {
isFinishedWithNoError_ = false; isFinishedWithNoError_ = false;
errorString_ = ""; errorString_ = "";
...@@ -62,12 +62,12 @@ void AppImageUpdater::updateAppImage() ...@@ -62,12 +62,12 @@ void AppImageUpdater::updateAppImage()
} }
auto timer = new QTimer(this); auto timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &AppImageUpdater::checkUpdaterProgress); connect(timer, &QTimer::timeout, this, &AppImageUpdater::checkProgress);
connect(this, &AppImageUpdater::finished, timer, &QTimer::stop); connect(this, &AppImageUpdater::finished, timer, &QTimer::stop);
timer->start(100); timer->start(100);
} }
void AppImageUpdater::checkUpdaterProgress() void AppImageUpdater::checkProgress()
{ {
if (!updater_->isDone()) { if (!updater_->isDone()) {
double progress; double progress;
......
...@@ -22,15 +22,15 @@ public: ...@@ -22,15 +22,15 @@ public:
QString errorString() const; QString errorString() const;
QString describeAppImage() const; QString describeAppImage() const;
bool checkAppImage() const; bool checkForChanges() const;
void updateAppImage(); void start();
signals: signals:
void finished(AppImageUpdater *updater); void finished(AppImageUpdater *updater);
void updateProgress(QString id, double progress); void updateProgress(QString id, double progress);
private slots: private slots:
void checkUpdaterProgress(); void checkProgress();
private: private:
QString id_; QString id_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment