Mercurial > hg > easyhg
changeset 186:6c15700f4103
* Open local folder in Finder/Explorer/whatever when its path is clicked on
author | Chris Cannam |
---|---|
date | Mon, 20 Dec 2010 14:37:35 +0000 |
parents | ec2baee80833 |
children | 869825bc8bc4 |
files | clickablelabel.h easyhg.pro filestatuswidget.cpp filestatuswidget.h mainwindow.cpp |
diffstat | 5 files changed, 145 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- /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 <QLabel> + +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("<u>%1</u>").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
--- 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 \
--- 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 <QLabel> #include <QListWidget> @@ -26,6 +27,9 @@ #include <QApplication> #include <QDateTime> #include <QPushButton> +#include <QToolButton> +#include <QDir> +#include <QProcess> 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.<br>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.<br>" - "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 <font color=#d40000>in red</font> " "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
--- 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;
--- 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("<qt><h2>About EasyMercurial</h2>" "<p>EasyMercurial is a simple user interface for the " - "Mercurial version control system.</p>" - "<p>EasyMercurial is based on hgExplorer by " - "Jari Korhonen, with thanks.<br>EasyMercurial development carried out by " - "Chris Cannam for soundsoftware.ac.uk at the Centre for Digital Music, Queen Mary, University of London." - "<ul><li>Copyright © 2010 Jari Korhonen</li>" - "<li>Copyright © 2010 Chris Cannam</li>" - "<li>Copyright © 2010 Queen Mary, University of London</li>" - "</ul>" - "<p> This program is free software; you can redistribute it and/or " + "Mercurial</a> version control system.</p>" + "<h4>Credits and Copyright</h4>" + "<p>Development carried out by Chris Cannam for " + "SoundSoftware.ac.uk at the Centre for Digital Music, " + "Queen Mary, University of London.</p>" + "<p>EasyMercurial is based on HgExplorer by " + "Jari Korhonen, with thanks.</p>" + "<p style=\"margin-left: 2em;\">" + "Copyright © 2010 Queen Mary, University of London.<br>" + "Copyright © 2010 Jari Korhonen.<br>" + "Copyright © 2010 Chris Cannam." + "</p>" + "<p style=\"margin-left: 2em;\">" + "This program requires Mercurial, by Matt Mackall and others.<br>" + "This program uses Qt by Nokia.<br>" + "This program uses Nuvola icons by David Vignoni.<br>" + "This program may use KDiff3 by Joachim Eibl.<br>" + "This program may use PyQt by River Bank Computing.<br>" + "Packaging for Mercurial and other dependencies on Windows is derived from TortoiseHg by Steve Borho and others." + "</p>" + "<h4>License</h4>" + "<p>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.</p>")); } void MainWindow::clearSelections() @@ -943,6 +956,7 @@ QSettings s(hgrc.canonicalFilePath(), QSettings::IniFormat); s.beginGroup("paths"); s.setValue("default", d->getArgument()); + stateUnknown = true; hgQueryPaths(); }