changeset 176:a6ec8d0bdd34

* Add option whether to use extension or not, and show path for it in settings
author Chris Cannam
date Thu, 16 Dec 2010 18:00:12 +0000
parents 6def8bf3be44
children bb89bcd8986b
files hgrunner.cpp settingsdialog.cpp settingsdialog.h
diffstat 3 files changed, 62 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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;
         }            
 
--- 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();
 }
--- 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 <QLineEdit>
 #include <QLabel>
 #include <QPushButton>
+#include <QCheckBox>
 
 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;
 };