comparison src/settingsdialog.cpp @ 406:c567fed39559

Add ability to configure the ssh client; default to TortoisePlink on Windows
author Chris Cannam <chris.cannam@eecs.qmul.ac.uk>
date Thu, 26 May 2011 15:48:11 +0100
parents b9c153e00e84
children b57d50114d8d
comparison
equal deleted inserted replaced
405:46267ab70ef3 406:c567fed39559
123 123
124 browse = new QPushButton(tr("Browse...")); 124 browse = new QPushButton(tr("Browse..."));
125 pathsLayout->addWidget(browse, row++, 1); 125 pathsLayout->addWidget(browse, row++, 1);
126 connect(browse, SIGNAL(clicked()), this, SLOT(mergePathBrowse())); 126 connect(browse, SIGNAL(clicked()), this, SLOT(mergePathBrowse()));
127 127
128 pathsLayout->addWidget(new QLabel(tr("SSH program (for ssh URLs):")), row, 0);
129
130 m_sshPathLabel = new QLineEdit();
131 pathsLayout->addWidget(m_sshPathLabel, row, 2);
132
133 browse = new QPushButton(tr("Browse..."));
134 pathsLayout->addWidget(browse, row++, 1);
135 connect(browse, SIGNAL(clicked()), this, SLOT(sshPathBrowse()));
136
128 pathsLayout->addWidget(new QLabel(tr("External text editor:")), row, 0); 137 pathsLayout->addWidget(new QLabel(tr("External text editor:")), row, 0);
129 138
130 m_editPathLabel = new QLineEdit(); 139 m_editPathLabel = new QLineEdit();
131 pathsLayout->addWidget(m_editPathLabel, row, 2); 140 pathsLayout->addWidget(m_editPathLabel, row, 2);
132 141
173 182
174 void 183 void
175 SettingsDialog::mergePathBrowse() 184 SettingsDialog::mergePathBrowse()
176 { 185 {
177 browseFor(tr("External file-merge program"), m_mergePathLabel); 186 browseFor(tr("External file-merge program"), m_mergePathLabel);
187 }
188
189 void
190 SettingsDialog::sshPathBrowse()
191 {
192 browseFor(tr("SSH program"), m_sshPathLabel);
178 } 193 }
179 194
180 void 195 void
181 SettingsDialog::editPathBrowse() 196 SettingsDialog::editPathBrowse()
182 { 197 {
228 m_installPath = installPath; 243 m_installPath = installPath;
229 findHgBinaryName(); 244 findHgBinaryName();
230 findExtension(); 245 findExtension();
231 findDiffBinaryName(); 246 findDiffBinaryName();
232 findMergeBinaryName(); 247 findMergeBinaryName();
248 findSshBinaryName();
233 findEditorBinaryName(); 249 findEditorBinaryName();
234 } 250 }
235 251
236 void 252 void
237 SettingsDialog::findHgBinaryName() 253 SettingsDialog::findHgBinaryName()
329 break; 345 break;
330 } 346 }
331 } 347 }
332 if (found) { 348 if (found) {
333 settings.setValue("mergebinary", merge); 349 settings.setValue("mergebinary", merge);
350 }
351 }
352
353 void
354 SettingsDialog::findSshBinaryName()
355 {
356 QSettings settings;
357 settings.beginGroup("Locations");
358 if (settings.contains("sshbinary")) {
359 return;
360 }
361 QString ssh;
362 QStringList bases;
363 #ifdef Q_OS_WIN32
364 bases << "TortoisePlink.exe";
365 #else
366 bases << "ssh";
367 #endif
368 bool found = false;
369 foreach (QString base, bases) {
370 ssh = findInPath(base, m_installPath, true);
371 if (ssh != "") {
372 found = true;
373 break;
374 }
375 }
376 if (found) {
377 settings.setValue("sshbinary", ssh);
334 } 378 }
335 } 379 }
336 380
337 void 381 void
338 SettingsDialog::findEditorBinaryName() 382 SettingsDialog::findEditorBinaryName()
379 settings.endGroup(); 423 settings.endGroup();
380 settings.beginGroup("Locations"); 424 settings.beginGroup("Locations");
381 settings.remove("hgbinary"); 425 settings.remove("hgbinary");
382 settings.remove("extdiffbinary"); 426 settings.remove("extdiffbinary");
383 settings.remove("mergebinary"); 427 settings.remove("mergebinary");
428 settings.remove("sshbinary");
384 settings.remove("editorbinary"); 429 settings.remove("editorbinary");
385 settings.remove("extensionpath"); 430 settings.remove("extensionpath");
386 settings.endGroup(); 431 settings.endGroup();
387 settings.beginGroup("General"); 432 settings.beginGroup("General");
388 settings.remove("useextension"); 433 settings.remove("useextension");
408 settings.endGroup(); 453 settings.endGroup();
409 settings.beginGroup("Locations"); 454 settings.beginGroup("Locations");
410 m_hgPathLabel->setText(settings.value("hgbinary").toString()); 455 m_hgPathLabel->setText(settings.value("hgbinary").toString());
411 m_diffPathLabel->setText(settings.value("extdiffbinary").toString()); 456 m_diffPathLabel->setText(settings.value("extdiffbinary").toString());
412 m_mergePathLabel->setText(settings.value("mergebinary").toString()); 457 m_mergePathLabel->setText(settings.value("mergebinary").toString());
458 m_sshPathLabel->setText(settings.value("sshbinary").toString());
413 m_editPathLabel->setText(settings.value("editorbinary").toString()); 459 m_editPathLabel->setText(settings.value("editorbinary").toString());
414 m_extensionPathLabel->setText(settings.value("extensionpath").toString()); 460 m_extensionPathLabel->setText(settings.value("extensionpath").toString());
415 settings.endGroup(); 461 settings.endGroup();
416 settings.beginGroup("General"); 462 settings.beginGroup("General");
417 m_useExtension->setChecked(settings.value("useextension", true).toBool()); 463 m_useExtension->setChecked(settings.value("useextension", true).toBool());
455 settings.endGroup(); 501 settings.endGroup();
456 settings.beginGroup("Locations"); 502 settings.beginGroup("Locations");
457 settings.setValue("hgbinary", m_hgPathLabel->text()); 503 settings.setValue("hgbinary", m_hgPathLabel->text());
458 settings.setValue("extdiffbinary", m_diffPathLabel->text()); 504 settings.setValue("extdiffbinary", m_diffPathLabel->text());
459 settings.setValue("mergebinary", m_mergePathLabel->text()); 505 settings.setValue("mergebinary", m_mergePathLabel->text());
506 settings.setValue("sshbinary", m_sshPathLabel->text());
460 settings.setValue("editorbinary", m_editPathLabel->text()); 507 settings.setValue("editorbinary", m_editPathLabel->text());
461 settings.setValue("extensionpath", m_extensionPathLabel->text()); 508 settings.setValue("extensionpath", m_extensionPathLabel->text());
462 settings.endGroup(); 509 settings.endGroup();
463 settings.beginGroup("General"); 510 settings.beginGroup("General");
464 settings.setValue("useextension", m_useExtension->isChecked()); 511 settings.setValue("useextension", m_useExtension->isChecked());