flatpak switch

This commit is contained in:
Martin Rotter 2022-05-03 06:49:43 +02:00
parent 4348a51d67
commit 4ddee5d32d
3 changed files with 26 additions and 3 deletions

View File

@ -21,6 +21,7 @@
# Variables:
# BUILD_WITH_QT6 - Build either with Qt 6 or Qt 5.
# NO_UPDATE_CHECK - Disable automatic checking for new application updates.
# IS_FLATPAK_BUILD - Set to "ON" when building RSS Guard with Flatpak.
# USE_WEBENGINE - if specified, then QtWebEngine module for internal web browser is used.
# Otherwise simple text component is used and some features will be disabled.
# Default value is "false". If QtWebEngine is installed during compilation, then
@ -108,6 +109,7 @@ option(UPDATE_TRANSLATIONS "Call lupdate to update translation files from source
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GCC/Clang only)" OFF)
option(REVISION_FROM_GIT "Get revision using `git rev-parse`" ON)
option(NO_UPDATE_CHECK "Disable automatic checking for new application updates" OFF)
option(IS_FLATPAK_BUILD "Set to 'ON' when building RSS Guard with Flatpak." OFF)
# Import Qt libraries.
set(QT6_MIN_VERSION 6.3.0)
@ -197,6 +199,7 @@ add_compile_definitions(
APP_URL="${APP_URL}"
APP_LONG_NAME="${APP_NAME} ${CMAKE_PROJECT_VERSION}"
APP_LOW_NAME="${CMAKE_PROJECT_NAME}"
APP_REVERSE_NAME="com.github.${CMAKE_PROJECT_NAME}"
QT_USE_QSTRINGBUILDER
QT_USE_FAST_CONCATENATION
@ -209,6 +212,10 @@ if(NO_UPDATE_CHECK)
add_compile_definitions(NO_UPDATE_CHECK)
endif()
if(IS_FLATPAK_BUILD)
add_compile_definitions(IS_FLATPAK_BUILD)
endif()
# Configure and copy some needed files.
if(WIN32)
configure_file(

View File

@ -3,8 +3,8 @@ Version=1.0
Type=Application
Terminal=false
Name=RSS Guard
TryExec=rssguard
Exec=rssguard
TryExec=%1
Exec=%1
Hidden=false
X-GNOME-Autostart-Delay=15
X-LXQt-Need-Tray=true

View File

@ -6,6 +6,7 @@
#include "gui/dialogs/formupdate.h"
#include "miscellaneous/application.h"
#include "miscellaneous/systemfactory.h"
#include "exceptions/applicationexception.h"
#include "network-web/networkfactory.h"
#if defined(Q_OS_WIN)
@ -157,7 +158,22 @@ bool SystemFactory::setAutoStartStatus(AutoStartStatus new_status) {
const QString source_autostart_desktop_file =
QString(APP_DESKTOP_ENTRY_PATH) + QDir::separator() + APP_DESKTOP_SOURCE_ENTRY_FILE;
return QFile::copy(source_autostart_desktop_file, destination_file);
try {
QString desktop_file_contents = QString::fromUtf8(IOFactory::readFile(source_autostart_desktop_file));
#if defined(IS_FLATPAK_BUILD)
desktop_file_contents = desktop_file_contents.arg(QSL("flatpak run %1").arg(QSL(APP_REVERSE_NAME)));
#else
desktop_file_contents = desktop_file_contents.arg(QSL(APP_LOW_NAME));
#endif
IOFactory::writeFile(destination_file, desktop_file_contents.toUtf8());
}
catch (const ApplicationException& ex) {
return false;
}
return true;
}
case AutoStartStatus::Disabled: