mirror of https://github.com/procxx/kepka.git
				
				
				
			Use base::Platform::ShowInFolder.
This commit is contained in:
		
							parent
							
								
									30a1bd7ba2
								
							
						
					
					
						commit
						7bb23519f9
					
				|  | @ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL | |||
| #include "mainwindow.h" | ||||
| #include "boxes/abstract_box.h" | ||||
| #include "storage/localstorage.h" | ||||
| #include "base/platform/base_platform_file_utilities.h" | ||||
| #include "base/call_delayed.h" | ||||
| #include "facades.h" | ||||
| 
 | ||||
|  | @ -56,32 +57,7 @@ QByteArray EscapeShell(const QByteArray &content) { | |||
| void UnsafeShowInFolder(const QString &filepath) { | ||||
| 	// Hide mediaview to make other apps visible.
 | ||||
| 	Ui::hideLayer(anim::type::instant); | ||||
| 
 | ||||
| 	auto absolutePath = QFileInfo(filepath).absoluteFilePath(); | ||||
| 	QProcess process; | ||||
| 	process.start("xdg-mime", QStringList() << "query" << "default" << "inode/directory"); | ||||
| 	process.waitForFinished(); | ||||
| 	auto output = QString::fromLatin1(process.readLine().simplified()); | ||||
| 	auto command = qsl("xdg-open"); | ||||
| 	auto arguments = QStringList(); | ||||
| 	if (output == qstr("dolphin.desktop") || output == qstr("org.kde.dolphin.desktop")) { | ||||
| 		command = qsl("dolphin"); | ||||
| 		arguments << "--select" << absolutePath; | ||||
| 	} else if (output == qstr("nautilus.desktop") || output == qstr("org.gnome.Nautilus.desktop") || output == qstr("nautilus-folder-handler.desktop")) { | ||||
| 		command = qsl("nautilus"); | ||||
| 		arguments << absolutePath; | ||||
| 	} else if (output == qstr("nemo.desktop")) { | ||||
| 		command = qsl("nemo"); | ||||
| 		arguments << "--no-desktop" << absolutePath; | ||||
| 	} else if (output == qstr("konqueror.desktop") || output == qstr("kfmclient_dir.desktop")) { | ||||
| 		command = qsl("konqueror"); | ||||
| 		arguments << "--select" << absolutePath; | ||||
| 	} else { | ||||
| 		arguments << QFileInfo(filepath).absoluteDir().absolutePath(); | ||||
| 	} | ||||
| 	if (!process.startDetached(command, arguments)) { | ||||
| 		LOG(("Failed to launch '%1 %2'").arg(command).arg(arguments.join(' '))); | ||||
| 	} | ||||
| 	base::Platform::ShowInFolder(filepath); | ||||
| } | ||||
| 
 | ||||
| } // namespace File
 | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL | |||
| #include "platform/mac/file_utilities_mac.h" | ||||
| 
 | ||||
| #include "base/platform/mac/base_utilities_mac.h" | ||||
| #include "base/platform/base_platform_file_utilities.h" | ||||
| #include "lang/lang_keys.h" | ||||
| #include "styles/style_window.h" | ||||
| 
 | ||||
|  | @ -573,13 +574,7 @@ void UnsafeLaunch(const QString &filepath) { | |||
| } | ||||
| 
 | ||||
| void UnsafeShowInFolder(const QString &filepath) { | ||||
| 	auto folder = QFileInfo(filepath).absolutePath(); | ||||
| 
 | ||||
| 	@autoreleasepool { | ||||
| 
 | ||||
| 	[[NSWorkspace sharedWorkspace] selectFile:Q2NSString(filepath) inFileViewerRootedAtPath:Q2NSString(folder)]; | ||||
| 
 | ||||
| 	} | ||||
| 	base::Platform::ShowInFolder(filepath); | ||||
| } | ||||
| 
 | ||||
| } // namespace File | ||||
|  |  | |||
|  | @ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL | |||
| #include "mainwindow.h" | ||||
| #include "storage/localstorage.h" | ||||
| #include "platform/win/windows_dlls.h" | ||||
| #include "base/platform/base_platform_file_utilities.h" | ||||
| #include "lang/lang_keys.h" | ||||
| #include "core/application.h" | ||||
| #include "core/crash_reports.h" | ||||
|  | @ -260,16 +261,7 @@ void UnsafeLaunch(const QString &filepath) { | |||
| } | ||||
| 
 | ||||
| void UnsafeShowInFolder(const QString &filepath) { | ||||
| 	auto nativePath = QDir::toNativeSeparators(filepath); | ||||
| 	auto wstringPath = nativePath.toStdWString(); | ||||
| 	if (auto pidl = ILCreateFromPathW(wstringPath.c_str())) { | ||||
| 		SHOpenFolderAndSelectItems(pidl, 0, nullptr, 0); | ||||
| 		ILFree(pidl); | ||||
| 	} else { | ||||
| 		auto pathEscaped = nativePath.replace('"', qsl("\"\"")); | ||||
| 		auto wstringParam = (qstr("/select,") + pathEscaped).toStdWString(); | ||||
| 		ShellExecute(0, 0, L"explorer", wstringParam.c_str(), 0, SW_SHOWNORMAL); | ||||
| 	} | ||||
| 	base::Platform::ShowInFolder(filepath); | ||||
| } | ||||
| 
 | ||||
| void PostprocessDownloaded(const QString &filepath) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue