Skip to content

Commit

Permalink
Further improvements for the 'Lite' Flatpak variant
Browse files Browse the repository at this point in the history
These changes should only affect the Linux build.
  • Loading branch information
guihkx committed Dec 10, 2022
1 parent 162f213 commit 349f40d
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 48 deletions.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,19 @@ else()
endif()

if(NOT USE_WEBENGINE)
set(APP_REVERSE_NAME "io.github.martinrotter.rssguardlite")
set(APP_REVISION "${APP_REVISION}-nowebengine")
endif()

set(APP_LOW_NAME "${CMAKE_PROJECT_NAME}")

# Pass common defines.
add_compile_definitions(
APP_NAME="${APP_NAME}"
APP_VERSION="${CMAKE_PROJECT_VERSION}"
APP_URL="${APP_URL}"
APP_LONG_NAME="${APP_NAME} ${CMAKE_PROJECT_VERSION}"
APP_LOW_NAME="${CMAKE_PROJECT_NAME}"
APP_LOW_NAME="${APP_LOW_NAME}"
APP_REVERSE_NAME="${APP_REVERSE_NAME}"

QT_USE_QSTRINGBUILDER
Expand Down Expand Up @@ -240,6 +243,12 @@ elseif(APPLE)
resources/macosx/Info.plist.in
${CMAKE_BINARY_DIR}/Info.plist
)
elseif(UNIX AND NOT ANDROID)
add_subdirectory(resources/desktop)
add_compile_definitions(
APPDATA_NAME="${APPDATA_NAME}"
APPDATA_SUMMARY="${APPDATA_SUMMARY}"
)
endif()

# Generate localizations, build library and application.
Expand Down
24 changes: 24 additions & 0 deletions resources/desktop/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
set(APPDATA_NAME_REGULAR ${APP_NAME})
set(APPDATA_NAME_LITE "${APP_NAME} Lite")
set(APPDATA_SUMMARY_REGULAR "Simple, yet powerful news feed reader")
set(APPDATA_SUMMARY_LITE "${APPDATA_SUMMARY_REGULAR} (no built-in web browser)")

if(USE_WEBENGINE)
set(APPDATA_NAME "${APPDATA_NAME_REGULAR}")
set(APPDATA_SUMMARY "${APPDATA_SUMMARY_REGULAR}")
else()
set(APPDATA_NAME "${APPDATA_NAME_LITE}")
set(APPDATA_SUMMARY "${APPDATA_SUMMARY_LITE}")
endif()

configure_file(
rssguard.desktop.in
${CMAKE_BINARY_DIR}/${APP_REVERSE_NAME}.desktop
)
configure_file(
rssguard.metainfo.xml.in
${CMAKE_BINARY_DIR}/${APP_REVERSE_NAME}.metainfo.xml
)

set(APPDATA_NAME ${APPDATA_NAME} PARENT_SCOPE)
set(APPDATA_SUMMARY ${APPDATA_SUMMARY} PARENT_SCOPE)
9 changes: 0 additions & 9 deletions resources/desktop/io.github.martinrotter.rssguard.autostart

This file was deleted.

17 changes: 0 additions & 17 deletions resources/desktop/io.github.martinrotter.rssguard.desktop

This file was deleted.

11 changes: 11 additions & 0 deletions resources/desktop/rssguard.desktop.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Desktop Entry]
Type=Application
Name=@APPDATA_NAME@
Comment=@APPDATA_SUMMARY@
Icon=@APP_REVERSE_NAME@
Exec=@APP_LOW_NAME@
Categories=Feed;News;Network;Qt;
StartupWMClass=@APP_LOW_NAME@
X-GNOME-SingleWindow=true
X-GNOME-Autostart-Delay=15
X-LXQt-Need-Tray=true
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2017-2022 Martin Rotter <[email protected]> -->
<component type="desktop-application">
<id>io.github.martinrotter.rssguard</id>
<id>@APP_REVERSE_NAME@</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0</project_license>
<name>RSS Guard</name>
<name>@APPDATA_NAME@</name>
<developer_name>Martin Rotter</developer_name>
<update_contact>rotter.martinos_AT_gmail.com</update_contact>
<summary>Simple (yet powerful) feed reader</summary>
<summary>@APPDATA_SUMMARY@</summary>
<description>
<p>
RSS Guard is a simple (yet powerful) feed reader, written in C++ and Qt.
@APPDATA_NAME@ is a news feed reader, written in C++ and Qt.
</p>
<p>
It supports many feed formats, such as:
Expand All @@ -31,7 +31,7 @@
<li>Tiny Tiny RSS</li>
</ul>
</description>
<launchable type="desktop-id">io.github.martinrotter.rssguard.desktop</launchable>
<launchable type="desktop-id">@APP_REVERSE_NAME@.desktop</launchable>
<screenshots>
<screenshot type="default">
<image>https://raw.githubusercontent.com/martinrotter/rssguard/master/resources/docs/images/rssguard-window.png</image>
Expand Down Expand Up @@ -63,6 +63,6 @@
<release version="4.2.5" date="2022-12-08" />
</releases>
<provides>
<binary>rssguard</binary>
<binary>@APP_LOW_NAME@</binary>
</provides>
</component>
3 changes: 1 addition & 2 deletions resources/rssguard.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@

<file>initial_feeds/feeds-en_US.opml</file>

<file>desktop/io.github.martinrotter.rssguard.desktop</file>
<file>desktop/io.github.martinrotter.rssguard.autostart</file>
<file>desktop/rssguard.desktop.in</file>

<file>../localization/rssguard_cs.qm</file>
<file>../localization/rssguard_da.qm</file>
Expand Down
6 changes: 5 additions & 1 deletion resources/scripts/github-actions/build-linux-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ if [[ "$os" == *"ubuntu"* ]]; then
echo "We are building for GNU/Linux on Ubuntu."
is_linux=true
prefix="AppDir/usr"
app_id="io.github.martinrotter.rssguard"
if [[ "$webengine" == "ON" ]]; then
app_id="io.github.martinrotter.rssguard"
else
app_id="io.github.martinrotter.rssguardlite"
fi
else
echo "We are building for macOS."
is_linux=false
Expand Down
2 changes: 1 addition & 1 deletion resources/scripts/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ changelog_file="resources/text/CHANGELOG"
datestring="$(date +%F)"
versionstring="$(head -n 1 "$changelog_file")"

for appdata_file in resources/desktop/*.metainfo.xml; do
for appdata_file in resources/desktop/*.metainfo.xml.in; do
appdata_file_n="${appdata_file}.n"

# Set version and date.
Expand Down
3 changes: 1 addition & 2 deletions src/librssguard/definitions/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@
#define APP_LANG_PATH QSL(":/localization")

#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
#define APP_DESKTOP_SOURCE_ENTRY_FILE APP_REVERSE_NAME ".autostart"
#define APP_DESKTOP_ENTRY_FILE APP_REVERSE_NAME ".desktop"
#define APP_DESKTOP_ENTRY_FILE "rssguard.desktop.in"

#define APP_DESKTOP_ENTRY_PATH QSL(":/desktop")
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/librssguard/miscellaneous/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ void Application::showMessagesNumber(int unread_messages, bool any_feed_has_new_
bool task_bar_count_enabled = settings()->value(GROUP(GUI), SETTING(GUI::UnreadNumbersOnTaskBar)).toBool();
QDBusMessage signal = QDBusMessage::createSignal(QSL("/"), QSL("com.canonical.Unity.LauncherEntry"), QSL("Update"));

signal << QSL("application://%1").arg(APP_DESKTOP_ENTRY_FILE);
signal << QSL("application://%1.desktop").arg(APP_REVERSE_NAME);

QVariantMap setProperty;

Expand Down
14 changes: 9 additions & 5 deletions src/librssguard/miscellaneous/systemfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ QString SystemFactory::autostartDesktopFileLocation() const {
if (!xdg_config_path.isEmpty()) {
// XDG_CONFIG_HOME variable is specified. Look for .desktop file
// in 'autostart' subdirectory.
desktop_file_location = xdg_config_path + QSL("/autostart/") + APP_DESKTOP_ENTRY_FILE;
desktop_file_location = xdg_config_path + QSL("/autostart/") + APP_REVERSE_NAME + QSL(".desktop");
}
else {
// Desired variable is not set, look for the default 'autostart' subdirectory.
Expand All @@ -103,7 +103,7 @@ QString SystemFactory::autostartDesktopFileLocation() const {
if (!home_directory.isEmpty()) {
// Home directory exists. Check if target .desktop file exists and
// return according status.
desktop_file_location = home_directory + QSL("/.config/autostart/") + APP_DESKTOP_ENTRY_FILE;
desktop_file_location = home_directory + QSL("/.config/autostart/") + APP_REVERSE_NAME + QSL(".desktop");
}
}

Expand Down Expand Up @@ -170,7 +170,7 @@ bool SystemFactory::setAutoStartStatus(AutoStartStatus new_status) {
}

const QString source_autostart_desktop_file =
QString(APP_DESKTOP_ENTRY_PATH) + QDir::separator() + APP_DESKTOP_SOURCE_ENTRY_FILE;
QString(APP_DESKTOP_ENTRY_PATH) + QDir::separator() + APP_DESKTOP_ENTRY_FILE;

try {
QString desktop_file_contents = QString::fromUtf8(IOFactory::readFile(source_autostart_desktop_file));
Expand All @@ -189,13 +189,17 @@ bool SystemFactory::setAutoStartStatus(AutoStartStatus new_status) {
args = FROM_STD_LIST(QStringList, std_args);

#if defined(IS_FLATPAK_BUILD)
const QString flatpak_run = QSL("flatpak run %1").arg(QSL(APP_REVERSE_NAME));
const QString flatpak_run = QSL("flatpak run %1").arg(APP_REVERSE_NAME);

args = args.mid(1);
args.prepend(flatpak_run);
#endif

desktop_file_contents = desktop_file_contents.arg(args.join(QL1C(' ')));
desktop_file_contents.replace("Exec=@APP_LOW_NAME@", QSL("Exec=") + args.join(QL1C(' ')));
desktop_file_contents.replace("@APPDATA_SUMMARY@", APPDATA_SUMMARY);
desktop_file_contents.replace("@APPDATA_NAME@", APPDATA_NAME);
desktop_file_contents.replace("@APP_REVERSE_NAME@", APP_REVERSE_NAME);
desktop_file_contents.replace("@APP_LOW_NAME@", APP_LOW_NAME);

IOFactory::writeFile(destination_file, desktop_file_contents.toUtf8());
}
Expand Down
5 changes: 3 additions & 2 deletions src/rssguard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,15 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID)
install(TARGETS app
DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(FILES ${CMAKE_SOURCE_DIR}/resources/desktop/${APP_REVERSE_NAME}.desktop
install(FILES ${CMAKE_BINARY_DIR}/${APP_REVERSE_NAME}.desktop
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications
)
install(FILES ${CMAKE_SOURCE_DIR}/resources/desktop/${APP_REVERSE_NAME}.metainfo.xml
install(FILES ${CMAKE_BINARY_DIR}/${APP_REVERSE_NAME}.metainfo.xml
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/metainfo
)
install(FILES ${CMAKE_SOURCE_DIR}/resources/graphics/${CMAKE_PROJECT_NAME}.png
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256/apps
RENAME ${APP_REVERSE_NAME}.png
)
elseif(APPLE)
install(TARGETS app
Expand Down
2 changes: 1 addition & 1 deletion src/rssguard/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main(int argc, char* argv[]) {
#endif

#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
QApplication::setDesktopFileName(APP_DESKTOP_ENTRY_FILE);
QApplication::setDesktopFileName(APP_REVERSE_NAME + QSL(".desktop"));
#endif

#if defined(QT_STATIC)
Expand Down

0 comments on commit 349f40d

Please sign in to comment.