changeset 472:2d57b81671de

Open the settings dialog at Paths tab when invoking it because of a failure to run hg
author Chris Cannam
date Thu, 14 Jul 2011 13:56:20 +0100
parents 8a10d3c396e8
children 101d113943c2 8bdc8f27d19c 2f59333952ce
files src/mainwindow.cpp src/mainwindow.h src/settingsdialog.cpp src/settingsdialog.h
diffstat 4 files changed, 36 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/mainwindow.cpp	Thu Jul 14 13:31:07 2011 +0100
+++ b/src/mainwindow.cpp	Thu Jul 14 13:56:20 2011 +0100
@@ -1718,7 +1718,13 @@
 
 void MainWindow::settings()
 {
+    settings(SettingsDialog::PersonalDetailsTab);
+}
+
+void MainWindow::settings(SettingsDialog::Tab tab)
+{
     SettingsDialog *settingsDlg = new SettingsDialog(this);
+    settingsDlg->setCurrentTab(tab);
     settingsDlg->exec();
 
     if (settingsDlg->presentationChanged()) {
@@ -2038,7 +2044,7 @@
              tr("Failed to run Mercurial"),
              tr("The Mercurial program either could not be found or failed to run.<br>Check that the Mercurial program path is correct in %1.").arg(setstr),
              output);
-        settings();
+        settings(SettingsDialog::PathsTab);
         return;
     case ACT_TEST_HG_EXT:
         MoreInformationDialog::warning
@@ -2047,7 +2053,7 @@
              tr("Failed to run Mercurial with extension enabled"),
              tr("The Mercurial program failed to run with the EasyMercurial interaction extension enabled.<br>This may indicate an installation problem.<br><br>You may be able to continue working if you switch off &ldquo;Use EasyHg Mercurial Extension&rdquo; in %1.  Note that remote repositories that require authentication might not work if you do this.").arg(setstr),
              output);
-        settings();
+        settings(SettingsDialog::PathsTab);
         return;
     case ACT_CLONEFROMREMOTE:
         // if clone fails, we have no repo
--- a/src/mainwindow.h	Thu Jul 14 13:31:07 2011 +0100
+++ b/src/mainwindow.h	Thu Jul 14 13:56:20 2011 +0100
@@ -23,6 +23,7 @@
 #include "common.h"
 #include "changeset.h"
 #include "hgaction.h"
+#include "settingsdialog.h"
 
 #include <QMainWindow>
 #include <QListWidget>
@@ -57,6 +58,7 @@
 private slots:
     void about();
     void settings();
+    void settings(SettingsDialog::Tab);
     void open();
     void recentMenuActivated();
     void changeRemoteRepo();
--- a/src/settingsdialog.cpp	Thu Jul 14 13:31:07 2011 +0100
+++ b/src/settingsdialog.cpp	Thu Jul 14 13:56:20 2011 +0100
@@ -41,15 +41,15 @@
     QGridLayout *mainLayout = new QGridLayout;
     setLayout(mainLayout);
 
-    QTabWidget *tw = new QTabWidget;
-    mainLayout->addWidget(tw, 0, 0);
+    m_tabs = new QTabWidget;
+    mainLayout->addWidget(m_tabs, 0, 0);
 
 
 //    QGroupBox *meBox = new QGroupBox(tr("User details"));
 //    mainLayout->addWidget(meBox, 0, 0);
 
     QWidget *meBox = new QWidget;
-    tw->addTab(meBox, tr("User details"));
+    m_tabs->addTab(meBox, tr("User details"));
 
     QGridLayout *meLayout = new QGridLayout;
     meBox->setLayout(meLayout);
@@ -73,7 +73,7 @@
 //    mainLayout->addWidget(lookBox, 1, 0);
     
     QWidget *lookBox = new QWidget;
-    tw->addTab(lookBox, tr("Presentation"));
+    m_tabs->addTab(lookBox, tr("Presentation"));
 
     QGridLayout *lookLayout = new QGridLayout;
     lookBox->setLayout(lookLayout);
@@ -106,7 +106,7 @@
     
 
     QWidget *pathsBox = new QWidget;
-    tw->addTab(pathsBox, tr("System application locations"));
+    m_tabs->addTab(pathsBox, tr("System application locations"));
 
 //    QGroupBox *pathsBox = new QGroupBox(tr("System application locations"));
 //    mainLayout->addWidget(pathsBox, 2, 0);
@@ -188,6 +188,16 @@
 }
 
 void
+SettingsDialog::setCurrentTab(Tab t)
+{
+    switch (t) {
+    case PersonalDetailsTab: m_tabs->setCurrentIndex(0); break;
+    case PresentationTab: m_tabs->setCurrentIndex(1); break;
+    case PathsTab: m_tabs->setCurrentIndex(2); break;
+    }
+}
+
+void
 SettingsDialog::hgPathBrowse()
 {
     browseFor(tr("Mercurial program"), m_hgPathLabel);
--- a/src/settingsdialog.h	Thu Jul 14 13:31:07 2011 +0100
+++ b/src/settingsdialog.h	Thu Jul 14 13:56:20 2011 +0100
@@ -24,14 +24,23 @@
 #include <QPushButton>
 #include <QCheckBox>
 #include <QComboBox>
+#include <QTabWidget>
 
 class SettingsDialog : public QDialog
 {
     Q_OBJECT
 
 public:
+    enum Tab {
+        PersonalDetailsTab,
+        PresentationTab,
+        PathsTab
+    };
+
     SettingsDialog(QWidget *parent = 0);
 
+    void setCurrentTab(Tab tab);
+
     bool presentationChanged() {
         return m_presentationChanged;
     }
@@ -53,6 +62,8 @@
     void restoreDefaults();
 
 private:
+    QTabWidget *m_tabs;
+
     QLineEdit *m_nameEdit;
     QLineEdit *m_emailEdit;
     QLineEdit *m_hgPathLabel;