xmlqtkdevelopkde4

Trying to add to a toolbar and menubar in KDevelop 4


How do I add to a toolbar or menubar for a KDevelop 4 plugin. I know I need to use a .rc file but I'm not sure the exact syntax of that xml file and also what I need to put in my code in order for KDevelop to show a toolbar.

void CSCMKPlugin::createActionsForMainWindow(Sublime::MainWindow*,
                                         QString& xmlFile, KActionCollection& actions)
{
xmlFile="kdevs.rc";

KAction*  startS = actions.addAction("startS");
startS->setText(i18n("Start S"));
// todo add icon
connect(startS, SIGNAL(triggered(bool)), this,
        SLOT(slotStartS()));
}

and then I have a slot that Starts S but thats not necessary in this question and then here is my xml file.

<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kdevs" version="1">
<MenuBar>
<Menu name="S">
    <Action name="startS"
</Menu>
</MenuBar>

</kpartgui>

Please tell me what I'm doing wrong and if you know any good resources in order to learn how to put different controls in a KDevelop 4 plugin.


Solution

  • For a tutorial about how to use the KPart API, try this: http://techbase.kde.org/Development/Tutorials/Using_KParts

    In KDevelop's kdevplatform repository you'll find plugins/contextbrowser/kdevcontextbrowser.rc. This shows how a kpart rc file should look like. It also makes use of the "ToolBar" tag.

    From the tutorial:

    <ToolBar noMerge="1" name="mainToolBar"><text>Main Toolbar</text>
      <Action name="file_open"/>
      <Merge/>
    </ToolBar>
    

    A general recommendation: just look at the existing plugins in kdevplatform to learn how things work together. Or join #kdevelop on Freenode.