From ecfc0b6ca81b8de7505a3fe336616d37a78ced64 Mon Sep 17 00:00:00 2001 From: namedkitten Date: Tue, 5 May 2020 15:28:04 +0100 Subject: [PATCH] Add update for appimages. --- src/qml/MainMenu.qml | 4 ++++ src/qml/Utils/translations.js | 4 +++- src/utils.cpp | 14 ++++++++++++++ src/utils.hpp | 4 ++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/qml/MainMenu.qml b/src/qml/MainMenu.qml index b8553d4..cc0a372 100644 --- a/src/qml/MainMenu.qml +++ b/src/qml/MainMenu.qml @@ -183,6 +183,10 @@ MenuBar { onTriggered: loadDialog.open() shortcut: keybinds.openURI } + Action { + text: translate.getTranslation("UPDATE_APPIMAGE", i18n.language) + onTriggered: utils.updateAppImage() + } Action { text: translate.getTranslation("EXIT", i18n.language) onTriggered: Qt.quit() diff --git a/src/qml/Utils/translations.js b/src/qml/Utils/translations.js index 67226c2..1bf8801 100644 --- a/src/qml/Utils/translations.js +++ b/src/qml/Utils/translations.js @@ -59,7 +59,9 @@ var translations = { DOUBLE_TAP_TO_SEEK_BY: "Seek by", FONT: "Font", SUBTITLES_FONT_SIZE: "Subtitles Font Size", - UI_FADE_TIME: "UI Fade Time (ms)" + UI_FADE_TIME: "UI Fade Time (ms)", + UPDATE: "Update (AppImage Only)" + }, spanish: { OPEN_FILE: "Abrir archivo", diff --git a/src/utils.cpp b/src/utils.cpp index 52f830f..abea03d 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -36,6 +36,20 @@ launchAboutQt() qapp->aboutQt(); } +void updateAppImage() +{ + QString program = + QProcessEnvironment::systemEnvironment().value("APPDIR", "") + + "/usr/bin/appimageupdatetool"; + QProcess updater; + updater.setProcessChannelMode(QProcess::ForwardedChannels); + updater.start(program, + QStringList() << QProcessEnvironment::systemEnvironment().value( + "APPIMAGE", "")); + updater.waitForFinished(); + qApp->exit(); +} + // https://www.youtube.com/watch?v=nXaxk27zwlk&feature=youtu.be&t=56m34s inline int fast_mod(const int input, const int ceil) diff --git a/src/utils.hpp b/src/utils.hpp index 6d2e419..a75b742 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -16,6 +16,8 @@ QString createTimestamp(int seconds); void launchAboutQt(); +void +updateAppImage(); } class UtilsClass : public QObject @@ -25,6 +27,8 @@ public slots: void SetDPMS(bool on) { Utils::SetDPMS(on); }; void AlwaysOnTop(WId wid, bool on) { Utils::AlwaysOnTop(wid, on); }; void launchAboutQt() { Utils::launchAboutQt(); }; + void updateAppImage() { Utils::updateAppImage(); }; + QString createTimestamp(int seconds) {