mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-15 03:22:11 +01:00
Use KIO::OpenFileManagerWindowJob to open folder
BUG: 460997 FIXED-IN: 24.12.0 Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
d2e2469655
commit
c1c917575f
|
@ -107,6 +107,9 @@ if (EXISTS "${CMAKE_SOURCE_DIR}/po")
|
||||||
find_package(KF6I18n REQUIRED)
|
find_package(KF6I18n REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Mandatory: KIO
|
||||||
|
find_package(KF6KIO ${KF_MIN_VERSION} REQUIRED)
|
||||||
|
|
||||||
# Optional: GnomeKeyring
|
# Optional: GnomeKeyring
|
||||||
find_package(PkgConfig)
|
find_package(PkgConfig)
|
||||||
if (PKG_CONFIG_FOUND)
|
if (PKG_CONFIG_FOUND)
|
||||||
|
@ -119,8 +122,6 @@ endif()
|
||||||
# Optional: KWallet, KIO, KCrash, KCoreAddons
|
# Optional: KWallet, KIO, KCrash, KCoreAddons
|
||||||
find_package(KF6Wallet ${KF_MIN_VERSION} CONFIG)
|
find_package(KF6Wallet ${KF_MIN_VERSION} CONFIG)
|
||||||
set_package_properties(KF6Wallet PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL)
|
set_package_properties(KF6Wallet PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL)
|
||||||
find_package(KF6KIO ${KF_MIN_VERSION} CONFIG)
|
|
||||||
set_package_properties(KF6KIO PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL)
|
|
||||||
find_package(KF6Crash ${KF_MIN_VERSION} CONFIG)
|
find_package(KF6Crash ${KF_MIN_VERSION} CONFIG)
|
||||||
set_package_properties(KF6Crash PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL)
|
set_package_properties(KF6Crash PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL)
|
||||||
find_package(KF6CoreAddons ${KF_MIN_VERSION} CONFIG)
|
find_package(KF6CoreAddons ${KF_MIN_VERSION} CONFIG)
|
||||||
|
|
|
@ -603,6 +603,7 @@ target_link_libraries(FalkonPrivate
|
||||||
Qt6::WebChannel
|
Qt6::WebChannel
|
||||||
Qt6::Core5Compat
|
Qt6::Core5Compat
|
||||||
KF6::Archive
|
KF6::Archive
|
||||||
|
KF6::KIOGui
|
||||||
${OPENSSL_CRYPTO_LIBRARY}
|
${OPENSSL_CRYPTO_LIBRARY}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,6 @@
|
||||||
#include <QWebEngineDownloadRequest>
|
#include <QWebEngineDownloadRequest>
|
||||||
#include <QtWebEngineWidgetsVersion>
|
#include <QtWebEngineWidgetsVersion>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
#include "Shlwapi.h"
|
|
||||||
#include "shellapi.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#define DOWNMANAGER_DEBUG
|
//#define DOWNMANAGER_DEBUG
|
||||||
|
|
||||||
DownloadItem::DownloadItem(QListWidgetItem *item, QWebEngineDownloadRequest* downloadItem, const QString &path, const QString &fileName, bool openFile, DownloadManager* manager)
|
DownloadItem::DownloadItem(QListWidgetItem *item, QWebEngineDownloadRequest* downloadItem, const QString &path, const QString &fileName, bool openFile, DownloadManager* manager)
|
||||||
|
@ -354,19 +349,12 @@ void DownloadItem::openFile()
|
||||||
|
|
||||||
void DownloadItem::openFolder()
|
void DownloadItem::openFolder()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
QString fileName = m_fileName;
|
||||||
QString winFileName = QSL("%1/%2").arg(m_path, m_fileName);
|
|
||||||
|
|
||||||
if (m_downloading) {
|
if (m_downloading) {
|
||||||
winFileName.append(QSL(".download"));
|
fileName.append(QSL(".download"));
|
||||||
}
|
}
|
||||||
|
QFileInfo info(m_path, fileName);
|
||||||
winFileName.replace(QLatin1Char('/'), QSL("\\"));
|
QzTools::openFolder({QUrl::fromLocalFile(info.absoluteFilePath())});
|
||||||
QString shExArg = QSL("/e,/select,\"") + winFileName + QSL("\"");
|
|
||||||
ShellExecute(NULL, NULL, TEXT("explorer.exe"), shExArg.toStdWString().c_str(), NULL, SW_SHOW);
|
|
||||||
#else
|
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(m_path));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl DownloadItem::url() const
|
QUrl DownloadItem::url() const
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QtGuiVersion>
|
#include <QtGuiVersion>
|
||||||
|
|
||||||
|
#include <KIO/OpenFileManagerWindowJob>
|
||||||
|
|
||||||
#ifdef QZ_WS_X11
|
#ifdef QZ_WS_X11
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -1037,3 +1039,31 @@ void QzTools::paintDropIndicator(QWidget *widget, const QRect &r)
|
||||||
p.drawLine(x + i, r.top(), x + i, r.bottom());
|
p.drawLine(x + i, r.top(), x + i, r.bottom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QzTools::openFolder(const QList<QUrl> &urls)
|
||||||
|
{
|
||||||
|
/* Filter the URL list for existing files, otherwise it will cause crash */
|
||||||
|
QList<QUrl> validUrls;
|
||||||
|
for (const QUrl &url : urls) {
|
||||||
|
if (QFileInfo::exists(url.toLocalFile())) {
|
||||||
|
validUrls.append(url);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qWarning() << "OpenFolder Filtered:" << url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validUrls.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto *job = new KIO::OpenFileManagerWindowJob();
|
||||||
|
job->setHighlightUrls(validUrls);
|
||||||
|
job->start();
|
||||||
|
|
||||||
|
QObject::connect(job, &KJob::result, job, [&](KJob *job) {
|
||||||
|
if (job->error() != 0) {
|
||||||
|
qWarning() << "OpenFileManagerWindowJob:" << job->errorString();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -98,6 +98,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
static void paintDropIndicator(QWidget *widget, const QRect &r);
|
static void paintDropIndicator(QWidget *widget, const QRect &r);
|
||||||
|
|
||||||
|
static void openFolder(const QList<QUrl> &urls);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QZTOOLS_H
|
#endif // QZTOOLS_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user