# HG changeset patch # User Chris Cannam # Date 1292522412 0 # Node ID a6ec8d0bdd34700d45471a5d26bb74e8edbc60f2 # Parent 6def8bf3be44bb719d94c43fbc6f511ecb48ce2f * Add option whether to use extension or not, and show path for it in settings diff -r 6def8bf3be44 -r a6ec8d0bdd34 hgrunner.cpp --- a/hgrunner.cpp Thu Dec 16 17:32:25 2010 +0000 +++ b/hgrunner.cpp Thu Dec 16 18:00:12 2010 +0000 @@ -64,12 +64,20 @@ void HgRunner::findExtension() { + QSettings settings; + settings.beginGroup("Locations"); + m_extensionPath = settings.value("extensionpath", "").toString(); + if (m_extensionPath != "") return; m_extensionPath = findInPath("easyhg.py", m_myDirPath, false); if (m_extensionPath == "easyhg.py") { if (!unbundleExtension()) { - m_extensionPath = ""; + // might have failed because the file already existed + if (!QFile(m_extensionPath).exists()) { + m_extensionPath = ""; + } } } + settings.setValue("extensionpath", m_extensionPath); } bool HgRunner::unbundleExtension() @@ -338,8 +346,13 @@ if (action.mayBeInteractive()) { params.push_front("ui.interactive=true"); params.push_front("--config"); - params.push_front(QString("extensions.easyhg=%1").arg(m_extensionPath)); - params.push_front("--config"); + + QSettings settings; + settings.beginGroup("General"); + if (settings.value("useextension", true).toBool()) { + params.push_front(QString("extensions.easyhg=%1").arg(m_extensionPath)); + params.push_front("--config"); + } interactive = true; } diff -r 6def8bf3be44 -r a6ec8d0bdd34 settingsdialog.cpp --- a/settingsdialog.cpp Thu Dec 16 17:32:25 2010 +0000 +++ b/settingsdialog.cpp Thu Dec 16 18:00:12 2010 +0000 @@ -107,6 +107,32 @@ connect(browse, SIGNAL(clicked()), this, SLOT(mergePathBrowse())); settings.endGroup(); + + settings.beginGroup("Locations"); + + pathsLayout->addWidget(new QLabel(tr("EasyHg Mercurial extension:")), row, 0); + + m_extensionPathEdit = new QLineEdit(); + m_extensionPathEdit->setText(settings.value("extensionpath").toString()); + connect(m_extensionPathEdit, SIGNAL(textChanged(const QString &)), + this, SLOT(extensionPathChanged(const QString &))); + pathsLayout->addWidget(m_extensionPathEdit, row, 1); + + browse = new QPushButton(tr("Browse...")); + pathsLayout->addWidget(browse, row++, 2); + connect(browse, SIGNAL(clicked()), this, SLOT(extensionPathBrowse())); + + settings.endGroup(); + + settings.beginGroup("General"); + + //!!! more info plz + m_useExtension = new QCheckBox(tr("Use EasyHg Mercurial extension")); + m_useExtension->setChecked(settings.value("useextension", true).toBool()); + pathsLayout->addWidget(m_useExtension, row++, 1); + + settings.endGroup(); + QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok); connect(bbox, SIGNAL(accepted()), this, SLOT(accept())); @@ -169,6 +195,16 @@ } void +SettingsDialog::extensionPathChanged(const QString &s) +{ +} + +void +SettingsDialog::extensionPathBrowse() +{ +} + +void SettingsDialog::accept() { QSettings settings; @@ -180,6 +216,10 @@ settings.setValue("hgbinary", m_hgPathEdit->text()); settings.setValue("extdiffbinary", m_diffPathEdit->text()); settings.setValue("mergebinary", m_mergePathEdit->text()); + settings.setValue("extensionpath", m_extensionPathEdit->text()); + settings.endGroup(); + settings.beginGroup("General"); + settings.setValue("useextension", m_useExtension->isChecked()); settings.endGroup(); QDialog::accept(); } diff -r 6def8bf3be44 -r a6ec8d0bdd34 settingsdialog.h --- a/settingsdialog.h Thu Dec 16 17:32:25 2010 +0000 +++ b/settingsdialog.h Thu Dec 16 18:00:12 2010 +0000 @@ -22,6 +22,7 @@ #include #include #include +#include class SettingsDialog : public QDialog { @@ -41,6 +42,8 @@ void mergePathBrowse(); void editorPathChanged(const QString &); void editorPathBrowse(); + void extensionPathChanged(const QString &); + void extensionPathBrowse(); void accept(); @@ -52,6 +55,9 @@ QLineEdit *m_mergePathEdit; QLineEdit *m_editorPathEdit; + QCheckBox *m_useExtension; + QLineEdit *m_extensionPathEdit; + QPushButton *m_ok; };