From f64c46c6ae72c14c0334e6af64bbe836f9898b1a Mon Sep 17 00:00:00 2001 From: Guilherme Silva <626206+guihkx@users.noreply.github.com> Date: Wed, 21 Dec 2022 11:02:27 -0300 Subject: [PATCH] Further improvements for the 'Lite' Flatpak variant (#836) These changes should only affect the Linux build. Co-authored-by: guihkx --- CMakeLists.txt | 11 ++++++++- resources/desktop/CMakeLists.txt | 24 +++++++++++++++++++ .../io.github.martinrotter.rssguard.autostart | 9 ------- .../io.github.martinrotter.rssguard.desktop | 17 ------------- resources/desktop/rssguard.desktop.in | 11 +++++++++ ....metainfo.xml => rssguard.metainfo.xml.in} | 12 +++++----- resources/rssguard.qrc | 3 +-- .../scripts/github-actions/build-linux-mac.sh | 6 ++++- resources/scripts/hooks/pre-commit | 2 +- src/librssguard/definitions/definitions.h | 3 +-- src/librssguard/miscellaneous/application.cpp | 2 +- .../miscellaneous/systemfactory.cpp | 14 +++++++---- src/rssguard/CMakeLists.txt | 5 ++-- src/rssguard/main.cpp | 2 +- 14 files changed, 73 insertions(+), 48 deletions(-) create mode 100644 resources/desktop/CMakeLists.txt delete mode 100644 resources/desktop/io.github.martinrotter.rssguard.autostart delete mode 100644 resources/desktop/io.github.martinrotter.rssguard.desktop create mode 100644 resources/desktop/rssguard.desktop.in rename resources/desktop/{io.github.martinrotter.rssguard.metainfo.xml => rssguard.metainfo.xml.in} (87%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f2187b31..90fc35691 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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. diff --git a/resources/desktop/CMakeLists.txt b/resources/desktop/CMakeLists.txt new file mode 100644 index 000000000..632f760ac --- /dev/null +++ b/resources/desktop/CMakeLists.txt @@ -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) diff --git a/resources/desktop/io.github.martinrotter.rssguard.autostart b/resources/desktop/io.github.martinrotter.rssguard.autostart deleted file mode 100644 index 58bcbcce9..000000000 --- a/resources/desktop/io.github.martinrotter.rssguard.autostart +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Version=1.0 -Type=Application -Terminal=false -Name=RSS Guard -Exec=%1 -Hidden=false -X-GNOME-Autostart-Delay=15 -X-LXQt-Need-Tray=true \ No newline at end of file diff --git a/resources/desktop/io.github.martinrotter.rssguard.desktop b/resources/desktop/io.github.martinrotter.rssguard.desktop deleted file mode 100644 index 8d9a3e04a..000000000 --- a/resources/desktop/io.github.martinrotter.rssguard.desktop +++ /dev/null @@ -1,17 +0,0 @@ -[Desktop Entry] -Type=Application -Version=1.0 -Exec=rssguard -X-GNOME-Autostart-Delay=15 -X-LXQt-Need-Tray=true -Name=RSS Guard -GenericName=Feed reader -GenericName[cs]=Velmi jednoduchá čtečka kanálů -GenericName[de]=Feedreader -Comment=Tiny yet feature rich Qt feed reader -Comment[cs]=Velmi jednoduchá čtečka kanálů -Comment[de]=Qt Feedreader mit großem Funktionsumfang bei geringem Ressourcenbedarf -Icon=rssguard -Terminal=false -Categories=Qt;Network;News; -StartupWMClass=rssguard diff --git a/resources/desktop/rssguard.desktop.in b/resources/desktop/rssguard.desktop.in new file mode 100644 index 000000000..a6212548f --- /dev/null +++ b/resources/desktop/rssguard.desktop.in @@ -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 diff --git a/resources/desktop/io.github.martinrotter.rssguard.metainfo.xml b/resources/desktop/rssguard.metainfo.xml.in similarity index 87% rename from resources/desktop/io.github.martinrotter.rssguard.metainfo.xml rename to resources/desktop/rssguard.metainfo.xml.in index 2dbacf51a..30ffe9568 100644 --- a/resources/desktop/io.github.martinrotter.rssguard.metainfo.xml +++ b/resources/desktop/rssguard.metainfo.xml.in @@ -1,16 +1,16 @@ - io.github.martinrotter.rssguard + @APP_REVERSE_NAME@ CC0-1.0 GPL-3.0 - RSS Guard + @APPDATA_NAME@ Martin Rotter rotter.martinos_AT_gmail.com - Simple (yet powerful) feed reader + @APPDATA_SUMMARY@

- 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.

It supports many feed formats, such as: @@ -31,7 +31,7 @@

  • Tiny Tiny RSS
  • - io.github.martinrotter.rssguard.desktop + @APP_REVERSE_NAME@.desktop https://raw.githubusercontent.com/martinrotter/rssguard/master/resources/docs/images/rssguard-window.png @@ -63,6 +63,6 @@ - rssguard + @APP_LOW_NAME@
    diff --git a/resources/rssguard.qrc b/resources/rssguard.qrc index 6d00794d1..a47f168ae 100644 --- a/resources/rssguard.qrc +++ b/resources/rssguard.qrc @@ -91,8 +91,7 @@ initial_feeds/feeds-en_US.opml - desktop/io.github.martinrotter.rssguard.desktop - desktop/io.github.martinrotter.rssguard.autostart + desktop/rssguard.desktop.in ../localization/rssguard_cs.qm ../localization/rssguard_da.qm diff --git a/resources/scripts/github-actions/build-linux-mac.sh b/resources/scripts/github-actions/build-linux-mac.sh index d8627dc1c..341d44613 100755 --- a/resources/scripts/github-actions/build-linux-mac.sh +++ b/resources/scripts/github-actions/build-linux-mac.sh @@ -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 diff --git a/resources/scripts/hooks/pre-commit b/resources/scripts/hooks/pre-commit index d3be8269e..255964435 100755 --- a/resources/scripts/hooks/pre-commit +++ b/resources/scripts/hooks/pre-commit @@ -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. diff --git a/src/librssguard/definitions/definitions.h b/src/librssguard/definitions/definitions.h index 67999dfec..dec825cfd 100644 --- a/src/librssguard/definitions/definitions.h +++ b/src/librssguard/definitions/definitions.h @@ -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 diff --git a/src/librssguard/miscellaneous/application.cpp b/src/librssguard/miscellaneous/application.cpp index d1a4132e3..7cf1a27e3 100644 --- a/src/librssguard/miscellaneous/application.cpp +++ b/src/librssguard/miscellaneous/application.cpp @@ -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; diff --git a/src/librssguard/miscellaneous/systemfactory.cpp b/src/librssguard/miscellaneous/systemfactory.cpp index 5e807f6a6..9b401a8f3 100644 --- a/src/librssguard/miscellaneous/systemfactory.cpp +++ b/src/librssguard/miscellaneous/systemfactory.cpp @@ -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. @@ -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"); } } @@ -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)); @@ -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()); } diff --git a/src/rssguard/CMakeLists.txt b/src/rssguard/CMakeLists.txt index fd2caf8be..7af935acd 100644 --- a/src/rssguard/CMakeLists.txt +++ b/src/rssguard/CMakeLists.txt @@ -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 diff --git a/src/rssguard/main.cpp b/src/rssguard/main.cpp index 663e603ce..bc0cb642c 100644 --- a/src/rssguard/main.cpp +++ b/src/rssguard/main.cpp @@ -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)