mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-31 03:50:20 -07:00
Fix "Open destination folder" delay on Windows
Replaced QDesktopServices by native Windows function to open destination folder due to QDesktopServices issues on Windows. The issues are described in #17482 and even more detailed in #17025. Closes #17482. PR #17723.
This commit is contained in:
parent
5e4a94e6b6
commit
cacfe4f3ca
1 changed files with 18 additions and 0 deletions
|
@ -31,6 +31,7 @@
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <Objbase.h>
|
#include <Objbase.h>
|
||||||
#include <Shlobj.h>
|
#include <Shlobj.h>
|
||||||
|
#include <Shellapi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
@ -146,7 +147,24 @@ void Utils::Gui::openPath(const Path &path)
|
||||||
const QUrl url = path.data().startsWith(u"//")
|
const QUrl url = path.data().startsWith(u"//")
|
||||||
? QUrl(u"file:" + path.data())
|
? QUrl(u"file:" + path.data())
|
||||||
: QUrl::fromLocalFile(path.data());
|
: QUrl::fromLocalFile(path.data());
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
auto *thread = QThread::create([path]()
|
||||||
|
{
|
||||||
|
if (SUCCEEDED(::CoInitializeEx(NULL, (COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE))))
|
||||||
|
{
|
||||||
|
const std::wstring pathWStr = path.toString().toStdWString();
|
||||||
|
|
||||||
|
::ShellExecuteW(nullptr, nullptr, pathWStr.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
|
||||||
|
|
||||||
|
::CoUninitialize();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
QObject::connect(thread, &QThread::finished, thread, &QObject::deleteLater);
|
||||||
|
thread->start();
|
||||||
|
#else
|
||||||
QDesktopServices::openUrl(url);
|
QDesktopServices::openUrl(url);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the parent directory of the given path with a file manager and select
|
// Open the parent directory of the given path with a file manager and select
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue