diff --git a/app/main.cpp b/app/main.cpp --- a/app/main.cpp +++ b/app/main.cpp @@ -451,6 +451,7 @@ parser.addOption(QCommandLineOption{QStringList{"ps", "pick-session"}, i18n("Shows all available sessions and lets you select one to open.")}); parser.addOption(QCommandLineOption{QStringList{"pss", "pick-session-shell"}, i18n("List all available sessions on shell and lets you select one to open.")}); parser.addOption(QCommandLineOption{QStringList{"l", "list-sessions"}, i18n("List available sessions and quit.")}); + parser.addOption(QCommandLineOption{QStringList{"f", "fetch"}, i18n("Open KDevelop and fetch the given project."), QStringLiteral("fetch")}); parser.addOption(QCommandLineOption{QStringList{"p", "project"}, i18n("Open KDevelop and load the given project."), QStringLiteral("project")}); parser.addOption(QCommandLineOption{QStringList{"d", "debug"}, i18n("Start debugging an application in KDevelop with the given debugger.\n" @@ -706,6 +707,11 @@ } } + const auto fetchUrlStrings = parser.values(QStringLiteral("fetch")); + for (const auto& fetchUrlString : fetchUrlStrings) { + core->projectControllerInternal()->fetchProjectFromUrl(QUrl::fromUserInput(fetchUrlString)); + } + const QString debugStr = QStringLiteral("debug"); if ( parser.isSet(debugStr) ) { Q_ASSERT( !debugeeName.isEmpty() ); diff --git a/kdevplatform/shell/mainwindow.cpp b/kdevplatform/shell/mainwindow.cpp --- a/kdevplatform/shell/mainwindow.cpp +++ b/kdevplatform/shell/mainwindow.cpp @@ -59,7 +59,6 @@ #include #include -#include #include #include #include @@ -247,21 +246,7 @@ bool eventUsed = false; if (urls.size() == 1) { - const QUrl& url = urls.at(0); - // TODO: query also projectprovider plugins, and that before plain vcs plugins - // e.g. KDE provider plugin could catch URLs from mirror or pickup kde:repo things - - auto* pluginController = Core::self()->pluginController(); - const auto& plugins = pluginController->allPluginsForExtension(QStringLiteral("org.kdevelop.IBasicVersionControl")); - - for (auto* plugin : plugins) { - auto* iface = plugin->extension(); - if (iface->isValidRemoteRepositoryUrl(url)) { - Core::self()->projectControllerInternal()->fetchProjectFromUrl(url, plugin); - eventUsed = true; - break; - } - } + eventUsed = Core::self()->projectControllerInternal()->fetchProjectFromUrl(urls.at(0)); } if (!eventUsed) { diff --git a/kdevplatform/shell/projectcontroller.h b/kdevplatform/shell/projectcontroller.h --- a/kdevplatform/shell/projectcontroller.h +++ b/kdevplatform/shell/projectcontroller.h @@ -96,7 +96,11 @@ ContextMenuExtension contextMenuExtension(KDevelop::Context* ctx, QWidget* parent); - void fetchProjectFromUrl(const QUrl& repoUrl, IPlugin* vcsOrProviderPlugin); + /** + * @param repoUrl url identifying the repo + * @returns @c true if a plugin was found to handle the repo (also if user cancelled), @c false otherwise + */ + bool fetchProjectFromUrl(const QUrl& repoUrl); public Q_SLOTS: Q_SCRIPTABLE void openProjectForUrl( const QString &sourceUrl ) { openProjectForUrl(QUrl(sourceUrl)); } diff --git a/kdevplatform/shell/projectcontroller.cpp b/kdevplatform/shell/projectcontroller.cpp --- a/kdevplatform/shell/projectcontroller.cpp +++ b/kdevplatform/shell/projectcontroller.cpp @@ -847,13 +847,35 @@ } } -void ProjectController::fetchProjectFromUrl(const QUrl& repoUrl, IPlugin* vcsOrProviderPlugin) +bool ProjectController::fetchProjectFromUrl(const QUrl& repoUrl) { + IPlugin* vcsOrProviderPlugin = nullptr; + + // TODO: query also projectprovider plugins, and that before plain vcs plugins + // e.g. KDE provider plugin could catch URLs from mirror or pickup kde:repo things + auto* pluginController = d->m_core->pluginController(); + const auto& vcsPlugins = pluginController->allPluginsForExtension(QStringLiteral("org.kdevelop.IBasicVersionControl")); + + for (auto* plugin : vcsPlugins) { + auto* iface = plugin->extension(); + if (iface->isValidRemoteRepositoryUrl(repoUrl)) { + vcsOrProviderPlugin = plugin; + break; + } + } + if (!vcsOrProviderPlugin) { + KMessageBox::error(Core::self()->uiController()->activeMainWindow(), + i18n("No enabled plugin supports this repository URL: %1", repoUrl.toDisplayString())); + return false; + } + const QUrl url = d->dialog->askProjectConfigLocation(true, QUrl(), repoUrl, vcsOrProviderPlugin); if (!url.isEmpty()) { d->importProject(url); } + + return true; } void ProjectController::fetchProject() diff --git a/plugins/bazaar/CMakeLists.txt b/plugins/bazaar/CMakeLists.txt --- a/plugins/bazaar/CMakeLists.txt +++ b/plugins/bazaar/CMakeLists.txt @@ -17,3 +17,5 @@ if(BUILD_TESTING) add_subdirectory(tests) endif() + +install(PROGRAMS org.kde.kdevelop_bzr.desktop DESTINATION ${KDE_INSTALL_APPDIR}) diff --git a/plugins/bazaar/org.kde.kdevelop_bzr.desktop b/plugins/bazaar/org.kde.kdevelop_bzr.desktop new file mode 100644 --- /dev/null +++ b/plugins/bazaar/org.kde.kdevelop_bzr.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=Application +Exec=kdevelop --ps --fetch %U +MimeType=x-scheme-handler/bzr;x-scheme-handler/bzr+ssh;x-scheme-handler/lp; +Icon=kdevelop +Terminal=false +Name=KDevelop (Fetch Bazaar Project) +GenericName=Integrated Development Environment +Categories=Qt;KDE;Development;IDE; +NoDisplay=true diff --git a/plugins/git/CMakeLists.txt b/plugins/git/CMakeLists.txt --- a/plugins/git/CMakeLists.txt +++ b/plugins/git/CMakeLists.txt @@ -33,5 +33,7 @@ endif() add_subdirectory(icons) +install(PROGRAMS org.kde.kdevelop_git.desktop DESTINATION ${KDE_INSTALL_APPDIR}) + install(FILES kdevgit.xml DESTINATION ${KDE_INSTALL_MIMEDIR}) update_xdg_mimetypes(${KDE_INSTALL_MIMEDIR}) diff --git a/plugins/git/org.kde.kdevelop_git.desktop b/plugins/git/org.kde.kdevelop_git.desktop new file mode 100644 --- /dev/null +++ b/plugins/git/org.kde.kdevelop_git.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=Application +Exec=kdevelop --ps --fetch %U +MimeType=x-scheme-handler/git;x-scheme-handler/git+ssh; +Icon=kdevelop +Terminal=false +Name=KDevelop (Fetch git Project) +GenericName=Integrated Development Environment +Categories=Qt;KDE;Development;IDE; +NoDisplay=true diff --git a/plugins/subversion/CMakeLists.txt b/plugins/subversion/CMakeLists.txt --- a/plugins/subversion/CMakeLists.txt +++ b/plugins/subversion/CMakeLists.txt @@ -68,3 +68,5 @@ KDev::Project kdevsvncpp ) + +install(PROGRAMS org.kde.kdevelop_svn.desktop DESTINATION ${KDE_INSTALL_APPDIR}) diff --git a/plugins/subversion/org.kde.kdevelop_svn.desktop b/plugins/subversion/org.kde.kdevelop_svn.desktop new file mode 100644 --- /dev/null +++ b/plugins/subversion/org.kde.kdevelop_svn.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=Application +Exec=kdevelop --ps --fetch %U +MimeType=x-scheme-handler/svn;x-scheme-handler/svn+ssh; +Icon=kdevelop +Terminal=false +Name=KDevelop (Fetch Subversion Project) +GenericName=Integrated Development Environment +Categories=Qt;KDE;Development;IDE; +NoDisplay=true