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