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@244
|
8 Copyright (c) 2011 Chris Cannam
|
Chris@244
|
9 Copyright (c) 2011 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@181
|
26 #include <QDir>
|
Chris@181
|
27 #include <QFileDialog>
|
Chris@273
|
28 #include <QMessageBox>
|
Chris@175
|
29
|
Chris@239
|
30 QString
|
Chris@239
|
31 SettingsDialog::m_installPath;
|
Chris@239
|
32
|
Chris@175
|
33 SettingsDialog::SettingsDialog(QWidget *parent) :
|
Chris@230
|
34 QDialog(parent),
|
Chris@230
|
35 m_presentationChanged(false)
|
Chris@175
|
36 {
|
Chris@175
|
37 setModal(true);
|
Chris@175
|
38 setWindowTitle(tr("Settings"));
|
Chris@175
|
39
|
Chris@175
|
40 QGridLayout *mainLayout = new QGridLayout;
|
Chris@175
|
41 setLayout(mainLayout);
|
Chris@175
|
42
|
Chris@230
|
43
|
Chris@230
|
44
|
Chris@181
|
45 QGroupBox *meBox = new QGroupBox(tr("User details"));
|
Chris@175
|
46 mainLayout->addWidget(meBox, 0, 0);
|
Chris@175
|
47 QGridLayout *meLayout = new QGridLayout;
|
Chris@175
|
48 meBox->setLayout(meLayout);
|
Chris@175
|
49
|
Chris@175
|
50 int row = 0;
|
Chris@175
|
51
|
Chris@175
|
52 meLayout->addWidget(new QLabel(tr("Name:")), row, 0);
|
Chris@175
|
53
|
Chris@175
|
54 m_nameEdit = new QLineEdit();
|
Chris@175
|
55 meLayout->addWidget(m_nameEdit, row++, 1);
|
Chris@175
|
56
|
Chris@175
|
57 meLayout->addWidget(new QLabel(tr("Email address:")), row, 0);
|
Chris@175
|
58
|
Chris@175
|
59 m_emailEdit = new QLineEdit();
|
Chris@175
|
60 meLayout->addWidget(m_emailEdit, row++, 1);
|
Chris@175
|
61
|
Chris@230
|
62
|
Chris@230
|
63
|
Chris@230
|
64 QGroupBox *lookBox = new QGroupBox(tr("Presentation"));
|
Chris@230
|
65 mainLayout->addWidget(lookBox, 1, 0);
|
Chris@230
|
66 QGridLayout *lookLayout = new QGridLayout;
|
Chris@230
|
67 lookBox->setLayout(lookLayout);
|
Chris@230
|
68
|
Chris@230
|
69 row = 0;
|
Chris@230
|
70
|
Chris@230
|
71 m_showIconLabels = new QCheckBox(tr("Show labels on toolbar icons"));
|
Chris@273
|
72 lookLayout->addWidget(m_showIconLabels, row++, 0, 1, 2);
|
Chris@230
|
73
|
Chris@230
|
74 m_showExtraText = new QCheckBox(tr("Show long descriptions for file status headings"));
|
Chris@273
|
75 lookLayout->addWidget(m_showExtraText, row++, 0, 1, 2);
|
Chris@273
|
76
|
Chris@273
|
77 #ifdef NOT_IMPLEMENTED_YET
|
Chris@273
|
78 lookLayout->addWidget(new QLabel(tr("Place the work and history views")), row, 0);
|
Chris@273
|
79 m_workHistoryArrangement = new QComboBox();
|
Chris@273
|
80 m_workHistoryArrangement->addItem(tr("In separate tabs"));
|
Chris@273
|
81 m_workHistoryArrangement->addItem(tr("Side-by-side in a single pane"));
|
Chris@273
|
82 lookLayout->addWidget(m_workHistoryArrangement, row++, 1, Qt::AlignLeft);
|
Chris@273
|
83 lookLayout->setColumnStretch(1, 20);
|
Chris@273
|
84 #endif
|
Chris@230
|
85
|
Chris@273
|
86 lookLayout->addWidget(new QLabel(tr("Label the history timeline with")), row, 0);
|
Chris@273
|
87 m_dateFormat = new QComboBox();
|
Chris@273
|
88 m_dateFormat->addItem(tr("Ages, for example \"5 weeks ago\""));
|
Chris@273
|
89 m_dateFormat->addItem(tr("Dates, for example \"2010-06-23\""));
|
Chris@273
|
90 lookLayout->addWidget(m_dateFormat, row++, 1, Qt::AlignLeft);
|
Chris@273
|
91 lookLayout->setColumnStretch(1, 20);
|
Chris@273
|
92
|
Chris@230
|
93
|
Chris@175
|
94 QGroupBox *pathsBox = new QGroupBox(tr("System application locations"));
|
Chris@230
|
95 mainLayout->addWidget(pathsBox, 2, 0);
|
Chris@175
|
96 QGridLayout *pathsLayout = new QGridLayout;
|
Chris@175
|
97 pathsBox->setLayout(pathsLayout);
|
Chris@175
|
98
|
Chris@175
|
99 row = 0;
|
Chris@175
|
100
|
Chris@175
|
101 pathsLayout->addWidget(new QLabel(tr("Mercurial (hg) program:")), row, 0);
|
Chris@175
|
102
|
Chris@195
|
103 m_hgPathLabel = new QLineEdit();
|
Chris@181
|
104 pathsLayout->addWidget(m_hgPathLabel, row, 2);
|
Chris@175
|
105
|
Chris@175
|
106 QPushButton *browse = new QPushButton(tr("Browse..."));
|
Chris@181
|
107 pathsLayout->addWidget(browse, row++, 1);
|
Chris@175
|
108 connect(browse, SIGNAL(clicked()), this, SLOT(hgPathBrowse()));
|
Chris@175
|
109
|
Chris@175
|
110 pathsLayout->addWidget(new QLabel(tr("External diff program:")), row, 0);
|
Chris@175
|
111
|
Chris@195
|
112 m_diffPathLabel = new QLineEdit();
|
Chris@181
|
113 pathsLayout->addWidget(m_diffPathLabel, row, 2);
|
Chris@175
|
114
|
Chris@175
|
115 browse = new QPushButton(tr("Browse..."));
|
Chris@181
|
116 pathsLayout->addWidget(browse, row++, 1);
|
Chris@175
|
117 connect(browse, SIGNAL(clicked()), this, SLOT(diffPathBrowse()));
|
Chris@178
|
118
|
Chris@175
|
119 pathsLayout->addWidget(new QLabel(tr("External file-merge program:")), row, 0);
|
Chris@175
|
120
|
Chris@195
|
121 m_mergePathLabel = new QLineEdit();
|
Chris@181
|
122 pathsLayout->addWidget(m_mergePathLabel, row, 2);
|
Chris@175
|
123
|
Chris@175
|
124 browse = new QPushButton(tr("Browse..."));
|
Chris@181
|
125 pathsLayout->addWidget(browse, row++, 1);
|
Chris@175
|
126 connect(browse, SIGNAL(clicked()), this, SLOT(mergePathBrowse()));
|
Chris@175
|
127
|
chris@406
|
128 pathsLayout->addWidget(new QLabel(tr("SSH program (for ssh URLs):")), row, 0);
|
chris@406
|
129
|
chris@406
|
130 m_sshPathLabel = new QLineEdit();
|
chris@406
|
131 pathsLayout->addWidget(m_sshPathLabel, row, 2);
|
chris@406
|
132
|
chris@406
|
133 browse = new QPushButton(tr("Browse..."));
|
chris@406
|
134 pathsLayout->addWidget(browse, row++, 1);
|
chris@406
|
135 connect(browse, SIGNAL(clicked()), this, SLOT(sshPathBrowse()));
|
chris@406
|
136
|
Chris@178
|
137 pathsLayout->addWidget(new QLabel(tr("External text editor:")), row, 0);
|
Chris@178
|
138
|
Chris@195
|
139 m_editPathLabel = new QLineEdit();
|
Chris@181
|
140 pathsLayout->addWidget(m_editPathLabel, row, 2);
|
Chris@178
|
141
|
Chris@178
|
142 browse = new QPushButton(tr("Browse..."));
|
Chris@181
|
143 pathsLayout->addWidget(browse, row++, 1);
|
Chris@178
|
144 connect(browse, SIGNAL(clicked()), this, SLOT(editPathBrowse()));
|
Chris@178
|
145
|
Chris@176
|
146 pathsLayout->addWidget(new QLabel(tr("EasyHg Mercurial extension:")), row, 0);
|
Chris@176
|
147
|
Chris@195
|
148 m_extensionPathLabel = new QLineEdit();
|
Chris@181
|
149 pathsLayout->addWidget(m_extensionPathLabel, row, 2);
|
Chris@176
|
150
|
Chris@176
|
151 browse = new QPushButton(tr("Browse..."));
|
Chris@181
|
152 pathsLayout->addWidget(browse, row++, 1);
|
Chris@176
|
153 connect(browse, SIGNAL(clicked()), this, SLOT(extensionPathBrowse()));
|
Chris@176
|
154
|
Chris@176
|
155 //!!! more info plz
|
Chris@176
|
156 m_useExtension = new QCheckBox(tr("Use EasyHg Mercurial extension"));
|
Chris@181
|
157 pathsLayout->addWidget(m_useExtension, row++, 2);
|
Chris@176
|
158
|
Chris@176
|
159
|
Chris@239
|
160 reset(); // loads current defaults from settings
|
Chris@175
|
161
|
Chris@230
|
162
|
Chris@175
|
163 QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok);
|
Chris@239
|
164 connect(bbox->addButton(tr("Restore defaults"), QDialogButtonBox::ResetRole),
|
Chris@239
|
165 SIGNAL(clicked()), this, SLOT(restoreDefaults()));
|
Chris@175
|
166 connect(bbox, SIGNAL(accepted()), this, SLOT(accept()));
|
Chris@230
|
167 mainLayout->addWidget(bbox, 3, 0);
|
Chris@175
|
168 m_ok = bbox->button(QDialogButtonBox::Ok);
|
Chris@175
|
169 }
|
Chris@175
|
170
|
Chris@175
|
171 void
|
Chris@175
|
172 SettingsDialog::hgPathBrowse()
|
Chris@175
|
173 {
|
Chris@181
|
174 browseFor(tr("Mercurial program"), m_hgPathLabel);
|
Chris@175
|
175 }
|
Chris@175
|
176
|
Chris@175
|
177 void
|
Chris@175
|
178 SettingsDialog::diffPathBrowse()
|
Chris@175
|
179 {
|
Chris@181
|
180 browseFor(tr("External diff program"), m_diffPathLabel);
|
Chris@175
|
181 }
|
Chris@175
|
182
|
Chris@175
|
183 void
|
Chris@175
|
184 SettingsDialog::mergePathBrowse()
|
Chris@175
|
185 {
|
Chris@181
|
186 browseFor(tr("External file-merge program"), m_mergePathLabel);
|
Chris@175
|
187 }
|
Chris@175
|
188
|
Chris@175
|
189 void
|
chris@406
|
190 SettingsDialog::sshPathBrowse()
|
chris@406
|
191 {
|
chris@406
|
192 browseFor(tr("SSH program"), m_sshPathLabel);
|
chris@406
|
193 }
|
chris@406
|
194
|
chris@406
|
195 void
|
Chris@178
|
196 SettingsDialog::editPathBrowse()
|
Chris@175
|
197 {
|
Chris@181
|
198 browseFor(tr("External text editor"), m_editPathLabel);
|
Chris@176
|
199 }
|
Chris@176
|
200
|
Chris@176
|
201 void
|
Chris@176
|
202 SettingsDialog::extensionPathBrowse()
|
Chris@176
|
203 {
|
Chris@181
|
204 browseFor(tr("EasyHg Mercurial extension"), m_extensionPathLabel);
|
Chris@181
|
205 }
|
Chris@181
|
206
|
Chris@181
|
207 void
|
Chris@195
|
208 SettingsDialog::browseFor(QString title, QLineEdit *edit)
|
Chris@181
|
209 {
|
Chris@181
|
210 QString origin = edit->text();
|
Chris@181
|
211
|
Chris@181
|
212 if (origin == "") {
|
Chris@181
|
213 #ifdef Q_OS_WIN32
|
Chris@181
|
214 origin = "c:";
|
Chris@181
|
215 #else
|
Chris@181
|
216 origin = QDir::homePath();
|
Chris@181
|
217 #endif
|
Chris@181
|
218 }
|
Chris@181
|
219
|
Chris@181
|
220 QString path = QFileDialog::getOpenFileName(this, title, origin);
|
Chris@181
|
221 if (path != QString()) {
|
Chris@181
|
222 edit->setText(path);
|
Chris@181
|
223 }
|
Chris@176
|
224 }
|
Chris@176
|
225
|
Chris@176
|
226 void
|
Chris@239
|
227 SettingsDialog::restoreDefaults()
|
Chris@239
|
228 {
|
Chris@273
|
229 if (QMessageBox::question
|
Chris@273
|
230 (this, tr("Restore default settings?"),
|
Chris@273
|
231 tr("<qt><b>Restore default settings?</b><br><br>Are you sure you want to reset all settings to their default values?"),
|
Chris@273
|
232 QMessageBox::Ok | QMessageBox::Cancel,
|
Chris@273
|
233 QMessageBox::Cancel) == QMessageBox::Ok) {
|
Chris@273
|
234 clear();
|
Chris@273
|
235 findDefaultLocations();
|
Chris@273
|
236 reset();
|
Chris@273
|
237 }
|
Chris@239
|
238 }
|
Chris@239
|
239
|
Chris@239
|
240 void
|
Chris@239
|
241 SettingsDialog::findDefaultLocations(QString installPath)
|
Chris@239
|
242 {
|
Chris@239
|
243 m_installPath = installPath;
|
Chris@239
|
244 findHgBinaryName();
|
Chris@239
|
245 findExtension();
|
Chris@239
|
246 findDiffBinaryName();
|
Chris@239
|
247 findMergeBinaryName();
|
chris@406
|
248 findSshBinaryName();
|
Chris@239
|
249 findEditorBinaryName();
|
Chris@239
|
250 }
|
Chris@239
|
251
|
Chris@239
|
252 void
|
Chris@239
|
253 SettingsDialog::findHgBinaryName()
|
Chris@239
|
254 {
|
Chris@239
|
255 QSettings settings;
|
Chris@239
|
256 settings.beginGroup("Locations");
|
Chris@239
|
257 QString hg = settings.value("hgbinary", "").toString();
|
Chris@239
|
258 if (hg == "") {
|
Chris@239
|
259 hg = findInPath("hg", m_installPath, true);
|
Chris@239
|
260 }
|
Chris@239
|
261 if (hg != "") {
|
Chris@239
|
262 settings.setValue("hgbinary", hg);
|
Chris@239
|
263 }
|
Chris@239
|
264 }
|
Chris@239
|
265
|
Chris@240
|
266 QString
|
Chris@240
|
267 SettingsDialog::getUnbundledExtensionFileName()
|
Chris@240
|
268 {
|
Chris@240
|
269 QString home = QDir::homePath();
|
Chris@240
|
270 QString target = QString("%1/.easyhg").arg(home);
|
Chris@240
|
271 QString extpath = QString("%1/easyhg.py").arg(target);
|
Chris@240
|
272 return extpath;
|
Chris@240
|
273 }
|
Chris@240
|
274
|
Chris@239
|
275 void
|
Chris@239
|
276 SettingsDialog::findExtension()
|
Chris@239
|
277 {
|
Chris@239
|
278 QSettings settings;
|
Chris@239
|
279 settings.beginGroup("Locations");
|
Chris@239
|
280
|
Chris@239
|
281 QString extpath = settings.value("extensionpath", "").toString();
|
Chris@239
|
282 if (extpath != "" || !QFile(extpath).exists()) {
|
Chris@239
|
283
|
Chris@240
|
284 extpath = getUnbundledExtensionFileName();
|
Chris@239
|
285
|
Chris@239
|
286 if (!QFile(extpath).exists()) {
|
Chris@239
|
287 extpath = findInPath("easyhg.py", m_installPath, false);
|
Chris@239
|
288 }
|
Chris@239
|
289 }
|
Chris@239
|
290
|
Chris@239
|
291 settings.setValue("extensionpath", extpath);
|
Chris@239
|
292 }
|
Chris@239
|
293
|
Chris@239
|
294 void
|
Chris@239
|
295 SettingsDialog::findDiffBinaryName()
|
Chris@239
|
296 {
|
Chris@239
|
297 QSettings settings;
|
Chris@239
|
298 settings.beginGroup("Locations");
|
Chris@239
|
299 QString diff = settings.value("extdiffbinary", "").toString();
|
Chris@239
|
300 if (diff == "") {
|
Chris@239
|
301 QStringList bases;
|
Chris@272
|
302 #ifdef Q_OS_WIN32
|
Chris@272
|
303 bases << "easyhg-extdiff.bat";
|
Chris@272
|
304 #else
|
Chris@269
|
305 bases << "easyhg-extdiff.sh";
|
Chris@272
|
306 #endif
|
Chris@239
|
307 bases << "kompare" << "kdiff3" << "meld";
|
Chris@239
|
308 bool found = false;
|
Chris@239
|
309 foreach (QString base, bases) {
|
Chris@239
|
310 diff = findInPath(base, m_installPath, true);
|
Chris@239
|
311 if (diff != "") {
|
Chris@239
|
312 found = true;
|
Chris@239
|
313 break;
|
Chris@239
|
314 }
|
Chris@239
|
315 }
|
Chris@239
|
316 if (found) {
|
Chris@239
|
317 settings.setValue("extdiffbinary", diff);
|
Chris@239
|
318 }
|
Chris@239
|
319 }
|
Chris@239
|
320 }
|
Chris@239
|
321
|
Chris@239
|
322 void
|
Chris@239
|
323 SettingsDialog::findMergeBinaryName()
|
Chris@239
|
324 {
|
Chris@239
|
325 QSettings settings;
|
Chris@239
|
326 settings.beginGroup("Locations");
|
Chris@239
|
327 if (settings.contains("mergebinary")) {
|
Chris@239
|
328 return;
|
Chris@239
|
329 }
|
Chris@239
|
330 QString merge;
|
Chris@239
|
331 QStringList bases;
|
Chris@272
|
332 #ifdef Q_OS_WIN32
|
Chris@272
|
333 bases << "easyhg-merge.bat";
|
Chris@272
|
334 #else
|
Chris@269
|
335 bases << "easyhg-merge.sh";
|
Chris@272
|
336 #endif
|
Chris@269
|
337 // NB it's not a good idea to add other tools here, as command
|
Chris@269
|
338 // line argument ordering varies. Configure them through hgrc
|
Chris@269
|
339 // instead
|
Chris@239
|
340 bool found = false;
|
Chris@239
|
341 foreach (QString base, bases) {
|
Chris@239
|
342 merge = findInPath(base, m_installPath, true);
|
Chris@239
|
343 if (merge != "") {
|
Chris@239
|
344 found = true;
|
Chris@239
|
345 break;
|
Chris@239
|
346 }
|
Chris@239
|
347 }
|
Chris@239
|
348 if (found) {
|
Chris@239
|
349 settings.setValue("mergebinary", merge);
|
Chris@239
|
350 }
|
Chris@239
|
351 }
|
Chris@239
|
352
|
Chris@239
|
353 void
|
chris@406
|
354 SettingsDialog::findSshBinaryName()
|
chris@406
|
355 {
|
chris@406
|
356 QSettings settings;
|
chris@406
|
357 settings.beginGroup("Locations");
|
chris@406
|
358 if (settings.contains("sshbinary")) {
|
chris@406
|
359 return;
|
chris@406
|
360 }
|
chris@406
|
361 QString ssh;
|
chris@406
|
362 QStringList bases;
|
chris@406
|
363 #ifdef Q_OS_WIN32
|
chris@406
|
364 bases << "TortoisePlink.exe";
|
chris@406
|
365 #else
|
chris@406
|
366 bases << "ssh";
|
chris@406
|
367 #endif
|
chris@406
|
368 bool found = false;
|
chris@406
|
369 foreach (QString base, bases) {
|
chris@406
|
370 ssh = findInPath(base, m_installPath, true);
|
chris@406
|
371 if (ssh != "") {
|
chris@406
|
372 found = true;
|
chris@406
|
373 break;
|
chris@406
|
374 }
|
chris@406
|
375 }
|
chris@406
|
376 if (found) {
|
chris@406
|
377 settings.setValue("sshbinary", ssh);
|
chris@406
|
378 }
|
chris@406
|
379 }
|
chris@406
|
380
|
chris@406
|
381 void
|
Chris@239
|
382 SettingsDialog::findEditorBinaryName()
|
Chris@239
|
383 {
|
Chris@239
|
384 QSettings settings;
|
Chris@239
|
385 settings.beginGroup("Locations");
|
Chris@239
|
386 QString editor = settings.value("editorbinary", "").toString();
|
Chris@239
|
387 if (editor == "") {
|
Chris@239
|
388 QStringList bases;
|
Chris@239
|
389 bases
|
Chris@239
|
390 #if defined Q_OS_WIN32
|
Chris@239
|
391 << "wordpad.exe"
|
Chris@239
|
392 << "C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe"
|
Chris@239
|
393 << "notepad.exe"
|
Chris@239
|
394 #elif defined Q_OS_MAC
|
Chris@239
|
395 << "/Applications/TextEdit.app/Contents/MacOS/TextEdit"
|
Chris@239
|
396 #else
|
Chris@239
|
397 << "gedit" << "kate"
|
Chris@239
|
398 #endif
|
Chris@239
|
399 ;
|
Chris@239
|
400 bool found = false;
|
Chris@239
|
401 foreach (QString base, bases) {
|
Chris@239
|
402 editor = findInPath(base, m_installPath, true);
|
Chris@239
|
403 if (editor != "") {
|
Chris@239
|
404 found = true;
|
Chris@239
|
405 break;
|
Chris@239
|
406 }
|
Chris@239
|
407 }
|
Chris@239
|
408 if (found) {
|
Chris@239
|
409 settings.setValue("editorbinary", editor);
|
Chris@239
|
410 }
|
Chris@239
|
411 }
|
Chris@239
|
412 }
|
Chris@239
|
413
|
Chris@239
|
414 void
|
Chris@239
|
415 SettingsDialog::clear()
|
Chris@239
|
416 {
|
Chris@239
|
417 // Clear everything that has a default setting
|
Chris@239
|
418 DEBUG << "SettingsDialog::clear" << endl;
|
Chris@239
|
419 QSettings settings;
|
Chris@239
|
420 settings.beginGroup("Presentation");
|
Chris@239
|
421 settings.remove("showiconlabels");
|
Chris@239
|
422 settings.remove("showhelpfultext");
|
Chris@239
|
423 settings.endGroup();
|
Chris@239
|
424 settings.beginGroup("Locations");
|
Chris@239
|
425 settings.remove("hgbinary");
|
Chris@239
|
426 settings.remove("extdiffbinary");
|
Chris@239
|
427 settings.remove("mergebinary");
|
chris@406
|
428 settings.remove("sshbinary");
|
Chris@239
|
429 settings.remove("editorbinary");
|
Chris@239
|
430 settings.remove("extensionpath");
|
Chris@239
|
431 settings.endGroup();
|
Chris@239
|
432 settings.beginGroup("General");
|
Chris@239
|
433 settings.remove("useextension");
|
Chris@239
|
434 settings.endGroup();
|
Chris@239
|
435 }
|
Chris@239
|
436
|
Chris@239
|
437 void
|
Chris@239
|
438 SettingsDialog::reset()
|
Chris@239
|
439 {
|
Chris@239
|
440 DEBUG << "SettingsDialog::reset" << endl;
|
Chris@239
|
441 QSettings settings;
|
Chris@239
|
442 settings.beginGroup("User Information");
|
Chris@239
|
443 m_nameEdit->setText(settings.value("name", getUserRealName()).toString());
|
Chris@239
|
444 m_emailEdit->setText(settings.value("email").toString());
|
Chris@239
|
445 settings.endGroup();
|
Chris@239
|
446 settings.beginGroup("Presentation");
|
Chris@239
|
447 m_showIconLabels->setChecked(settings.value("showiconlabels", true).toBool());
|
Chris@239
|
448 m_showExtraText->setChecked(settings.value("showhelpfultext", true).toBool());
|
Chris@273
|
449 #ifdef NOT_IMPLEMENTED_YET
|
Chris@273
|
450 m_workHistoryArrangement->setCurrentIndex(settings.value("workhistoryarrangement", 0).toInt());
|
Chris@273
|
451 #endif
|
Chris@273
|
452 m_dateFormat->setCurrentIndex(settings.value("dateformat", 0).toInt());
|
Chris@239
|
453 settings.endGroup();
|
Chris@239
|
454 settings.beginGroup("Locations");
|
Chris@239
|
455 m_hgPathLabel->setText(settings.value("hgbinary").toString());
|
Chris@239
|
456 m_diffPathLabel->setText(settings.value("extdiffbinary").toString());
|
Chris@239
|
457 m_mergePathLabel->setText(settings.value("mergebinary").toString());
|
chris@406
|
458 m_sshPathLabel->setText(settings.value("sshbinary").toString());
|
Chris@239
|
459 m_editPathLabel->setText(settings.value("editorbinary").toString());
|
Chris@239
|
460 m_extensionPathLabel->setText(settings.value("extensionpath").toString());
|
Chris@239
|
461 settings.endGroup();
|
Chris@239
|
462 settings.beginGroup("General");
|
Chris@239
|
463 m_useExtension->setChecked(settings.value("useextension", true).toBool());
|
Chris@239
|
464 settings.endGroup();
|
Chris@239
|
465 }
|
Chris@239
|
466
|
Chris@239
|
467 void
|
Chris@175
|
468 SettingsDialog::accept()
|
Chris@175
|
469 {
|
Chris@177
|
470 DEBUG << "SettingsDialog::accept" << endl;
|
Chris@175
|
471 QSettings settings;
|
Chris@175
|
472 settings.beginGroup("User Information");
|
Chris@175
|
473 settings.setValue("name", m_nameEdit->text());
|
Chris@175
|
474 settings.setValue("email", m_emailEdit->text());
|
Chris@175
|
475 settings.endGroup();
|
Chris@230
|
476 settings.beginGroup("Presentation");
|
Chris@230
|
477 bool b;
|
Chris@230
|
478 b = m_showIconLabels->isChecked();
|
Chris@230
|
479 if (b != settings.value("showiconlabels", true)) {
|
Chris@230
|
480 settings.setValue("showiconlabels", b);
|
Chris@230
|
481 m_presentationChanged = true;
|
Chris@230
|
482 }
|
Chris@230
|
483 b = m_showExtraText->isChecked();
|
Chris@230
|
484 if (b != settings.value("showhelpfultext", true)) {
|
Chris@230
|
485 settings.setValue("showhelpfultext", b);
|
Chris@230
|
486 m_presentationChanged = true;
|
Chris@230
|
487 }
|
Chris@273
|
488 int i;
|
Chris@273
|
489 #ifdef NOT_IMPLEMENTED_YET
|
Chris@273
|
490 i = m_workHistoryArrangement->currentIndex();
|
Chris@273
|
491 if (i != settings.value("workhistoryarrangement", 0)) {
|
Chris@273
|
492 settings.setValue("workhistoryarrangement", i);
|
Chris@273
|
493 m_presentationChanged = true;
|
Chris@273
|
494 }
|
Chris@273
|
495 #endif
|
Chris@273
|
496 i = m_dateFormat->currentIndex();
|
Chris@273
|
497 if (i != settings.value("dateformat", 0)) {
|
Chris@273
|
498 settings.setValue("dateformat", i);
|
Chris@273
|
499 m_presentationChanged = true;
|
Chris@273
|
500 }
|
Chris@230
|
501 settings.endGroup();
|
Chris@175
|
502 settings.beginGroup("Locations");
|
Chris@181
|
503 settings.setValue("hgbinary", m_hgPathLabel->text());
|
Chris@181
|
504 settings.setValue("extdiffbinary", m_diffPathLabel->text());
|
Chris@181
|
505 settings.setValue("mergebinary", m_mergePathLabel->text());
|
chris@406
|
506 settings.setValue("sshbinary", m_sshPathLabel->text());
|
Chris@221
|
507 settings.setValue("editorbinary", m_editPathLabel->text());
|
Chris@181
|
508 settings.setValue("extensionpath", m_extensionPathLabel->text());
|
Chris@176
|
509 settings.endGroup();
|
Chris@176
|
510 settings.beginGroup("General");
|
Chris@176
|
511 settings.setValue("useextension", m_useExtension->isChecked());
|
Chris@175
|
512 settings.endGroup();
|
Chris@175
|
513 QDialog::accept();
|
Chris@175
|
514 }
|
Chris@175
|
515
|
Chris@175
|
516
|