diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d07700..931ac1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,8 +66,6 @@ elseif(APPLE) else() set(tenmon_ICON "") find_package(Qt6 COMPONENTS DBus REQUIRED) - find_package(PkgConfig REQUIRED) - pkg_search_module(GIO REQUIRED gio-2.0) endif() qt_add_executable(tenmon WIN32 MACOSX_BUNDLE ${tenmon_ICON} ${TENMON_SRC}) @@ -80,15 +78,12 @@ if(COLOR_MANAGMENT) target_compile_definitions(tenmon PRIVATE "COLOR_MANAGMENT") endif(COLOR_MANAGMENT) -if(UNIX AND NOT APPLE) - target_include_directories(tenmon PRIVATE ${GIO_INCLUDE_DIRS}) -endif() target_link_libraries(tenmon PRIVATE Qt6::Widgets Qt6::Sql Qt6::OpenGLWidgets Qt6::Qml ${GSL_LIB} ${GSLCBLAS_LIB} ${EXIF_LIB} ${FITS_LIB} ${RAW_LIB} ${WCS_LIB} XISF lcms2) if(APPLE) target_link_libraries(tenmon PRIVATE Qt6::DBus "-framework CoreFoundation") elseif(UNIX) - target_link_libraries(tenmon PRIVATE Qt6::DBus ${GIO_LDFLAGS}) + target_link_libraries(tenmon PRIVATE Qt6::DBus) endif(APPLE) if(LIBRAW_STATIC) @@ -96,6 +91,11 @@ if(LIBRAW_STATIC) target_link_libraries(tenmon PRIVATE jasper) endif() +option(FLATPAK "Flatpak build" OFF) +if(FLATPAK) + target_compile_definitions(tenmon PRIVATE FLATPAK) +endif(FLATPAK) + install(TARGETS tenmon BUNDLE DESTINATION .) if(UNIX AND NOT APPLE) include(GNUInstallDirs) diff --git a/README b/README index a733e1b..a169d7a 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ FITS/XISF image viewer with multithreaded image loading To get all dependencies install these packages - sudo apt install qt6-base-dev qt6-declarative-dev libqt6opengl6-dev libraw-dev libexif-dev libcfitsio-dev libgsl-dev wcslib-dev cmake libzstd-dev pkg-config libqt6sql6-sqlite + sudo apt install qt6-base-dev qt6-declarative-dev libqt6opengl6-dev libraw-dev libexif-dev libcfitsio-dev libgsl-dev wcslib-dev cmake libzstd-dev libqt6sql6-sqlite on OpenSUSE diff --git a/delete.cpp b/delete.cpp index ea5ae5f..6244368 100644 --- a/delete.cpp +++ b/delete.cpp @@ -1,20 +1,30 @@ -#ifdef __linux__ +#ifdef FLATPAK -#define QT_NO_KEYWORDS +#include +#include +#include #include -#include -#include +#include +#include //flatpak bug prevent to use QFile::moveToTrash bool moveToTrash(const QString &path) { - GFile *gfile = g_file_new_for_path(path.toLocal8Bit().data()); - GError *error = nullptr; - g_file_trash(gfile, nullptr, &error); - if(error)std::cerr << "failed to trash file " << error->code << " " << error->message << std::endl; - g_clear_error(&error); - g_object_unref(gfile); - return true; + QDBusConnection con = QDBusConnection::sessionBus(); + QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop", "org.freedesktop.portal.Trash", "TrashFile"); + int fd = ::open(path.toLocal8Bit().data(), O_RDWR); + if(fd >= 0) + { + QList args = {QVariant::fromValue(QDBusUnixFileDescriptor(fd))}; + message.setArguments(args); + QDBusMessage reply = con.call(message); + ::close(fd); + if(reply.type() == QDBusMessage::ReplyMessage && reply.arguments().size() && reply.arguments().first().toInt()) + return true; + else + return false; + } + return false; } #else