[Qt-creator] Use git plugin in another plugin

Thorbjørn Lindeijer thorbjorn.lindeijer at nokia.com
Fri Apr 23 16:10:34 CEST 2010


On 02/23/2010 09:04 AM, ext Liebe Markus (RtP2/TEF72) wrote:
> Hi there,
>
> I want to use the gitplugin in an own plugin. I have the SHA ID of a commit and want to display the diff for this commit.
> To display the diff I'd like to use the screen you get via: Git ->  Log ->  click on the SHA ID.
> I digged around in the code and found that
> void GitClient::show(const QString&source, const QString&id)
>
> Seems to be the function that I'd like to call.
>
> Is it possible to access this function from within my plugin? And if so, how would I do that?

You would have to make the Git plugin export this function, and then 
link your plugin with the Git plugin and mark it as a dependency in both 
its pluginspec file and, if your plugin is inside the Qt Creator source 
tree, in the plugins.pro file.

You can look at other plugins for how to export GitClient from the Git 
plugin. You need to define GIT_LIBRARY in git.pro, write a 
git_dependencies.pri and include the Git plugin's dependencies there, 
write a git.pri that includes this git_dependencies.pri and also adds 
-l$$qtLibraryTarget(ScmGit) to LIBS, and then include this git.pri in 
the .pro file of your plugin.

Then, add a git_global.h file to the Git plugin, similar to the 
_global.h files found in other plugins. Include that in gitclient.h and 
add then use GIT_EXPORT like "class GIT_EXPORT GitClient ...".

I guess I probably still missed something, but that's the general idea. :-)

Regards,
Bjørn

-- 
Thorbjørn Lindeijer
Software Engineer
Nokia, Qt Development Frameworks



More information about the Qt-creator-old mailing list