Mercurial > hg > easyhg
comparison src/settingsdialog.cpp @ 476:7e8688784980
Use built-in edit window for editing .hgignore file (fixes #215)
author | Chris Cannam |
---|---|
date | Tue, 26 Jul 2011 15:21:45 +0100 |
parents | 2d57b81671de |
children | 896b7903e8f2 |
comparison
equal
deleted
inserted
replaced
475:dec4695f64e0 | 476:7e8688784980 |
---|---|
149 | 149 |
150 browse = new QPushButton(tr("Browse...")); | 150 browse = new QPushButton(tr("Browse...")); |
151 pathsLayout->addWidget(browse, row++, 1); | 151 pathsLayout->addWidget(browse, row++, 1); |
152 connect(browse, SIGNAL(clicked()), this, SLOT(sshPathBrowse())); | 152 connect(browse, SIGNAL(clicked()), this, SLOT(sshPathBrowse())); |
153 | 153 |
154 pathsLayout->addWidget(new QLabel(tr("External text editor:")), row, 0); | |
155 | |
156 m_editPathLabel = new QLineEdit(); | |
157 pathsLayout->addWidget(m_editPathLabel, row, 2); | |
158 | |
159 browse = new QPushButton(tr("Browse...")); | |
160 pathsLayout->addWidget(browse, row++, 1); | |
161 connect(browse, SIGNAL(clicked()), this, SLOT(editPathBrowse())); | |
162 | |
163 pathsLayout->addWidget(new QLabel(tr("EasyHg Mercurial extension:")), row, 0); | 154 pathsLayout->addWidget(new QLabel(tr("EasyHg Mercurial extension:")), row, 0); |
164 | 155 |
165 m_extensionPathLabel = new QLineEdit(); | 156 m_extensionPathLabel = new QLineEdit(); |
166 pathsLayout->addWidget(m_extensionPathLabel, row, 2); | 157 pathsLayout->addWidget(m_extensionPathLabel, row, 2); |
167 | 158 |
217 | 208 |
218 void | 209 void |
219 SettingsDialog::sshPathBrowse() | 210 SettingsDialog::sshPathBrowse() |
220 { | 211 { |
221 browseFor(tr("SSH program"), m_sshPathLabel); | 212 browseFor(tr("SSH program"), m_sshPathLabel); |
222 } | |
223 | |
224 void | |
225 SettingsDialog::editPathBrowse() | |
226 { | |
227 browseFor(tr("External text editor"), m_editPathLabel); | |
228 } | 213 } |
229 | 214 |
230 void | 215 void |
231 SettingsDialog::extensionPathBrowse() | 216 SettingsDialog::extensionPathBrowse() |
232 { | 217 { |
273 findHgBinaryName(); | 258 findHgBinaryName(); |
274 findExtension(); | 259 findExtension(); |
275 findDiffBinaryName(); | 260 findDiffBinaryName(); |
276 findMergeBinaryName(); | 261 findMergeBinaryName(); |
277 findSshBinaryName(); | 262 findSshBinaryName(); |
278 findEditorBinaryName(); | |
279 } | 263 } |
280 | 264 |
281 void | 265 void |
282 SettingsDialog::findHgBinaryName() | 266 SettingsDialog::findHgBinaryName() |
283 { | 267 { |
407 settings.setValue("sshbinary", ssh); | 391 settings.setValue("sshbinary", ssh); |
408 } | 392 } |
409 } | 393 } |
410 | 394 |
411 void | 395 void |
412 SettingsDialog::findEditorBinaryName() | |
413 { | |
414 QSettings settings; | |
415 settings.beginGroup("Locations"); | |
416 QString editor = settings.value("editorbinary", "").toString(); | |
417 if (editor != "" && QFile(editor).exists()) { | |
418 return; | |
419 } | |
420 QStringList bases; | |
421 bases | |
422 #if defined Q_OS_WIN32 | |
423 << "wordpad.exe" | |
424 << "C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe" | |
425 << "notepad.exe" | |
426 #elif defined Q_OS_MAC | |
427 << "/Applications/TextEdit.app/Contents/MacOS/TextEdit" | |
428 #else | |
429 << "gedit" << "kate" | |
430 #endif | |
431 ; | |
432 bool found = false; | |
433 foreach (QString base, bases) { | |
434 editor = findInPath(base, m_installPath, true); | |
435 if (editor != "") { | |
436 found = true; | |
437 break; | |
438 } | |
439 } | |
440 if (found) { | |
441 settings.setValue("editorbinary", editor); | |
442 } | |
443 } | |
444 | |
445 void | |
446 SettingsDialog::clear() | 396 SettingsDialog::clear() |
447 { | 397 { |
448 // Clear everything that has a default setting | 398 // Clear everything that has a default setting |
449 DEBUG << "SettingsDialog::clear" << endl; | 399 DEBUG << "SettingsDialog::clear" << endl; |
450 QSettings settings; | 400 QSettings settings; |
456 settings.beginGroup("Locations"); | 406 settings.beginGroup("Locations"); |
457 settings.remove("hgbinary"); | 407 settings.remove("hgbinary"); |
458 settings.remove("extdiffbinary"); | 408 settings.remove("extdiffbinary"); |
459 settings.remove("mergebinary"); | 409 settings.remove("mergebinary"); |
460 settings.remove("sshbinary"); | 410 settings.remove("sshbinary"); |
461 settings.remove("editorbinary"); | |
462 settings.remove("extensionpath"); | 411 settings.remove("extensionpath"); |
463 settings.endGroup(); | 412 settings.endGroup(); |
464 settings.beginGroup("General"); | 413 settings.beginGroup("General"); |
465 settings.remove("useextension"); | 414 settings.remove("useextension"); |
466 settings.endGroup(); | 415 settings.endGroup(); |
486 settings.beginGroup("Locations"); | 435 settings.beginGroup("Locations"); |
487 m_hgPathLabel->setText(settings.value("hgbinary").toString()); | 436 m_hgPathLabel->setText(settings.value("hgbinary").toString()); |
488 m_diffPathLabel->setText(settings.value("extdiffbinary").toString()); | 437 m_diffPathLabel->setText(settings.value("extdiffbinary").toString()); |
489 m_mergePathLabel->setText(settings.value("mergebinary").toString()); | 438 m_mergePathLabel->setText(settings.value("mergebinary").toString()); |
490 m_sshPathLabel->setText(settings.value("sshbinary").toString()); | 439 m_sshPathLabel->setText(settings.value("sshbinary").toString()); |
491 m_editPathLabel->setText(settings.value("editorbinary").toString()); | |
492 m_extensionPathLabel->setText(settings.value("extensionpath").toString()); | 440 m_extensionPathLabel->setText(settings.value("extensionpath").toString()); |
493 settings.endGroup(); | 441 settings.endGroup(); |
494 settings.beginGroup("General"); | 442 settings.beginGroup("General"); |
495 m_useExtension->setChecked(settings.value("useextension", true).toBool()); | 443 m_useExtension->setChecked(settings.value("useextension", true).toBool()); |
496 settings.endGroup(); | 444 settings.endGroup(); |
534 settings.beginGroup("Locations"); | 482 settings.beginGroup("Locations"); |
535 settings.setValue("hgbinary", m_hgPathLabel->text()); | 483 settings.setValue("hgbinary", m_hgPathLabel->text()); |
536 settings.setValue("extdiffbinary", m_diffPathLabel->text()); | 484 settings.setValue("extdiffbinary", m_diffPathLabel->text()); |
537 settings.setValue("mergebinary", m_mergePathLabel->text()); | 485 settings.setValue("mergebinary", m_mergePathLabel->text()); |
538 settings.setValue("sshbinary", m_sshPathLabel->text()); | 486 settings.setValue("sshbinary", m_sshPathLabel->text()); |
539 settings.setValue("editorbinary", m_editPathLabel->text()); | |
540 settings.setValue("extensionpath", m_extensionPathLabel->text()); | 487 settings.setValue("extensionpath", m_extensionPathLabel->text()); |
541 settings.endGroup(); | 488 settings.endGroup(); |
542 settings.beginGroup("General"); | 489 settings.beginGroup("General"); |
543 settings.setValue("useextension", m_useExtension->isChecked()); | 490 settings.setValue("useextension", m_useExtension->isChecked()); |
544 settings.endGroup(); | 491 settings.endGroup(); |