diff mainwindow.cpp @ 64:794db9353c7f

* Start rejigging the settings/repo-path dialog setup: startup dialog now asks for user name and email only
author Chris Cannam
date Wed, 17 Nov 2010 17:49:16 +0000
parents 2340b00561d2
children 7b1b333acf93
line wrap: on
line diff
--- a/mainwindow.cpp	Wed Nov 17 14:26:27 2010 +0000
+++ b/mainwindow.cpp	Wed Nov 17 17:49:16 2010 +0000
@@ -31,6 +31,7 @@
 
 #include "mainwindow.h"
 #include "settingsdialog.h"
+#include "startupdialog.h"
 #include "colourset.h"
 #include "debug.h"
 
@@ -68,13 +69,15 @@
     connectActions();
     enableDisableActions();
 
-    if (firstStart)
-    {
-        QMessageBox::information(this, tr("First start todo"), tr("Going to \"Settings\" first."));
-        settings();
+    if (firstStart) {
+        startupDialog();
+        firstStart = false;
     }
 
-    DEBUG << "User's real name is " << getUserRealName() << endl;
+    ColourSet *cs = ColourSet::instance();
+    cs->clearDefaultNames();
+    cs->addDefaultName("");
+    cs->addDefaultName(getUserInfo());
 
     hgStat();
 }
@@ -86,6 +89,24 @@
 }
 
 
+QString MainWindow::getUserInfo() const
+{
+    QSettings settings;
+    settings.beginGroup("User Information");
+    QString name = settings.value("name", getUserRealName()).toString();
+    QString email = settings.value("email", "").toString();
+
+    QString identifier;
+
+    if (email != "") {
+	identifier = QString("%1 <%2>").arg(name).arg(email);
+    } else {
+	identifier = name;
+    }
+
+    return identifier;
+}
+
 void MainWindow::about()
 {
    QMessageBox::about(this, tr("About HgExplorer"),
@@ -321,7 +342,7 @@
                 if ((justMerged == false) && (areAllSelectedCommitable(hgExp -> workFolderFileList)))
                 {
                     //User wants to commit selected file(s) (and this is not merge commit, which would fail if we selected files)
-                    params << "commit" << "--message" << comment << "--user" << userInfo << "--";
+                    params << "commit" << "--message" << comment << "--user" << getUserInfo() << "--";
 
                     QList <QListWidgetItem *> selList = hgExp -> workFolderFileList -> selectedItems();
                     for (int i = 0; i < selList.size(); ++i)
@@ -333,7 +354,7 @@
                 else
                 {
                     //Commit all changes
-                    params << "commit" << "--message" << comment << "--user" << userInfo;
+                    params << "commit" << "--message" << comment << "--user" << getUserInfo();
                 }
 
                 runner -> startHgCommand(workFolderPath, params);
@@ -371,7 +392,7 @@
         {
             if (!tag.isEmpty())
             {
-                params << "tag" << "--user" << userInfo << filterTag(tag);
+                params << "tag" << "--user" << getUserInfo() << filterTag(tag);
 
                 runner -> startHgCommand(workFolderPath, params);
                 runningAction = ACT_TAG;
@@ -667,6 +688,12 @@
 }
 
 
+void MainWindow::startupDialog()
+{
+    StartupDialog *dlg = new StartupDialog(this);
+    dlg->exec();
+}
+    
 
 void MainWindow::settings()
 {
@@ -1454,8 +1481,6 @@
         workFolderPath = "";
     }
 
-    userInfo = settings.value("userinfo", "").toString();
-
     QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
     QSize size = settings.value("size", QSize(400, 400)).toSize();
     firstStart = settings.value("firststart", QVariant(true)).toBool();
@@ -1463,12 +1488,6 @@
     initialFileTypesBits = (unsigned char) settings.value("viewFileTypes", QVariant(DEFAULT_HG_STAT_BITS)).toInt();
     resize(size);
     move(pos);
-
-    ColourSet *cs = ColourSet::instance();
-    cs->clearDefaultNames();
-    cs->addDefaultName("");
-    cs->addDefaultName("default");
-    cs->addDefaultName(userInfo);
 }
 
 
@@ -1479,7 +1498,6 @@
     settings.setValue("size", size());
     settings.setValue("remoterepopath", remoteRepoPath);
     settings.setValue("workfolderpath", workFolderPath);
-    settings.setValue("userinfo", userInfo);
     settings.setValue("firststart", firstStart);
     settings.setValue("viewFileTypes", hgExp -> getFileTypesBits());
 }