From 572dd5101254af3a5540754ff3651076aa2a4640 Mon Sep 17 00:00:00 2001 From: Akira Ohgaki <akiraohgaki@gmail.com> Date: Fri, 17 Nov 2017 01:25:08 +0900 Subject: [PATCH] Add AppImageHandler class --- app/app.pri | 2 ++ app/src/handlers/appimagehandler.cpp | 32 ++++++++++++++++++++++++++++ app/src/handlers/appimagehandler.h | 23 ++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 app/src/handlers/appimagehandler.cpp create mode 100644 app/src/handlers/appimagehandler.h diff --git a/app/app.pri b/app/app.pri index 7e03a9c..6bdffab 100644 --- a/app/app.pri +++ b/app/app.pri @@ -29,6 +29,7 @@ unix:!ios:!android { QT += dbus HEADERS += \ + $${PWD}/src/handlers/appimagehandler.h \ $${PWD}/src/handlers/desktopthemehandler.h \ $${PWD}/src/desktopthemes/kdetheme.h \ $${PWD}/src/desktopthemes/gnometheme.h \ @@ -37,6 +38,7 @@ unix:!ios:!android { $${PWD}/src/desktopthemes/matetheme.h SOURCES += \ + $${PWD}/src/handlers/appimagehandler.cpp \ $${PWD}/src/handlers/desktopthemehandler.cpp \ $${PWD}/src/desktopthemes/kdetheme.cpp \ $${PWD}/src/desktopthemes/gnometheme.cpp \ diff --git a/app/src/handlers/appimagehandler.cpp b/app/src/handlers/appimagehandler.cpp new file mode 100644 index 0000000..920610e --- /dev/null +++ b/app/src/handlers/appimagehandler.cpp @@ -0,0 +1,32 @@ +#include "appimagehandler.h" + +#ifdef QTLIB_UNIX +#include "appimage/update.h" +#endif + +#include "handlers/confighandler.h" + +AppImageHandler::AppImageHandler(ConfigHandler *configHandler, QObject *parent) + : QObject(parent), configHandler_(configHandler) +{} + +bool AppImageHandler::isUpdateAvailable(const QString &path) const +{ +#ifdef QTLIB_UNIX + appimage::update::Updater appImageUpdater(path.toStdString()); + bool updateAvailable; + if (appImageUpdater.checkForChanges(updateAvailable)) { + return true; + } +#endif + return false; +} + +#ifdef QTLIB_UNIX +bool AppImageHandler::updateAppImage(const QString &path) const +{ + appimage::update::Updater appImageUpdater(path.toStdString(), false); + return appImageUpdater.start(); + // TODO: make signals&slots bindings later +} +#endif diff --git a/app/src/handlers/appimagehandler.h b/app/src/handlers/appimagehandler.h new file mode 100644 index 0000000..1360c76 --- /dev/null +++ b/app/src/handlers/appimagehandler.h @@ -0,0 +1,23 @@ +#pragma once + +#include <QObject> + +class ConfigHandler; + +class AppImageHandler : public QObject +{ + Q_OBJECT + +public: + explicit AppImageHandler(ConfigHandler *configHandler, QObject *parent = nullptr); + +public slots: + bool isUpdateAvailable(const QString &path) const; + +#ifdef QTLIB_UNIX + bool updateAppImage(const QString &path) const; +#endif + +private: + ConfigHandler *configHandler_; +}; -- GitLab