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