Showing the changes to interface/src/Application.cpp (1 of 4 files). Show all
Unified · Split
| @@ -2443,6 +2443,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 2442 unmodified lines | |||
| 2443 | DependencyManager::get<TabletScriptingInterface>()->preloadSounds(); | 2443 | DependencyManager::get<TabletScriptingInterface>()->preloadSounds(); |
| 2444 | DependencyManager::get<Keyboard>()->createKeyboard(); | 2444 | DependencyManager::get<Keyboard>()->createKeyboard(); |
| 2445 | 2445 | ||
| 2446 | FileDialogHelper::setOpenDirectoryOperator([this](const QString& path) { openDirectory(path); }); | ||
| 2446 | QDesktopServices::setUrlHandler("file", this, "showUrlHandler"); | 2447 | QDesktopServices::setUrlHandler("file", this, "showUrlHandler"); |
| 2447 | QDesktopServices::setUrlHandler("", this, "showUrlHandler"); | 2448 | QDesktopServices::setUrlHandler("", this, "showUrlHandler"); |
| 2448 | auto drives = QDir::drives(); | 2449 | auto drives = QDir::drives(); |
| @@ -9272,6 +9273,26 @@ QString Application::getGraphicsCardType() { · 6823 unmodified lines | |||
| 9272 | return GPUIdent::getInstance()->getName(); | 9273 | return GPUIdent::getInstance()->getName(); |
| 9273 | } | 9274 | } |
| 9274 | 9275 | ||
| 9276 | void Application::openDirectory(const QString& path) { | ||
| 9277 | if (QThread::currentThread() != thread()) { | ||
| 9278 | QMetaObject::invokeMethod(this, "openDirectory", Q_ARG(const QString&, path)); | ||
| 9279 | return; | ||
| 9280 | } | ||
| 9281 | |||
| 9282 | QString dirPath = path; | ||
| 9283 | const QString FILE_SCHEME = "file:///"; | ||
| 9284 | if (dirPath.startsWith(FILE_SCHEME)) { | ||
| 9285 | dirPath.remove(0, FILE_SCHEME.length()); | ||
| 9286 | } | ||
| 9287 | QFileInfo fileInfo(dirPath); | ||
| 9288 | if (fileInfo.isDir()) { | ||
| 9289 | auto scheme = QUrl(path).scheme(); | ||
| 9290 | QDesktopServices::unsetUrlHandler(scheme); | ||
| 9291 | QDesktopServices::openUrl(path); | ||
| 9292 | QDesktopServices::setUrlHandler(scheme, this, "showUrlHandler"); | ||
| 9293 | } | ||
| 9294 | } | ||
| 9295 | |||
| 9275 | void Application::showUrlHandler(const QUrl& url) { | 9296 | void Application::showUrlHandler(const QUrl& url) { |
| 9276 | if (QThread::currentThread() != thread()) { | 9297 | if (QThread::currentThread() != thread()) { |
| 9277 | QMetaObject::invokeMethod(this, "showUrlHandler", Q_ARG(const QUrl&, url)); | 9298 | QMetaObject::invokeMethod(this, "showUrlHandler", Q_ARG(const QUrl&, url)); |