# HG changeset patch # User Chris Cannam # Date 1292520745 0 # Node ID 6def8bf3be44bb719d94c43fbc6f511ecb48ce2f # Parent 4dc802a4d5ae471fc2724298782a3ad2dd29ca1b * Start implementing Settings dialog; add Test function to run on startup to make sure hg works diff -r 4dc802a4d5ae -r 6def8bf3be44 easyhg.pro --- a/easyhg.pro Thu Dec 16 12:40:04 2010 +0000 +++ b/easyhg.pro Thu Dec 16 17:32:25 2010 +0000 @@ -40,7 +40,8 @@ historywidget.h \ changesetscene.h \ incomingdialog.h \ - uncommitteditem.h + uncommitteditem.h \ + settingsdialog.h SOURCES = main.cpp \ mainwindow.cpp \ hgtabwidget.cpp \ @@ -69,7 +70,8 @@ historywidget.cpp \ changesetscene.cpp \ incomingdialog.cpp \ - uncommitteditem.cpp + uncommitteditem.cpp \ + settingsdialog.cpp macx-* { SOURCES += common_osx.mm diff -r 4dc802a4d5ae -r 6def8bf3be44 hgaction.h --- a/hgaction.h Thu Dec 16 12:40:04 2010 +0000 +++ b/hgaction.h Thu Dec 16 17:32:25 2010 +0000 @@ -24,6 +24,7 @@ enum HGACTIONS { ACT_NONE, + ACT_TEST_HG, ACT_QUERY_PATHS, ACT_QUERY_BRANCH, ACT_STAT, @@ -77,6 +78,7 @@ case ACT_QUERY_PATHS: case ACT_QUERY_BRANCH: case ACT_STAT: + case ACT_RESOLVE_LIST: case ACT_QUERY_HEADS: case ACT_QUERY_PARENTS: case ACT_LOG_INCREMENTAL: @@ -88,6 +90,7 @@ bool mayBeInteractive() const { switch (action) { + case ACT_TEST_HG: // so we force the module load to be tested case ACT_INCOMING: case ACT_PUSH: case ACT_PULL: diff -r 4dc802a4d5ae -r 6def8bf3be44 hgrunner.cpp --- a/hgrunner.cpp Thu Dec 16 12:40:04 2010 +0000 +++ b/hgrunner.cpp Thu Dec 16 17:32:25 2010 +0000 @@ -50,6 +50,7 @@ m_isRunning = false; findExtension(); + (void)getHgBinaryName(); } HgRunner::~HgRunner() @@ -118,6 +119,7 @@ QString HgRunner::getHgBinaryName() { QSettings settings; + settings.beginGroup("Locations"); QString hg = settings.value("hgbinary", "").toString(); if (hg == "") { hg = findInPath("hg", m_myDirPath, true); diff -r 4dc802a4d5ae -r 6def8bf3be44 mainwindow.cpp --- a/mainwindow.cpp Thu Dec 16 12:40:04 2010 +0000 +++ b/mainwindow.cpp Thu Dec 16 17:32:25 2010 +0000 @@ -39,6 +39,7 @@ #include "logparser.h" #include "confirmcommentdialog.h" #include "incomingdialog.h" +#include "settingsdialog.h" MainWindow::MainWindow(QString myDirPath) : @@ -99,7 +100,7 @@ open(); } - hgQueryPaths(); + hgTest(); } @@ -159,6 +160,13 @@ hgQueryPaths(); } +void MainWindow::hgTest() +{ + QStringList params; + params << "--version"; + runner->requestAction(HgAction(ACT_TEST_HG, m_myDirPath, params)); +} + void MainWindow::hgStat() { QStringList params; @@ -395,6 +403,7 @@ void MainWindow::findDiffBinaryName() { QSettings settings; + settings.beginGroup("Locations"); QString diff = settings.value("extdiffbinary", "").toString(); if (diff == "") { QStringList bases; @@ -419,6 +428,7 @@ void MainWindow::findMergeBinaryName() { QSettings settings; + settings.beginGroup("Locations"); QString merge = settings.value("mergebinary", "").toString(); if (merge == "") { QStringList bases; @@ -1084,14 +1094,8 @@ void MainWindow::settings() { -/*!!! SettingsDialog *settingsDlg = new SettingsDialog(this); - settingsDlg->setModal(true); settingsDlg->exec(); - hgTabs -> clearLists(); - enableDisableActions(); - hgStat(); -*/ } #define STDOUT_NEEDS_BIG_WINDOW 512 @@ -1178,7 +1182,7 @@ QString MainWindow::format3(QString head, QString intro, QString code) { - code = xmlEncode(code).replace("\n", "
").replace(" ", " "); + code = xmlEncode(code).replace("\n", "
").replace("-", "‑").replace(" ", " "); if (intro == "") { return QString("

%1

%2

") .arg(head).arg(code); @@ -1292,6 +1296,14 @@ case ACT_NONE: // uh huh return; + case ACT_TEST_HG: + QMessageBox::warning + (this, tr("Failed to run Mercurial"), + format3(tr("Failed to run Mercurial"), + tr("The Mercurial program either could not be found or failed to run.
This may indicate a problem with the Mercurial installation, or with the EasyHg interaction extension.

The test command said:"), + output)); + settings(); + return; case ACT_INCOMING: // returns non-zero code if the check was successful but there // are no changes pending @@ -1350,6 +1362,9 @@ switch (action) { + case ACT_TEST_HG: + break; + case ACT_QUERY_PATHS: { DEBUG << "stdout is " << output << endl; @@ -1533,6 +1548,10 @@ bool noMore = false; switch (action) { + + case ACT_TEST_HG: + hgQueryPaths(); + break; case ACT_QUERY_PATHS: hgQueryBranch(); diff -r 4dc802a4d5ae -r 6def8bf3be44 mainwindow.h --- a/mainwindow.h Thu Dec 16 12:40:04 2010 +0000 +++ b/mainwindow.h Thu Dec 16 17:32:25 2010 +0000 @@ -51,6 +51,7 @@ Changesets currentParents; int commitsSincePush; bool stateUnknown; + bool hgIsOK; bool needNewLog; protected: @@ -70,6 +71,7 @@ void startupDialog(); void clearSelections(); + void hgTest(); void hgQueryPaths(); void hgStat(); void hgRemove(); diff -r 4dc802a4d5ae -r 6def8bf3be44 settingsdialog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/settingsdialog.cpp Thu Dec 16 17:32:25 2010 +0000 @@ -0,0 +1,187 @@ +/* -*- 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. +*/ + +#include "settingsdialog.h" +#include "common.h" + +#include +#include +#include +#include + +SettingsDialog::SettingsDialog(QWidget *parent) : + QDialog(parent) +{ + setModal(true); + setWindowTitle(tr("Settings")); + + QSettings settings; + + QGridLayout *mainLayout = new QGridLayout; + setLayout(mainLayout); + + QGroupBox *meBox = new QGroupBox(tr("About me")); + mainLayout->addWidget(meBox, 0, 0); + QGridLayout *meLayout = new QGridLayout; + meBox->setLayout(meLayout); + + settings.beginGroup("User Information"); + + int row = 0; + + meLayout->addWidget(new QLabel(tr("Name:")), row, 0); + + m_nameEdit = new QLineEdit(); + m_nameEdit->setText(settings.value("name", getUserRealName()).toString()); + connect(m_nameEdit, SIGNAL(textChanged(const QString &)), + this, SLOT(realNameChanged(const QString &))); + meLayout->addWidget(m_nameEdit, row++, 1); + + meLayout->addWidget(new QLabel(tr("Email address:")), row, 0); + + m_emailEdit = new QLineEdit(); + m_emailEdit->setText(settings.value("email").toString()); + connect(m_emailEdit, SIGNAL(textChanged(const QString &)), + this, SLOT(emailChanged(const QString &))); + meLayout->addWidget(m_emailEdit, row++, 1); + + settings.endGroup(); + + QGroupBox *pathsBox = new QGroupBox(tr("System application locations")); + mainLayout->addWidget(pathsBox, 1, 0); + QGridLayout *pathsLayout = new QGridLayout; + pathsBox->setLayout(pathsLayout); + + settings.beginGroup("Locations"); + + row = 0; + + pathsLayout->addWidget(new QLabel(tr("Mercurial (hg) program:")), row, 0); + + m_hgPathEdit = new QLineEdit(); + m_hgPathEdit->setText(settings.value("hgbinary").toString()); + connect(m_hgPathEdit, SIGNAL(textChanged(const QString &)), + this, SLOT(hgPathChanged(const QString &))); + pathsLayout->addWidget(m_hgPathEdit, row, 1); + + QPushButton *browse = new QPushButton(tr("Browse...")); + pathsLayout->addWidget(browse, row++, 2); + connect(browse, SIGNAL(clicked()), this, SLOT(hgPathBrowse())); + + pathsLayout->addWidget(new QLabel(tr("External diff program:")), row, 0); + + m_diffPathEdit = new QLineEdit(); + m_diffPathEdit->setText(settings.value("extdiffbinary").toString()); + connect(m_diffPathEdit, SIGNAL(textChanged(const QString &)), + this, SLOT(diffPathChanged(const QString &))); + pathsLayout->addWidget(m_diffPathEdit, row, 1); + + browse = new QPushButton(tr("Browse...")); + pathsLayout->addWidget(browse, row++, 2); + connect(browse, SIGNAL(clicked()), this, SLOT(diffPathBrowse())); + + pathsLayout->addWidget(new QLabel(tr("External file-merge program:")), row, 0); + + m_mergePathEdit = new QLineEdit(); + m_mergePathEdit->setText(settings.value("mergebinary").toString()); + connect(m_mergePathEdit, SIGNAL(textChanged(const QString &)), + this, SLOT(mergePathChanged(const QString &))); + pathsLayout->addWidget(m_mergePathEdit, row, 1); + + browse = new QPushButton(tr("Browse...")); + pathsLayout->addWidget(browse, row++, 2); + connect(browse, SIGNAL(clicked()), this, SLOT(mergePathBrowse())); + + settings.endGroup(); + + QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok); + connect(bbox, SIGNAL(accepted()), this, SLOT(accept())); + mainLayout->addWidget(bbox, 2, 0); + m_ok = bbox->button(QDialogButtonBox::Ok); +// m_ok->setEnabled(false); + +//!!! m_ok->setEnabled(m_name != ""); +// updateExample(); +} + +void +SettingsDialog::realNameChanged(const QString &s) +{ +} + +void +SettingsDialog::emailChanged(const QString &s) +{ +} + +void +SettingsDialog::hgPathChanged(const QString &s) +{ +} + +void +SettingsDialog::hgPathBrowse() +{ +} + +void +SettingsDialog::diffPathChanged(const QString &s) +{ +} + +void +SettingsDialog::diffPathBrowse() +{ +} + +void +SettingsDialog::mergePathChanged(const QString &s) +{ +} + +void +SettingsDialog::mergePathBrowse() +{ +} + +void +SettingsDialog::editorPathChanged(const QString &s) +{ +} + +void +SettingsDialog::editorPathBrowse() +{ +} + +void +SettingsDialog::accept() +{ + QSettings settings; + settings.beginGroup("User Information"); + settings.setValue("name", m_nameEdit->text()); + settings.setValue("email", m_emailEdit->text()); + settings.endGroup(); + settings.beginGroup("Locations"); + settings.setValue("hgbinary", m_hgPathEdit->text()); + settings.setValue("extdiffbinary", m_diffPathEdit->text()); + settings.setValue("mergebinary", m_mergePathEdit->text()); + settings.endGroup(); + QDialog::accept(); +} + + diff -r 4dc802a4d5ae -r 6def8bf3be44 settingsdialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/settingsdialog.h Thu Dec 16 17:32:25 2010 +0000 @@ -0,0 +1,58 @@ +/* -*- 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 SETTINGS_DIALOG_H +#define SETTINGS_DIALOG_H + +#include +#include +#include +#include + +class SettingsDialog : public QDialog +{ + Q_OBJECT + +public: + SettingsDialog(QWidget *parent = 0); + +private slots: + void realNameChanged(const QString &); + void emailChanged(const QString &); + void hgPathChanged(const QString &); + void hgPathBrowse(); + void diffPathChanged(const QString &); + void diffPathBrowse(); + void mergePathChanged(const QString &); + void mergePathBrowse(); + void editorPathChanged(const QString &); + void editorPathBrowse(); + + void accept(); + +private: + QLineEdit *m_nameEdit; + QLineEdit *m_emailEdit; + QLineEdit *m_hgPathEdit; + QLineEdit *m_diffPathEdit; + QLineEdit *m_mergePathEdit; + QLineEdit *m_editorPathEdit; + + QPushButton *m_ok; +}; + +#endif