# HG changeset patch # User Chris Cannam # Date 1290016156 0 # Node ID 794db9353c7ff00930bcbde586e74a6b99e6b44d # Parent 2340b00561d2c88d4484d2bba9baa32f208b60ae * Start rejigging the settings/repo-path dialog setup: startup dialog now asks for user name and email only diff -r 2340b00561d2 -r 794db9353c7f easyhg.pro --- a/easyhg.pro Wed Nov 17 14:26:27 2010 +0000 +++ b/easyhg.pro Wed Nov 17 17:49:16 2010 +0000 @@ -23,7 +23,8 @@ dateitem.h \ colourset.h \ debug.h \ - recentfiles.h + recentfiles.h \ + startupdialog.h SOURCES = main.cpp \ mainwindow.cpp \ hgexpwidget.cpp \ @@ -41,7 +42,8 @@ dateitem.cpp \ colourset.cpp \ debug.cpp \ - recentfiles.cpp + recentfiles.cpp \ + startupdialog.cpp macx-* { SOURCES += common_osx.mm diff -r 2340b00561d2 -r 794db9353c7f hgrunner.cpp --- a/hgrunner.cpp Wed Nov 17 14:26:27 2010 +0000 +++ b/hgrunner.cpp Wed Nov 17 17:49:16 2010 +0000 @@ -76,16 +76,16 @@ { stdOut = QString::fromUtf8(proc -> readAllStandardOutput()); stdErr = QString::fromUtf8(proc -> readAllStandardError()); + + DEBUG << "saveOutput: " << stdOut.split("\n").size() << " line(s) of stdout, " << stdErr.split("\n").size() << " line(s) of stderr" << endl; + +// std::cerr << "stdout was " << stdOut.toStdString() << std::endl; } void HgRunner::setProcExitInfo(int procExitCode, QProcess::ExitStatus procExitStatus) { exitCode = procExitCode; exitStatus = procExitStatus; - - DEBUG << "setProcExitInfo: " << stdOut.split("\n").size() << " line(s) of stdout, " << stdErr.split("\n").size() << " line(s) of stderr"; - -// std::cerr << "stdout was " << stdOut.toStdString() << std::endl; } QString HgRunner::getLastCommandLine() @@ -96,6 +96,7 @@ void HgRunner::finished(int procExitCode, QProcess::ExitStatus procExitStatus) { setProcExitInfo(procExitCode, procExitStatus); + saveOutput(); isRunning = false; if (procExitCode == 0 || procExitStatus == QProcess::NormalExit) { @@ -142,7 +143,8 @@ QString cmdline = command; foreach (QString param, params) cmdline += " " + param; - DEBUG << "HgRunner: starting: " << cmdline; + DEBUG << "HgRunner: starting: " << cmdline << " with cwd " + << workingDir << endl; proc -> start(command, params); } diff -r 2340b00561d2 -r 794db9353c7f mainwindow.cpp --- 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 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()); } diff -r 2340b00561d2 -r 794db9353c7f mainwindow.h --- a/mainwindow.h Wed Nov 17 14:26:27 2010 +0000 +++ b/mainwindow.h Wed Nov 17 17:49:16 2010 +0000 @@ -76,10 +76,6 @@ QString remoteRepoPath; QString workFolderPath; - //User info for commits - QString userInfo; - bool firstStart; - protected: void closeEvent(QCloseEvent *event); @@ -91,6 +87,9 @@ private slots: void about(); + void settings(); + void startupDialog(); + void hgRemove(); void hgAdd(); void hgCommit(); @@ -101,7 +100,6 @@ void hgRevert(); void hgMerge(); void hgRetryMerge(); - void settings(); void hgCloneFromRemote(); void hgInit(); void hgIncoming(); @@ -138,6 +136,10 @@ QString listAllUpIpV4Addresses(); QString filterTag(QString tag); + QString getUserInfo() const; + + bool firstStart; + //Actions enabled flags bool remoteRepoActionsEnabled; bool localRepoActionsEnabled; diff -r 2340b00561d2 -r 794db9353c7f settingsdialog.cpp --- a/settingsdialog.cpp Wed Nov 17 14:26:27 2010 +0000 +++ b/settingsdialog.cpp Wed Nov 17 17:49:16 2010 +0000 @@ -31,7 +31,7 @@ mainWnd = (MainWindow *) parent; userInfoLabel = new QLabel(tr("User info for commits, e.g. John Smith ")); - userInfoLineEdit = new QLineEdit(mainWnd->userInfo); + userInfoLineEdit = new QLineEdit("");//!!!mainWnd->userInfo); userInfoLabel -> setBuddy(userInfoLineEdit); remoteRepoLabel = new QLabel(tr("Remote repository path, e.g. http://192.168.1.10:8000/ or /home/mike/anotherrepo/ or c:\\anotherrepo\\")); @@ -101,8 +101,8 @@ { QString tmp; - mainWnd -> firstStart = false; - mainWnd -> userInfo = userInfoLineEdit->text(); +//!!! mainWnd -> firstStart = false; +//!!! mainWnd -> userInfo = userInfoLineEdit->text(); if (mainWnd -> remoteRepoPath != remoteRepoCombo-> currentText()) { diff -r 2340b00561d2 -r 794db9353c7f startupdialog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/startupdialog.cpp Wed Nov 17 17:49:16 2010 +0000 @@ -0,0 +1,113 @@ +/* -*- 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 "startupdialog.h" +#include "common.h" + +#include +#include +#include + +StartupDialog::StartupDialog(QWidget *parent) : + QDialog(parent) +{ + setModal(true); + setWindowTitle(tr("About me")); + + QSettings settings; + settings.beginGroup("User Information"); + m_name = settings.value("name", getUserRealName()).toString(); + m_email = settings.value("email").toString(); + + QGridLayout *layout = new QGridLayout; + int row = 0; + + layout->addWidget(new QLabel(tr("Welcome to EasyMercurial!
How would you like to be identified in commit messages?")), + row++, 0, 1, 2); + + layout->addWidget(new QLabel(tr("Name:")), row, 0); + + m_nameEdit = new QLineEdit(); + m_nameEdit->setText(m_name); + connect(m_nameEdit, SIGNAL(textChanged(const QString &)), + this, SLOT(realNameChanged(const QString &))); + layout->addWidget(m_nameEdit, row++, 1); + + layout->addWidget(new QLabel(tr("Email address:")), row, 0); + + m_emailEdit = new QLineEdit(); + m_emailEdit->setText(m_email); + connect(m_emailEdit, SIGNAL(textChanged(const QString &)), + this, SLOT(emailChanged(const QString &))); + layout->addWidget(m_emailEdit, row++, 1); + + layout->addWidget(new QLabel(tr("
You will appear as:")), row, 0, Qt::AlignBottom); + m_example = new QLabel(); + layout->addWidget(m_example, row++, 1, Qt::AlignBottom); + + QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok); + connect(bbox, SIGNAL(accepted()), this, SLOT(accept())); + layout->addWidget(bbox, row++, 0, 1, 2); + m_ok = bbox->button(QDialogButtonBox::Ok); + m_ok->setEnabled(false); + + setLayout(layout); + + m_ok->setEnabled(m_name != ""); + updateExample(); +} + +void +StartupDialog::realNameChanged(const QString &s) +{ + m_name = s.trimmed(); + m_ok->setEnabled(m_name != ""); + updateExample(); +} + +void +StartupDialog::emailChanged(const QString &s) +{ + m_email = s.trimmed(); + updateExample(); +} + +void +StartupDialog::accept() +{ + QSettings settings; + settings.beginGroup("User Information"); + settings.setValue("name", m_name); + settings.setValue("email", m_email); + QDialog::accept(); +} + +void +StartupDialog::updateExample() +{ + QString identifier; + + if (m_email != "") { + identifier = QString("%1 <%2>").arg(m_name).arg(m_email); + } else { + identifier = m_name; + } + + m_example->setText(identifier); +} + + diff -r 2340b00561d2 -r 794db9353c7f startupdialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/startupdialog.h Wed Nov 17 17:49:16 2010 +0000 @@ -0,0 +1,50 @@ +/* -*- 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 STARTUP_DIALOG_H +#define STARTUP_DIALOG_H + +#include +#include +#include +#include + +class StartupDialog : public QDialog +{ + Q_OBJECT + +public: + StartupDialog(QWidget *parent = 0); + +private slots: + void realNameChanged(const QString &); + void emailChanged(const QString &); + void accept(); + +private: + QLineEdit *m_nameEdit; + QLineEdit *m_emailEdit; + QLabel *m_example; + QPushButton *m_ok; + + QString m_name; + QString m_email; + + void updateExample(); +}; + +#endif