From a072f940858d75816a5a9f0e53743ebc7b191ce8 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 17 Apr 2017 16:44:11 -0700 Subject: [PATCH] leverage QDesktopServices to show output directory --- tools/oven/src/ui/ResultsWindow.cpp | 45 +++++------------------------ 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/tools/oven/src/ui/ResultsWindow.cpp b/tools/oven/src/ui/ResultsWindow.cpp index 387e3698b8..cfbd07090f 100644 --- a/tools/oven/src/ui/ResultsWindow.cpp +++ b/tools/oven/src/ui/ResultsWindow.cpp @@ -9,7 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include +#include +#include #include #include #include @@ -57,45 +58,15 @@ void ResultsWindow::setupUI() { setLayout(resultsLayout); } -void revealDirectory(const QDir& dirToReveal) { - - // See http://stackoverflow.com/questions/3490336/how-to-reveal-in-finder-or-show-in-explorer-with-qt - // for details - - // Mac, Windows support folder or file. -#if defined(Q_OS_WIN) - const QString explorer = Environment::systemEnvironment().searchInPath(QLatin1String("explorer.exe")); - if (explorer.isEmpty()) { - QMessageBox::warning(parent, - tr("Launching Windows Explorer failed"), - tr("Could not find explorer.exe in path to launch Windows Explorer.")); - return; - } - - QString param = QLatin1String("/select,") + QDir::toNativeSeparators(dirToReveal.absolutePath()); - - QString command = explorer + " " + param; - QProcess::startDetached(command); - -#elif defined(Q_OS_MAC) - QStringList scriptArgs; - scriptArgs << QLatin1String("-e") - << QString::fromLatin1("tell application \"Finder\" to reveal POSIX file \"%1\"").arg(dirToReveal.absolutePath()); - QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs); - - scriptArgs.clear(); - scriptArgs << QLatin1String("-e") << QLatin1String("tell application \"Finder\" to activate"); - QProcess::execute("/usr/bin/osascript", scriptArgs); -#endif - -} - void ResultsWindow::handleCellClicked(int rowIndex, int columnIndex) { - // use revealDirectory to show the output directory for this row - revealDirectory(_outputDirectories[rowIndex]); + // make sure this click was on the file/domain being baked + if (columnIndex == 0) { + // use QDesktopServices to show the output directory for this row + auto directory = _outputDirectories[rowIndex]; + QDesktopServices::openUrl(QUrl::fromLocalFile(directory.absolutePath())); + } } - int ResultsWindow::addPendingResultRow(const QString& fileName, const QDir& outputDirectory) { int rowIndex = _resultsTable->rowCount();