Commit 12b1096a authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Register kdevelop as handler for repo urls, add --fetch argument

Summary:
Allows to speed-up the import of new projects, just clicking a repo url
would start a kdevelop instance right into the import dialog, with data
prefilled.

Using --ps argument with the handlers allows to keep control with which
session a project should be fetched.

Test Plan:
Calling kdevelop --fetch git://anongit.kde.org/kdevelop.git starts last
kdevelop session right into fetch dialog.
Invoking a handler onto a git://anongit.kde.org/kdevelop.git starts
kdevelop, asks for session and then proceeds into fetch dialog.
DnD of repo urls onto the mainwindow works as before

Reviewers: #kdevelop, apol, kfunk

Reviewed By: #kdevelop, apol, kfunk

Subscribers: kfunk, apol, kdevelop-devel

Differential Revision: https://phabricator.kde.org/D8830
parent 17d91fb2
......@@ -451,6 +451,7 @@ int main( int argc, char *argv[] )
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 @@ int main( int argc, char *argv[] )
}
}
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() );
......
......@@ -59,7 +59,6 @@ Boston, MA 02110-1301, USA.
#include <interfaces/isession.h>
#include <interfaces/iprojectcontroller.h>
#include <vcs/interfaces/ibasicversioncontrol.h>
#include <sublime/view.h>
#include <sublime/document.h>
#include <sublime/urldocument.h>
......@@ -247,21 +246,7 @@ void MainWindow::dropEvent( QDropEvent* ev )
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<IBasicVersionControl>();
if (iface->isValidRemoteRepositoryUrl(url)) {
Core::self()->projectControllerInternal()->fetchProjectFromUrl(url, plugin);
eventUsed = true;
break;
}
}
eventUsed = Core::self()->projectControllerInternal()->fetchProjectFromUrl(urls.at(0));
}
if (!eventUsed) {
......
......@@ -847,13 +847,35 @@ void ProjectController::openProject( const QUrl &projectFile )
}
}
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<IBasicVersionControl>();
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()
......
......@@ -96,7 +96,11 @@ public:
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)); }
......
......@@ -17,3 +17,5 @@ add_subdirectory(icons)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
install(PROGRAMS org.kde.kdevelop_bzr.desktop DESTINATION ${KDE_INSTALL_APPDIR})
[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
......@@ -33,5 +33,7 @@ if(BUILD_TESTING)
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})
[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
......@@ -68,3 +68,5 @@ target_link_libraries(kdevsubversion
KDev::Project
kdevsvncpp
)
install(PROGRAMS org.kde.kdevelop_svn.desktop DESTINATION ${KDE_INSTALL_APPDIR})
[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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment