Commit 1f35917b authored by Thomas Friedrichsmeier's avatar Thomas Friedrichsmeier
Browse files

A few more bits of adjusting plugin UI

parent f3a35e6c
......@@ -63,7 +63,16 @@ namespace RKCommonFunctions {
}
}
void moveContainer (KXMLGUIClient *client, const QString &tagname, const QString &name, const QString &to_name, bool recursive) {
void moveContainer (KXMLGUIClient *client, const QString &tagname, const QString &name, const QString &to_name, bool recursive, bool flatten) {
// recurse first
if (recursive) {
QList<KXMLGUIClient*> children = client->childClients ();
QList<KXMLGUIClient*>::const_iterator it;
for (it = children.constBegin (); it != children.constEnd (); ++it) {
moveContainer (*it, tagname, name, to_name, true);
}
}
QDomDocument doc = client->xmlguiBuildDocument ();
if (doc.documentElement ().isNull ()) doc = client->domDocument ();
......@@ -73,33 +82,37 @@ namespace RKCommonFunctions {
QDomElement from_elem;
QDomElement to_elem;
QDomNodeList list = e.elementsByTagName (tagname);
const QString name_attr ("name");
const QDomNodeList list = e.elementsByTagName (tagname);
int count = list.count ();
for (int i = 0; i < count; ++i) {
QDomElement elem = list.item (i).toElement ();
const QDomElement elem = list.item (i).toElement ();
if (elem.isNull ()) continue;
if (elem.attribute ("name") == name) {
if (elem.attribute (name_attr) == name) {
from_elem = elem;
} else if (elem.attribute ("name") == to_name) {
} else if (elem.attribute (name_attr) == to_name) {
to_elem = elem;
}
}
if (from_elem.isNull ()) return;
if (to_elem.isNull ()) { // if no place to move to, just rename (Note: children will be moved, below)
to_elem = from_elem.cloneNode (false).toElement ();
to_elem.setAttribute (name_attr, to_name);
from_elem.parentNode().appendChild(to_elem);
}
// move
from_elem.parentNode ().removeChild (from_elem);
to_elem.appendChild (from_elem);
if (flatten) {
while (from_elem.hasChildNodes()) {
to_elem.appendChild (from_elem.firstChild());
}
} else {
to_elem.appendChild (from_elem);
}
// set result
client->setXMLGUIBuildDocument (doc);
// recurse
if (recursive) {
QList<KXMLGUIClient*> children = client->childClients ();
QList<KXMLGUIClient*>::const_iterator it;
for (it = children.constBegin (); it != children.constEnd (); ++it) {
moveContainer (*it, tagname, name, to_name, true);
}
}
}
QString getCurrentSymbol (const QString &context_line, int cursor_pos, bool strict) {
......
......@@ -2,7 +2,7 @@
rkcommonfunctions - description
-------------------
begin : Mon Oct 17 2005
copyright : (C) 2005, 2006, 2007, 2009, 2010, 2011 by Thomas Friedrichsmeier
copyright : (C) 2005-2020 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
......@@ -36,7 +36,7 @@ namespace RKCommonFunctions {
/** remove containers (actions, menus, etc.) with attribute 'name="..."' from KXMLGUIClient from s XML gui, where "..." is any of the strings in names. If recursive, also removes those containers from child clients. */
void removeContainers (KXMLGUIClient *from, const QStringList &names, bool recursive);
/** move container (action, menu, etc.) with tagname "tagname" and attribute 'name="..."' to be a child node of the tag with tagname=tagname and attribute name=to_name. Can be used to make a top-level menu a sub-menu of another menu instead */
void moveContainer (KXMLGUIClient *client, const QString &tagname, const QString &name, const QString &to_name, bool recursive);
void moveContainer (KXMLGUIClient *client, const QString &tagname, const QString &name, const QString &to_name, bool recursive, bool flatten=false);
/** Get the base directory where RKWard data files are stored */
QString getRKWardDataDir ();
......
......@@ -37,6 +37,7 @@
#include "rkworkplaceview.h"
#include "rkcommandeditorwindow.h"
#include "../misc/rkdummypart.h"
#include "../misc/rkcommonfunctions.h"
#include "../settings/rksettingsmodulecommandeditor.h"
#include "../debug.h"
......@@ -467,9 +468,10 @@ void fixupPluginUI(const QString &id, int num_of_client, KXMLGUIClient* client,
if (num_of_client == 0) {
if (id == QStringLiteral("katesearchplugin")) {
window->setCaption("Search in Scripts");
// TODO
RKCommonFunctions::removeContainers(client, QStringList() << "search_in_files", true);
}
}
RKCommonFunctions::moveContainer(client, "Menu", "tools", "edit", true, true);
}
QObject* KatePluginIntegrationWindow::createPluginView(KTextEditor::Plugin* plugin) {
......@@ -514,7 +516,6 @@ void KatePluginIntegrationWindow::catchXMLGUIClientsHack(KXMLGUIClient* client)
// TODO: Don't forget to make sure to emit all the signals!
// - MainWindow signals
// - pluginDeleted
// TODO: Apply plugin specific hacks as needed (e.g. moving "Tool" menu, removing broken actions)
// TODO: new RKToplevelWindowGUI should be called after all plugins are loaded (and have registered their tool views). However
// that may be a problem, if there is no KXMLGUIFactory around, yet. So, annoyingly, we need to create the GUI, before we
......
Supports Markdown
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