| 422 | } |
| 423 | |
| 424 | QUrl ProjectDialogProvider::askProjectConfigLocation(bool fetch, const QUrl& startUrl, |
| 425 | const QUrl& repoUrl, IPlugin* vcsOrProviderPlugin) |
| 426 | { |
| 427 | Q_ASSERT(d); |
| 428 | ScopedDialog<OpenProjectDialog> dlg(fetch, startUrl, repoUrl, vcsOrProviderPlugin, |
| 429 | Core::self()->uiController()->activeMainWindow()); |
| 430 | if(dlg->exec() == QDialog::Rejected) { |
| 431 | return QUrl(); |
| 432 | } |
| 433 | |
| 434 | QUrl projectFileUrl = dlg->projectFileUrl(); |
| 435 | qCDebug(SHELL) << "selected project:" << projectFileUrl << dlg->projectName() << dlg->projectManager(); |
| 436 | if ( dlg->projectManager() == QLatin1String("<built-in>") ) { |
| 437 | return projectFileUrl; |
| 438 | } |
| 439 | |
| 440 | // controls if existing project file should be saved |
| 441 | bool writeProjectConfigToFile = true; |
| 442 | if( projectFileExists( projectFileUrl ) ) |
| 443 | { |
| 444 | // check whether config is equal |
| 445 | bool shouldAsk = true; |
| 446 | if( projectFileUrl == dlg->selectedUrl() ) |
| 447 | { |
| 448 | if( projectFileUrl.isLocalFile() ) |
| 449 | { |
| 450 | shouldAsk = !equalProjectFile( projectFileUrl.toLocalFile(), dlg ); |
| 451 | } else { |
| 452 | shouldAsk = false; |
| 453 | |
| 454 | QTemporaryFile tmpFile; |
| 455 | if (tmpFile.open()) { |
| 456 | auto downloadJob = KIO::file_copy(projectFileUrl, QUrl::fromLocalFile(tmpFile.fileName())); |
| 457 | KJobWidgets::setWindow(downloadJob, qApp->activeWindow()); |
| 458 | if (downloadJob->exec()) { |
| 459 | shouldAsk = !equalProjectFile(tmpFile.fileName(), dlg); |
| 460 | } |
| 461 | } |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | if ( shouldAsk ) |
| 466 | { |
| 467 | KGuiItem yes(i18nc("@action:button", "Override")); |
| 468 | yes.setToolTip(i18nc("@info:tooltip", "Continue to open the project and use the just provided project configuration")); |
| 469 | KGuiItem no(i18nc("@action:button", "Open Existing File")); |
| 470 | no.setToolTip(i18nc("@info:tooltip", "Continue to open the project but use the existing project configuration")); |
| 471 | KGuiItem cancel = KStandardGuiItem::cancel(); |
| 472 | cancel.setToolTip(i18nc("@info:tooltip", "Cancel and do not open the project")); |
| 473 | int ret = KMessageBox::questionTwoActionsCancel( |
| 474 | qApp->activeWindow(), |
| 475 | i18n("There already exists a project configuration file at %1.\n" |
| 476 | "Do you want to override it or open the existing file?", |
| 477 | projectFileUrl.toDisplayString(QUrl::PreferLocalFile)), |
| 478 | i18nc("@title:window", "Override Existing Project Configuration"), yes, no, cancel); |
| 479 | if (ret == KMessageBox::SecondaryAction) { |
| 480 | writeProjectConfigToFile = false; |
| 481 | } else if (ret == KMessageBox::Cancel) { |
no test coverage detected