Mercurial > hg > easyhg
comparison startupdialog.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 | |
children | 121cb1032717 |
comparison
equal
deleted
inserted
replaced
63:2340b00561d2 | 64:794db9353c7f |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 EasyMercurial | |
5 | |
6 Based on HgExplorer by Jari Korhonen | |
7 Copyright (c) 2010 Jari Korhonen | |
8 Copyright (c) 2010 Chris Cannam | |
9 Copyright (c) 2010 Queen Mary, University of London | |
10 | |
11 This program is free software; you can redistribute it and/or | |
12 modify it under the terms of the GNU General Public License as | |
13 published by the Free Software Foundation; either version 2 of the | |
14 License, or (at your option) any later version. See the file | |
15 COPYING included with this distribution for more information. | |
16 */ | |
17 | |
18 #include "startupdialog.h" | |
19 #include "common.h" | |
20 | |
21 #include <QGridLayout> | |
22 #include <QDialogButtonBox> | |
23 #include <QSettings> | |
24 | |
25 StartupDialog::StartupDialog(QWidget *parent) : | |
26 QDialog(parent) | |
27 { | |
28 setModal(true); | |
29 setWindowTitle(tr("About me")); | |
30 | |
31 QSettings settings; | |
32 settings.beginGroup("User Information"); | |
33 m_name = settings.value("name", getUserRealName()).toString(); | |
34 m_email = settings.value("email").toString(); | |
35 | |
36 QGridLayout *layout = new QGridLayout; | |
37 int row = 0; | |
38 | |
39 layout->addWidget(new QLabel(tr("<qt><big><bold>Welcome to EasyMercurial!</qt></bold></big><br>How would you like to be identified in commit messages?")), | |
40 row++, 0, 1, 2); | |
41 | |
42 layout->addWidget(new QLabel(tr("Name:")), row, 0); | |
43 | |
44 m_nameEdit = new QLineEdit(); | |
45 m_nameEdit->setText(m_name); | |
46 connect(m_nameEdit, SIGNAL(textChanged(const QString &)), | |
47 this, SLOT(realNameChanged(const QString &))); | |
48 layout->addWidget(m_nameEdit, row++, 1); | |
49 | |
50 layout->addWidget(new QLabel(tr("Email address:")), row, 0); | |
51 | |
52 m_emailEdit = new QLineEdit(); | |
53 m_emailEdit->setText(m_email); | |
54 connect(m_emailEdit, SIGNAL(textChanged(const QString &)), | |
55 this, SLOT(emailChanged(const QString &))); | |
56 layout->addWidget(m_emailEdit, row++, 1); | |
57 | |
58 layout->addWidget(new QLabel(tr("<br>You will appear as:")), row, 0, Qt::AlignBottom); | |
59 m_example = new QLabel(); | |
60 layout->addWidget(m_example, row++, 1, Qt::AlignBottom); | |
61 | |
62 QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok); | |
63 connect(bbox, SIGNAL(accepted()), this, SLOT(accept())); | |
64 layout->addWidget(bbox, row++, 0, 1, 2); | |
65 m_ok = bbox->button(QDialogButtonBox::Ok); | |
66 m_ok->setEnabled(false); | |
67 | |
68 setLayout(layout); | |
69 | |
70 m_ok->setEnabled(m_name != ""); | |
71 updateExample(); | |
72 } | |
73 | |
74 void | |
75 StartupDialog::realNameChanged(const QString &s) | |
76 { | |
77 m_name = s.trimmed(); | |
78 m_ok->setEnabled(m_name != ""); | |
79 updateExample(); | |
80 } | |
81 | |
82 void | |
83 StartupDialog::emailChanged(const QString &s) | |
84 { | |
85 m_email = s.trimmed(); | |
86 updateExample(); | |
87 } | |
88 | |
89 void | |
90 StartupDialog::accept() | |
91 { | |
92 QSettings settings; | |
93 settings.beginGroup("User Information"); | |
94 settings.setValue("name", m_name); | |
95 settings.setValue("email", m_email); | |
96 QDialog::accept(); | |
97 } | |
98 | |
99 void | |
100 StartupDialog::updateExample() | |
101 { | |
102 QString identifier; | |
103 | |
104 if (m_email != "") { | |
105 identifier = QString("%1 <%2>").arg(m_name).arg(m_email); | |
106 } else { | |
107 identifier = m_name; | |
108 } | |
109 | |
110 m_example->setText(identifier); | |
111 } | |
112 | |
113 |