comparison src/settingsdialog.cpp @ 465:b57d50114d8d

Look up diff/merge paths again if current settings are found not to exist (fixes #111)
author Chris Cannam
date Mon, 04 Jul 2011 14:03:31 +0100
parents c567fed39559
children 46ef2f03273c
comparison
equal deleted inserted replaced
464:6fc4fafc5e6b 465:b57d50114d8d
295 SettingsDialog::findDiffBinaryName() 295 SettingsDialog::findDiffBinaryName()
296 { 296 {
297 QSettings settings; 297 QSettings settings;
298 settings.beginGroup("Locations"); 298 settings.beginGroup("Locations");
299 QString diff = settings.value("extdiffbinary", "").toString(); 299 QString diff = settings.value("extdiffbinary", "").toString();
300 if (diff == "") { 300 if (diff != "" && QFile(diff).exists()) {
301 QStringList bases; 301 return;
302 }
303 QStringList bases;
302 #ifdef Q_OS_WIN32 304 #ifdef Q_OS_WIN32
303 bases << "easyhg-extdiff.bat"; 305 bases << "easyhg-extdiff.bat";
304 #else 306 #else
305 bases << "easyhg-extdiff.sh"; 307 bases << "easyhg-extdiff.sh";
306 #endif 308 #endif
307 bases << "kompare" << "kdiff3" << "meld"; 309 bases << "kompare" << "kdiff3" << "meld";
308 bool found = false; 310 bool found = false;
309 foreach (QString base, bases) { 311 foreach (QString base, bases) {
310 diff = findInPath(base, m_installPath, true); 312 diff = findInPath(base, m_installPath, true);
311 if (diff != "") { 313 if (diff != "") {
312 found = true; 314 found = true;
313 break; 315 break;
314 }
315 } 316 }
316 if (found) { 317 }
317 settings.setValue("extdiffbinary", diff); 318 if (found) {
318 } 319 settings.setValue("extdiffbinary", diff);
319 } 320 }
320 } 321 }
321 322
322 void 323 void
323 SettingsDialog::findMergeBinaryName() 324 SettingsDialog::findMergeBinaryName()
324 { 325 {
325 QSettings settings; 326 QSettings settings;
326 settings.beginGroup("Locations"); 327 settings.beginGroup("Locations");
327 if (settings.contains("mergebinary")) { 328 QString merge = settings.value("mergebinary", "").toString();
329 if (merge != "" && QFile(merge).exists()) {
328 return; 330 return;
329 } 331 }
330 QString merge;
331 QStringList bases; 332 QStringList bases;
332 #ifdef Q_OS_WIN32 333 #ifdef Q_OS_WIN32
333 bases << "easyhg-merge.bat"; 334 bases << "easyhg-merge.bat";
334 #else 335 #else
335 bases << "easyhg-merge.sh"; 336 bases << "easyhg-merge.sh";
353 void 354 void
354 SettingsDialog::findSshBinaryName() 355 SettingsDialog::findSshBinaryName()
355 { 356 {
356 QSettings settings; 357 QSettings settings;
357 settings.beginGroup("Locations"); 358 settings.beginGroup("Locations");
358 if (settings.contains("sshbinary")) { 359 QString ssh = settings.value("sshbinary", "").toString();
360 if (ssh != "" && QFile(ssh).exists()) {
359 return; 361 return;
360 } 362 }
361 QString ssh;
362 QStringList bases; 363 QStringList bases;
363 #ifdef Q_OS_WIN32 364 #ifdef Q_OS_WIN32
364 bases << "TortoisePlink.exe"; 365 bases << "TortoisePlink.exe";
365 #else 366 #else
366 bases << "ssh"; 367 bases << "ssh";
382 SettingsDialog::findEditorBinaryName() 383 SettingsDialog::findEditorBinaryName()
383 { 384 {
384 QSettings settings; 385 QSettings settings;
385 settings.beginGroup("Locations"); 386 settings.beginGroup("Locations");
386 QString editor = settings.value("editorbinary", "").toString(); 387 QString editor = settings.value("editorbinary", "").toString();
387 if (editor == "") { 388 if (editor != "" && QFile(editor).exists()) {
388 QStringList bases; 389 return;
389 bases 390 }
391 QStringList bases;
392 bases
390 #if defined Q_OS_WIN32 393 #if defined Q_OS_WIN32
391 << "wordpad.exe" 394 << "wordpad.exe"
392 << "C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe" 395 << "C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe"
393 << "notepad.exe" 396 << "notepad.exe"
394 #elif defined Q_OS_MAC 397 #elif defined Q_OS_MAC
395 << "/Applications/TextEdit.app/Contents/MacOS/TextEdit" 398 << "/Applications/TextEdit.app/Contents/MacOS/TextEdit"
396 #else 399 #else
397 << "gedit" << "kate" 400 << "gedit" << "kate"
398 #endif 401 #endif
399 ; 402 ;
400 bool found = false; 403 bool found = false;
401 foreach (QString base, bases) { 404 foreach (QString base, bases) {
402 editor = findInPath(base, m_installPath, true); 405 editor = findInPath(base, m_installPath, true);
403 if (editor != "") { 406 if (editor != "") {
404 found = true; 407 found = true;
405 break; 408 break;
406 }
407 } 409 }
408 if (found) { 410 }
409 settings.setValue("editorbinary", editor); 411 if (found) {
410 } 412 settings.setValue("editorbinary", editor);
411 } 413 }
412 } 414 }
413 415
414 void 416 void
415 SettingsDialog::clear() 417 SettingsDialog::clear()