diff src/mainwindow.cpp @ 624:38c84c66ad7a

* Added "show in" to show selected file in explorer
author Sam Izzo <sam@humbug.net>
date Sun, 26 Aug 2012 01:59:53 +1000
parents 2d5b831c1a0a
children db62a0cb3037
line wrap: on
line diff
--- a/src/mainwindow.cpp	Sat Aug 25 23:04:10 2012 +1000
+++ b/src/mainwindow.cpp	Sun Aug 26 01:59:53 2012 +1000
@@ -857,6 +857,26 @@
     hgEditIgnore();
 }
 
+void MainWindow::hgShowIn(QStringList files)
+{
+    foreach (QString file, files)
+    {
+        QStringList args;
+    #if defined Q_OS_WIN32
+        // Although the Win32 API is quite happy to have
+        // forward slashes as directory separators, Windows
+        // Explorer is not
+        file = file.replace('/', '\\');
+        args << "/select," << file;
+        // FIXME: This shouldn't be using a hardcoded path.
+        QProcess::execute("c:/windows/explorer.exe", args);
+    #else if defined(Q_OS_MAC)
+        args << file;
+        QProcess::execute("/usr/bin/open", args);
+    #endif
+    }
+}
+
 QString MainWindow::getDiffBinaryName()
 {
     QSettings settings;
@@ -2670,6 +2690,9 @@
 
     connect(m_hgTabs, SIGNAL(unIgnoreFiles(QStringList)),
             this, SLOT(hgUnIgnoreFiles(QStringList)));
+
+    connect(m_hgTabs, SIGNAL(showIn(QStringList)),
+            this, SLOT(hgShowIn(QStringList)));
 }    
 
 void MainWindow::enableDisableActions()