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 | 2443 | DependencyManager::get<TabletScriptingInterface>()->preloadSounds(); |
| 2444 | 2444 | DependencyManager::get<Keyboard>()->createKeyboard(); |
| 2445 | 2445 | |
| 2446 | + FileDialogHelper::setOpenDirectoryOperator([this](const QString& path) { openDirectory(path); }); | |
| 2446 | 2447 | QDesktopServices::setUrlHandler("file", this, "showUrlHandler"); |
| 2447 | 2448 | QDesktopServices::setUrlHandler("", this, "showUrlHandler"); |
| 2448 | 2449 | auto drives = QDir::drives(); |
| @@ -9272,6 +9273,26 @@ QString Application::getGraphicsCardType() { · 6823 unmodified lines | ||
| 9272 | 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 | 9296 | void Application::showUrlHandler(const QUrl& url) { |
| 9276 | 9297 | if (QThread::currentThread() != thread()) { |
| 9277 | 9298 | QMetaObject::invokeMethod(this, "showUrlHandler", Q_ARG(const QUrl&, url)); |