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