Mercurial > hg > easyhg
changeset 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 | 0ef4ed400ced |
children | 3c3827eb5106 |
files | src/filestates.cpp src/filestates.h src/filestatuswidget.cpp src/filestatuswidget.h src/hgtabwidget.cpp src/hgtabwidget.h src/mainwindow.cpp src/mainwindow.h |
diffstat | 8 files changed, 57 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/filestates.cpp Sat Aug 25 23:04:10 2012 +1000 +++ b/src/filestates.cpp Sun Aug 26 01:59:53 2012 +1000 @@ -161,11 +161,11 @@ switch (s) { case Modified: - a << Annotate << Diff << Commit << Revert << Rename << Copy << Remove; + a << Annotate << Diff << Commit << Revert << Rename << Copy << Remove << ShowIn; break; case Added: - a << Commit << Revert << Rename << Copy << Remove; + a << Commit << Revert << Rename << Copy << Remove << ShowIn; break; case Removed: @@ -173,7 +173,7 @@ break; case InConflict: - a << Annotate << Diff << RedoMerge << MarkResolved << Revert; + a << Annotate << Diff << RedoMerge << MarkResolved << Revert << ShowIn; break; case Missing: @@ -185,11 +185,11 @@ break; case Clean: - a << Annotate << Rename << Copy << Remove; + a << Annotate << Rename << Copy << Remove << ShowIn; break; case Ignored: - a << UnIgnore; + a << UnIgnore << ShowIn; break; }
--- a/src/filestates.h Sat Aug 25 23:04:10 2012 +1000 +++ b/src/filestates.h Sun Aug 26 01:59:53 2012 +1000 @@ -77,6 +77,8 @@ Ignore, UnIgnore, + ShowIn, + FirstActivity = Diff, LastActivity = UnIgnore };
--- a/src/filestatuswidget.cpp Sat Aug 25 23:04:10 2012 +1000 +++ b/src/filestatuswidget.cpp Sun Aug 26 01:59:53 2012 +1000 @@ -72,6 +72,15 @@ // Unignore is too difficult in fact, so we just offer to edit the hgignore m_actionLabels[FileStates::UnIgnore] = tr("Edit .hgignore File"); + // No "show in" under Unix at the moment. +#if defined Q_OS_MAC + m_actionLabels[FileStates::ShowIn] = tr("Show in Finder"); +#elif defined Q_OS_WIN32 + m_actionLabels[FileStates::ShowIn] = tr("Show in Windows Explorer"); +#endif + + m_shortcuts[FileStates::ShowIn] = tr("Ctrl+Shift+S"); + m_descriptions[FileStates::Clean] = tr("You have not changed these files."); m_descriptions[FileStates::Modified] = tr("You have changed these files since you last committed them."); m_descriptions[FileStates::Added] = tr("These files will be added to version control next time you commit them."); @@ -127,6 +136,11 @@ FileStates::Activities activities = m_fileStates.activitiesSupportedBy(s); int prevGroup = -1; foreach (FileStates::Activity a, activities) { + QString label = m_actionLabels[a]; + if (label.length() == 0) { + // Skip empty labels. + continue; + } int group = FileStates::activityGroup(a); if (group != prevGroup && prevGroup != -1) { QAction *sep = new QAction("", w); @@ -134,9 +148,13 @@ w->insertAction(0, sep); } prevGroup = group; - QAction *act = new QAction(m_actionLabels[a], w); + QAction *act = new QAction(label, w); act->setProperty("state", s); act->setProperty("activity", a); + if (m_shortcuts.contains(a)) { + QString shortcut = m_shortcuts[a]; + act->setShortcut(shortcut); + } connect(act, SIGNAL(triggered()), this, SLOT(menuActionActivated())); w->insertAction(0, act); } @@ -282,6 +300,7 @@ case FileStates::MarkResolved: emit markFilesResolved(files); break; case FileStates::Ignore: emit ignoreFiles(files); break; case FileStates::UnIgnore: emit unIgnoreFiles(files); break; + case FileStates::ShowIn: emit showIn(files); break; } }
--- a/src/filestatuswidget.h Sat Aug 25 23:04:10 2012 +1000 +++ b/src/filestatuswidget.h Sun Aug 26 01:59:53 2012 +1000 @@ -74,6 +74,7 @@ void markFilesResolved(QStringList); void ignoreFiles(QStringList); void unIgnoreFiles(QStringList); + void showIn(QStringList); public slots: void clearSelections(); @@ -99,6 +100,7 @@ QMap<FileStates::State, QString> m_descriptions; QMap<FileStates::State, QListWidget *> m_stateListMap; QMap<FileStates::Activity, QString> m_actionLabels; + QMap<FileStates::Activity, QString> m_shortcuts; QString m_highlightExplanation; QFileInfo *m_dateReference;
--- a/src/hgtabwidget.cpp Sat Aug 25 23:04:10 2012 +1000 +++ b/src/hgtabwidget.cpp Sun Aug 26 01:59:53 2012 +1000 @@ -77,6 +77,9 @@ connect(m_fileStatusWidget, SIGNAL(unIgnoreFiles(QStringList)), this, SIGNAL(unIgnoreFiles(QStringList))); + connect(m_fileStatusWidget, SIGNAL(showIn(QStringList)), + this, SIGNAL(showIn(QStringList))); + addTab(m_fileStatusWidget, tr("My work")); // History graph tab
--- a/src/hgtabwidget.h Sat Aug 25 23:04:10 2012 +1000 +++ b/src/hgtabwidget.h Sun Aug 26 01:59:53 2012 +1000 @@ -108,6 +108,7 @@ void markFilesResolved(QStringList); void ignoreFiles(QStringList); void unIgnoreFiles(QStringList); + void showIn(QStringList); public slots: void clearSelections();
--- 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()
--- a/src/mainwindow.h Sat Aug 25 23:04:10 2012 +1000 +++ b/src/mainwindow.h Sun Aug 26 01:59:53 2012 +1000 @@ -114,6 +114,7 @@ void hgMarkFilesResolved(QStringList); void hgIgnoreFiles(QStringList); void hgUnIgnoreFiles(QStringList); + void hgShowIn(QStringList); void updateFsWatcher(); void checkFilesystem();