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

Add show/hide actions for all plugin tool windows, too.

parent 1f35917b
......@@ -159,10 +159,13 @@ RKWardMainWindow::RKWardMainWindow () : KParts::MainWindow ((QWidget *)0, (Qt::W
katePluginIntegration ()->loadPlugin ("katesearchplugin");
katePluginIntegration ()->loadPlugin ("kateprojectplugin");
katePluginIntegration ()->loadPlugin ("katesnippetsplugin");
// This is pretty silly, but while loading plugins the katePluginIntegration-client may gain new actions and thus needs
// to be reloaded. We cannot - currently, KF5.65 - delay loading it, because plugins rely on it having a GUI factory.
// This is pretty convoluted, but while loading plugins the katePluginIntegration-client may gain new actions and thus needs
// to be reloaded. We cannot - currently, KF5.65 - delay loading the UI defintion(s), because plugins rely on it having a GUI factory.
factory()->removeClient (katePluginIntegration ()->mainWindow ());
factory()->addClient (katePluginIntegration ()->mainWindow ());
toplevel_actions->initToolWindowActions ();
factory()->removeClient (toplevel_actions);
factory()->addClient (toplevel_actions);
RKXMLGUISyncer::self ()->watchXMLGUIClientUIrc (this);
// replicate File->import and export menus into the Open/Save toolbar button menus
......
......@@ -31,6 +31,7 @@
#include <KSharedConfig>
#include <KConfigGroup>
#include <KXMLGUIFactory>
#include <KLocalizedString>
#include "../rkward.h"
#include "rkworkplace.h"
......@@ -467,7 +468,7 @@ 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");
window->setCaption(i18nc("Tab title", "Search in Scripts"));
RKCommonFunctions::removeContainers(client, QStringList() << "search_in_files", true);
}
}
......
......@@ -2,7 +2,7 @@
rktoplevelwindowgui - description
-------------------
begin : Tue Apr 24 2007
copyright : (C) 2007, 2009, 2011 by Thomas Friedrichsmeier
copyright : (C) 2007-2020 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
......@@ -26,6 +26,8 @@
#include <kshortcutsdialog.h>
#include <QWhatsThis>
#include <QDomDocument>
#include <QDomElement>
#include "../rkconsole.h"
#include "../windows/robjectbrowser.h"
......@@ -82,15 +84,7 @@ RKTopLevelWindowGUI::RKTopLevelWindowGUI (KXmlGuiWindow *for_window) : QObject (
next_action->setIcon (QIcon (RKCommonFunctions::getRKWardDataDir () + "icons/window_forward.png"));
actionCollection ()->setDefaultShortcut (next_action, Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Tab);
QAction *action;
foreach (const RKToolWindowList::ToolWindowRepresentation& rep, RKToolWindowList::registeredToolWindows ()) {
action = actionCollection ()->addAction ("window_show_" + rep.id, this, SLOT (toggleToolView()));
action->setText (i18n ("Show/Hide %1", rep.window->shortCaption ()));
action->setIcon (rep.window->windowIcon ());
actionCollection ()->setDefaultShortcut (action, rep.default_shortcut);
action->setProperty ("rk_toolwindow_id", rep.id);
}
action = actionCollection ()->addAction ("window_activate_docview", this, SLOT(activateDocumentView()));
QAction* action = actionCollection ()->addAction ("window_activate_docview", this, SLOT(activateDocumentView()));
action->setText (i18n ("Activate Document view"));
actionCollection ()->setDefaultShortcut (action, Qt::AltModifier + Qt::Key_0);
......@@ -107,6 +101,34 @@ RKTopLevelWindowGUI::~RKTopLevelWindowGUI () {
RK_TRACE (APP);
}
void RKTopLevelWindowGUI::initToolWindowActions () {
RK_TRACE (APP);
// Tool window actions
QString action_tag ("Action");
QString name_attr ("name");
QDomDocument doc = xmlguiBuildDocument ();
if (doc.documentElement ().isNull ()) doc = domDocument ();
QDomElement menu = doc.elementsByTagName("Menu").at (1).toElement (); // NOTE: this is known to be the "Windows"-Menu
QDomElement ref = menu.firstChildElement (action_tag);
while (!ref.isNull() && ref.attribute (name_attr) != QLatin1String ("window_show_PLACEHOLDER")) {
ref = ref.nextSiblingElement (action_tag);
}
QAction *action;
foreach (const RKToolWindowList::ToolWindowRepresentation& rep, RKToolWindowList::registeredToolWindows ()) {
QString id = QLatin1String ("window_show_") + rep.id;
action = actionCollection ()->addAction (id, this, SLOT (toggleToolView()));
action->setText (i18n ("Show/Hide %1", rep.window->shortCaption ()));
action->setIcon (rep.window->windowIcon ());
actionCollection ()->setDefaultShortcut (action, rep.default_shortcut);
action->setProperty ("rk_toolwindow_id", rep.id);
QDomElement e = doc.createElement (action_tag);
e.setAttribute (name_attr, id);
menu.insertBefore (e, ref);
}
setXMLGUIBuildDocument (doc);
}
void RKTopLevelWindowGUI::configureShortcuts () {
RK_TRACE (APP);
......
......@@ -2,7 +2,7 @@
rktoplevelwindowgui - description
-------------------
begin : Tue Apr 24 2007
copyright : (C) 2007, 2009, 2011 by Thomas Friedrichsmeier
copyright : (C) 2007-2020 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
......@@ -32,6 +32,7 @@ class RKTopLevelWindowGUI : public QObject, public KXMLGUIClient {
public:
explicit RKTopLevelWindowGUI (KXmlGuiWindow *for_window);
~RKTopLevelWindowGUI ();
void initToolWindowActions ();
public slots:
// windows menu
/** Raise the help search window */
......
<!DOCTYPE kpartgui>
<kpartgui name="rkward_toplevel" version="610">
<kpartgui name="rkward_toplevel" version="710">
<MenuBar>
<Merge/>
<Menu name="window"><text>&amp;Window</text>
......@@ -10,15 +10,8 @@
<Action name="prev_window"/>
<Action name="next_window"/>
<Separator/>
<Action name="window_show_workspace"/>
<Action name="window_show_filebrowser"/>
<Action name="window_show_commandlog"/>
<Action name="window_show_pendingjobs"/>
<Action name="window_show_console"/>
<Action name="window_show_helpsearch"/>
<Action name="window_show_debugconsole"/>
<Action name="window_show_debugframes"/>
<Action name="window_show_rkdebugmessages"/>
<!-- NOTE: Actions for showing / hiding the various tool views are added below this placeholder, dynamically. Since some of those are plugins, their ids cannot be hardcoded, here. -->
<Action name="window_show_PLACEHOLDER"/>
<Separator/>
<Action name="window_activate_docview"/>
</Menu>
......
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