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@472
|
44 m_tabs = new QTabWidget;
|
Chris@472
|
45 mainLayout->addWidget(m_tabs, 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@472
|
52 m_tabs->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@472
|
76 m_tabs->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@472
|
109 m_tabs->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@472
|
191 SettingsDialog::setCurrentTab(Tab t)
|
Chris@472
|
192 {
|
Chris@472
|
193 switch (t) {
|
Chris@472
|
194 case PersonalDetailsTab: m_tabs->setCurrentIndex(0); break;
|
Chris@472
|
195 case PresentationTab: m_tabs->setCurrentIndex(1); break;
|
Chris@472
|
196 case PathsTab: m_tabs->setCurrentIndex(2); break;
|
Chris@472
|
197 }
|
Chris@472
|
198 }
|
Chris@472
|
199
|
Chris@472
|
200 void
|
Chris@175
|
201 SettingsDialog::hgPathBrowse()
|
Chris@175
|
202 {
|
Chris@181
|
203 browseFor(tr("Mercurial program"), m_hgPathLabel);
|
Chris@175
|
204 }
|
Chris@175
|
205
|
Chris@175
|
206 void
|
Chris@175
|
207 SettingsDialog::diffPathBrowse()
|
Chris@175
|
208 {
|
Chris@181
|
209 browseFor(tr("External diff program"), m_diffPathLabel);
|
Chris@175
|
210 }
|
Chris@175
|
211
|
Chris@175
|
212 void
|
Chris@175
|
213 SettingsDialog::mergePathBrowse()
|
Chris@175
|
214 {
|
Chris@181
|
215 browseFor(tr("External file-merge program"), m_mergePathLabel);
|
Chris@175
|
216 }
|
Chris@175
|
217
|
Chris@175
|
218 void
|
chris@406
|
219 SettingsDialog::sshPathBrowse()
|
chris@406
|
220 {
|
chris@406
|
221 browseFor(tr("SSH program"), m_sshPathLabel);
|
chris@406
|
222 }
|
chris@406
|
223
|
chris@406
|
224 void
|
Chris@178
|
225 SettingsDialog::editPathBrowse()
|
Chris@175
|
226 {
|
Chris@181
|
227 browseFor(tr("External text editor"), m_editPathLabel);
|
Chris@176
|
228 }
|
Chris@176
|
229
|
Chris@176
|
230 void
|
Chris@176
|
231 SettingsDialog::extensionPathBrowse()
|
Chris@176
|
232 {
|
Chris@181
|
233 browseFor(tr("EasyHg Mercurial extension"), m_extensionPathLabel);
|
Chris@181
|
234 }
|
Chris@181
|
235
|
Chris@181
|
236 void
|
Chris@195
|
237 SettingsDialog::browseFor(QString title, QLineEdit *edit)
|
Chris@181
|
238 {
|
Chris@181
|
239 QString origin = edit->text();
|
Chris@181
|
240
|
Chris@181
|
241 if (origin == "") {
|
Chris@181
|
242 #ifdef Q_OS_WIN32
|
Chris@181
|
243 origin = "c:";
|
Chris@181
|
244 #else
|
Chris@181
|
245 origin = QDir::homePath();
|
Chris@181
|
246 #endif
|
Chris@181
|
247 }
|
Chris@181
|
248
|
Chris@181
|
249 QString path = QFileDialog::getOpenFileName(this, title, origin);
|
Chris@181
|
250 if (path != QString()) {
|
Chris@181
|
251 edit->setText(path);
|
Chris@181
|
252 }
|
Chris@176
|
253 }
|
Chris@176
|
254
|
Chris@176
|
255 void
|
Chris@239
|
256 SettingsDialog::restoreDefaults()
|
Chris@239
|
257 {
|
Chris@273
|
258 if (QMessageBox::question
|
Chris@273
|
259 (this, tr("Restore default settings?"),
|
Chris@273
|
260 tr("<qt><b>Restore default settings?</b><br><br>Are you sure you want to reset all settings to their default values?"),
|
Chris@273
|
261 QMessageBox::Ok | QMessageBox::Cancel,
|
Chris@273
|
262 QMessageBox::Cancel) == QMessageBox::Ok) {
|
Chris@273
|
263 clear();
|
Chris@273
|
264 findDefaultLocations();
|
Chris@273
|
265 reset();
|
Chris@273
|
266 }
|
Chris@239
|
267 }
|
Chris@239
|
268
|
Chris@239
|
269 void
|
Chris@239
|
270 SettingsDialog::findDefaultLocations(QString installPath)
|
Chris@239
|
271 {
|
Chris@239
|
272 m_installPath = installPath;
|
Chris@239
|
273 findHgBinaryName();
|
Chris@239
|
274 findExtension();
|
Chris@239
|
275 findDiffBinaryName();
|
Chris@239
|
276 findMergeBinaryName();
|
chris@406
|
277 findSshBinaryName();
|
Chris@239
|
278 findEditorBinaryName();
|
Chris@239
|
279 }
|
Chris@239
|
280
|
Chris@239
|
281 void
|
Chris@239
|
282 SettingsDialog::findHgBinaryName()
|
Chris@239
|
283 {
|
Chris@239
|
284 QSettings settings;
|
Chris@239
|
285 settings.beginGroup("Locations");
|
Chris@239
|
286 QString hg = settings.value("hgbinary", "").toString();
|
Chris@239
|
287 if (hg == "") {
|
Chris@239
|
288 hg = findInPath("hg", m_installPath, true);
|
Chris@239
|
289 }
|
Chris@239
|
290 if (hg != "") {
|
Chris@239
|
291 settings.setValue("hgbinary", hg);
|
Chris@239
|
292 }
|
Chris@239
|
293 }
|
Chris@239
|
294
|
Chris@240
|
295 QString
|
Chris@240
|
296 SettingsDialog::getUnbundledExtensionFileName()
|
Chris@240
|
297 {
|
Chris@240
|
298 QString home = QDir::homePath();
|
Chris@240
|
299 QString target = QString("%1/.easyhg").arg(home);
|
Chris@240
|
300 QString extpath = QString("%1/easyhg.py").arg(target);
|
Chris@240
|
301 return extpath;
|
Chris@240
|
302 }
|
Chris@240
|
303
|
Chris@239
|
304 void
|
Chris@239
|
305 SettingsDialog::findExtension()
|
Chris@239
|
306 {
|
Chris@239
|
307 QSettings settings;
|
Chris@239
|
308 settings.beginGroup("Locations");
|
Chris@239
|
309
|
Chris@239
|
310 QString extpath = settings.value("extensionpath", "").toString();
|
Chris@239
|
311 if (extpath != "" || !QFile(extpath).exists()) {
|
Chris@239
|
312
|
Chris@240
|
313 extpath = getUnbundledExtensionFileName();
|
Chris@239
|
314
|
Chris@239
|
315 if (!QFile(extpath).exists()) {
|
Chris@239
|
316 extpath = findInPath("easyhg.py", m_installPath, false);
|
Chris@239
|
317 }
|
Chris@239
|
318 }
|
Chris@239
|
319
|
Chris@239
|
320 settings.setValue("extensionpath", extpath);
|
Chris@239
|
321 }
|
Chris@239
|
322
|
Chris@239
|
323 void
|
Chris@239
|
324 SettingsDialog::findDiffBinaryName()
|
Chris@239
|
325 {
|
Chris@239
|
326 QSettings settings;
|
Chris@239
|
327 settings.beginGroup("Locations");
|
Chris@239
|
328 QString diff = settings.value("extdiffbinary", "").toString();
|
Chris@465
|
329 if (diff != "" && QFile(diff).exists()) {
|
Chris@465
|
330 return;
|
Chris@465
|
331 }
|
Chris@465
|
332 QStringList bases;
|
Chris@272
|
333 #ifdef Q_OS_WIN32
|
Chris@465
|
334 bases << "easyhg-extdiff.bat";
|
Chris@272
|
335 #else
|
Chris@465
|
336 bases << "easyhg-extdiff.sh";
|
Chris@272
|
337 #endif
|
Chris@465
|
338 bases << "kompare" << "kdiff3" << "meld";
|
Chris@465
|
339 bool found = false;
|
Chris@465
|
340 foreach (QString base, bases) {
|
Chris@465
|
341 diff = findInPath(base, m_installPath, true);
|
Chris@465
|
342 if (diff != "") {
|
Chris@465
|
343 found = true;
|
Chris@465
|
344 break;
|
Chris@239
|
345 }
|
Chris@465
|
346 }
|
Chris@465
|
347 if (found) {
|
Chris@465
|
348 settings.setValue("extdiffbinary", diff);
|
Chris@239
|
349 }
|
Chris@239
|
350 }
|
Chris@239
|
351
|
Chris@239
|
352 void
|
Chris@239
|
353 SettingsDialog::findMergeBinaryName()
|
Chris@239
|
354 {
|
Chris@239
|
355 QSettings settings;
|
Chris@239
|
356 settings.beginGroup("Locations");
|
Chris@465
|
357 QString merge = settings.value("mergebinary", "").toString();
|
Chris@465
|
358 if (merge != "" && QFile(merge).exists()) {
|
Chris@239
|
359 return;
|
Chris@239
|
360 }
|
Chris@239
|
361 QStringList bases;
|
Chris@272
|
362 #ifdef Q_OS_WIN32
|
Chris@272
|
363 bases << "easyhg-merge.bat";
|
Chris@272
|
364 #else
|
Chris@269
|
365 bases << "easyhg-merge.sh";
|
Chris@272
|
366 #endif
|
Chris@269
|
367 // NB it's not a good idea to add other tools here, as command
|
Chris@269
|
368 // line argument ordering varies. Configure them through hgrc
|
Chris@269
|
369 // instead
|
Chris@239
|
370 bool found = false;
|
Chris@239
|
371 foreach (QString base, bases) {
|
Chris@239
|
372 merge = findInPath(base, m_installPath, true);
|
Chris@239
|
373 if (merge != "") {
|
Chris@239
|
374 found = true;
|
Chris@239
|
375 break;
|
Chris@239
|
376 }
|
Chris@239
|
377 }
|
Chris@239
|
378 if (found) {
|
Chris@239
|
379 settings.setValue("mergebinary", merge);
|
Chris@239
|
380 }
|
Chris@239
|
381 }
|
Chris@239
|
382
|
Chris@239
|
383 void
|
chris@406
|
384 SettingsDialog::findSshBinaryName()
|
chris@406
|
385 {
|
chris@406
|
386 QSettings settings;
|
chris@406
|
387 settings.beginGroup("Locations");
|
Chris@465
|
388 QString ssh = settings.value("sshbinary", "").toString();
|
Chris@465
|
389 if (ssh != "" && QFile(ssh).exists()) {
|
chris@406
|
390 return;
|
chris@406
|
391 }
|
chris@406
|
392 QStringList bases;
|
chris@406
|
393 #ifdef Q_OS_WIN32
|
chris@406
|
394 bases << "TortoisePlink.exe";
|
chris@406
|
395 #else
|
chris@406
|
396 bases << "ssh";
|
chris@406
|
397 #endif
|
chris@406
|
398 bool found = false;
|
chris@406
|
399 foreach (QString base, bases) {
|
chris@406
|
400 ssh = findInPath(base, m_installPath, true);
|
chris@406
|
401 if (ssh != "") {
|
chris@406
|
402 found = true;
|
chris@406
|
403 break;
|
chris@406
|
404 }
|
chris@406
|
405 }
|
chris@406
|
406 if (found) {
|
chris@406
|
407 settings.setValue("sshbinary", ssh);
|
chris@406
|
408 }
|
chris@406
|
409 }
|
chris@406
|
410
|
chris@406
|
411 void
|
Chris@239
|
412 SettingsDialog::findEditorBinaryName()
|
Chris@239
|
413 {
|
Chris@239
|
414 QSettings settings;
|
Chris@239
|
415 settings.beginGroup("Locations");
|
Chris@239
|
416 QString editor = settings.value("editorbinary", "").toString();
|
Chris@465
|
417 if (editor != "" && QFile(editor).exists()) {
|
Chris@465
|
418 return;
|
Chris@465
|
419 }
|
Chris@465
|
420 QStringList bases;
|
Chris@465
|
421 bases
|
Chris@239
|
422 #if defined Q_OS_WIN32
|
Chris@465
|
423 << "wordpad.exe"
|
Chris@465
|
424 << "C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe"
|
Chris@465
|
425 << "notepad.exe"
|
Chris@239
|
426 #elif defined Q_OS_MAC
|
Chris@465
|
427 << "/Applications/TextEdit.app/Contents/MacOS/TextEdit"
|
Chris@239
|
428 #else
|
Chris@465
|
429 << "gedit" << "kate"
|
Chris@239
|
430 #endif
|
Chris@465
|
431 ;
|
Chris@465
|
432 bool found = false;
|
Chris@465
|
433 foreach (QString base, bases) {
|
Chris@465
|
434 editor = findInPath(base, m_installPath, true);
|
Chris@465
|
435 if (editor != "") {
|
Chris@465
|
436 found = true;
|
Chris@465
|
437 break;
|
Chris@239
|
438 }
|
Chris@465
|
439 }
|
Chris@465
|
440 if (found) {
|
Chris@465
|
441 settings.setValue("editorbinary", editor);
|
Chris@239
|
442 }
|
Chris@239
|
443 }
|
Chris@239
|
444
|
Chris@239
|
445 void
|
Chris@239
|
446 SettingsDialog::clear()
|
Chris@239
|
447 {
|
Chris@239
|
448 // Clear everything that has a default setting
|
Chris@239
|
449 DEBUG << "SettingsDialog::clear" << endl;
|
Chris@239
|
450 QSettings settings;
|
Chris@239
|
451 settings.beginGroup("Presentation");
|
Chris@239
|
452 settings.remove("showiconlabels");
|
Chris@239
|
453 settings.remove("showhelpfultext");
|
Chris@466
|
454 settings.remove("dateformat");
|
Chris@239
|
455 settings.endGroup();
|
Chris@239
|
456 settings.beginGroup("Locations");
|
Chris@239
|
457 settings.remove("hgbinary");
|
Chris@239
|
458 settings.remove("extdiffbinary");
|
Chris@239
|
459 settings.remove("mergebinary");
|
chris@406
|
460 settings.remove("sshbinary");
|
Chris@239
|
461 settings.remove("editorbinary");
|
Chris@239
|
462 settings.remove("extensionpath");
|
Chris@239
|
463 settings.endGroup();
|
Chris@239
|
464 settings.beginGroup("General");
|
Chris@239
|
465 settings.remove("useextension");
|
Chris@239
|
466 settings.endGroup();
|
Chris@239
|
467 }
|
Chris@239
|
468
|
Chris@239
|
469 void
|
Chris@239
|
470 SettingsDialog::reset()
|
Chris@239
|
471 {
|
Chris@239
|
472 DEBUG << "SettingsDialog::reset" << endl;
|
Chris@239
|
473 QSettings settings;
|
Chris@239
|
474 settings.beginGroup("User Information");
|
Chris@239
|
475 m_nameEdit->setText(settings.value("name", getUserRealName()).toString());
|
Chris@239
|
476 m_emailEdit->setText(settings.value("email").toString());
|
Chris@239
|
477 settings.endGroup();
|
Chris@239
|
478 settings.beginGroup("Presentation");
|
Chris@239
|
479 m_showIconLabels->setChecked(settings.value("showiconlabels", true).toBool());
|
Chris@239
|
480 m_showExtraText->setChecked(settings.value("showhelpfultext", true).toBool());
|
Chris@273
|
481 #ifdef NOT_IMPLEMENTED_YET
|
Chris@273
|
482 m_workHistoryArrangement->setCurrentIndex(settings.value("workhistoryarrangement", 0).toInt());
|
Chris@273
|
483 #endif
|
Chris@273
|
484 m_dateFormat->setCurrentIndex(settings.value("dateformat", 0).toInt());
|
Chris@239
|
485 settings.endGroup();
|
Chris@239
|
486 settings.beginGroup("Locations");
|
Chris@239
|
487 m_hgPathLabel->setText(settings.value("hgbinary").toString());
|
Chris@239
|
488 m_diffPathLabel->setText(settings.value("extdiffbinary").toString());
|
Chris@239
|
489 m_mergePathLabel->setText(settings.value("mergebinary").toString());
|
chris@406
|
490 m_sshPathLabel->setText(settings.value("sshbinary").toString());
|
Chris@239
|
491 m_editPathLabel->setText(settings.value("editorbinary").toString());
|
Chris@239
|
492 m_extensionPathLabel->setText(settings.value("extensionpath").toString());
|
Chris@239
|
493 settings.endGroup();
|
Chris@239
|
494 settings.beginGroup("General");
|
Chris@239
|
495 m_useExtension->setChecked(settings.value("useextension", true).toBool());
|
Chris@239
|
496 settings.endGroup();
|
Chris@239
|
497 }
|
Chris@239
|
498
|
Chris@239
|
499 void
|
Chris@175
|
500 SettingsDialog::accept()
|
Chris@175
|
501 {
|
Chris@177
|
502 DEBUG << "SettingsDialog::accept" << endl;
|
Chris@175
|
503 QSettings settings;
|
Chris@175
|
504 settings.beginGroup("User Information");
|
Chris@175
|
505 settings.setValue("name", m_nameEdit->text());
|
Chris@175
|
506 settings.setValue("email", m_emailEdit->text());
|
Chris@175
|
507 settings.endGroup();
|
Chris@230
|
508 settings.beginGroup("Presentation");
|
Chris@230
|
509 bool b;
|
Chris@230
|
510 b = m_showIconLabels->isChecked();
|
Chris@230
|
511 if (b != settings.value("showiconlabels", true)) {
|
Chris@230
|
512 settings.setValue("showiconlabels", b);
|
Chris@230
|
513 m_presentationChanged = true;
|
Chris@230
|
514 }
|
Chris@230
|
515 b = m_showExtraText->isChecked();
|
Chris@230
|
516 if (b != settings.value("showhelpfultext", true)) {
|
Chris@230
|
517 settings.setValue("showhelpfultext", b);
|
Chris@230
|
518 m_presentationChanged = true;
|
Chris@230
|
519 }
|
Chris@273
|
520 int i;
|
Chris@273
|
521 #ifdef NOT_IMPLEMENTED_YET
|
Chris@273
|
522 i = m_workHistoryArrangement->currentIndex();
|
Chris@273
|
523 if (i != settings.value("workhistoryarrangement", 0)) {
|
Chris@273
|
524 settings.setValue("workhistoryarrangement", i);
|
Chris@273
|
525 m_presentationChanged = true;
|
Chris@273
|
526 }
|
Chris@273
|
527 #endif
|
Chris@273
|
528 i = m_dateFormat->currentIndex();
|
Chris@273
|
529 if (i != settings.value("dateformat", 0)) {
|
Chris@273
|
530 settings.setValue("dateformat", i);
|
Chris@273
|
531 m_presentationChanged = true;
|
Chris@273
|
532 }
|
Chris@230
|
533 settings.endGroup();
|
Chris@175
|
534 settings.beginGroup("Locations");
|
Chris@181
|
535 settings.setValue("hgbinary", m_hgPathLabel->text());
|
Chris@181
|
536 settings.setValue("extdiffbinary", m_diffPathLabel->text());
|
Chris@181
|
537 settings.setValue("mergebinary", m_mergePathLabel->text());
|
chris@406
|
538 settings.setValue("sshbinary", m_sshPathLabel->text());
|
Chris@221
|
539 settings.setValue("editorbinary", m_editPathLabel->text());
|
Chris@181
|
540 settings.setValue("extensionpath", m_extensionPathLabel->text());
|
Chris@176
|
541 settings.endGroup();
|
Chris@176
|
542 settings.beginGroup("General");
|
Chris@176
|
543 settings.setValue("useextension", m_useExtension->isChecked());
|
Chris@175
|
544 settings.endGroup();
|
Chris@175
|
545 QDialog::accept();
|
Chris@175
|
546 }
|
Chris@175
|
547
|
Chris@175
|
548
|