Changeset View
Changeset View
Standalone View
Standalone View
shell/projectcontroller.cpp
Show All 23 Lines | |||||
24 | #include <QAction> | 24 | #include <QAction> | ||
25 | #include <QApplication> | 25 | #include <QApplication> | ||
26 | #include <QDBusConnection> | 26 | #include <QDBusConnection> | ||
27 | #include <QDir> | 27 | #include <QDir> | ||
28 | #include <QGroupBox> | 28 | #include <QGroupBox> | ||
29 | #include <QLabel> | 29 | #include <QLabel> | ||
30 | #include <QList> | 30 | #include <QList> | ||
31 | #include <QMap> | 31 | #include <QMap> | ||
32 | #include <QPointer> | ||||
32 | #include <QPushButton> | 33 | #include <QPushButton> | ||
33 | #include <QRadioButton> | 34 | #include <QRadioButton> | ||
34 | #include <QSet> | 35 | #include <QSet> | ||
35 | #include <QTemporaryFile> | 36 | #include <QTemporaryFile> | ||
36 | #include <QVBoxLayout> | 37 | #include <QVBoxLayout> | ||
37 | 38 | | |||
38 | #include <KActionCollection> | 39 | #include <KActionCollection> | ||
39 | #include <KConfigGroup> | 40 | #include <KConfigGroup> | ||
Show All 18 Lines | |||||
58 | #include <project/interfaces/ibuildsystemmanager.h> | 59 | #include <project/interfaces/ibuildsystemmanager.h> | ||
59 | #include <project/interfaces/iprojectbuilder.h> | 60 | #include <project/interfaces/iprojectbuilder.h> | ||
60 | #include <project/projectchangesmodel.h> | 61 | #include <project/projectchangesmodel.h> | ||
61 | #include <project/projectmodel.h> | 62 | #include <project/projectmodel.h> | ||
62 | #include <project/projectbuildsetmodel.h> | 63 | #include <project/projectbuildsetmodel.h> | ||
63 | #include <projectconfigpage.h> | 64 | #include <projectconfigpage.h> | ||
64 | #include <language/backgroundparser/parseprojectjob.h> | 65 | #include <language/backgroundparser/parseprojectjob.h> | ||
65 | #include <interfaces/iruncontroller.h> | 66 | #include <interfaces/iruncontroller.h> | ||
67 | #include <util/scopeddialog.h> | ||||
66 | #include <vcs/widgets/vcsdiffpatchsources.h> | 68 | #include <vcs/widgets/vcsdiffpatchsources.h> | ||
67 | #include <vcs/widgets/vcscommitdialog.h> | 69 | #include <vcs/widgets/vcscommitdialog.h> | ||
68 | 70 | | |||
69 | #include "core.h" | 71 | #include "core.h" | ||
70 | // TODO: Should get rid off this include (should depend on IProject only) | 72 | // TODO: Should get rid off this include (should depend on IProject only) | ||
71 | #include "project.h" | 73 | #include "project.h" | ||
72 | #include "mainwindow.h" | 74 | #include "mainwindow.h" | ||
73 | #include "shellextension.h" | 75 | #include "shellextension.h" | ||
▲ Show 20 Lines • Show All 340 Lines • ▼ Show 20 Line(s) | 412 | { | |||
414 | return (grp.readEntry( "Name", QString() ) == dlg->projectName() || dlg->projectName() == defaultName) && | 416 | return (grp.readEntry( "Name", QString() ) == dlg->projectName() || dlg->projectName() == defaultName) && | ||
415 | grp.readEntry( "Manager", QString() ) == dlg->projectManager(); | 417 | grp.readEntry( "Manager", QString() ) == dlg->projectManager(); | ||
416 | } | 418 | } | ||
417 | 419 | | |||
418 | QUrl ProjectDialogProvider::askProjectConfigLocation(bool fetch, const QUrl& startUrl, | 420 | QUrl ProjectDialogProvider::askProjectConfigLocation(bool fetch, const QUrl& startUrl, | ||
419 | const QUrl& repoUrl, IPlugin* vcsOrProviderPlugin) | 421 | const QUrl& repoUrl, IPlugin* vcsOrProviderPlugin) | ||
420 | { | 422 | { | ||
421 | Q_ASSERT(d); | 423 | Q_ASSERT(d); | ||
422 | OpenProjectDialog dlg(fetch, startUrl, repoUrl, vcsOrProviderPlugin, Core::self()->uiController()->activeMainWindow()); | 424 | ScopedDialog<OpenProjectDialog> dlg(fetch, startUrl, repoUrl, vcsOrProviderPlugin, | ||
423 | if(dlg.exec() == QDialog::Rejected) | 425 | Core::self()->uiController()->activeMainWindow()); | ||
426 | if(dlg->exec() == QDialog::Rejected) { | ||||
424 | return QUrl(); | 427 | return QUrl(); | ||
428 | } | ||||
425 | 429 | | |||
426 | QUrl projectFileUrl = dlg.projectFileUrl(); | 430 | QUrl projectFileUrl = dlg->projectFileUrl(); | ||
427 | qCDebug(SHELL) << "selected project:" << projectFileUrl << dlg.projectName() << dlg.projectManager(); | 431 | qCDebug(SHELL) << "selected project:" << projectFileUrl << dlg->projectName() << dlg->projectManager(); | ||
428 | if ( dlg.projectManager() == QLatin1String("<built-in>") ) { | 432 | if ( dlg->projectManager() == QLatin1String("<built-in>") ) { | ||
429 | return projectFileUrl; | 433 | return projectFileUrl; | ||
430 | } | 434 | } | ||
431 | 435 | | |||
432 | // controls if existing project file should be saved | 436 | // controls if existing project file should be saved | ||
433 | bool writeProjectConfigToFile = true; | 437 | bool writeProjectConfigToFile = true; | ||
434 | if( projectFileExists( projectFileUrl ) ) | 438 | if( projectFileExists( projectFileUrl ) ) | ||
435 | { | 439 | { | ||
436 | // check whether config is equal | 440 | // check whether config is equal | ||
437 | bool shouldAsk = true; | 441 | bool shouldAsk = true; | ||
438 | if( projectFileUrl == dlg.selectedUrl() ) | 442 | if( projectFileUrl == dlg->selectedUrl() ) | ||
439 | { | 443 | { | ||
440 | if( projectFileUrl.isLocalFile() ) | 444 | if( projectFileUrl.isLocalFile() ) | ||
441 | { | 445 | { | ||
442 | shouldAsk = !equalProjectFile( projectFileUrl.toLocalFile(), &dlg ); | 446 | shouldAsk = !equalProjectFile( projectFileUrl.toLocalFile(), dlg ); | ||
443 | } else { | 447 | } else { | ||
444 | shouldAsk = false; | 448 | shouldAsk = false; | ||
445 | 449 | | |||
446 | QTemporaryFile tmpFile; | 450 | QTemporaryFile tmpFile; | ||
447 | if (tmpFile.open()) { | 451 | if (tmpFile.open()) { | ||
448 | auto downloadJob = KIO::file_copy(projectFileUrl, QUrl::fromLocalFile(tmpFile.fileName())); | 452 | auto downloadJob = KIO::file_copy(projectFileUrl, QUrl::fromLocalFile(tmpFile.fileName())); | ||
449 | KJobWidgets::setWindow(downloadJob, qApp->activeWindow()); | 453 | KJobWidgets::setWindow(downloadJob, qApp->activeWindow()); | ||
450 | if (downloadJob->exec()) { | 454 | if (downloadJob->exec()) { | ||
451 | shouldAsk = !equalProjectFile(tmpFile.fileName(), &dlg); | 455 | shouldAsk = !equalProjectFile(tmpFile.fileName(), dlg); | ||
452 | } | 456 | } | ||
453 | } | 457 | } | ||
454 | } | 458 | } | ||
455 | } | 459 | } | ||
456 | 460 | | |||
457 | if ( shouldAsk ) | 461 | if ( shouldAsk ) | ||
458 | { | 462 | { | ||
459 | KGuiItem yes = KStandardGuiItem::yes(); | 463 | KGuiItem yes = KStandardGuiItem::yes(); | ||
Show All 18 Lines | 481 | { | |||
478 | return QUrl(); | 482 | return QUrl(); | ||
479 | } // else fall through and write new file | 483 | } // else fall through and write new file | ||
480 | } else { | 484 | } else { | ||
481 | writeProjectConfigToFile = false; | 485 | writeProjectConfigToFile = false; | ||
482 | } | 486 | } | ||
483 | } | 487 | } | ||
484 | 488 | | |||
485 | if (writeProjectConfigToFile) { | 489 | if (writeProjectConfigToFile) { | ||
486 | if (!writeProjectSettingsToConfigFile(projectFileUrl, &dlg)) { | 490 | if (!writeProjectSettingsToConfigFile(projectFileUrl, dlg)) { | ||
487 | KMessageBox::error(d->m_core->uiControllerInternal()->defaultMainWindow(), | 491 | KMessageBox::error(d->m_core->uiControllerInternal()->defaultMainWindow(), | ||
488 | i18n("Unable to create configuration file %1", projectFileUrl.url())); | 492 | i18n("Unable to create configuration file %1", projectFileUrl.url())); | ||
489 | return QUrl(); | 493 | return QUrl(); | ||
490 | } | 494 | } | ||
491 | } | 495 | } | ||
496 | | ||||
492 | return projectFileUrl; | 497 | return projectFileUrl; | ||
493 | } | 498 | } | ||
494 | 499 | | |||
495 | bool ProjectDialogProvider::userWantsReopen() | 500 | bool ProjectDialogProvider::userWantsReopen() | ||
496 | { | 501 | { | ||
497 | Q_ASSERT(d); | 502 | Q_ASSERT(d); | ||
498 | return (KMessageBox::questionYesNo( d->m_core->uiControllerInternal()->defaultMainWindow(), | 503 | return (KMessageBox::questionYesNo( d->m_core->uiControllerInternal()->defaultMainWindow(), | ||
499 | i18n( "Reopen the current project?" ) ) | 504 | i18n( "Reopen the current project?" ) ) | ||
▲ Show 20 Lines • Show All 280 Lines • ▼ Show 20 Line(s) | 784 | foreach(Sublime::MainWindow* window, Core::self()->uiController()->controller()->mainWindows()) | |||
780 | window->close(); | 785 | window->close(); | ||
781 | } | 786 | } | ||
782 | #endif | 787 | #endif | ||
783 | } | 788 | } | ||
784 | } | 789 | } | ||
785 | } | 790 | } | ||
786 | 791 | | |||
787 | if ( ! existingSessions.isEmpty() ) { | 792 | if ( ! existingSessions.isEmpty() ) { | ||
788 | QDialog dialog(Core::self()->uiControllerInternal()->activeMainWindow()); | 793 | ScopedDialog<QDialog> dialog(Core::self()->uiControllerInternal()->activeMainWindow()); | ||
789 | dialog.setWindowTitle(i18n("Project Already Open")); | 794 | dialog->setWindowTitle(i18n("Project Already Open")); | ||
790 | 795 | | |||
791 | auto mainLayout = new QVBoxLayout(&dialog); | 796 | auto mainLayout = new QVBoxLayout(dialog); | ||
792 | mainLayout->addWidget(new QLabel(i18n("The project you're trying to open is already open in at least one " | 797 | mainLayout->addWidget(new QLabel(i18n("The project you're trying to open is already open in at least one " | ||
793 | "other session.<br>What do you want to do?"))); | 798 | "other session.<br>What do you want to do?"))); | ||
794 | QGroupBox sessions; | 799 | QGroupBox sessions; | ||
795 | sessions.setLayout(new QVBoxLayout); | 800 | sessions.setLayout(new QVBoxLayout); | ||
796 | QRadioButton* newSession = new QRadioButton(i18n("Add project to current session")); | 801 | QRadioButton* newSession = new QRadioButton(i18n("Add project to current session")); | ||
797 | sessions.layout()->addWidget(newSession); | 802 | sessions.layout()->addWidget(newSession); | ||
798 | newSession->setChecked(true); | 803 | newSession->setChecked(true); | ||
799 | foreach ( const Session* session, existingSessions ) { | 804 | foreach ( const Session* session, existingSessions ) { | ||
800 | QRadioButton* button = new QRadioButton(i18n("Open session %1", session->description())); | 805 | QRadioButton* button = new QRadioButton(i18n("Open session %1", session->description())); | ||
801 | button->setProperty("sessionid", session->id().toString()); | 806 | button->setProperty("sessionid", session->id().toString()); | ||
802 | sessions.layout()->addWidget(button); | 807 | sessions.layout()->addWidget(button); | ||
803 | } | 808 | } | ||
804 | sessions.layout()->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding)); | 809 | sessions.layout()->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding)); | ||
805 | mainLayout->addWidget(&sessions); | 810 | mainLayout->addWidget(&sessions); | ||
806 | 811 | | |||
807 | auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Abort); | 812 | auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Abort); | ||
808 | auto okButton = buttonBox->button(QDialogButtonBox::Ok); | 813 | auto okButton = buttonBox->button(QDialogButtonBox::Ok); | ||
809 | okButton->setDefault(true); | 814 | okButton->setDefault(true); | ||
810 | okButton->setShortcut(Qt::CTRL | Qt::Key_Return); | 815 | okButton->setShortcut(Qt::CTRL | Qt::Key_Return); | ||
811 | connect(buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept); | 816 | connect(buttonBox, &QDialogButtonBox::accepted, dialog, &QDialog::accept); | ||
812 | connect(buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject); | 817 | connect(buttonBox, &QDialogButtonBox::rejected, dialog, &QDialog::reject); | ||
813 | mainLayout->addWidget(buttonBox); | 818 | mainLayout->addWidget(buttonBox); | ||
814 | 819 | | |||
815 | bool success = dialog.exec(); | 820 | if (!dialog->exec()) | ||
816 | if (!success) | | |||
817 | return; | 821 | return; | ||
818 | 822 | | |||
819 | foreach ( const QObject* obj, sessions.children() ) { | 823 | foreach ( const QObject* obj, sessions.children() ) { | ||
820 | if ( const QRadioButton* button = qobject_cast<const QRadioButton*>(obj) ) { | 824 | if ( const QRadioButton* button = qobject_cast<const QRadioButton*>(obj) ) { | ||
821 | QString sessionid = button->property("sessionid").toString(); | 825 | QString sessionid = button->property("sessionid").toString(); | ||
822 | if ( button->isChecked() && ! sessionid.isEmpty() ) { | 826 | if ( button->isChecked() && ! sessionid.isEmpty() ) { | ||
823 | Core::self()->sessionController()->loadSession(sessionid); | 827 | Core::self()->sessionController()->loadSession(sessionid); | ||
824 | return; | 828 | return; | ||
▲ Show 20 Lines • Show All 328 Lines • ▼ Show 20 Line(s) | 1156 | if(vcs) { | |||
1153 | ICore::self()->documentController()->saveAllDocuments(KDevelop::IDocument::Silent); | 1157 | ICore::self()->documentController()->saveAllDocuments(KDevelop::IDocument::Silent); | ||
1154 | 1158 | | |||
1155 | const Path basePath = project->path(); | 1159 | const Path basePath = project->path(); | ||
1156 | VCSCommitDiffPatchSource* patchSource = new VCSCommitDiffPatchSource(new VCSStandardDiffUpdater(vcs, basePath.toUrl())); | 1160 | VCSCommitDiffPatchSource* patchSource = new VCSCommitDiffPatchSource(new VCSStandardDiffUpdater(vcs, basePath.toUrl())); | ||
1157 | 1161 | | |||
1158 | bool ret = showVcsDiff(patchSource); | 1162 | bool ret = showVcsDiff(patchSource); | ||
1159 | 1163 | | |||
1160 | if(!ret) { | 1164 | if(!ret) { | ||
1161 | VcsCommitDialog *commitDialog = new VcsCommitDialog(patchSource); | 1165 | ScopedDialog<VcsCommitDialog> commitDialog(patchSource); | ||
1162 | commitDialog->setCommitCandidates(patchSource->infos()); | 1166 | commitDialog->setCommitCandidates(patchSource->infos()); | ||
1163 | commitDialog->exec(); | 1167 | commitDialog->exec(); | ||
1164 | } | 1168 | } | ||
1165 | } | 1169 | } | ||
1166 | } | 1170 | } | ||
1167 | } | 1171 | } | ||
1168 | 1172 | | |||
1169 | QString ProjectController::mapSourceBuild( const QString& path_, bool reverse, bool fallbackRoot ) const | 1173 | QString ProjectController::mapSourceBuild( const QString& path_, bool reverse, bool fallbackRoot ) const | ||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |