diff -Nru libqtxdg-3.4.0/CHANGELOG libqtxdg-3.6.0/CHANGELOG --- libqtxdg-3.4.0/CHANGELOG 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/CHANGELOG 2020-10-30 13:18:22.000000000 +0000 @@ -1,3 +1,22 @@ +libqtxdg-3.6.0 / 2020-11-01 +=========================== + * Dropped deprecated QLinkedList. + * Code cleanup. + * Memory leaks are fixed. + * Fixed setting of default apps with GLib backend. + * Fixed (recommended) apps list given by GLib backend. + * Added a XdgDefaultApps class with email client, file manager and web browser set/get methods. + * Used Qt's fix for too big SVG icons with scale factors > 1. + * Added methods to XdgDefaultApps for getting special applications. + * Fixed unneeded URL encoding for %U/%u in "xdgdesktopfile.cpp". + +libqtxdg-3.5.0 / 2020-04-22 +=========================== + * Removed dead Qt4 Mac code from XdgIconLoader. + * Removed obsolete qSwap. + * Silenced clazy warnings + * Sharp SVG icons with scale factors > 1. + libqtxdg-3.4.0 / 2019-10-27 =========================== diff -Nru libqtxdg-3.4.0/CMakeLists.txt libqtxdg-3.6.0/CMakeLists.txt --- libqtxdg-3.4.0/CMakeLists.txt 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/CMakeLists.txt 2020-10-30 13:18:22.000000000 +0000 @@ -13,12 +13,12 @@ set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(QTXDG_MAJOR_VERSION 3) -set(QTXDG_MINOR_VERSION 4) +set(QTXDG_MINOR_VERSION 6) set(QTXDG_PATCH_VERSION 0) set(QTXDG_VERSION_STRING ${QTXDG_MAJOR_VERSION}.${QTXDG_MINOR_VERSION}.${QTXDG_PATCH_VERSION}) -set(LXQTBT_MINIMUM_VERSION "0.6.0") -set(QT_MINIMUM_VERSION "5.7.1") +set(LXQTBT_MINIMUM_VERSION "0.8.0") +set(QT_MINIMUM_VERSION "5.12.0") set(GLIB_MINIMUM_VERSION "2.41.0") # Mime Apps new implementation find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED) diff -Nru libqtxdg-3.4.0/debian/changelog libqtxdg-3.6.0/debian/changelog --- libqtxdg-3.4.0/debian/changelog 2020-04-10 19:02:54.000000000 +0000 +++ libqtxdg-3.6.0/debian/changelog 2021-01-10 15:46:31.000000000 +0000 @@ -1,14 +1,18 @@ -libqtxdg (3.4.0-1build2) focal; urgency=medium +libqtxdg (3.6.0-0~ppa1) focal; urgency=medium - * No-change rebuild against qtbase-abi-5-12-8. + * Sync with Debian. - -- Rik Mills Fri, 10 Apr 2020 20:02:54 +0100 + -- Julien Lavergne Sun, 10 Jan 2021 16:46:31 +0100 -libqtxdg (3.4.0-1build1) focal; urgency=medium +libqtxdg (3.6.0-1) unstable; urgency=medium - * No-change rebuild for libgcc-s1 package name change. + [ Andrew Lee (李健秋) ] + * New upstream version 3.6.0. + * refresh debian/libqt5xdg3.symbols file. + * Fix unindented lines. + * Add salsa-ci.yml file. - -- Matthias Klose Mon, 23 Mar 2020 07:18:26 +0100 + -- Andrew Lee (李健秋) Fri, 25 Dec 2020 10:53:00 +0800 libqtxdg (3.4.0-1) unstable; urgency=medium diff -Nru libqtxdg-3.4.0/debian/control libqtxdg-3.6.0/debian/control --- libqtxdg-3.4.0/debian/control 2019-10-27 16:55:07.000000000 +0000 +++ libqtxdg-3.6.0/debian/control 2021-01-10 15:43:37.000000000 +0000 @@ -87,6 +87,7 @@ libqt5xdgiconloader3 (= ${binary:Version}) Description: Tools for QtXdg This package provide some tools for qtxdg: - * qtxdg-desktop-file-start - QtXdg XdgDesktopFile start Tester - * qtxdg-iconfinder - Find icons the QtXdg way - * qtxdg-mat - Mime app tool for QtXdg + . + * qtxdg-desktop-file-start - QtXdg XdgDesktopFile start Tester + * qtxdg-iconfinder - Find icons the QtXdg way + * qtxdg-mat - Mime app tool for QtXdg diff -Nru libqtxdg-3.4.0/debian/libqt5xdg3.symbols libqtxdg-3.6.0/debian/libqt5xdg3.symbols --- libqtxdg-3.4.0/debian/libqt5xdg3.symbols 2019-10-27 16:54:08.000000000 +0000 +++ libqtxdg-3.6.0/debian/libqt5xdg3.symbols 2021-01-10 15:43:37.000000000 +0000 @@ -140,6 +140,17 @@ (c++)"XdgMimeType::iconName() const@Base" 1.0.0 (c++)"XdgMimeType::operator=(XdgMimeType const&)@Base" 1.0.0 (c++)"XdgMimeType::~XdgMimeType()@Base" 1.0.0 + _ZN11XdgMimeType4swapERS_@Base 3.6.0 + _ZN14XdgDefaultApps10webBrowserEv@Base 3.6.0 + _ZN14XdgDefaultApps11emailClientEv@Base 3.6.0 + _ZN14XdgDefaultApps11fileManagerEv@Base 3.6.0 + _ZN14XdgDefaultApps11webBrowsersEv@Base 3.6.0 + _ZN14XdgDefaultApps12emailClientsEv@Base 3.6.0 + _ZN14XdgDefaultApps12fileManagersEv@Base 3.6.0 + _ZN14XdgDefaultApps13setWebBrowserERK14XdgDesktopFile@Base 3.6.0 + _ZN14XdgDefaultApps14setEmailClientERK14XdgDesktopFile@Base 3.6.0 + _ZN14XdgDefaultApps14setFileManagerERK14XdgDesktopFile@Base 3.6.0 + _ZNSt6vectorISt10unique_ptrI14XdgDesktopFileSt14default_deleteIS1_EESaIS4_EE17_M_realloc_insertIJS4_EEEvN9__gnu_cxx17__normal_iteratorIPS4_S6_EEDpOT_@Base 3.6.0 (c++)"non-virtual thunk to XdgMenuWidget::~XdgMenuWidget()@Base" 1.0.0 (c++)"typeinfo for XdgAction@Base" 1.0.0 (c++)"typeinfo for XdgDesktopFile@Base" 1.0.0 diff -Nru libqtxdg-3.4.0/debian/salsa-ci.yml libqtxdg-3.6.0/debian/salsa-ci.yml --- libqtxdg-3.4.0/debian/salsa-ci.yml 1970-01-01 00:00:00.000000000 +0000 +++ libqtxdg-3.6.0/debian/salsa-ci.yml 2021-01-10 15:43:37.000000000 +0000 @@ -0,0 +1,12 @@ +# For more information on what jobs are run see: +# https://salsa.debian.org/salsa-ci-team/pipeline +# +# To enable the jobs, go to your repository (at salsa.debian.org) +# and click over Settings > CI/CD > Expand (in General pipelines). +# In "Custom CI config path" write debian/salsa-ci.yml and click +# in "Save Changes". The CI tests will run after the next commit. +--- +include: + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml + diff -Nru libqtxdg-3.4.0/src/qtxdg/CMakeLists.txt libqtxdg-3.6.0/src/qtxdg/CMakeLists.txt --- libqtxdg-3.4.0/src/qtxdg/CMakeLists.txt 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/qtxdg/CMakeLists.txt 2020-10-30 13:18:22.000000000 +0000 @@ -14,6 +14,7 @@ xdgmacros.h xdgmimetype.h xdgmimeapps.h + xdgdefaultapps.h ) set(libqtxdg_PUBLIC_CLASSES @@ -27,6 +28,7 @@ XdgAutoStart XdgMimeType XdgMimeApps + XdgDefaultApps ) set(libqtxdg_PRIVATE_H_FILES @@ -58,6 +60,7 @@ xdgmimeapps.cpp xdgmimeappsbackendinterface.cpp xdgmimeappsglibbackend.cpp + xdgdefaultapps.cpp ) QT5_ADD_DBUS_INTERFACE(libqtxdg_DBUS_INTERFACE_SRCS diff -Nru libqtxdg-3.4.0/src/qtxdg/xdgdefaultapps.cpp libqtxdg-3.6.0/src/qtxdg/xdgdefaultapps.cpp --- libqtxdg-3.4.0/src/qtxdg/xdgdefaultapps.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libqtxdg-3.6.0/src/qtxdg/xdgdefaultapps.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -0,0 +1,169 @@ +/* + * libqtxdg - An Qt implementation of freedesktop.org xdg specs + * Copyright (C) 2020 Luís Pereira + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#include "xdgdefaultapps.h" + +#include "xdgdesktopfile.h" +#include "xdgmimeapps.h" + +#include +#include +#include + +#include +#include + +static QStringList getWebBrowserProtocolsGet() +{ + // Protocols needed to quailify a application as the default browser + static const QStringList webBrowserProtocolsGet = { + QL1S("text/html"), + QL1S("x-scheme-handler/http"), + QL1S("x-scheme-handler/https") + }; + return webBrowserProtocolsGet; +} + +static QStringList getWebBrowserProtocolsSet() +{ + // When setting an application as the default browser xdg-settings also + // sets these protocols. We simply follow it as good practice. + static const QStringList webBrowserProtocolsSet { + QL1S("x-scheme-handler/about"), + QL1S("x-scheme-handler/unknown") + }; + return webBrowserProtocolsSet; +} + +// returns the list of apps that are from category and support protocols +static QList categoryAndMimeTypeApps(const QString &category, const QStringList &protocols) +{ + XdgMimeApps db; + QList apps = db.categoryApps(category); +#if (QT_VERSION < QT_VERSION_CHECK(5,14,0)) + const QSet protocolsSet = QSet::fromList(protocols); +#else + const QSet protocolsSet = QSet(protocols.begin(), protocols.end()); +#endif + QList::iterator it = apps.begin(); + while (it != apps.end()) { + const auto list = (*it)->mimeTypes(); +#if (QT_VERSION < QT_VERSION_CHECK(5,14,0)) + const QSet appSupportsSet = QSet::fromList(list); +#else + const QSet appSupportsSet = QSet(list.begin(), list.end()); +#endif + if (appSupportsSet.contains(protocolsSet) && (*it)->isShown()) { + ++it; + } else { + delete *it; + it = apps.erase(it); + } + } + return apps; +} + +static XdgDesktopFile *defaultApp(const QString &protocol) +{ + XdgMimeApps db; + XdgDesktopFile *app = db.defaultApp(protocol); + if (app && app->isValid()) { + return app; + } else { + delete app; // it's fine to delete a nullptr + return nullptr; + } +} + +static bool setDefaultApp(const QString &protocol, const XdgDesktopFile &app) +{ + XdgMimeApps db; + return db.setDefaultApp(protocol, app); +} + +XdgDesktopFile *XdgDefaultApps::emailClient() +{ + return defaultApp(QL1S("x-scheme-handler/mailto")); +} + +QList XdgDefaultApps::emailClients() +{ + return categoryAndMimeTypeApps(QSL("Email"), QStringList() << QL1S("x-scheme-handler/mailto")); +} + +XdgDesktopFile *XdgDefaultApps::fileManager() +{ + return defaultApp(QL1S("inode/directory")); +} + +QList XdgDefaultApps::fileManagers() +{ + return categoryAndMimeTypeApps(QSL("FileManager"), QStringList() << QL1S("inode/directory")); +} + +bool XdgDefaultApps::setEmailClient(const XdgDesktopFile &app) +{ + return setDefaultApp(QL1S("x-scheme-handler/mailto"), app); +} + +bool XdgDefaultApps::setFileManager(const XdgDesktopFile &app) +{ + return setDefaultApp(QL1S("inode/directory"), app); +} + +bool XdgDefaultApps::setWebBrowser(const XdgDesktopFile &app) +{ + const QStringList protocols = + QStringList() << getWebBrowserProtocolsGet() << getWebBrowserProtocolsSet(); + + for (const QString &protocol : protocols) { + if (!setDefaultApp(protocol, app)) + return false; + } + return true; +} + +// To be qualified as the default browser all protocols must be set to the same +// valid application +XdgDesktopFile *XdgDefaultApps::webBrowser() +{ + const QStringList webBrowserProtocolsGet = getWebBrowserProtocolsGet(); + std::vector> apps; + for (int i = 0; i < webBrowserProtocolsGet.count(); ++i) { + auto a = std::unique_ptr(defaultApp(webBrowserProtocolsGet.at(i))); + apps.push_back(std::move(a)); + if (apps.at(i) && apps.at(i)->isValid()) + continue; + else + return nullptr; + } + + // At this point all apps are non null and valid + for (int i = 1; i < webBrowserProtocolsGet.count(); ++i) { + if (*apps.at(i - 1) != *apps.at(i)) + return nullptr; + } + return new XdgDesktopFile(*apps.at(0).get()); +} + +QList XdgDefaultApps::webBrowsers() +{ + return categoryAndMimeTypeApps(QSL("WebBrowser"), getWebBrowserProtocolsGet()); +} diff -Nru libqtxdg-3.4.0/src/qtxdg/xdgdefaultapps.h libqtxdg-3.6.0/src/qtxdg/xdgdefaultapps.h --- libqtxdg-3.4.0/src/qtxdg/xdgdefaultapps.h 1970-01-01 00:00:00.000000000 +0000 +++ libqtxdg-3.6.0/src/qtxdg/xdgdefaultapps.h 2020-10-30 13:18:22.000000000 +0000 @@ -0,0 +1,92 @@ +/* + * libqtxdg - An Qt implementation of freedesktop.org xdg specs + * Copyright (C) 2020 Luís Pereira + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifndef XDGDEFAULTAPPS_H +#define XDGDEFAULTAPPS_H + +#include "xdgmacros.h" + +class XdgDesktopFile; + +/*! + * \brief Sets the default app for special case applications categories(web browser, etc) + */ +class QTXDG_API XdgDefaultApps { + +public: + /*! + * \brief Sets the default email client + * \return The default email client. nullptr if it's not set or a error ocurred. + */ + static XdgDesktopFile *emailClient(); + + /*! + * \brief Gets the installed email clients + * \return A list of installed email clients + */ + static QList emailClients(); + + /*! + * \brief Sets the default file manager + * \return The default file manager. nullptr if it's not set or a error ocurred. + */ + static XdgDesktopFile *fileManager(); + + /*! + * \brief Gets the installed file managers + * \return A list of installed file managers + */ + static QList fileManagers(); + + /*! + * \brief Sets the default email client + * \param The app to be set as the default email client + * \return True if successful, false otherwise + */ + static bool setEmailClient(const XdgDesktopFile &app); + + /*! + * \brief Sets the default file manager + * \param The app to be set as the default file manager + * \return True if successful, false otherwise + */ + static bool setFileManager(const XdgDesktopFile &app); + + /*! + * \brief Sets the default web browser + * \param The app to be set as the default web browser + * \return True if successful, false otherwise + */ + static bool setWebBrowser(const XdgDesktopFile &app); + + /*! + * \brief Gets the default web browser + * \return The default web browser. nullptr if it's not set or a error ocurred. + */ + static XdgDesktopFile *webBrowser(); + + /*! + * \brief Gets the installed web browsers + * \return A list of installed web browsers + */ + static QList webBrowsers(); +}; + +#endif // XDGDEFAULTAPPS_H diff -Nru libqtxdg-3.4.0/src/qtxdg/xdgdesktopfile.cpp libqtxdg-3.6.0/src/qtxdg/xdgdesktopfile.cpp --- libqtxdg-3.4.0/src/qtxdg/xdgdesktopfile.cpp 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/qtxdg/xdgdesktopfile.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -25,6 +25,8 @@ * * END_COMMON_COPYRIGHT_HEADER */ +// clazy:excludeall=non-pod-global-static + #include "desktopenvironment_p.cpp" #include "xdgdesktopfile.h" #include "xdgdesktopfile_p.h" @@ -92,8 +94,8 @@ QString &escape(QString& str); QString &escapeExec(QString& str); QString expandDynamicUrl(QString url); -QString expandEnvVariables(const QString str); -QStringList expandEnvVariables(const QStringList strs); +QString expandEnvVariables(const QString &str); +QStringList expandEnvVariables(const QStringList &strs); QString findDesktopFile(const QString& dirName, const QString& desktopName); QString findDesktopFile(const QString& desktopName); static QStringList parseCombinedArgString(const QString &program); @@ -1023,7 +1025,7 @@ } -QString expandEnvVariables(const QString str) +QString expandEnvVariables(const QString &str) { QString scheme = QUrl(str).scheme(); @@ -1060,7 +1062,7 @@ } -QStringList expandEnvVariables(const QStringList strs) +QStringList expandEnvVariables(const QStringList &strs) { QStringList res; for (const QString &s : strs) @@ -1116,7 +1118,12 @@ { QUrl url; url.setUrl(expandEnvVariables(urls.at(0))); - result << ((!url.toLocalFile().isEmpty()) ? url.toLocalFile() : QString::fromUtf8(url.toEncoded())); + const QString localFile = url.toLocalFile(); + if (localFile.isEmpty()) { + result << ((!url.scheme().isEmpty()) ? QString::fromUtf8(url.toEncoded()) : urls.at(0)); + } else { + result << localFile; + } } continue; } @@ -1129,7 +1136,12 @@ for (const QString &s : urls) { QUrl url(expandEnvVariables(s)); - result << ((!url.toLocalFile().isEmpty()) ? url.toLocalFile() : QString::fromUtf8(url.toEncoded())); + const QString localFile = url.toLocalFile(); + if (localFile.isEmpty()) { + result << ((!url.scheme().isEmpty()) ? QString::fromUtf8(url.toEncoded()) : s); + } else { + result << localFile; + } } continue; } diff -Nru libqtxdg-3.4.0/src/qtxdg/xdgdirs.cpp libqtxdg-3.6.0/src/qtxdg/xdgdirs.cpp --- libqtxdg-3.4.0/src/qtxdg/xdgdirs.cpp 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/qtxdg/xdgdirs.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -25,6 +25,8 @@ * * END_COMMON_COPYRIGHT_HEADER */ +// clazy:excludeall=non-pod-global-static + #include "xdgdirs.h" #include #include diff -Nru libqtxdg-3.4.0/src/qtxdg/xdgmenuapplinkprocessor.cpp libqtxdg-3.6.0/src/qtxdg/xdgmenuapplinkprocessor.cpp --- libqtxdg-3.4.0/src/qtxdg/xdgmenuapplinkprocessor.cpp 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/qtxdg/xdgmenuapplinkprocessor.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -33,20 +33,19 @@ #include -XdgMenuApplinkProcessor::XdgMenuApplinkProcessor(QDomElement& element, XdgMenu* menu, XdgMenuApplinkProcessor *parent) : - QObject(parent) +XdgMenuApplinkProcessor::XdgMenuApplinkProcessor(QDomElement& element, XdgMenu* menu, XdgMenuApplinkProcessor *parent) + : QObject(parent), + mParent(parent), + mElement(element), + mMenu(menu) { - mElement = element; - mParent = parent; - mMenu = menu; - mOnlyUnallocated = element.attribute(QLatin1String("onlyUnallocated")) == QLatin1String("1"); MutableDomElementIterator i(element, QLatin1String("Menu")); while(i.hasNext()) { QDomElement e = i.next(); - mChilds.append(new XdgMenuApplinkProcessor(e, mMenu, this)); + mChilds.push_back(new XdgMenuApplinkProcessor(e, mMenu, this)); } } @@ -83,7 +82,7 @@ if (!mRules.checkExclude(i.key(), *file)) { - mSelected.append(i.value()); + mSelected.push_back(i.value()); } } @@ -192,9 +191,9 @@ for (const QFileInfo &file : files) { - XdgDesktopFile *f = new XdgDesktopFile; + auto f = std::make_unique(); if (f->load(file.canonicalFilePath()) && f->isValid()) - mAppFileInfoHash.insert(prefix + file.fileName(), new XdgMenuAppFileInfo(f, prefix + file.fileName(), this)); + mAppFileInfoHash.insert(prefix + file.fileName(), new XdgMenuAppFileInfo(std::move(f), prefix + file.fileName(), this)); } diff -Nru libqtxdg-3.4.0/src/qtxdg/xdgmenuapplinkprocessor.h libqtxdg-3.6.0/src/qtxdg/xdgmenuapplinkprocessor.h --- libqtxdg-3.4.0/src/qtxdg/xdgmenuapplinkprocessor.h 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/qtxdg/xdgmenuapplinkprocessor.h 2020-10-30 13:18:22.000000000 +0000 @@ -31,15 +31,17 @@ #include "xdgmenurules.h" #include #include -#include #include #include +#include + +#include class XdgMenu; class XdgMenuAppFileInfo; class XdgDesktopFile; -typedef QLinkedList XdgMenuAppFileInfoList; +typedef std::list XdgMenuAppFileInfoList; typedef QHash XdgMenuAppFileInfoHash; typedef QHashIterator XdgMenuAppFileInfoHashIterator; @@ -65,7 +67,7 @@ private: XdgMenuApplinkProcessor* mParent; - QLinkedList mChilds; + std::list mChilds; XdgMenuAppFileInfoHash mAppFileInfoHash; XdgMenuAppFileInfoList mSelected; QDomElement mElement; @@ -80,20 +82,20 @@ { Q_OBJECT public: - explicit XdgMenuAppFileInfo(XdgDesktopFile* desktopFile, const QString& id, QObject *parent) - : QObject(parent) + explicit XdgMenuAppFileInfo(std::unique_ptr desktopFile, const QString& id, QObject *parent) + : QObject(parent), + mDesktopFile{std::move(desktopFile)}, + mAllocated(false), + mId(id) { - mDesktopFile = desktopFile; - mAllocated = false; - mId = id; } - XdgDesktopFile* desktopFile() const { return mDesktopFile; } + XdgDesktopFile* desktopFile() const { return mDesktopFile.get(); } bool allocated() const { return mAllocated; } void setAllocated(bool value) { mAllocated = value; } QString id() const { return mId; } private: - XdgDesktopFile* mDesktopFile; + std::unique_ptr mDesktopFile; bool mAllocated; QString mId; }; diff -Nru libqtxdg-3.4.0/src/qtxdg/xdgmenulayoutprocessor.cpp libqtxdg-3.6.0/src/qtxdg/xdgmenulayoutprocessor.cpp --- libqtxdg-3.4.0/src/qtxdg/xdgmenulayoutprocessor.cpp 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/qtxdg/xdgmenulayoutprocessor.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -32,11 +32,11 @@ // Helper functions prototypes -QDomElement findLastElementByTag(const QDomElement element, const QString tagName); +QDomElement findLastElementByTag(const QDomElement &element, const QString &tagName); int childsCount(const QDomElement& element); -QDomElement findLastElementByTag(const QDomElement element, const QString tagName) +QDomElement findLastElementByTag(const QDomElement &element, const QString &tagName) { QDomNodeList l = element.elementsByTagName(tagName); if (l.isEmpty()) @@ -60,7 +60,8 @@ ************************************************/ XdgMenuLayoutProcessor::XdgMenuLayoutProcessor(QDomElement& element): - mElement(element) + mElement(element), + mDefaultLayout(findLastElementByTag(element, QLatin1String("DefaultLayout"))) { mDefaultParams.mShowEmpty = false; mDefaultParams.mInline = false; @@ -68,8 +69,6 @@ mDefaultParams.mInlineHeader = true; mDefaultParams.mInlineAlias = false; - mDefaultLayout = findLastElementByTag(element, QLatin1String("DefaultLayout")); - if (mDefaultLayout.isNull()) { // Create DefaultLayout node @@ -98,10 +97,9 @@ XdgMenuLayoutProcessor::XdgMenuLayoutProcessor(QDomElement& element, XdgMenuLayoutProcessor *parent): + mDefaultParams(parent->mDefaultParams), mElement(element) { - mDefaultParams = parent->mDefaultParams; - // DefaultLayout ............................ QDomElement defaultLayout = findLastElementByTag(element, QLatin1String("DefaultLayout")); diff -Nru libqtxdg-3.4.0/src/qtxdg/xdgmenurules.cpp libqtxdg-3.6.0/src/qtxdg/xdgmenurules.cpp --- libqtxdg-3.4.0/src/qtxdg/xdgmenurules.cpp 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/qtxdg/xdgmenurules.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -64,22 +64,22 @@ QDomElement e = iter.next(); if (e.tagName() == QLatin1String("Or")) - mChilds.append(new XdgMenuRuleOr(e, this)); + mChilds.push_back(new XdgMenuRuleOr(e, this)); else if (e.tagName() == QLatin1String("And")) - mChilds.append(new XdgMenuRuleAnd(e, this)); + mChilds.push_back(new XdgMenuRuleAnd(e, this)); else if (e.tagName() == QLatin1String("Not")) - mChilds.append(new XdgMenuRuleNot(e, this)); + mChilds.push_back(new XdgMenuRuleNot(e, this)); else if (e.tagName() == QLatin1String("Filename")) - mChilds.append(new XdgMenuRuleFileName(e, this)); + mChilds.push_back(new XdgMenuRuleFileName(e, this)); else if (e.tagName() == QLatin1String("Category")) - mChilds.append(new XdgMenuRuleCategory(e, this)); + mChilds.push_back(new XdgMenuRuleCategory(e, this)); else if (e.tagName() == QLatin1String("All")) - mChilds.append(new XdgMenuRuleAll(e, this)); + mChilds.push_back(new XdgMenuRuleAll(e, this)); else qWarning() << QString::fromLatin1("Unknown rule") << e.tagName(); @@ -90,7 +90,7 @@ bool XdgMenuRuleOr::check(const QString& desktopFileId, const XdgDesktopFile& desktopFile) { - for (QLinkedList::Iterator i=mChilds.begin(); i!=mChilds.end(); ++i) + for (std::list::const_iterator i=mChilds.cbegin(); i!=mChilds.cend(); ++i) if ((*i)->check(desktopFileId, desktopFile)) return true; return false; @@ -111,10 +111,11 @@ bool XdgMenuRuleAnd::check(const QString& desktopFileId, const XdgDesktopFile& desktopFile) { - for (QLinkedList::Iterator i=mChilds.begin(); i!=mChilds.end(); ++i) + for (std::list::const_iterator i=mChilds.cbegin(); i!=mChilds.cend(); ++i) if (!(*i)->check(desktopFileId, desktopFile)) return false; - return mChilds.count(); + //FIXME: Doon't use implicit casts + return mChilds.size(); } @@ -142,10 +143,10 @@ if the desktop entry has the given desktop-file id. See Desktop-File Id. ************************************************/ XdgMenuRuleFileName::XdgMenuRuleFileName(const QDomElement& element, QObject *parent) : - XdgMenuRule(element, parent) + XdgMenuRule(element, parent), + mId(element.text()) { //qDebug() << "Create FILENAME rule"; - mId = element.text(); } @@ -162,9 +163,9 @@ if the desktop entry has the given category in its Categories field. ************************************************/ XdgMenuRuleCategory::XdgMenuRuleCategory(const QDomElement& element, QObject *parent) : - XdgMenuRule(element, parent) + XdgMenuRule(element, parent), + mCategory(element.text()) { - mCategory = element.text(); } @@ -206,19 +207,19 @@ void XdgMenuRules::addInclude(const QDomElement& element) { - mIncludeRules.append(new XdgMenuRuleOr(element, this)); + mIncludeRules.push_back(new XdgMenuRuleOr(element, this)); } void XdgMenuRules::addExclude(const QDomElement& element) { - mExcludeRules.append(new XdgMenuRuleOr(element, this)); + mExcludeRules.push_back(new XdgMenuRuleOr(element, this)); } bool XdgMenuRules::checkInclude(const QString& desktopFileId, const XdgDesktopFile& desktopFile) { - for (QLinkedList::Iterator i=mIncludeRules.begin(); i!=mIncludeRules.end(); ++i) + for (std::list::const_iterator i=mIncludeRules.cbegin(); i!=mIncludeRules.cend(); ++i) if ((*i)->check(desktopFileId, desktopFile)) return true; return false; @@ -227,7 +228,7 @@ bool XdgMenuRules::checkExclude(const QString& desktopFileId, const XdgDesktopFile& desktopFile) { - for (QLinkedList::Iterator i=mExcludeRules.begin(); i!=mExcludeRules.end(); ++i) + for (std::list::const_iterator i=mExcludeRules.cbegin(); i!=mExcludeRules.cend(); ++i) if ((*i)->check(desktopFileId, desktopFile)) return true; return false; diff -Nru libqtxdg-3.4.0/src/qtxdg/xdgmenurules.h libqtxdg-3.6.0/src/qtxdg/xdgmenurules.h --- libqtxdg-3.4.0/src/qtxdg/xdgmenurules.h 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/qtxdg/xdgmenurules.h 2020-10-30 13:18:22.000000000 +0000 @@ -30,7 +30,8 @@ #include #include -#include + +#include #include "xdgdesktopfile.h" @@ -59,7 +60,7 @@ bool check(const QString& desktopFileId, const XdgDesktopFile& desktopFile) override; protected: - QLinkedList mChilds; + std::list mChilds; }; @@ -127,8 +128,8 @@ bool checkExclude(const QString& desktopFileId, const XdgDesktopFile& desktopFile); protected: - QLinkedList mIncludeRules; - QLinkedList mExcludeRules; + std::list mIncludeRules; + std::list mExcludeRules; }; #endif // QTXDG_XDGMENURULES_H diff -Nru libqtxdg-3.4.0/src/qtxdg/xdgmimeapps.cpp libqtxdg-3.6.0/src/qtxdg/xdgmimeapps.cpp --- libqtxdg-3.4.0/src/qtxdg/xdgmimeapps.cpp 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/qtxdg/xdgmimeapps.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -95,6 +95,8 @@ const QStringList categories = df->value(QL1S("Categories")).toString().toUpper().split(QL1C(';')); if (!categories.isEmpty() && (categories.contains(cat) || categories.contains(QL1S("X-") + cat))) dl.append(df); + else + delete df; } return dl; } diff -Nru libqtxdg-3.4.0/src/qtxdg/xdgmimeappsglibbackend.cpp libqtxdg-3.6.0/src/qtxdg/xdgmimeappsglibbackend.cpp --- libqtxdg-3.4.0/src/qtxdg/xdgmimeappsglibbackend.cpp 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/qtxdg/xdgmimeappsglibbackend.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -23,6 +23,7 @@ #include "qtxdglogging.h" #include "xdgdesktopfile.h" +#include "xdgdirs.h" #include #include @@ -41,6 +42,8 @@ XdgDesktopFile *df = new XdgDesktopFile; if (df->load(file) && df->isValid()) { dl.append(df); + } else { + delete df; } } } @@ -106,6 +109,7 @@ g_object_unref(gApp); return false; } + g_object_unref(gApp); return true; } @@ -119,8 +123,9 @@ QList XdgMimeAppsGLibBackend::apps(const QString &mimeType) { - QList dl = recommendedApps(mimeType); - dl.append(fallbackApps(mimeType)); + GList *list = g_app_info_get_all_for_type(mimeType.toUtf8().constData()); + QList dl = GAppInfoGListToXdgDesktopQList(list); + g_list_free_full(list, g_object_unref); return dl; } @@ -136,22 +141,7 @@ QList XdgMimeAppsGLibBackend::recommendedApps(const QString &mimeType) { - QByteArray ba = mimeType.toUtf8(); - const char *contentType = ba.constData(); - - GAppInfo *defaultApp = g_app_info_get_default_for_type(contentType, FALSE); - GList *list = g_app_info_get_recommended_for_type(contentType); - - if (list != nullptr && defaultApp != nullptr) { - GAppInfo *first = G_APP_INFO(g_list_nth_data(list, 0)); - GAppInfo *second = G_APP_INFO(g_list_nth_data(list, 1)); - if (!g_app_info_equal(defaultApp, first) && g_app_info_equal(defaultApp, second)) { - // we are sure that the first element comes from - // g_app_info_set_as_last_used(). We remove it becouse it's not - // part on the standard - list = g_list_remove(list, first); - } - } + GList *list = g_app_info_get_recommended_for_type(mimeType.toUtf8().constData()); QList dl = GAppInfoGListToXdgDesktopQList(list); g_list_free_full(list, g_object_unref); return dl; @@ -173,6 +163,7 @@ g_object_unref(gApp); return false; } + g_object_unref(gApp); return true; } @@ -209,20 +200,42 @@ bool XdgMimeAppsGLibBackend::setDefaultApp(const QString &mimeType, const XdgDesktopFile &app) { + // NOTE: "g_app_info_set_as_default_for_type()" writes to "~/.config/mimeapps.list" + // but we want to set the default app only for the DE (e.g., LXQt). + + if (!addAssociation(mimeType, app)) + return false; + GDesktopAppInfo *gApp = XdgDesktopFileToGDesktopAppinfo(app); if (gApp == nullptr) return false; + // first find the DE's mimeapps list file + QByteArray mimeappsList = "mimeapps.list"; + QList desktopsList = qgetenv("XDG_CURRENT_DESKTOP").toLower().split(':'); + if (!desktopsList.isEmpty()) { + mimeappsList = desktopsList.at(0) + "-" + mimeappsList; + } + char *mimeappsListPath = g_build_filename(XdgDirs::configHome(true).toUtf8().constData(), + mimeappsList.constData(), + nullptr); + + const char *desktop_id = g_app_info_get_id(G_APP_INFO(gApp)); + GKeyFile *kf = g_key_file_new(); + g_key_file_load_from_file(kf, mimeappsListPath, G_KEY_FILE_NONE, nullptr); + g_key_file_set_string(kf, "Default Applications", mimeType.toUtf8().constData(), desktop_id); GError *error = nullptr; - if (g_app_info_set_as_default_for_type(G_APP_INFO(gApp), - mimeType.toUtf8().constData(), &error) == FALSE) { + if (g_key_file_save_to_file(kf, mimeappsListPath, &error) == false) { qCWarning(QtXdgMimeAppsGLib, "Failed to set '%s' as the default for '%s'. %s", g_desktop_app_info_get_filename(gApp), qPrintable(mimeType), error->message); - g_error_free(error); + g_key_file_free(kf); + g_free(mimeappsListPath); g_object_unref(gApp); return false; } + g_key_file_free(kf); + g_free(mimeappsListPath); qCDebug(QtXdgMimeAppsGLib, "Set '%s' as the default for '%s'", g_desktop_app_info_get_filename(gApp), qPrintable(mimeType)); diff -Nru libqtxdg-3.4.0/src/qtxdg/xdgmimetype.cpp libqtxdg-3.6.0/src/qtxdg/xdgmimetype.cpp --- libqtxdg-3.4.0/src/qtxdg/xdgmimetype.cpp 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/qtxdg/xdgmimetype.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -22,6 +22,7 @@ #include "xdgicon.h" +#include class XdgMimeTypePrivate : public QSharedData { public: @@ -79,6 +80,11 @@ return *this; } +void XdgMimeType::swap(XdgMimeType &other) noexcept +{ + QMimeType::swap(other); + std::swap(dx, other.dx); +} XdgMimeType::~XdgMimeType() { diff -Nru libqtxdg-3.4.0/src/qtxdg/xdgmimetype.h libqtxdg-3.6.0/src/qtxdg/xdgmimetype.h --- libqtxdg-3.4.0/src/qtxdg/xdgmimetype.h 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/qtxdg/xdgmimetype.h 2020-10-30 13:18:22.000000000 +0000 @@ -80,11 +80,7 @@ return !QMimeType::operator==(other); } - void swap(XdgMimeType &other) - { - QMimeType::swap(other); - qSwap(dx, other.dx); - } + void swap(XdgMimeType &other) noexcept; //! Destructs the mimetype ~XdgMimeType(); diff -Nru libqtxdg-3.4.0/src/qtxdg/xmlhelper.h libqtxdg-3.6.0/src/qtxdg/xmlhelper.h --- libqtxdg-3.4.0/src/qtxdg/xmlhelper.h 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/qtxdg/xmlhelper.h 2020-10-30 13:18:22.000000000 +0000 @@ -37,9 +37,9 @@ { public: explicit DomElementIterator(const QDomNode& parentNode, const QString& tagName = QString()) + : mTagName(tagName), + mParent(parentNode) { - mTagName = tagName; - mParent = parentNode; toFront(); } @@ -96,9 +96,9 @@ { public: explicit MutableDomElementIterator(QDomNode& parentNode, const QString& tagName = QString()) + : mTagName(tagName), + mParent(parentNode) { - mTagName = tagName; - mParent = parentNode; toFront(); } diff -Nru libqtxdg-3.4.0/src/tools/mat/CMakeLists.txt libqtxdg-3.6.0/src/tools/mat/CMakeLists.txt --- libqtxdg-3.4.0/src/tools/mat/CMakeLists.txt 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/tools/mat/CMakeLists.txt 2020-10-30 13:18:22.000000000 +0000 @@ -4,6 +4,9 @@ defappmatcommand.cpp openmatcommand.cpp mimetypematcommand.cpp + defwebbrowsermatcommand.cpp + defemailclientmatcommand.cpp + deffilemanagermatcommand.cpp qtxdg-mat.cpp ) diff -Nru libqtxdg-3.4.0/src/tools/mat/defemailclientmatcommand.cpp libqtxdg-3.6.0/src/tools/mat/defemailclientmatcommand.cpp --- libqtxdg-3.4.0/src/tools/mat/defemailclientmatcommand.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libqtxdg-3.6.0/src/tools/mat/defemailclientmatcommand.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -0,0 +1,179 @@ +/* + * libqtxdg - An Qt implementation of freedesktop.org xdg specs + * Copyright (C) 2020 Luís Pereira + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#include "defemailclientmatcommand.h" + +#include "matglobals.h" +#include "xdgmacros.h" +#include "xdgdefaultapps.h" +#include "xdgdesktopfile.h" + +#include +#include +#include +#include +#include +#include + +#include + +enum DefEmailClientCommandMode { + CommandModeGetDefEmailClient, + CommandModeSetDefEmailClient, + CommandModeListAvailableEmailClients +}; + +struct DefEmailClientData { + DefEmailClientData() : mode(CommandModeGetDefEmailClient) {} + + DefEmailClientCommandMode mode; + QString defEmailClientName; +}; + +static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefEmailClientData *data, QString *errorMessage) +{ + parser->clearPositionalArguments(); + parser->setApplicationDescription(QL1S("Get/Set the default email client")); + + parser->addPositionalArgument(QL1S("def-email-client"), QL1S()); + + const QCommandLineOption defEmailClientNameOption(QStringList() << QSL("s") << QSL("set"), + QSL("Email Client to be set as default"), QSL("email client")); + + const QCommandLineOption listAvailableOption(QStringList() << QSL("l") << QSL("list-available"), + QSL("List available email clients")); + + parser->addOption(defEmailClientNameOption); + parser->addOption(listAvailableOption); + const QCommandLineOption helpOption = parser->addHelpOption(); + const QCommandLineOption versionOption = parser->addVersionOption(); + + if (!parser->parse(QCoreApplication::arguments())) { + *errorMessage = parser->errorText(); + return CommandLineError; + } + + if (parser->isSet(versionOption)) { + return CommandLineVersionRequested; + } + + if (parser->isSet(helpOption)) { + return CommandLineHelpRequested; + } + + const bool isListAvailableSet = parser->isSet(listAvailableOption); + const bool isDefEmailClientNameSet = parser->isSet(defEmailClientNameOption); + QString defEmailClientName; + + if (isDefEmailClientNameSet) + defEmailClientName = parser->value(defEmailClientNameOption); + + QStringList posArgs = parser->positionalArguments(); + posArgs.removeAt(0); + + if (isDefEmailClientNameSet && posArgs.size() > 0) { + *errorMessage = QSL("Extra arguments given: "); + errorMessage->append(posArgs.join(QLatin1Char(','))); + return CommandLineError; + } + + if (isListAvailableSet && (isDefEmailClientNameSet || posArgs.size() > 0)) { + *errorMessage = QSL("list-available can't be used with other options and doesn't take arguments"); + return CommandLineError; + } + + if (isListAvailableSet) { + data->mode = CommandModeListAvailableEmailClients; + } else { + data->mode = isDefEmailClientNameSet ? CommandModeSetDefEmailClient: CommandModeGetDefEmailClient; + data->defEmailClientName = defEmailClientName; + } + + return CommandLineOk; +} + +DefEmailClientMatCommand::DefEmailClientMatCommand(QCommandLineParser *parser) + : MatCommandInterface(QL1S("def-email-client"), + QSL("Get/Set the default email client"), + parser) +{ + Q_CHECK_PTR(parser); +} + +DefEmailClientMatCommand::~DefEmailClientMatCommand() +{ +} + +int DefEmailClientMatCommand::run(const QStringList & /*arguments*/) +{ + bool success = true; + DefEmailClientData data; + QString errorMessage; + if (!MatCommandInterface::parser()) { + qFatal("DefEmailClientMatCommand::run: MatCommandInterface::parser() returned a null pointer"); + } + switch(parseCommandLine(parser(), &data, &errorMessage)) { + case CommandLineOk: + break; + case CommandLineError: + std::cerr << qPrintable(errorMessage); + std::cerr << "\n\n"; + std::cerr << qPrintable(parser()->helpText()); + return EXIT_FAILURE; + case CommandLineVersionRequested: + showVersion(); + Q_UNREACHABLE(); + case CommandLineHelpRequested: + showHelp(); + Q_UNREACHABLE(); + } + + if (data.mode == CommandModeListAvailableEmailClients) { + const auto emailClients = XdgDefaultApps::emailClients(); + for (const auto *app : emailClients) + std::cout << qPrintable(XdgDesktopFile::id(app->fileName())) << "\n"; + + qDeleteAll(emailClients); + return EXIT_SUCCESS; + } + + if (data.mode == CommandModeGetDefEmailClient) { // Get default email client + XdgDesktopFile *defEmailClient = XdgDefaultApps::emailClient(); + if (defEmailClient != nullptr && defEmailClient->isValid()) { + std::cout << qPrintable(XdgDesktopFile::id(defEmailClient->fileName())) << "\n"; + delete defEmailClient; + } + } else { // Set default email client + XdgDesktopFile toSetDefEmailClient; + if (toSetDefEmailClient.load(data.defEmailClientName)) { + if (XdgDefaultApps::setEmailClient(toSetDefEmailClient)) { + std::cout << qPrintable(QSL("Set '%1' as the default email client\n").arg(toSetDefEmailClient.fileName())); + } else { + std::cerr << qPrintable(QSL("Could not set '%1' as the default email client\n").arg(toSetDefEmailClient.fileName())); + success = false; + } + } else { // could not load application file + std::cerr << qPrintable(QSL("Could not find find '%1'\n").arg(data.defEmailClientName)); + success = false; + } + } + + return success ? EXIT_SUCCESS : EXIT_FAILURE; +} diff -Nru libqtxdg-3.4.0/src/tools/mat/defemailclientmatcommand.h libqtxdg-3.6.0/src/tools/mat/defemailclientmatcommand.h --- libqtxdg-3.4.0/src/tools/mat/defemailclientmatcommand.h 1970-01-01 00:00:00.000000000 +0000 +++ libqtxdg-3.6.0/src/tools/mat/defemailclientmatcommand.h 2020-10-30 13:18:22.000000000 +0000 @@ -0,0 +1,34 @@ +/* + * libqtxdg - An Qt implementation of freedesktop.org xdg specs + * Copyright (C) 2020 Luís Pereira + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifndef DEFEMAILCLIENTMATCOMMAND_H +#define DEFEMAILCLIENTMATCOMMAND_H + +#include "matcommandinterface.h" + +class DefEmailClientMatCommand : public MatCommandInterface { +public: + explicit DefEmailClientMatCommand(QCommandLineParser *parser); + ~DefEmailClientMatCommand() override; + + int run(const QStringList &arguments) override; +}; + +#endif // DEFEMAILCLIENTMATCOMMAND_H diff -Nru libqtxdg-3.4.0/src/tools/mat/deffilemanagermatcommand.cpp libqtxdg-3.6.0/src/tools/mat/deffilemanagermatcommand.cpp --- libqtxdg-3.4.0/src/tools/mat/deffilemanagermatcommand.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libqtxdg-3.6.0/src/tools/mat/deffilemanagermatcommand.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -0,0 +1,179 @@ +/* + * libqtxdg - An Qt implementation of freedesktop.org xdg specs + * Copyright (C) 2020 Luís Pereira + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#include "deffilemanagermatcommand.h" + +#include "matglobals.h" +#include "xdgmacros.h" +#include "xdgdefaultapps.h" +#include "xdgdesktopfile.h" + +#include +#include +#include +#include +#include +#include + +#include + +enum DefFileManagerCommandMode { + CommandModeGetDefFileManager, + CommandModeSetDefFileManager, + CommandModeListAvailableFileManagers, +}; + +struct DefFileManagerData { + DefFileManagerData() : mode(CommandModeGetDefFileManager) {} + + DefFileManagerCommandMode mode; + QString defFileManagerName; +}; + +static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefFileManagerData *data, QString *errorMessage) +{ + parser->clearPositionalArguments(); + parser->setApplicationDescription(QL1S("Get/Set the default file manager")); + + parser->addPositionalArgument(QL1S("def-file-manager"), QL1S()); + + const QCommandLineOption defFileManagerNameOption(QStringList() << QSL("s") << QSL("set"), + QSL("File Manager to be set as default"), QSL("file manager")); + + const QCommandLineOption listAvailableOption(QStringList() << QSL("l") << QSL("list-available"), + QSL("List available file managers")); + + parser->addOption(defFileManagerNameOption); + parser->addOption(listAvailableOption); + const QCommandLineOption helpOption = parser->addHelpOption(); + const QCommandLineOption versionOption = parser->addVersionOption(); + + if (!parser->parse(QCoreApplication::arguments())) { + *errorMessage = parser->errorText(); + return CommandLineError; + } + + if (parser->isSet(versionOption)) { + return CommandLineVersionRequested; + } + + if (parser->isSet(helpOption)) { + return CommandLineHelpRequested; + } + + const bool isListAvailableSet = parser->isSet(listAvailableOption); + const bool isDefFileManagerNameSet = parser->isSet(defFileManagerNameOption); + QString defFileManagerName; + + if (isDefFileManagerNameSet) + defFileManagerName = parser->value(defFileManagerNameOption); + + QStringList posArgs = parser->positionalArguments(); + posArgs.removeAt(0); + + if (isDefFileManagerNameSet && posArgs.size() > 0) { + *errorMessage = QSL("Extra arguments given: "); + errorMessage->append(posArgs.join(QLatin1Char(','))); + return CommandLineError; + } + + if (isListAvailableSet && (isDefFileManagerNameSet || posArgs.size() > 0)) { + *errorMessage = QSL("list-available can't be used with other options and doesn't take arguments"); + return CommandLineError; + } + + if (isListAvailableSet) { + data->mode = CommandModeListAvailableFileManagers; + } else { + data->mode = isDefFileManagerNameSet ? CommandModeSetDefFileManager: CommandModeGetDefFileManager; + data->defFileManagerName = defFileManagerName; + } + + return CommandLineOk; +} + +DefFileManagerMatCommand::DefFileManagerMatCommand(QCommandLineParser *parser) + : MatCommandInterface(QL1S("def-file-manager"), + QSL("Get/Set the default file manager"), + parser) +{ + Q_CHECK_PTR(parser); +} + +DefFileManagerMatCommand::~DefFileManagerMatCommand() +{ +} + +int DefFileManagerMatCommand::run(const QStringList & /*arguments*/) +{ + bool success = true; + DefFileManagerData data; + QString errorMessage; + if (!MatCommandInterface::parser()) { + qFatal("DefFileManagerMatCommand::run: MatCommandInterface::parser() returned a null pointer"); + } + switch(parseCommandLine(parser(), &data, &errorMessage)) { + case CommandLineOk: + break; + case CommandLineError: + std::cerr << qPrintable(errorMessage); + std::cerr << "\n\n"; + std::cerr << qPrintable(parser()->helpText()); + return EXIT_FAILURE; + case CommandLineVersionRequested: + showVersion(); + Q_UNREACHABLE(); + case CommandLineHelpRequested: + showHelp(); + Q_UNREACHABLE(); + } + + if (data.mode == CommandModeListAvailableFileManagers) { + const auto fileManagers = XdgDefaultApps::fileManagers(); + for (const auto *app : fileManagers) + std::cout << qPrintable(XdgDesktopFile::id(app->fileName())) << "\n"; + + qDeleteAll(fileManagers); + return EXIT_SUCCESS; + } + + if (data.mode == CommandModeGetDefFileManager) { // Get default file manager + XdgDesktopFile *defFileManager = XdgDefaultApps::fileManager(); + if (defFileManager != nullptr && defFileManager->isValid()) { + std::cout << qPrintable(XdgDesktopFile::id(defFileManager->fileName())) << "\n"; + delete defFileManager; + } + } else { // Set default file manager + XdgDesktopFile toSetDefFileManager; + if (toSetDefFileManager.load(data.defFileManagerName)) { + if (XdgDefaultApps::setFileManager(toSetDefFileManager)) { + std::cout << qPrintable(QSL("Set '%1' as the default file manager\n").arg(toSetDefFileManager.fileName())); + } else { + std::cerr << qPrintable(QSL("Could not set '%1' as the default file manager\n").arg(toSetDefFileManager.fileName())); + success = false; + } + } else { // could not load application file + std::cerr << qPrintable(QSL("Could not find find '%1'\n").arg(data.defFileManagerName)); + success = false; + } + } + + return success ? EXIT_SUCCESS : EXIT_FAILURE; +} diff -Nru libqtxdg-3.4.0/src/tools/mat/deffilemanagermatcommand.h libqtxdg-3.6.0/src/tools/mat/deffilemanagermatcommand.h --- libqtxdg-3.4.0/src/tools/mat/deffilemanagermatcommand.h 1970-01-01 00:00:00.000000000 +0000 +++ libqtxdg-3.6.0/src/tools/mat/deffilemanagermatcommand.h 2020-10-30 13:18:22.000000000 +0000 @@ -0,0 +1,34 @@ +/* + * libqtxdg - An Qt implementation of freedesktop.org xdg specs + * Copyright (C) 2020 Luís Pereira + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifndef DEFFILEMANAGERMATCOMMAND_H +#define DEFFILEMANAGERMATCOMMAND_H + +#include "matcommandinterface.h" + +class DefFileManagerMatCommand : public MatCommandInterface { +public: + explicit DefFileManagerMatCommand(QCommandLineParser *parser); + ~DefFileManagerMatCommand() override; + + int run(const QStringList &arguments) override; +}; + +#endif // DEFFILEMANAGERMATCOMMAND_H diff -Nru libqtxdg-3.4.0/src/tools/mat/defwebbrowsermatcommand.cpp libqtxdg-3.6.0/src/tools/mat/defwebbrowsermatcommand.cpp --- libqtxdg-3.4.0/src/tools/mat/defwebbrowsermatcommand.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libqtxdg-3.6.0/src/tools/mat/defwebbrowsermatcommand.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -0,0 +1,184 @@ +/* + * libqtxdg - An Qt implementation of freedesktop.org xdg specs + * Copyright (C) 2020 Luís Pereira + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#include "defwebbrowsermatcommand.h" + +#include "matglobals.h" +#include "xdgmacros.h" +#include "xdgdefaultapps.h" +#include "xdgdesktopfile.h" + +#include +#include +#include +#include +#include +#include + +#include + +enum DefWebBrowserCommandMode { + CommandModeGetDefWebBrowser, + CommandModeSetDefWebBrowser, + CommandModeListAvailableWebBrowsers +}; + +struct DefWebBrowserData { + DefWebBrowserData() : mode(CommandModeGetDefWebBrowser) {} + + DefWebBrowserCommandMode mode; + QString defWebBrowserName; +}; + +static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefWebBrowserData *data, QString *errorMessage) +{ + parser->clearPositionalArguments(); + parser->setApplicationDescription(QL1S("Get/Set the default web browser")); + + parser->addPositionalArgument(QL1S("def-web-browser"), QL1S()); + + const QCommandLineOption defWebBrowserNameOption(QStringList() << QSL("s") << QSL("set"), + QSL("Web Browser to be set as default"), QSL("web bowser")); + + const QCommandLineOption listAvailableOption(QStringList() << QSL("l") << QSL("list-available"), + QSL("List available web browsers")); + + parser->addOption(defWebBrowserNameOption); + parser->addOption(listAvailableOption); + const QCommandLineOption helpOption = parser->addHelpOption(); + const QCommandLineOption versionOption = parser->addVersionOption(); + + if (!parser->parse(QCoreApplication::arguments())) { + *errorMessage = parser->errorText(); + return CommandLineError; + } + + if (parser->isSet(versionOption)) { + return CommandLineVersionRequested; + } + + if (parser->isSet(helpOption)) { + return CommandLineHelpRequested; + } + + const bool isListAvailableSet = parser->isSet(listAvailableOption); + const bool isDefWebBrowserNameSet = parser->isSet(defWebBrowserNameOption); + QString defWebBrowserName; + + if (isDefWebBrowserNameSet) + defWebBrowserName = parser->value(defWebBrowserNameOption); + + QStringList posArgs = parser->positionalArguments(); + posArgs.removeAt(0); + + if (isDefWebBrowserNameSet && posArgs.size() > 0) { + *errorMessage = QSL("Extra arguments given: "); + errorMessage->append(posArgs.join(QLatin1Char(','))); + return CommandLineError; + } + + if (!isDefWebBrowserNameSet && posArgs.size() > 0) { + *errorMessage = QSL("To set the default browser use the -s/--set option"); + return CommandLineError; + } + + if (isListAvailableSet && (isDefWebBrowserNameSet || posArgs.size() > 0)) { + *errorMessage = QSL("list-available can't be used with other options and doesn't take arguments"); + return CommandLineError; + } + + if (isListAvailableSet) { + data->mode = CommandModeListAvailableWebBrowsers; + } else { + data->mode = isDefWebBrowserNameSet ? CommandModeSetDefWebBrowser : CommandModeGetDefWebBrowser; + data->defWebBrowserName = defWebBrowserName; + } + + return CommandLineOk; +} + +DefWebBrowserMatCommand::DefWebBrowserMatCommand(QCommandLineParser *parser) + : MatCommandInterface(QL1S("def-web-browser"), + QSL("Get/Set the default web browser"), + parser) +{ + Q_CHECK_PTR(parser); +} + +DefWebBrowserMatCommand::~DefWebBrowserMatCommand() +{ +} + +int DefWebBrowserMatCommand::run(const QStringList & /*arguments*/) +{ + bool success = true; + DefWebBrowserData data; + QString errorMessage; + if (!MatCommandInterface::parser()) { + qFatal("DefWebBrowserMatCommand::run: MatCommandInterface::parser() returned a null pointer"); + } + switch(parseCommandLine(parser(), &data, &errorMessage)) { + case CommandLineOk: + break; + case CommandLineError: + std::cerr << qPrintable(errorMessage); + std::cerr << "\n\n"; + std::cerr << qPrintable(parser()->helpText()); + return EXIT_FAILURE; + case CommandLineVersionRequested: + showVersion(); + Q_UNREACHABLE(); + case CommandLineHelpRequested: + showHelp(); + Q_UNREACHABLE(); + } + + if (data.mode == CommandModeListAvailableWebBrowsers) { + const auto webBrowsers = XdgDefaultApps::webBrowsers(); + for (const auto *app : webBrowsers) + std::cout << qPrintable(XdgDesktopFile::id(app->fileName())) << "\n"; + + qDeleteAll(webBrowsers); + return EXIT_SUCCESS; + } + + if (data.mode == CommandModeGetDefWebBrowser) { // Get default web browser + XdgDesktopFile *defWebBrowser = XdgDefaultApps::webBrowser(); + if (defWebBrowser != nullptr && defWebBrowser->isValid()) { + std::cout << qPrintable(XdgDesktopFile::id(defWebBrowser->fileName())) << "\n"; + delete defWebBrowser; + } + } else { // Set default web browser + XdgDesktopFile toSetDefWebBrowser; + if (toSetDefWebBrowser.load(data.defWebBrowserName)) { + if (XdgDefaultApps::setWebBrowser(toSetDefWebBrowser)) { + std::cout << qPrintable(QSL("Set '%1' as the default web browser\n").arg(toSetDefWebBrowser.fileName())); + } else { + std::cerr << qPrintable(QSL("Could not set '%1' as the default web browser\n").arg(toSetDefWebBrowser.fileName())); + success = false; + } + } else { // could not load application file + std::cerr << qPrintable(QSL("Could not find find '%1'\n").arg(data.defWebBrowserName)); + success = false; + } + } + + return success ? EXIT_SUCCESS : EXIT_FAILURE; +} diff -Nru libqtxdg-3.4.0/src/tools/mat/defwebbrowsermatcommand.h libqtxdg-3.6.0/src/tools/mat/defwebbrowsermatcommand.h --- libqtxdg-3.4.0/src/tools/mat/defwebbrowsermatcommand.h 1970-01-01 00:00:00.000000000 +0000 +++ libqtxdg-3.6.0/src/tools/mat/defwebbrowsermatcommand.h 2020-10-30 13:18:22.000000000 +0000 @@ -0,0 +1,14 @@ +#ifndef DEFWEBBROWSERMATCOMMAND_H +#define DEFWEBBROWSERMATCOMMAND_H + +#include "matcommandinterface.h" + +class DefWebBrowserMatCommand : public MatCommandInterface { +public: + explicit DefWebBrowserMatCommand(QCommandLineParser *parser); + ~DefWebBrowserMatCommand() override; + + int run(const QStringList &arguments) override; +}; + +#endif // DEFWEBBROWSERMATCOMMAND_H diff -Nru libqtxdg-3.4.0/src/tools/mat/openmatcommand.cpp libqtxdg-3.6.0/src/tools/mat/openmatcommand.cpp --- libqtxdg-3.4.0/src/tools/mat/openmatcommand.cpp 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/tools/mat/openmatcommand.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -100,7 +100,7 @@ XdgMimeApps appsDb; QMimeDatabase mimeDb; - XdgDesktopFile *df; + XdgDesktopFile *df = nullptr; bool isLocalFile = false; QString localFilename; for (const QString &urlString : qAsConst(files)) { @@ -134,6 +134,8 @@ QSL("Error while running the default application (%1) for %2\n").arg(df->name(), urlString)); success = false; } + delete df; + df = nullptr; } else { // no default app found std::cout << qPrintable(QSL("No default application for '%1'\n").arg(urlString)); } diff -Nru libqtxdg-3.4.0/src/tools/mat/qtxdg-mat.cpp libqtxdg-3.6.0/src/tools/mat/qtxdg-mat.cpp --- libqtxdg-3.4.0/src/tools/mat/qtxdg-mat.cpp 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/tools/mat/qtxdg-mat.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -22,6 +22,9 @@ #include "mimetypematcommand.h" #include "defappmatcommand.h" #include "openmatcommand.h" +#include "defwebbrowsermatcommand.h" +#include "defemailclientmatcommand.h" +#include "deffilemanagermatcommand.h" #include "xdgmacros.h" @@ -76,6 +79,15 @@ MatCommandInterface *const mimeTypeCmd = new MimeTypeMatCommand(&parser); manager->add(mimeTypeCmd); + MatCommandInterface *const defWebBrowserCmd = new DefWebBrowserMatCommand(&parser); + manager->add(defWebBrowserCmd); + + MatCommandInterface *const defEmailClientCmd = new DefEmailClientMatCommand(&parser); + manager->add(defEmailClientCmd); + + MatCommandInterface *const defFileManagerCmd = new DefFileManagerMatCommand(&parser); + manager->add(defFileManagerCmd); + // Find out the positional arguments. parser.parse(QCoreApplication::arguments()); const QStringList args = parser.positionalArguments(); diff -Nru libqtxdg-3.4.0/src/xdgiconloader/xdgiconloader.cpp libqtxdg-3.6.0/src/xdgiconloader/xdgiconloader.cpp --- libqtxdg-3.4.0/src/xdgiconloader/xdgiconloader.cpp 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/src/xdgiconloader/xdgiconloader.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -30,6 +30,9 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + +// clazy:excludeall=non-pod-global-static + #ifndef QT_NO_ICON #include "xdgiconloader_p.h" @@ -50,10 +53,6 @@ #include #include -#ifdef Q_DEAD_CODE_FROM_QT4_MAC -#include -#endif - #include //QT_BEGIN_NAMESPACE @@ -221,7 +220,7 @@ QVector QIconCacheGtkReader::lookup(const QStringRef &name) { QVector ret; - if (!isValid()) + if (!isValid() || name.isEmpty()) return ret; QByteArray nameUtf8 = name.toUtf8(); @@ -326,11 +325,9 @@ dirInfo.maxSize = indexReader.value(directoryKey + QLatin1String("/MaxSize"), size).toInt(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) dirInfo.scale = indexReader.value(directoryKey + QLatin1String("/Scale"), 1).toInt(); -#endif m_keyList.append(dirInfo); } } @@ -626,11 +623,8 @@ QIcon::Mode mode, QIcon::State state) { QSize pixmapSize = rect.size(); -#if defined(Q_DEAD_CODE_FROM_QT4_MAC) - pixmapSize *= qt_mac_get_scalefactor(); -#endif const qreal dpr = painter->device()->devicePixelRatioF(); - painter->drawPixmap(rect, pixmap(pixmapSize * dpr, mode, state)); + painter->drawPixmap(rect, pixmap(QSizeF(pixmapSize * dpr).toSize(), mode, state)); } /* @@ -639,10 +633,8 @@ */ static bool directoryMatchesSize(const QIconDirInfo &dir, int iconsize, int iconscale) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) if (dir.scale != iconscale) return false; -#endif if (dir.type == QIconDirInfo::Fixed) { return dir.size == iconsize; @@ -665,7 +657,6 @@ */ static int directorySizeDistance(const QIconDirInfo &dir, int iconsize, int iconscale) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) const int scaledIconSize = iconsize * iconscale; if (dir.type == QIconDirInfo::Fixed) { return qAbs(dir.size * dir.scale - scaledIconSize); @@ -685,26 +676,6 @@ return scaledIconSize - dir.maxSize * dir.scale; else return 0; } -#else - if (dir.type == QIconDirInfo::Fixed) { - return qAbs(dir.size - iconsize); - - } else if (dir.type == QIconDirInfo::Scalable) { - if (iconsize < dir.minSize) - return dir.minSize - iconsize; - else if (iconsize > dir.maxSize) - return iconsize - dir.maxSize; - else - return 0; - - } else if (dir.type == QIconDirInfo::Threshold) { - if (iconsize < dir.size - dir.threshold) - return dir.minSize - iconsize; - else if (iconsize > dir.size + dir.threshold) - return iconsize - dir.maxSize; - else return 0; - } -#endif Q_ASSERT(1); // Not a valid value return INT_MAX; @@ -821,8 +792,12 @@ if (svgIcon.isNull()) svgIcon = QIcon(filename); - // Simply reuse svg icon engine - return svgIcon.pixmap(size, mode, state); + // Bypass QIcon API, as that will scale by device pixel ratio of the + // highest DPR screen since we're not passing on any QWindow. + if (QIconEngine *engine = svgIcon.data_ptr() ? svgIcon.data_ptr()->engine : nullptr) + return engine->pixmap(size, mode, state); + + return QPixmap(); } static const QString STYLE = QStringLiteral("\n.ColorScheme-Text, .ColorScheme-NeutralText {color:%1;}\ @@ -833,7 +808,11 @@ QPixmap ScalableFollowsColorEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) { - QPixmap pm = svgIcon.pixmap(size, mode, state); + QPixmap pm; + // see ScalableEntry::pixmap() for the reason + if (QIconEngine *engine = svgIcon.data_ptr() ? svgIcon.data_ptr()->engine : nullptr) + pm = engine->pixmap(size, mode, state); + // Note: not checking the QIcon::isNull(), because in Qt5.10 the isNull() is not reliable // for svg icons desierialized from stream (see https://codereview.qt-project.org/#/c/216086/) if (pm.isNull()) @@ -912,13 +891,15 @@ str_read.setVersion(QDataStream::Qt_4_4); str_read >> svgIcon; - pm = svgIcon.pixmap(size, mode, state); + if (QIconEngine *engine = svgIcon.data_ptr() ? svgIcon.data_ptr()->engine : nullptr) + pm = engine->pixmap(size, mode, state); // load the icon directly from file, if still null if (pm.isNull()) { svgIcon = QIcon(filename); - pm = svgIcon.pixmap(size, mode, state); + if (QIconEngine *engine = svgIcon.data_ptr() ? svgIcon.data_ptr()->engine : nullptr) + pm = engine->pixmap(size, mode, state); } } @@ -969,14 +950,11 @@ name = m_info.iconName; } break; -#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) case QIconEngine::IsNullHook: { *reinterpret_cast(data) = m_info.entries.isEmpty(); } break; -#endif -#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) case QIconEngine::ScaledPixmapHook: { QIconEngine::ScaledPixmapArgument &arg = *reinterpret_cast(data); @@ -986,7 +964,6 @@ arg.pixmap = entry ? entry->pixmap(arg.size, arg.mode, arg.state) : QPixmap(); } break; -#endif default: QIconEngine::virtual_hook(id, data); } diff -Nru libqtxdg-3.4.0/test/qtxdg_test.cpp libqtxdg-3.6.0/test/qtxdg_test.cpp --- libqtxdg-3.4.0/test/qtxdg_test.cpp 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/test/qtxdg_test.cpp 2020-10-30 13:18:22.000000000 +0000 @@ -76,7 +76,7 @@ } } -void QtXdgTest::compare(QString mimetype) +void QtXdgTest::compare(const QString &mimetype) { QString xdgUtilDefault = xdgUtilDefaultApp(mimetype); QString xdgDesktopDefault = xdgDesktopFileDefaultApp(mimetype); @@ -137,7 +137,7 @@ } -QString QtXdgTest::xdgDesktopFileDefaultApp(QString mimetype) +QString QtXdgTest::xdgDesktopFileDefaultApp(const QString &mimetype) { XdgMimeApps appsDb; XdgDesktopFile *defaultApp = appsDb.defaultApp(mimetype); @@ -151,7 +151,7 @@ -QString QtXdgTest::xdgUtilDefaultApp(QString mimetype) +QString QtXdgTest::xdgUtilDefaultApp(const QString &mimetype) { QProcess xdg_mime; QString program = QStringLiteral("xdg-mime"); diff -Nru libqtxdg-3.4.0/test/qtxdg_test.h libqtxdg-3.6.0/test/qtxdg_test.h --- libqtxdg-3.4.0/test/qtxdg_test.h 2019-10-27 16:22:17.000000000 +0000 +++ libqtxdg-3.6.0/test/qtxdg_test.h 2020-10-30 13:18:22.000000000 +0000 @@ -49,9 +49,9 @@ void testTextHtml(); void testMeldComparison(); - void compare(QString mimetype); - QString xdgDesktopFileDefaultApp(QString mimetype); - QString xdgUtilDefaultApp(QString mimetype); + void compare(const QString &mimetype); + QString xdgDesktopFileDefaultApp(const QString &mimetype); + QString xdgUtilDefaultApp(const QString &mimetype); };