Mercurial > hg > easyhg
changeset 301:3bb6b63420ad status_outside_tabs
Merge from the default branch
author | Chris Cannam |
---|---|
date | Tue, 22 Feb 2011 15:52:22 +0000 |
parents | e4284fab6962 (diff) 5e4a10af7945 (current diff) |
children | 031dddcd967f |
files | mainwindow.cpp |
diffstat | 9 files changed, 241 insertions(+), 142 deletions(-) [+] |
line wrap: on
line diff
--- a/easyhg.pro Tue Feb 22 15:51:47 2011 +0000 +++ b/easyhg.pro Tue Feb 22 15:52:22 2011 +0000 @@ -50,6 +50,7 @@ uncommitteditem.h \ settingsdialog.h \ clickablelabel.h \ + workstatuswidget.h \ moreinformationdialog.h SOURCES = main.cpp \ mainwindow.cpp \ @@ -81,6 +82,7 @@ incomingdialog.cpp \ uncommitteditem.cpp \ settingsdialog.cpp \ + workstatuswidget.cpp \ moreinformationdialog.cpp macx-* {
--- a/filestatuswidget.cpp Tue Feb 22 15:51:47 2011 +0000 +++ b/filestatuswidget.cpp Tue Feb 22 15:52:22 2011 +0000 @@ -18,7 +18,6 @@ #include "filestatuswidget.h" #include "debug.h" #include "multichoicedialog.h" -#include "clickablelabel.h" #include <QLabel> #include <QListWidget> @@ -43,40 +42,9 @@ int row = 0; -#ifndef Q_OS_MAC - layout->addItem(new QSpacerItem(1, 1), row, 0); - ++row; -#endif - - layout->addWidget(new QLabel(tr("Local:")), row, 0); - - m_openButton = new ClickableLabel; - QFont f(m_openButton->font()); - f.setBold(true); - m_openButton->setFont(f); - m_openButton->setMouseUnderline(true); - connect(m_openButton, SIGNAL(clicked()), this, SLOT(openButtonClicked())); - layout->addWidget(m_openButton, row, 1, 1, 2, Qt::AlignLeft); - - ++row; - layout->addWidget(new QLabel(tr("Remote:")), row, 0); - m_remoteURLLabel = new QLabel; - layout->addWidget(m_remoteURLLabel, row, 1, 1, 2); - - ++row; - layout->addWidget(new QLabel(tr("State:")), row, 0); - m_stateLabel = new QLabel; - layout->addWidget(m_stateLabel, row, 1, 1, 2); - - layout->setColumnStretch(1, 20); - - layout->addWidget(new QLabel("<qt><hr></qt>"), ++row, 0, 1, 3); - - ++row; - m_noModificationsLabel = new QLabel; setNoModificationsLabelText(); - layout->addWidget(m_noModificationsLabel, row, 1, 1, 2); + layout->addWidget(m_noModificationsLabel, row, 0); m_noModificationsLabel->hide(); m_simpleLabels[FileStates::Clean] = tr("Unmodified:"); @@ -107,7 +75,7 @@ "have appeared since your most recent commit or update."); m_boxesParent = new QWidget(this); - layout->addWidget(m_boxesParent, ++row, 0, 1, 3); + layout->addWidget(m_boxesParent, ++row, 0); QGridLayout *boxesLayout = new QGridLayout; boxesLayout->setMargin(0); @@ -152,7 +120,7 @@ layout->addItem(new QSpacerItem(8, 8), ++row, 0); m_showAllFiles = new QCheckBox(tr("Show all files"), this); - layout->addWidget(m_showAllFiles, ++row, 0, 1, 3, Qt::AlignLeft); + layout->addWidget(m_showAllFiles, ++row, 0, Qt::AlignLeft); connect(m_showAllFiles, SIGNAL(toggled(bool)), this, SIGNAL(showAllChanged(bool))); } @@ -162,32 +130,6 @@ delete m_dateReference; } -void FileStatusWidget::openButtonClicked() -{ - QDir d(m_localPath); - if (d.exists()) { - QStringList args; - QString path = d.canonicalPath(); -#if defined Q_OS_WIN32 - // Although the Win32 API is quite happy to have - // forward slashes as directory separators, Windows - // Explorer is not - path = path.replace('/', '\\'); - args << path; - QProcess::execute("c:/windows/explorer.exe", args); -#else - args << path; - QProcess::execute( -#if defined Q_OS_MAC - "/usr/bin/open", -#else - "/usr/bin/xdg-open", -#endif - args); -#endif - } -} - QString FileStatusWidget::labelFor(FileStates::State s, bool addHighlightExplanation) { QSettings settings; @@ -412,11 +354,16 @@ return files; } +QString +FileStatusWidget::localPath() const +{ + return m_localPath; +} + void FileStatusWidget::setLocalPath(QString p) { m_localPath = p; - m_openButton->setText(p); delete m_dateReference; m_dateReference = new QFileInfo(p + "/.hg/dirstate"); if (!m_dateReference->exists() || @@ -429,14 +376,6 @@ delete m_dateReference; m_dateReference = 0; } - m_openButton->setEnabled(QDir(m_localPath).exists()); -} - -void -FileStatusWidget::setRemoteURL(QString r) -{ - m_remoteURL = r; - m_remoteURLLabel->setText(r); } void @@ -447,13 +386,6 @@ } void -FileStatusWidget::setState(QString b) -{ - m_state = b; - updateStateLabel(); -} - -void FileStatusWidget::updateWidgets() { QDateTime lastInteractionTime; @@ -530,7 +462,6 @@ layoutBoxesLinearly(); } - updateStateLabel(); setNoModificationsLabelText(); } @@ -594,7 +525,3 @@ if (!ql.empty()) ql[0]->setText(text); } -void FileStatusWidget::updateStateLabel() -{ - m_stateLabel->setText(m_state); -}
--- a/filestatuswidget.h Tue Feb 22 15:51:47 2011 +0000 +++ b/filestatuswidget.h Tue Feb 22 15:52:22 2011 +0000 @@ -27,7 +27,6 @@ class QListWidget; class QPushButton; class QFileInfo; -class ClickableLabel; class QCheckBox; class FileStatusWidget : public QWidget @@ -38,16 +37,10 @@ FileStatusWidget(QWidget *parent = 0); ~FileStatusWidget(); - QString localPath() const { return m_localPath; } + QString localPath() const; void setLocalPath(QString p); - QString remoteURL() const { return m_remoteURL; } - void setRemoteURL(QString u); - - QString state() const { return m_state; } - void setState(QString b); - - FileStates fileStates() const { return m_fileStates; } + FileStates fileStates() const; void setFileStates(FileStates sp); bool haveChangesToCommit() const; @@ -80,18 +73,9 @@ private slots: void itemSelectionChanged(); - void openButtonClicked(); private: QString m_localPath; - ClickableLabel *m_openButton; - - QString m_remoteURL; - QLabel *m_remoteURLLabel; - - QString m_state; - QLabel *m_stateLabel; - QLabel *m_noModificationsLabel; QCheckBox *m_showAllFiles; @@ -112,7 +96,6 @@ void layoutBoxesGridly(int count); void layoutBoxesLinearly(); - void updateStateLabel(); void setNoModificationsLabelText(); QString labelFor(FileStates::State, bool addHighlightExplanation = false); void setLabelFor(QWidget *w, FileStates::State, bool addHighlightExplanation);
--- a/hgtabwidget.cpp Tue Feb 22 15:51:47 2011 +0000 +++ b/hgtabwidget.cpp Tue Feb 22 15:52:22 2011 +0000 @@ -27,14 +27,12 @@ #include <iostream> HgTabWidget::HgTabWidget(QWidget *parent, - QString remoteRepo, QString workFolderPath) : QTabWidget(parent) { // Work page m_fileStatusWidget = new FileStatusWidget; m_fileStatusWidget->setLocalPath(workFolderPath); - m_fileStatusWidget->setRemoteURL(remoteRepo); connect(m_fileStatusWidget, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); connect(m_fileStatusWidget, SIGNAL(showAllChanged(bool)), @@ -243,15 +241,9 @@ } } -void HgTabWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath) +void HgTabWidget::setLocalPath(QString workFolderPath) { m_fileStatusWidget->setLocalPath(workFolderPath); - m_fileStatusWidget->setRemoteURL(remoteRepoPath); -} - -void HgTabWidget::setState(QString state) -{ - m_fileStatusWidget->setState(state); } void HgTabWidget::showWorkTab()
--- a/hgtabwidget.h Tue Feb 22 15:51:47 2011 +0000 +++ b/hgtabwidget.h Tue Feb 22 15:52:22 2011 +0000 @@ -38,15 +38,14 @@ Q_OBJECT public: - HgTabWidget(QWidget *parent, QString remoteRepo, QString workFolderPath); + HgTabWidget(QWidget *parent, QString workFolderPath); void updateWorkFolderFileList(QString fileList); void setNewLog(QString hgLogList); void addIncrementalLog(QString hgLogList); - void setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath); - void setState(QString state); + void setLocalPath(QString workFolderPath); void setCurrent(QStringList ids, QString branch);
--- a/mainwindow.cpp Tue Feb 22 15:51:47 2011 +0000 +++ b/mainwindow.cpp Tue Feb 22 15:52:22 2011 +0000 @@ -45,6 +45,7 @@ #include "settingsdialog.h" #include "moreinformationdialog.h" #include "version.h" +#include "workstatuswidget.h" MainWindow::MainWindow(QString myDirPath) : @@ -89,20 +90,21 @@ QWidget *central = new QWidget(this); setCentralWidget(central); - m_hgTabs = new HgTabWidget(central, m_remoteRepoPath, m_workFolderPath); - connectTabsSignals(); - - // Instead of setting the tab widget as our central widget - // directly, put it in a layout, so that we can have some space - // around it on the Mac where it looks very strange without - QGridLayout *cl = new QGridLayout(central); - cl->addWidget(m_hgTabs, 0, 0); + int row = 0; #ifndef Q_OS_MAC cl->setMargin(0); #endif + m_workStatus = new WorkStatusWidget(this); + cl->addWidget(m_workStatus, row++, 0); + + m_hgTabs = new HgTabWidget(central, m_workFolderPath); + connectTabsSignals(); + + cl->addWidget(m_hgTabs, row++, 0); + connect(m_hgTabs, SIGNAL(selectionChanged()), this, SLOT(enableDisableActions())); connect(m_hgTabs, SIGNAL(showAllChanged(bool)), @@ -261,7 +263,7 @@ // We have to do this here, because commandCompleted won't be called MultiChoiceDialog::addRecentArgument("local", m_workFolderPath); MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath); - m_hgTabs->setWorkFolderAndRepoNames(m_workFolderPath, m_remoteRepoPath); + updateWorkFolderAndRepoNames(); hgQueryBranch(); return; @@ -830,7 +832,7 @@ params << "clone" << m_remoteRepoPath << m_workFolderPath; - m_hgTabs->setWorkFolderAndRepoNames(m_workFolderPath, m_remoteRepoPath); + updateWorkFolderAndRepoNames(); m_hgTabs->updateWorkFolderFileList(""); m_runner->requestAction(HgAction(ACT_CLONEFROMREMOTE, m_workFolderPath, params)); @@ -1808,7 +1810,7 @@ } MultiChoiceDialog::addRecentArgument("local", m_workFolderPath); MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath); - m_hgTabs->setWorkFolderAndRepoNames(m_workFolderPath, m_remoteRepoPath); + updateWorkFolderAndRepoNames(); break; } @@ -2310,34 +2312,34 @@ if (m_stateUnknown) { if (m_workFolderPath == "") { - m_hgTabs->setState(tr("No repository open")); + m_workStatus->setState(tr("No repository open")); } else { - m_hgTabs->setState(tr("(Examining repository)")); + m_workStatus->setState(tr("(Examining repository)")); } } else if (emptyRepo) { - m_hgTabs->setState(tr("Nothing committed to this repository yet")); + m_workStatus->setState(tr("Nothing committed to this repository yet")); } else if (noWorkingCopy) { - m_hgTabs->setState(tr("No working copy yet: consider updating")); + m_workStatus->setState(tr("No working copy yet: consider updating")); } else if (canMerge) { - m_hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText)); + m_workStatus->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText)); } else if (!m_hgTabs->getAllUnresolvedFiles().empty()) { - m_hgTabs->setState(tr("Have unresolved files following merge on %1").arg(branchText)); + m_workStatus->setState(tr("Have unresolved files following merge on %1").arg(branchText)); } else if (haveMerge) { - m_hgTabs->setState(tr("Have merged but not yet committed on %1").arg(branchText)); + m_workStatus->setState(tr("Have merged but not yet committed on %1").arg(branchText)); } else if (newBranch) { - m_hgTabs->setState(tr("On %1. New branch: has not yet been committed").arg(branchText)); + m_workStatus->setState(tr("On %1. New branch: has not yet been committed").arg(branchText)); } else if (canUpdate) { if (m_hgTabs->haveChangesToCommit()) { // have uncommitted changes - m_hgTabs->setState(tr("On %1. Not at the head of the branch").arg(branchText)); + m_workStatus->setState(tr("On %1. Not at the head of the branch").arg(branchText)); } else { // no uncommitted changes - m_hgTabs->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText)); + m_workStatus->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText)); } } else if (m_currentBranchHeads > 1) { - m_hgTabs->setState(tr("At one of %n heads of %1", "", m_currentBranchHeads).arg(branchText)); + m_workStatus->setState(tr("At one of %n heads of %1", "", m_currentBranchHeads).arg(branchText)); } else { - m_hgTabs->setState(tr("At the head of %1").arg(branchText)); + m_workStatus->setState(tr("At the head of %1").arg(branchText)); } } @@ -2484,14 +2486,19 @@ } } +void MainWindow::updateWorkFolderAndRepoNames() +{ + m_hgTabs->setLocalPath(m_workFolderPath); + + m_workStatus->setLocalPath(m_workFolderPath); + m_workStatus->setRemoteURL(m_remoteRepoPath); +} + void MainWindow::createStatusBar() { statusBar()->showMessage(tr("Ready")); } - -//!!! review these: - void MainWindow::readSettings() { QDir workFolder; @@ -2509,12 +2516,10 @@ QSize size = settings.value("size", QSize(400, 400)).toSize(); m_firstStart = settings.value("firststart", QVariant(true)).toBool(); -//!!! initialFileTypesBits = (unsigned char) settings.value("viewFileTypes", QVariant(DEFAULT_HG_STAT_BITS)).toInt(); resize(size); move(pos); } - void MainWindow::writeSettings() { QSettings settings; @@ -2523,7 +2528,6 @@ settings.setValue("remoterepopath", m_remoteRepoPath); settings.setValue("workfolderpath", m_workFolderPath); settings.setValue("firststart", m_firstStart); - //!!!settings.setValue("viewFileTypes", m_hgTabs -> getFileTypesBits()); }
--- a/mainwindow.h Tue Feb 22 15:51:47 2011 +0000 +++ b/mainwindow.h Tue Feb 22 15:52:22 2011 +0000 @@ -34,6 +34,8 @@ class QTimer; QT_END_NAMESPACE +class WorkStatusWidget; + class MainWindow : public QMainWindow { Q_OBJECT @@ -151,6 +153,9 @@ void suspendFileSystemWatcher(); void restoreFileSystemWatcher(); + void updateWorkFolderAndRepoNames(); + + WorkStatusWidget *m_workStatus; HgTabWidget *m_hgTabs; QString m_remoteRepoPath;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/workstatuswidget.cpp Tue Feb 22 15:52:22 2011 +0000 @@ -0,0 +1,125 @@ +/* -*- 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) 2011 Chris Cannam + Copyright (c) 2011 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. +*/ + +#include "workstatuswidget.h" +#include "debug.h" +#include "clickablelabel.h" + +#include <QGridLayout> +#include <QSpacerItem> +#include <QLabel> +#include <QProcess> +#include <QDir> + +WorkStatusWidget::WorkStatusWidget(QWidget *parent) : + QWidget(parent) +{ + QGridLayout *layout = new QGridLayout; + layout->setMargin(6); + layout->setSpacing(6); + setLayout(layout); + + int row = 0; + +#ifndef Q_OS_MAC + layout->addItem(new QSpacerItem(1, 1), row, 0); + ++row; +#endif + + layout->addWidget(new QLabel(tr("Local:")), row, 1); + + m_openButton = new ClickableLabel; + QFont f(m_openButton->font()); + f.setBold(true); + m_openButton->setFont(f); + m_openButton->setMouseUnderline(true); + connect(m_openButton, SIGNAL(clicked()), this, SLOT(openButtonClicked())); + layout->addWidget(m_openButton, row, 2, 1, 2, Qt::AlignLeft); + + ++row; + layout->addWidget(new QLabel(tr("Remote:")), row, 1); + m_remoteURLLabel = new QLabel; + layout->addWidget(m_remoteURLLabel, row, 2, 1, 2); + + ++row; + layout->addWidget(new QLabel(tr("State:")), row, 1); + m_stateLabel = new QLabel; + layout->addWidget(m_stateLabel, row, 2, 1, 2); + + layout->setColumnStretch(2, 20); + + +} + +WorkStatusWidget::~WorkStatusWidget() +{ +} + +void +WorkStatusWidget::setLocalPath(QString p) +{ + m_localPath = p; + m_openButton->setText(p); + m_openButton->setEnabled(QDir(m_localPath).exists()); +} + +void +WorkStatusWidget::setRemoteURL(QString r) +{ + m_remoteURL = r; + m_remoteURLLabel->setText(r); +} + +void +WorkStatusWidget::setState(QString b) +{ + m_state = b; + updateStateLabel(); +} + +void +WorkStatusWidget::updateStateLabel() +{ + m_stateLabel->setText(m_state); +} + +void +WorkStatusWidget::openButtonClicked() +{ + QDir d(m_localPath); + if (d.exists()) { + QStringList args; + QString path = d.canonicalPath(); +#if defined Q_OS_WIN32 + // Although the Win32 API is quite happy to have + // forward slashes as directory separators, Windows + // Explorer is not + path = path.replace('/', '\\'); + args << path; + QProcess::execute("c:/windows/explorer.exe", args); +#else + args << path; + QProcess::execute( +#if defined Q_OS_MAC + "/usr/bin/open", +#else + "/usr/bin/xdg-open", +#endif + args); +#endif + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/workstatuswidget.h Tue Feb 22 15:52:22 2011 +0000 @@ -0,0 +1,62 @@ +/* -*- 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) 2011 Chris Cannam + Copyright (c) 2011 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 WORKSTATUSWIDGET_H +#define WORKSTATUSWIDGET_H + +#include <QWidget> + +class QLabel; +class QPushButton; +class QFileInfo; +class ClickableLabel; +class QCheckBox; + +class WorkStatusWidget : public QWidget +{ + Q_OBJECT + +public: + WorkStatusWidget(QWidget *parent = 0); + ~WorkStatusWidget(); + + QString localPath() const { return m_localPath; } + void setLocalPath(QString p); + + QString remoteURL() const { return m_remoteURL; } + void setRemoteURL(QString u); + + QString state() const { return m_state; } + void setState(QString b); + +private slots: + void openButtonClicked(); + +private: + QString m_localPath; + ClickableLabel *m_openButton; + + QString m_remoteURL; + QLabel *m_remoteURLLabel; + + QString m_state; + QLabel *m_stateLabel; + + void updateStateLabel(); +}; + +#endif