Development/Tutorials/Writing kontact plugins: Difference between revisions

From KDE TechBase
Line 16: Line 16:
The following is what you do
The following is what you do
* write a subclass mypart of KParts::Part
* write a subclass mypart of KParts::Part
** because [http://api.kde.org/4.x-api/kdelibs-apidocs/kparts/html/classKParts_1_1Part.html#399fea8c8f8d4ee321118d1ec85775db setWidget] is protected
** use a Widget in it and use setWidget to get your widget into the KPart
** use a Widget in it and use setWidget to get your widget into the KPart
* write a subclass mypartmainwindow of KParts::MainWindow
* write a subclass mypartmainwindow of KParts::MainWindow

Revision as of 18:41, 9 February 2008

Kontact plugins are KParts that get loaded at runtime. To integrate your KPart into kontact, you will need to have a .desktop file like this:

ls /home/kde-devel/kde/share/kde4/services/kontact/
akregatorplugin.desktop     knotesplugin.desktop
akregatorplugin3.2.desktop  korganizerplugin.desktop
journalplugin.desktop       newstickerplugin.desktop
kaddressbookplugin.desktop  plannerplugin.desktop
karmplugin.desktop          specialdatesplugin.desktop
kmailplugin.desktop         summaryplugin.desktop
kmobiletools.desktop        todoplugin.desktop
knodeplugin.desktop         weatherplugin.desktop

Writing a KPart

The following is what you do

  • write a subclass mypart of KParts::Part
    • because setWidget is protected
    • use a Widget in it and use setWidget to get your widget into the KPart
  • write a subclass mypartmainwindow of KParts::MainWindow
  • write main.cpp
    • use new mypart(mw) to get your part into your main window

See also