Chris@175
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@175
|
2
|
Chris@175
|
3 /*
|
Chris@175
|
4 EasyMercurial
|
Chris@175
|
5
|
Chris@175
|
6 Based on HgExplorer by Jari Korhonen
|
Chris@175
|
7 Copyright (c) 2010 Jari Korhonen
|
Chris@175
|
8 Copyright (c) 2010 Chris Cannam
|
Chris@175
|
9 Copyright (c) 2010 Queen Mary, University of London
|
Chris@175
|
10
|
Chris@175
|
11 This program is free software; you can redistribute it and/or
|
Chris@175
|
12 modify it under the terms of the GNU General Public License as
|
Chris@175
|
13 published by the Free Software Foundation; either version 2 of the
|
Chris@175
|
14 License, or (at your option) any later version. See the file
|
Chris@175
|
15 COPYING included with this distribution for more information.
|
Chris@175
|
16 */
|
Chris@175
|
17
|
Chris@175
|
18 #include "settingsdialog.h"
|
Chris@175
|
19 #include "common.h"
|
Chris@177
|
20 #include "debug.h"
|
Chris@175
|
21
|
Chris@175
|
22 #include <QGridLayout>
|
Chris@175
|
23 #include <QGroupBox>
|
Chris@175
|
24 #include <QDialogButtonBox>
|
Chris@175
|
25 #include <QSettings>
|
Chris@175
|
26
|
Chris@175
|
27 SettingsDialog::SettingsDialog(QWidget *parent) :
|
Chris@175
|
28 QDialog(parent)
|
Chris@175
|
29 {
|
Chris@175
|
30 setModal(true);
|
Chris@175
|
31 setWindowTitle(tr("Settings"));
|
Chris@175
|
32
|
Chris@175
|
33 QSettings settings;
|
Chris@175
|
34
|
Chris@175
|
35 QGridLayout *mainLayout = new QGridLayout;
|
Chris@175
|
36 setLayout(mainLayout);
|
Chris@175
|
37
|
Chris@175
|
38 QGroupBox *meBox = new QGroupBox(tr("About me"));
|
Chris@175
|
39 mainLayout->addWidget(meBox, 0, 0);
|
Chris@175
|
40 QGridLayout *meLayout = new QGridLayout;
|
Chris@175
|
41 meBox->setLayout(meLayout);
|
Chris@175
|
42
|
Chris@175
|
43 settings.beginGroup("User Information");
|
Chris@175
|
44
|
Chris@175
|
45 int row = 0;
|
Chris@175
|
46
|
Chris@175
|
47 meLayout->addWidget(new QLabel(tr("Name:")), row, 0);
|
Chris@175
|
48
|
Chris@175
|
49 m_nameEdit = new QLineEdit();
|
Chris@175
|
50 m_nameEdit->setText(settings.value("name", getUserRealName()).toString());
|
Chris@175
|
51 connect(m_nameEdit, SIGNAL(textChanged(const QString &)),
|
Chris@175
|
52 this, SLOT(realNameChanged(const QString &)));
|
Chris@175
|
53 meLayout->addWidget(m_nameEdit, row++, 1);
|
Chris@175
|
54
|
Chris@175
|
55 meLayout->addWidget(new QLabel(tr("Email address:")), row, 0);
|
Chris@175
|
56
|
Chris@175
|
57 m_emailEdit = new QLineEdit();
|
Chris@175
|
58 m_emailEdit->setText(settings.value("email").toString());
|
Chris@175
|
59 connect(m_emailEdit, SIGNAL(textChanged(const QString &)),
|
Chris@175
|
60 this, SLOT(emailChanged(const QString &)));
|
Chris@175
|
61 meLayout->addWidget(m_emailEdit, row++, 1);
|
Chris@175
|
62
|
Chris@175
|
63 settings.endGroup();
|
Chris@175
|
64
|
Chris@175
|
65 QGroupBox *pathsBox = new QGroupBox(tr("System application locations"));
|
Chris@175
|
66 mainLayout->addWidget(pathsBox, 1, 0);
|
Chris@175
|
67 QGridLayout *pathsLayout = new QGridLayout;
|
Chris@175
|
68 pathsBox->setLayout(pathsLayout);
|
Chris@175
|
69
|
Chris@175
|
70 settings.beginGroup("Locations");
|
Chris@175
|
71
|
Chris@175
|
72 row = 0;
|
Chris@175
|
73
|
Chris@175
|
74 pathsLayout->addWidget(new QLabel(tr("Mercurial (hg) program:")), row, 0);
|
Chris@175
|
75
|
Chris@175
|
76 m_hgPathEdit = new QLineEdit();
|
Chris@175
|
77 m_hgPathEdit->setText(settings.value("hgbinary").toString());
|
Chris@175
|
78 connect(m_hgPathEdit, SIGNAL(textChanged(const QString &)),
|
Chris@175
|
79 this, SLOT(hgPathChanged(const QString &)));
|
Chris@175
|
80 pathsLayout->addWidget(m_hgPathEdit, row, 1);
|
Chris@175
|
81
|
Chris@175
|
82 QPushButton *browse = new QPushButton(tr("Browse..."));
|
Chris@175
|
83 pathsLayout->addWidget(browse, row++, 2);
|
Chris@175
|
84 connect(browse, SIGNAL(clicked()), this, SLOT(hgPathBrowse()));
|
Chris@175
|
85
|
Chris@175
|
86 pathsLayout->addWidget(new QLabel(tr("External diff program:")), row, 0);
|
Chris@175
|
87
|
Chris@175
|
88 m_diffPathEdit = new QLineEdit();
|
Chris@175
|
89 m_diffPathEdit->setText(settings.value("extdiffbinary").toString());
|
Chris@175
|
90 connect(m_diffPathEdit, SIGNAL(textChanged(const QString &)),
|
Chris@175
|
91 this, SLOT(diffPathChanged(const QString &)));
|
Chris@175
|
92 pathsLayout->addWidget(m_diffPathEdit, row, 1);
|
Chris@175
|
93
|
Chris@175
|
94 browse = new QPushButton(tr("Browse..."));
|
Chris@175
|
95 pathsLayout->addWidget(browse, row++, 2);
|
Chris@175
|
96 connect(browse, SIGNAL(clicked()), this, SLOT(diffPathBrowse()));
|
Chris@178
|
97
|
Chris@175
|
98 pathsLayout->addWidget(new QLabel(tr("External file-merge program:")), row, 0);
|
Chris@175
|
99
|
Chris@175
|
100 m_mergePathEdit = new QLineEdit();
|
Chris@175
|
101 m_mergePathEdit->setText(settings.value("mergebinary").toString());
|
Chris@175
|
102 connect(m_mergePathEdit, SIGNAL(textChanged(const QString &)),
|
Chris@175
|
103 this, SLOT(mergePathChanged(const QString &)));
|
Chris@175
|
104 pathsLayout->addWidget(m_mergePathEdit, row, 1);
|
Chris@175
|
105
|
Chris@175
|
106 browse = new QPushButton(tr("Browse..."));
|
Chris@175
|
107 pathsLayout->addWidget(browse, row++, 2);
|
Chris@175
|
108 connect(browse, SIGNAL(clicked()), this, SLOT(mergePathBrowse()));
|
Chris@175
|
109
|
Chris@178
|
110 pathsLayout->addWidget(new QLabel(tr("External text editor:")), row, 0);
|
Chris@178
|
111
|
Chris@178
|
112 m_editPathEdit = new QLineEdit();
|
Chris@178
|
113 m_editPathEdit->setText(settings.value("editorbinary").toString());
|
Chris@178
|
114 connect(m_editPathEdit, SIGNAL(textChanged(const QString &)),
|
Chris@178
|
115 this, SLOT(editPathChanged(const QString &)));
|
Chris@178
|
116 pathsLayout->addWidget(m_editPathEdit, row, 1);
|
Chris@178
|
117
|
Chris@178
|
118 browse = new QPushButton(tr("Browse..."));
|
Chris@178
|
119 pathsLayout->addWidget(browse, row++, 2);
|
Chris@178
|
120 connect(browse, SIGNAL(clicked()), this, SLOT(editPathBrowse()));
|
Chris@178
|
121
|
Chris@175
|
122 settings.endGroup();
|
Chris@176
|
123
|
Chris@176
|
124 settings.beginGroup("Locations");
|
Chris@176
|
125
|
Chris@176
|
126 pathsLayout->addWidget(new QLabel(tr("EasyHg Mercurial extension:")), row, 0);
|
Chris@176
|
127
|
Chris@176
|
128 m_extensionPathEdit = new QLineEdit();
|
Chris@176
|
129 m_extensionPathEdit->setText(settings.value("extensionpath").toString());
|
Chris@176
|
130 connect(m_extensionPathEdit, SIGNAL(textChanged(const QString &)),
|
Chris@176
|
131 this, SLOT(extensionPathChanged(const QString &)));
|
Chris@176
|
132 pathsLayout->addWidget(m_extensionPathEdit, row, 1);
|
Chris@176
|
133
|
Chris@176
|
134 browse = new QPushButton(tr("Browse..."));
|
Chris@176
|
135 pathsLayout->addWidget(browse, row++, 2);
|
Chris@176
|
136 connect(browse, SIGNAL(clicked()), this, SLOT(extensionPathBrowse()));
|
Chris@176
|
137
|
Chris@176
|
138 settings.endGroup();
|
Chris@176
|
139
|
Chris@176
|
140 settings.beginGroup("General");
|
Chris@176
|
141
|
Chris@176
|
142 //!!! more info plz
|
Chris@176
|
143 m_useExtension = new QCheckBox(tr("Use EasyHg Mercurial extension"));
|
Chris@176
|
144 m_useExtension->setChecked(settings.value("useextension", true).toBool());
|
Chris@176
|
145 pathsLayout->addWidget(m_useExtension, row++, 1);
|
Chris@176
|
146
|
Chris@176
|
147 settings.endGroup();
|
Chris@176
|
148
|
Chris@175
|
149
|
Chris@175
|
150 QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok);
|
Chris@175
|
151 connect(bbox, SIGNAL(accepted()), this, SLOT(accept()));
|
Chris@175
|
152 mainLayout->addWidget(bbox, 2, 0);
|
Chris@175
|
153 m_ok = bbox->button(QDialogButtonBox::Ok);
|
Chris@175
|
154 // m_ok->setEnabled(false);
|
Chris@175
|
155
|
Chris@175
|
156 //!!! m_ok->setEnabled(m_name != "");
|
Chris@175
|
157 // updateExample();
|
Chris@175
|
158 }
|
Chris@175
|
159
|
Chris@175
|
160 void
|
Chris@175
|
161 SettingsDialog::realNameChanged(const QString &s)
|
Chris@175
|
162 {
|
Chris@175
|
163 }
|
Chris@175
|
164
|
Chris@175
|
165 void
|
Chris@175
|
166 SettingsDialog::emailChanged(const QString &s)
|
Chris@175
|
167 {
|
Chris@175
|
168 }
|
Chris@175
|
169
|
Chris@175
|
170 void
|
Chris@175
|
171 SettingsDialog::hgPathChanged(const QString &s)
|
Chris@175
|
172 {
|
Chris@175
|
173 }
|
Chris@175
|
174
|
Chris@175
|
175 void
|
Chris@175
|
176 SettingsDialog::hgPathBrowse()
|
Chris@175
|
177 {
|
Chris@175
|
178 }
|
Chris@175
|
179
|
Chris@175
|
180 void
|
Chris@175
|
181 SettingsDialog::diffPathChanged(const QString &s)
|
Chris@175
|
182 {
|
Chris@175
|
183 }
|
Chris@175
|
184
|
Chris@175
|
185 void
|
Chris@175
|
186 SettingsDialog::diffPathBrowse()
|
Chris@175
|
187 {
|
Chris@175
|
188 }
|
Chris@175
|
189
|
Chris@175
|
190 void
|
Chris@175
|
191 SettingsDialog::mergePathChanged(const QString &s)
|
Chris@175
|
192 {
|
Chris@175
|
193 }
|
Chris@175
|
194
|
Chris@175
|
195 void
|
Chris@175
|
196 SettingsDialog::mergePathBrowse()
|
Chris@175
|
197 {
|
Chris@175
|
198 }
|
Chris@175
|
199
|
Chris@175
|
200 void
|
Chris@178
|
201 SettingsDialog::editPathChanged(const QString &s)
|
Chris@175
|
202 {
|
Chris@175
|
203 }
|
Chris@175
|
204
|
Chris@175
|
205 void
|
Chris@178
|
206 SettingsDialog::editPathBrowse()
|
Chris@175
|
207 {
|
Chris@175
|
208 }
|
Chris@175
|
209
|
Chris@175
|
210 void
|
Chris@176
|
211 SettingsDialog::extensionPathChanged(const QString &s)
|
Chris@176
|
212 {
|
Chris@176
|
213 }
|
Chris@176
|
214
|
Chris@176
|
215 void
|
Chris@176
|
216 SettingsDialog::extensionPathBrowse()
|
Chris@176
|
217 {
|
Chris@176
|
218 }
|
Chris@176
|
219
|
Chris@176
|
220 void
|
Chris@175
|
221 SettingsDialog::accept()
|
Chris@175
|
222 {
|
Chris@177
|
223 DEBUG << "SettingsDialog::accept" << endl;
|
Chris@175
|
224 QSettings settings;
|
Chris@175
|
225 settings.beginGroup("User Information");
|
Chris@175
|
226 settings.setValue("name", m_nameEdit->text());
|
Chris@175
|
227 settings.setValue("email", m_emailEdit->text());
|
Chris@175
|
228 settings.endGroup();
|
Chris@175
|
229 settings.beginGroup("Locations");
|
Chris@175
|
230 settings.setValue("hgbinary", m_hgPathEdit->text());
|
Chris@175
|
231 settings.setValue("extdiffbinary", m_diffPathEdit->text());
|
Chris@175
|
232 settings.setValue("mergebinary", m_mergePathEdit->text());
|
Chris@176
|
233 settings.setValue("extensionpath", m_extensionPathEdit->text());
|
Chris@176
|
234 settings.endGroup();
|
Chris@176
|
235 settings.beginGroup("General");
|
Chris@176
|
236 settings.setValue("useextension", m_useExtension->isChecked());
|
Chris@175
|
237 settings.endGroup();
|
Chris@175
|
238 QDialog::accept();
|
Chris@175
|
239 }
|
Chris@175
|
240
|
Chris@175
|
241
|