diff --git a/src/gui/tray/unifiedsearchresultslistmodel.cpp b/src/gui/tray/unifiedsearchresultslistmodel.cpp index 0cee17591..5f951c07c 100644 --- a/src/gui/tray/unifiedsearchresultslistmodel.cpp +++ b/src/gui/tray/unifiedsearchresultslistmodel.cpp @@ -579,16 +579,6 @@ void UnifiedSearchResultsListModel::parseResultsForProvider(const QJsonObject &d QVector newEntries; - const auto makeResourceUrl = [](const QUrl &resourceUrl, const QUrl &accountUrl) { - if (!resourceUrl.isRelative()) { - return resourceUrl; - } - - QUrl finalResourceUrl(accountUrl); - finalResourceUrl.setPath(resourceUrl.toString()); - return finalResourceUrl; - }; - for (const auto &entry : entries) { const auto entryMap = entry.toMap(); if (entryMap.isEmpty()) { @@ -605,7 +595,7 @@ void UnifiedSearchResultsListModel::parseResultsForProvider(const QJsonObject &d const auto resourceUrl = entryMap.value(QStringLiteral("resourceUrl")).toUrl(); const auto accountUrl = (_accountState && _accountState->account()) ? _accountState->account()->url() : QUrl(); - result._resourceUrl = makeResourceUrl(resourceUrl, accountUrl); + result._resourceUrl = openableResourceUrl(resourceUrl, accountUrl); const auto darkIconsData = iconsFromThumbnailAndFallbackIcon(entryMap.value(QStringLiteral("thumbnailUrl")).toString(), entryMap.value(QStringLiteral("icon")).toString(), accountUrl, true); const auto lightIconsData = iconsFromThumbnailAndFallbackIcon(entryMap.value(QStringLiteral("thumbnailUrl")).toString(), @@ -625,6 +615,17 @@ void UnifiedSearchResultsListModel::parseResultsForProvider(const QJsonObject &d } } +QUrl UnifiedSearchResultsListModel::openableResourceUrl(const QUrl &resourceUrl, const QUrl &accountUrl) +{ + if (!resourceUrl.isRelative()) { + return resourceUrl; + } + + QUrl finalResourceUrl(accountUrl); + finalResourceUrl.setPath(resourceUrl.toString()); + return finalResourceUrl; +} + void UnifiedSearchResultsListModel::appendResults(QVector results, const UnifiedSearchProvider &provider) { if (provider._cursor > 0 && provider._isPaginated) { diff --git a/src/gui/tray/unifiedsearchresultslistmodel.h b/src/gui/tray/unifiedsearchresultslistmodel.h index 4feadf2a3..539b4f59c 100644 --- a/src/gui/tray/unifiedsearchresultslistmodel.h +++ b/src/gui/tray/unifiedsearchresultslistmodel.h @@ -119,6 +119,8 @@ private slots: void slotSearchForProviderFinished(const QJsonDocument &json, int statusCode); private: + static QUrl openableResourceUrl(const QUrl &resourceUrl, const QUrl &accountUrl); + QMap _providers; QVector _results;