From 0624184b184c09905b645e0550efa6dda90fe3ff Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 27 Feb 2020 11:29:25 +1100 Subject: [PATCH] projectexplorer: re-implemented reveal in explorer function --- .../projectexplorer/projectexplorer.cpp | 47 ++++++++++++++++++- app/widget/projectexplorer/projectexplorer.h | 2 + 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/app/widget/projectexplorer/projectexplorer.cpp b/app/widget/projectexplorer/projectexplorer.cpp index 1d070dfb2..f2baebebb 100644 --- a/app/widget/projectexplorer/projectexplorer.cpp +++ b/app/widget/projectexplorer/projectexplorer.cpp @@ -21,7 +21,11 @@ #include "projectexplorer.h" #include +#include +#include #include +#include +#include #include #include "common/define.h" @@ -242,9 +246,25 @@ void ProjectExplorer::ShowContextMenu() QAction* project_properties = menu.addAction(tr("&Project Properties...")); connect(project_properties, &QAction::triggered, Core::instance(), &Core::DialogProjectPropertiesShow); } else { + if (selected_items.first()->type() == Item::kFootage) { + QString reveal_text; + +#ifdef Q_OS_WINDOWS + reveal_text = tr("Reveal in Explorer"); +#elif Q_OS_MAC + reveal_text = tr("Reveal in Finder"); +#else + reveal_text = tr("Reveal in File Manager"); + #endif + + QAction* reveal_action = menu.addAction(reveal_text); + connect(reveal_action, &QAction::triggered, this, &ProjectExplorer::RevealSelectedFootage); + + menu.addSeparator(); + } + QAction* properties_action = menu.addAction(tr("P&roperties")); - // FIXME: Support for multiple items if (selected_items.first()->type() == Item::kFootage) { connect(properties_action, &QAction::triggered, this, &ProjectExplorer::ShowFootagePropertiesDialog); } else if (selected_items.first()->type() == Item::kSequence) { @@ -269,6 +289,31 @@ void ProjectExplorer::ShowSequencePropertiesDialog() sd.exec(); } +void ProjectExplorer::RevealSelectedFootage() +{ + Footage* footage = static_cast(SelectedItems().first()); + +#ifdef Q_OS_WINDOWS + // Explorer + QStringList args; + args << "/select," << QDir::toNativeSeparators(footage->filename()); + QProcess::startDetached("explorer", args); +#elif Q_OS_MAC + QStringList args; + args << "-e"; + args << "tell application \"Finder\""; + args << "-e"; + args << "activate"; + args << "-e"; + args << "select POSIX file \""+footage->filename()+"\""; + args << "-e"; + args << "end tell"; + QProcess::startDetached("osascript", args); +#else + QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(footage->filename()).dir().absolutePath())); +#endif +} + Project *ProjectExplorer::project() { return model_.project(); diff --git a/app/widget/projectexplorer/projectexplorer.h b/app/widget/projectexplorer/projectexplorer.h index 65cf68335..910ebfd19 100644 --- a/app/widget/projectexplorer/projectexplorer.h +++ b/app/widget/projectexplorer/projectexplorer.h @@ -155,6 +155,8 @@ private slots: void ShowSequencePropertiesDialog(); + void RevealSelectedFootage(); + }; #endif // PROJECTEXPLORER_H