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@465
|
300 if (diff != "" && QFile(diff).exists()) {
|
Chris@465
|
301 return;
|
Chris@465
|
302 }
|
Chris@465
|
303 QStringList bases;
|
Chris@272
|
304 #ifdef Q_OS_WIN32
|
Chris@465
|
305 bases << "easyhg-extdiff.bat";
|
Chris@272
|
306 #else
|
Chris@465
|
307 bases << "easyhg-extdiff.sh";
|
Chris@272
|
308 #endif
|
Chris@465
|
309 bases << "kompare" << "kdiff3" << "meld";
|
Chris@465
|
310 bool found = false;
|
Chris@465
|
311 foreach (QString base, bases) {
|
Chris@465
|
312 diff = findInPath(base, m_installPath, true);
|
Chris@465
|
313 if (diff != "") {
|
Chris@465
|
314 found = true;
|
Chris@465
|
315 break;
|
Chris@239
|
316 }
|
Chris@465
|
317 }
|
Chris@465
|
318 if (found) {
|
Chris@465
|
319 settings.setValue("extdiffbinary", diff);
|
Chris@239
|
320 }
|
Chris@239
|
321 }
|
Chris@239
|
322
|
Chris@239
|
323 void
|
Chris@239
|
324 SettingsDialog::findMergeBinaryName()
|
Chris@239
|
325 {
|
Chris@239
|
326 QSettings settings;
|
Chris@239
|
327 settings.beginGroup("Locations");
|
Chris@465
|
328 QString merge = settings.value("mergebinary", "").toString();
|
Chris@465
|
329 if (merge != "" && QFile(merge).exists()) {
|
Chris@239
|
330 return;
|
Chris@239
|
331 }
|
Chris@239
|
332 QStringList bases;
|
Chris@272
|
333 #ifdef Q_OS_WIN32
|
Chris@272
|
334 bases << "easyhg-merge.bat";
|
Chris@272
|
335 #else
|
Chris@269
|
336 bases << "easyhg-merge.sh";
|
Chris@272
|
337 #endif
|
Chris@269
|
338 // NB it's not a good idea to add other tools here, as command
|
Chris@269
|
339 // line argument ordering varies. Configure them through hgrc
|
Chris@269
|
340 // instead
|
Chris@239
|
341 bool found = false;
|
Chris@239
|
342 foreach (QString base, bases) {
|
Chris@239
|
343 merge = findInPath(base, m_installPath, true);
|
Chris@239
|
344 if (merge != "") {
|
Chris@239
|
345 found = true;
|
Chris@239
|
346 break;
|
Chris@239
|
347 }
|
Chris@239
|
348 }
|
Chris@239
|
349 if (found) {
|
Chris@239
|
350 settings.setValue("mergebinary", merge);
|
Chris@239
|
351 }
|
Chris@239
|
352 }
|
Chris@239
|
353
|
Chris@239
|
354 void
|
chris@406
|
355 SettingsDialog::findSshBinaryName()
|
chris@406
|
356 {
|
chris@406
|
357 QSettings settings;
|
chris@406
|
358 settings.beginGroup("Locations");
|
Chris@465
|
359 QString ssh = settings.value("sshbinary", "").toString();
|
Chris@465
|
360 if (ssh != "" && QFile(ssh).exists()) {
|
chris@406
|
361 return;
|
chris@406
|
362 }
|
chris@406
|
363 QStringList bases;
|
chris@406
|
364 #ifdef Q_OS_WIN32
|
chris@406
|
365 bases << "TortoisePlink.exe";
|
chris@406
|
366 #else
|
chris@406
|
367 bases << "ssh";
|
chris@406
|
368 #endif
|
chris@406
|
369 bool found = false;
|
chris@406
|
370 foreach (QString base, bases) {
|
chris@406
|
371 ssh = findInPath(base, m_installPath, true);
|
chris@406
|
372 if (ssh != "") {
|
chris@406
|
373 found = true;
|
chris@406
|
374 break;
|
chris@406
|
375 }
|
chris@406
|
376 }
|
chris@406
|
377 if (found) {
|
chris@406
|
378 settings.setValue("sshbinary", ssh);
|
chris@406
|
379 }
|
chris@406
|
380 }
|
chris@406
|
381
|
chris@406
|
382 void
|
Chris@239
|
383 SettingsDialog::findEditorBinaryName()
|
Chris@239
|
384 {
|
Chris@239
|
385 QSettings settings;
|
Chris@239
|
386 settings.beginGroup("Locations");
|
Chris@239
|
387 QString editor = settings.value("editorbinary", "").toString();
|
Chris@465
|
388 if (editor != "" && QFile(editor).exists()) {
|
Chris@465
|
389 return;
|
Chris@465
|
390 }
|
Chris@465
|
391 QStringList bases;
|
Chris@465
|
392 bases
|
Chris@239
|
393 #if defined Q_OS_WIN32
|
Chris@465
|
394 << "wordpad.exe"
|
Chris@465
|
395 << "C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe"
|
Chris@465
|
396 << "notepad.exe"
|
Chris@239
|
397 #elif defined Q_OS_MAC
|
Chris@465
|
398 << "/Applications/TextEdit.app/Contents/MacOS/TextEdit"
|
Chris@239
|
399 #else
|
Chris@465
|
400 << "gedit" << "kate"
|
Chris@239
|
401 #endif
|
Chris@465
|
402 ;
|
Chris@465
|
403 bool found = false;
|
Chris@465
|
404 foreach (QString base, bases) {
|
Chris@465
|
405 editor = findInPath(base, m_installPath, true);
|
Chris@465
|
406 if (editor != "") {
|
Chris@465
|
407 found = true;
|
Chris@465
|
408 break;
|
Chris@239
|
409 }
|
Chris@465
|
410 }
|
Chris@465
|
411 if (found) {
|
Chris@465
|
412 settings.setValue("editorbinary", editor);
|
Chris@239
|
413 }
|
Chris@239
|
414 }
|
Chris@239
|
415
|
Chris@239
|
416 void
|
Chris@239
|
417 SettingsDialog::clear()
|
Chris@239
|
418 {
|
Chris@239
|
419 // Clear everything that has a default setting
|
Chris@239
|
420 DEBUG << "SettingsDialog::clear" << endl;
|
Chris@239
|
421 QSettings settings;
|
Chris@239
|
422 settings.beginGroup("Presentation");
|
Chris@239
|
423 settings.remove("showiconlabels");
|
Chris@239
|
424 settings.remove("showhelpfultext");
|
Chris@239
|
425 settings.endGroup();
|
Chris@239
|
426 settings.beginGroup("Locations");
|
Chris@239
|
427 settings.remove("hgbinary");
|
Chris@239
|
428 settings.remove("extdiffbinary");
|
Chris@239
|
429 settings.remove("mergebinary");
|
chris@406
|
430 settings.remove("sshbinary");
|
Chris@239
|
431 settings.remove("editorbinary");
|
Chris@239
|
432 settings.remove("extensionpath");
|
Chris@239
|
433 settings.endGroup();
|
Chris@239
|
434 settings.beginGroup("General");
|
Chris@239
|
435 settings.remove("useextension");
|
Chris@239
|
436 settings.endGroup();
|
Chris@239
|
437 }
|
Chris@239
|
438
|
Chris@239
|
439 void
|
Chris@239
|
440 SettingsDialog::reset()
|
Chris@239
|
441 {
|
Chris@239
|
442 DEBUG << "SettingsDialog::reset" << endl;
|
Chris@239
|
443 QSettings settings;
|
Chris@239
|
444 settings.beginGroup("User Information");
|
Chris@239
|
445 m_nameEdit->setText(settings.value("name", getUserRealName()).toString());
|
Chris@239
|
446 m_emailEdit->setText(settings.value("email").toString());
|
Chris@239
|
447 settings.endGroup();
|
Chris@239
|
448 settings.beginGroup("Presentation");
|
Chris@239
|
449 m_showIconLabels->setChecked(settings.value("showiconlabels", true).toBool());
|
Chris@239
|
450 m_showExtraText->setChecked(settings.value("showhelpfultext", true).toBool());
|
Chris@273
|
451 #ifdef NOT_IMPLEMENTED_YET
|
Chris@273
|
452 m_workHistoryArrangement->setCurrentIndex(settings.value("workhistoryarrangement", 0).toInt());
|
Chris@273
|
453 #endif
|
Chris@273
|
454 m_dateFormat->setCurrentIndex(settings.value("dateformat", 0).toInt());
|
Chris@239
|
455 settings.endGroup();
|
Chris@239
|
456 settings.beginGroup("Locations");
|
Chris@239
|
457 m_hgPathLabel->setText(settings.value("hgbinary").toString());
|
Chris@239
|
458 m_diffPathLabel->setText(settings.value("extdiffbinary").toString());
|
Chris@239
|
459 m_mergePathLabel->setText(settings.value("mergebinary").toString());
|
chris@406
|
460 m_sshPathLabel->setText(settings.value("sshbinary").toString());
|
Chris@239
|
461 m_editPathLabel->setText(settings.value("editorbinary").toString());
|
Chris@239
|
462 m_extensionPathLabel->setText(settings.value("extensionpath").toString());
|
Chris@239
|
463 settings.endGroup();
|
Chris@239
|
464 settings.beginGroup("General");
|
Chris@239
|
465 m_useExtension->setChecked(settings.value("useextension", true).toBool());
|
Chris@239
|
466 settings.endGroup();
|
Chris@239
|
467 }
|
Chris@239
|
468
|
Chris@239
|
469 void
|
Chris@175
|
470 SettingsDialog::accept()
|
Chris@175
|
471 {
|
Chris@177
|
472 DEBUG << "SettingsDialog::accept" << endl;
|
Chris@175
|
473 QSettings settings;
|
Chris@175
|
474 settings.beginGroup("User Information");
|
Chris@175
|
475 settings.setValue("name", m_nameEdit->text());
|
Chris@175
|
476 settings.setValue("email", m_emailEdit->text());
|
Chris@175
|
477 settings.endGroup();
|
Chris@230
|
478 settings.beginGroup("Presentation");
|
Chris@230
|
479 bool b;
|
Chris@230
|
480 b = m_showIconLabels->isChecked();
|
Chris@230
|
481 if (b != settings.value("showiconlabels", true)) {
|
Chris@230
|
482 settings.setValue("showiconlabels", b);
|
Chris@230
|
483 m_presentationChanged = true;
|
Chris@230
|
484 }
|
Chris@230
|
485 b = m_showExtraText->isChecked();
|
Chris@230
|
486 if (b != settings.value("showhelpfultext", true)) {
|
Chris@230
|
487 settings.setValue("showhelpfultext", b);
|
Chris@230
|
488 m_presentationChanged = true;
|
Chris@230
|
489 }
|
Chris@273
|
490 int i;
|
Chris@273
|
491 #ifdef NOT_IMPLEMENTED_YET
|
Chris@273
|
492 i = m_workHistoryArrangement->currentIndex();
|
Chris@273
|
493 if (i != settings.value("workhistoryarrangement", 0)) {
|
Chris@273
|
494 settings.setValue("workhistoryarrangement", i);
|
Chris@273
|
495 m_presentationChanged = true;
|
Chris@273
|
496 }
|
Chris@273
|
497 #endif
|
Chris@273
|
498 i = m_dateFormat->currentIndex();
|
Chris@273
|
499 if (i != settings.value("dateformat", 0)) {
|
Chris@273
|
500 settings.setValue("dateformat", i);
|
Chris@273
|
501 m_presentationChanged = true;
|
Chris@273
|
502 }
|
Chris@230
|
503 settings.endGroup();
|
Chris@175
|
504 settings.beginGroup("Locations");
|
Chris@181
|
505 settings.setValue("hgbinary", m_hgPathLabel->text());
|
Chris@181
|
506 settings.setValue("extdiffbinary", m_diffPathLabel->text());
|
Chris@181
|
507 settings.setValue("mergebinary", m_mergePathLabel->text());
|
chris@406
|
508 settings.setValue("sshbinary", m_sshPathLabel->text());
|
Chris@221
|
509 settings.setValue("editorbinary", m_editPathLabel->text());
|
Chris@181
|
510 settings.setValue("extensionpath", m_extensionPathLabel->text());
|
Chris@176
|
511 settings.endGroup();
|
Chris@176
|
512 settings.beginGroup("General");
|
Chris@176
|
513 settings.setValue("useextension", m_useExtension->isChecked());
|
Chris@175
|
514 settings.endGroup();
|
Chris@175
|
515 QDialog::accept();
|
Chris@175
|
516 }
|
Chris@175
|
517
|
Chris@175
|
518
|