# HG changeset patch # User Chris Cannam # Date 1292855855 0 # Node ID 6c15700f4103c21a4428c136947819f758e51f33 # Parent ec2baee80833078490bdda0aa2a4eb18de0b66d2 * Open local folder in Finder/Explorer/whatever when its path is clicked on diff -r ec2baee80833 -r 6c15700f4103 clickablelabel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clickablelabel.h Mon Dec 20 14:37:35 2010 +0000 @@ -0,0 +1,81 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + EasyMercurial + + Based on HgExplorer by Jari Korhonen + Copyright (c) 2010 Jari Korhonen + Copyright (c) 2010 Chris Cannam + Copyright (c) 2010 Queen Mary, University of London + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#ifndef _CLICKABLE_LABEL_H_ +#define _CLICKABLE_LABEL_H_ + +#include + +class ClickableLabel : public QLabel +{ + Q_OBJECT + + Q_PROPERTY(bool mouseUnderline READ mouseUnderline WRITE setMouseUnderline) + +public: + ClickableLabel(const QString &text, QWidget *parent = 0) : + QLabel(text, parent), + m_naturalText(text) + { } + + ClickableLabel(QWidget *parent = 0) : + QLabel(parent) + { } + + ~ClickableLabel() + { } + + void setText(const QString &t) { + m_naturalText = t; + QLabel::setText(t); + } + + bool mouseUnderline() const { + return m_mouseUnderline; + } + + void setMouseUnderline(bool mu) { + m_mouseUnderline = mu; + if (mu) setTextFormat(Qt::RichText); + } + +signals: + void clicked(); + +protected: + virtual void enterEvent(QEvent *) { + if (m_mouseUnderline) { + QLabel::setText(tr("%1").arg(m_naturalText)); + } + } + + virtual void leaveEvent(QEvent *) { + if (m_mouseUnderline) { + QLabel::setText(m_naturalText); + } + } + + virtual void mousePressEvent(QMouseEvent *) { + emit clicked(); + } + +private: + bool m_mouseUnderline; + QString m_naturalText; +}; + +#endif diff -r ec2baee80833 -r 6c15700f4103 easyhg.pro --- a/easyhg.pro Sun Dec 19 19:12:52 2010 +0000 +++ b/easyhg.pro Mon Dec 20 14:37:35 2010 +0000 @@ -41,7 +41,8 @@ changesetscene.h \ incomingdialog.h \ uncommitteditem.h \ - settingsdialog.h + settingsdialog.h \ + clickablelabel.h SOURCES = main.cpp \ mainwindow.cpp \ hgtabwidget.cpp \ diff -r ec2baee80833 -r 6c15700f4103 filestatuswidget.cpp --- a/filestatuswidget.cpp Sun Dec 19 19:12:52 2010 +0000 +++ b/filestatuswidget.cpp Mon Dec 20 14:37:35 2010 +0000 @@ -18,6 +18,7 @@ #include "filestatuswidget.h" #include "debug.h" #include "multichoicedialog.h" +#include "clickablelabel.h" #include #include @@ -26,6 +27,9 @@ #include #include #include +#include +#include +#include FileStatusWidget::FileStatusWidget(QWidget *parent) : QWidget(parent), @@ -40,16 +44,19 @@ ++row; layout->addWidget(new QLabel(tr("Local:")), row, 0); - m_localPathLabel = new QLabel; - QFont f(m_localPathLabel->font()); + + m_openButton = new ClickableLabel; + QFont f(m_openButton->font()); f.setBold(true); - m_localPathLabel->setFont(f); - layout->addWidget(m_localPathLabel, row, 1); + m_openButton->setFont(f); + m_openButton->setMouseUnderline(true); + connect(m_openButton, SIGNAL(clicked()), this, SLOT(openButtonClicked())); + layout->addWidget(m_openButton, row, 1, 1, 2); ++row; layout->addWidget(new QLabel(tr("Remote:")), row, 0); m_remoteURLLabel = new QLabel; - layout->addWidget(m_remoteURLLabel, row, 1); + layout->addWidget(m_remoteURLLabel, row, 1, 1, 2); ++row; layout->addWidget(new QLabel(tr("State:")), row, 0); @@ -83,7 +90,8 @@ "If you deleted them by accident, select them and use Revert to restore their previous contents."); m_descriptions[FileStates::InConflict] = tr("These files are unresolved following an incomplete merge.
Select a file and use Merge to try to resolve the merge again."); m_descriptions[FileStates::Unknown] = tr("These files are in your working folder but are not under version control.
" - "Select a file and use Add to place it under version control or Ignore to remove it from this list."); +// "Select a file and use Add to place it under version control or Ignore to remove it from this list."); + "Select a file and use Add to place it under version control."); m_highlightExplanation = tr("Files highlighted in red " "have appeared since your most recent commit or update."); @@ -115,6 +123,7 @@ } layout->setRowStretch(++row, 20); + } FileStatusWidget::~FileStatusWidget() @@ -122,6 +131,24 @@ delete m_dateReference; } +void FileStatusWidget::openButtonClicked() +{ + QDir d(m_localPath); + if (d.exists()) { + QStringList args; + args << d.canonicalPath(); + QProcess::execute( +#if defined Q_OS_WIN32 + "c:/windows/explorer.exe", +#elif defined Q_OS_MAC + "/usr/bin/open", +#else + "/usr/bin/xdg-open", +#endif + args); + } +} + QString FileStatusWidget::labelFor(FileStates::State s, bool addHighlightExplanation) { if (addHighlightExplanation) { @@ -321,7 +348,7 @@ FileStatusWidget::setLocalPath(QString p) { m_localPath = p; - m_localPathLabel->setText(p); + m_openButton->setText(p); delete m_dateReference; m_dateReference = new QFileInfo(p + "/.hg/dirstate"); if (!m_dateReference->exists() || @@ -334,6 +361,7 @@ delete m_dateReference; m_dateReference = 0; } + m_openButton->setEnabled(QDir(m_localPath).exists()); } void diff -r ec2baee80833 -r 6c15700f4103 filestatuswidget.h --- a/filestatuswidget.h Sun Dec 19 19:12:52 2010 +0000 +++ b/filestatuswidget.h Mon Dec 20 14:37:35 2010 +0000 @@ -26,6 +26,7 @@ class QListWidget; class QPushButton; class QFileInfo; +class ClickableLabel; class FileStatusWidget : public QWidget { @@ -75,10 +76,11 @@ private slots: void itemSelectionChanged(); + void openButtonClicked(); private: QString m_localPath; - QLabel *m_localPathLabel; + ClickableLabel *m_openButton; QString m_remoteURL; QLabel *m_remoteURLLabel; diff -r ec2baee80833 -r 6c15700f4103 mainwindow.cpp --- a/mainwindow.cpp Sun Dec 19 19:12:52 2010 +0000 +++ b/mainwindow.cpp Mon Dec 20 14:37:35 2010 +0000 @@ -135,19 +135,32 @@ QMessageBox::about(this, tr("About EasyMercurial"), tr("

About EasyMercurial

" "

EasyMercurial is a simple user interface for the " - "Mercurial version control system.

" - "

EasyMercurial is based on hgExplorer by " - "Jari Korhonen, with thanks.
EasyMercurial development carried out by " - "Chris Cannam for soundsoftware.ac.uk at the Centre for Digital Music, Queen Mary, University of London." - "

  • Copyright © 2010 Jari Korhonen
  • " - "
  • Copyright © 2010 Chris Cannam
  • " - "
  • Copyright © 2010 Queen Mary, University of London
  • " - "
" - "

This program is free software; you can redistribute it and/or " + "Mercurial version control system.

" + "

Credits and Copyright

" + "

Development carried out by Chris Cannam for " + "SoundSoftware.ac.uk at the Centre for Digital Music, " + "Queen Mary, University of London.

" + "

EasyMercurial is based on HgExplorer by " + "Jari Korhonen, with thanks.

" + "

" + "Copyright © 2010 Queen Mary, University of London.
" + "Copyright © 2010 Jari Korhonen.
" + "Copyright © 2010 Chris Cannam." + "

" + "

" + "This program requires Mercurial, by Matt Mackall and others.
" + "This program uses Qt by Nokia.
" + "This program uses Nuvola icons by David Vignoni.
" + "This program may use KDiff3 by Joachim Eibl.
" + "This program may use PyQt by River Bank Computing.
" + "Packaging for Mercurial and other dependencies on Windows is derived from TortoiseHg by Steve Borho and others." + "

" + "

License

" + "

This program is free software; you can redistribute it and/or " "modify it under the terms of the GNU General Public License as " "published by the Free Software Foundation; either version 2 of the " "License, or (at your option) any later version. See the file " - "COPYING included with this distribution for more information.")); + "COPYING included with this distribution for more information.

")); } void MainWindow::clearSelections() @@ -943,6 +956,7 @@ QSettings s(hgrc.canonicalFilePath(), QSettings::IniFormat); s.beginGroup("paths"); s.setValue("default", d->getArgument()); + stateUnknown = true; hgQueryPaths(); }