[rkward-cvs] SF.net SVN: rkward:[2601] trunk/rkward/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Aug 6 15:02:04 UTC 2009


Revision: 2601
          http://rkward.svn.sourceforge.net/rkward/?rev=2601&view=rev
Author:   tfry
Date:     2009-08-06 15:02:00 +0000 (Thu, 06 Aug 2009)

Log Message:
-----------
This should finally be a clean solution to syncing KXMLGUIClient on changes.
The RKXMLGUISyncer-class(es) could/should be cleaned up for offering them to kdelibs.

Modified Paths:
--------------
    trunk/rkward/rkward/misc/CMakeLists.txt
    trunk/rkward/rkward/rkward.cpp
    trunk/rkward/rkward/rkward.h
    trunk/rkward/rkward/windows/detachedwindowcontainer.cpp
    trunk/rkward/rkward/windows/detachedwindowcontainer.h
    trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
    trunk/rkward/rkward/windows/rkcommandeditorwindow.h
    trunk/rkward/rkward/windows/rkhtmlwindow.cpp
    trunk/rkward/rkward/windows/rkhtmlwindow.h
    trunk/rkward/rkward/windows/rkmdiwindow.cpp
    trunk/rkward/rkward/windows/rkmdiwindow.h

Added Paths:
-----------
    trunk/rkward/rkward/misc/rkxmlguisyncer.cpp
    trunk/rkward/rkward/misc/rkxmlguisyncer.h

Modified: trunk/rkward/rkward/misc/CMakeLists.txt
===================================================================
--- trunk/rkward/rkward/misc/CMakeLists.txt	2009-08-05 20:01:26 UTC (rev 2600)
+++ trunk/rkward/rkward/misc/CMakeLists.txt	2009-08-06 15:02:00 UTC (rev 2601)
@@ -15,6 +15,7 @@
    rkdummypart.cpp
    rkstandardicons.cpp
    rkstandardactions.cpp
+   rkxmlguisyncer.cpp
    )
 
 QT4_AUTOMOC(${misc_STAT_SRCS})

Added: trunk/rkward/rkward/misc/rkxmlguisyncer.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkxmlguisyncer.cpp	                        (rev 0)
+++ trunk/rkward/rkward/misc/rkxmlguisyncer.cpp	2009-08-06 15:02:00 UTC (rev 2601)
@@ -0,0 +1,175 @@
+/***************************************************************************
+                          rkxmlguisyncer.cpp  -  description
+                             -------------------
+    begin                : Wed Aug 5 2009
+    copyright            : (C) 2009 by Thomas Friedrichsmeier
+    email                : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "rkxmlguisyncer.h"
+
+#include <kxmlguiclient.h>
+#include <kxmlguifactory.h>
+#include <kactioncollection.h>
+#include <kdirwatch.h>
+#include <kapplication.h>
+
+#include <QDir>
+
+#include "../debug.h"
+
+RKXMLGUISyncer* RKXMLGUISyncer::syncer = 0;
+
+//static
+RKXMLGUISyncer *RKXMLGUISyncer::self () {
+	RK_TRACE (MISC);
+
+	if (!syncer) syncer = new RKXMLGUISyncer ();
+	return syncer;
+}
+
+RKXMLGUISyncer::RKXMLGUISyncer () : QObject () {
+	RK_TRACE (MISC);
+
+	file_watcher = KDirWatch::self ();
+	connect (file_watcher, SIGNAL (dirty(const QString&)), this, SLOT (uiRcFileChanged(const QString&)));
+
+	connect (&rebuild_guis_timer, SIGNAL (timeout()), this, SLOT (rebuildGUIs()));
+	rebuild_guis_timer.setSingleShot (true);
+}
+
+RKXMLGUISyncer::~RKXMLGUISyncer () {
+	RK_TRACE (MISC);
+}
+
+void RKXMLGUISyncer::watchXMLGUIClientUIrc (KXMLGUIClient *client, bool recursive) {
+	RK_TRACE (MISC);
+
+	KActionCollection *ac = client->actionCollection ();
+	QString local_xml_file = client->localXMLFile ();
+
+	// local_xml_file *can* be the name of a directory, if the client->xmlFile() is empty.
+	if (ac && (!local_xml_file.isEmpty()) && (!QDir (local_xml_file).exists ())) {
+		RK_ASSERT (ac->parentGUIClient () == client);
+
+		if (!client_map.contains (local_xml_file, ac)) {
+			if (!client_map.contains (local_xml_file)) {
+				file_watcher->addFile (local_xml_file);
+			}
+
+			client_map.insertMulti (local_xml_file, ac);
+			connect (ac, SIGNAL (destroyed(QObject*)), this, SLOT (actionCollectionDestroyed(QObject*)));
+		} // we simply ignore attempts to watch the same client twice
+	}
+
+	if (recursive) {
+		foreach (KXMLGUIClient *child, client->childClients ()) {
+			watchXMLGUIClientUIrc (child, true);
+		}
+	}
+}
+
+void RKXMLGUISyncer::registerChangeListener (KXMLGUIClient *watched_client, QObject *receiver, const char *method) {
+	RK_TRACE (MISC);
+
+	KActionCollection *ac = watched_client->actionCollection ();
+
+	RKXMLGUISyncerNotifier *notifier = new RKXMLGUISyncerNotifier (0);
+	connect (notifier, SIGNAL (changed(KXMLGUIClient*)), receiver, method);
+
+	notifier_map.insertMulti (ac, notifier);
+}
+
+void RKXMLGUISyncer::uiRcFileChanged (const QString &path)  {
+	RK_TRACE (MISC);
+
+	RK_ASSERT (client_map.contains (path));
+
+	// find affected clients and reload them
+	QMultiHash<QString, KActionCollection*>::const_iterator i = client_map.find(path);
+	while (i != client_map.constEnd() && i.key() == path) {
+		KXMLGUIClient *client = const_cast<KXMLGUIClient*> (i.value ()->parentGUIClient ());
+		if (!client) {
+			RK_ASSERT (false);
+			continue;
+		}
+		RK_ASSERT (client->localXMLFile () == path);
+		client->reloadXML ();
+		RK_DO (qDebug ("reloaded client %p for file %s", client, qPrintable (path)), MISC, DL_DEBUG);
+		if (client->factory ()) {
+			affected_factories.insert (client->factory ());
+			connect (client->factory (), SIGNAL (destroyed(QObject*)), this, SLOT (guiFactoryDestroyed(QObject*)));
+		}
+
+		// find notifiers listening for this client
+		QMultiHash<KActionCollection*, RKXMLGUISyncerNotifier*>::const_iterator n = notifier_map.find(i.value ());
+		while (n != notifier_map.constEnd() && n.key() == i.value ()) {
+			n.value ()->emitChangeSignal (client);
+			++n;
+		}
+
+		++i;
+	}
+
+	rebuild_guis_timer.start (0);
+}
+
+void RKXMLGUISyncer::rebuildGUIs () {
+	RK_TRACE (MISC);
+
+	while (!affected_factories.isEmpty ()) {
+		KXMLGUIFactory *factory = *(affected_factories.begin ());
+		affected_factories.remove (factory);
+
+		RK_DO (qDebug ("rebuilding factory %p", factory), MISC, DL_DEBUG);
+		QList<KXMLGUIClient*> clients = factory->clients ();
+		for (int i = clients.size () - 1; i >= 0; --i) {
+			factory->removeClient (clients[i]);
+		}
+		for (int i = 0; i < clients.size (); ++i) {
+			factory->addClient (clients[i]);
+		}
+		RK_DO (qDebug ("done rebuilding factory"), MISC, DL_DEBUG);
+	}
+}
+
+void RKXMLGUISyncer::actionCollectionDestroyed (QObject *object) {
+	RK_TRACE (MISC);
+
+	// warning: Do not call any methods on the ac. It is half-destroyed, already.
+	KActionCollection *ac = static_cast<KActionCollection*> (object);
+
+	// stop listening for the corresponding client
+	QString path_key = client_map.key (static_cast<KActionCollection*> (object));
+	client_map.remove (path_key, ac);
+
+	// if there are no futher clients with this path, stop watching it.
+	if (!client_map.contains (path_key)) {
+		file_watcher->removeFile (path_key);
+	}
+
+	// remove any notifiers, too
+	RKXMLGUISyncerNotifier* notifier;
+	while ((notifier = notifier_map.take (ac))) {
+		notifier->deleteLater ();
+	}
+
+	RK_DO (qDebug ("action collection destroyed. Still watch %d clients with %d notifiers", client_map.size (), notifier_map.size ()), MISC, DL_DEBUG);
+}
+
+void RKXMLGUISyncer::guiFactoryDestroyed (QObject *object) {
+	RK_TRACE (MISC);
+
+	affected_factories.remove (static_cast<KXMLGUIFactory*>(object));
+}
+
+#include "rkxmlguisyncer.moc"

Added: trunk/rkward/rkward/misc/rkxmlguisyncer.h
===================================================================
--- trunk/rkward/rkward/misc/rkxmlguisyncer.h	                        (rev 0)
+++ trunk/rkward/rkward/misc/rkxmlguisyncer.h	2009-08-06 15:02:00 UTC (rev 2601)
@@ -0,0 +1,84 @@
+/***************************************************************************
+                          rkxmlguisyncer.h  -  description
+                             -------------------
+    begin                : Wed Aug 5 2009
+    copyright            : (C) 2009 by Thomas Friedrichsmeier
+    email                : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef RKXMLGUISYNCER_H
+#define RKXMLGUISYNCER_H
+
+#include <QObject>
+#include <QMultiHash>
+#include <QSet>
+#include <QTimer>
+
+class KXMLGUIClient;
+class KActionCollection;
+class KDirWatch;
+class KXMLGUIFactory;
+
+/** For internal use by RKXMLGUISyncer, only */
+class RKXMLGUISyncerNotifier : public QObject {
+Q_OBJECT
+public:
+	RKXMLGUISyncerNotifier (QObject *parent) : QObject (parent) {};
+	~RKXMLGUISyncerNotifier () {};
+
+	void emitChangeSignal (KXMLGUIClient *client) { changed (client); };
+signals:
+	void changed (KXMLGUIClient *client);
+};
+
+/** This class listens for changes in the XMLGUI-configuration files of registered KXMLGUIClients. It then takes care of updating those KXMLGUIClients. */
+class RKXMLGUISyncer : public QObject {
+Q_OBJECT
+public:
+	/** Returns the single static instance of the syncer. If the instance did not exit, yet, it is created, now. */
+	static RKXMLGUISyncer *self ();
+
+	/** start watching for changes in the given KXMLGUIClient's local ui.rc .
+	@param client The client to monitor
+	@param recursive Also monitor the client's child clients? */
+	void watchXMLGUIClientUIrc (KXMLGUIClient *client, bool recursive=true);
+
+	/** You can use this function to receive a signal, when an KXMLGUIClient's ui.rc file has been reloaded (after the reload, before the factory is told to rebuild).
+	@param watched_client The client to monitor. This needs to be registered using watchXMLGUIClientUIrc, first.
+	@param receiver QObject to receive notification
+	@param method slot to recieve notification. This needs to have the signature
+	\code
+		void someSlotName (KXMLGUIClient *changed_client);
+	\endcode
+	*/
+	void registerChangeListener (KXMLGUIClient *watched_client, QObject *receiver, const char *method);
+private slots:
+	void uiRcFileChanged (const QString &path);
+	void actionCollectionDestroyed (QObject *object);
+	void guiFactoryDestroyed (QObject *object);
+	void rebuildGUIs ();
+protected:
+	RKXMLGUISyncer ();
+	~RKXMLGUISyncer ();
+private:
+	/** Internally we store the actionCollection() of each KXMLGUIClient, instead of a pointer to the client, directly. This is because KXMLGUIClient is not a QObject, and so we cannot safely detect its destruction. */
+	QMultiHash<QString, KActionCollection*> client_map;
+	QMultiHash<KActionCollection*, RKXMLGUISyncerNotifier*> notifier_map;
+
+	QSet<KXMLGUIFactory*> affected_factories;
+	QTimer rebuild_guis_timer;
+
+	KDirWatch *file_watcher;
+	static RKXMLGUISyncer *syncer;
+};
+
+#endif

Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp	2009-08-05 20:01:26 UTC (rev 2600)
+++ trunk/rkward/rkward/rkward.cpp	2009-08-06 15:02:00 UTC (rev 2601)
@@ -61,6 +61,7 @@
 #include "core/renvironmentobject.h"
 #include "misc/rkstandardicons.h"
 #include "misc/rkcommonfunctions.h"
+#include "misc/rkxmlguisyncer.h"
 #include "rkglobals.h"
 #include "robjectbrowser.h"
 #include "dialogs/startupdialog.h"
@@ -129,6 +130,7 @@
 	setXMLFile ("rkwardui.rc");
 	insertChildClient (toplevel_actions = new RKTopLevelWindowGUI (this));
 	createShellGUI (true);
+	RKXMLGUISyncer::self ()->watchXMLGUIClientUIrc (this);
 
 	RKGlobals::mtracker = new RKModificationTracker (this);
 	RKComponentMap::initialize ();
@@ -390,41 +392,9 @@
 	run_menu_dummy->setEnabled (false);
 }
 
-void RKWardMainWindow::changeEvent (QEvent *e) {
-	RK_TRACE (APP);
-
-	// see RKWardMainWindow::partChanged() for a detailed comment
-	if ((e->type () == QEvent::ActivationChange) && isActiveWindow () && isVisible ()) {
-		RKMDIWindow *active = RKWorkplace::mainWorkplace ()->activeWindow (RKMDIWindow::Attached);
-		toplevel_actions->reloadXML ();
-		createGUI (0);
-		if (active) {
-			active->fixupPartGUI (true);
-			createGUI (active->getPart ());
-		}
-		// NOTE: KXMLGUIFactory::refreshActionProperties(), which would be a simple repalcement for the above, seems to cause crashes, at least with KDElibs 4.2.2: http://sourceforge.net/tracker/?func=detail&atid=459007&aid=2828002&group_id=50231
-	}
-
-	KParts::MainWindow::changeEvent (e);
-}
-
 void RKWardMainWindow::partChanged (KParts::Part *part) {
 	RK_TRACE (APP);
 
-	/* Changes in shortcut-settings are not automatically synced between all action collections. Therefore, if we change between parts with the same actions, the new part simply does not have any changes that happend while the other part was active.
-	Reliably detecting such changes seems impossible (QAction::changed() gets emitted all the time for all sorts of non-interesting changes as well). So what we do is simply make sure we sync the KXMLGUI-files each time we switch to a new part. Fortunately, the performance impact appears to be small. */
-
-	// first: find out, which window is about to be activated
-	if (part) {
-		QList<RKMDIWindow*> list = RKWorkplace::mainWorkplace ()->getObjectList ();
-		for (int i = 0; i < list.count (); ++i) {
-			if (list[i]->getPart () == part) {
-				// now reload XML and apply customizations
-				list[i]->fixupPartGUI (true);
-				break;
-			}
-		}
-	}
 	createGUI (part);
 
 	if (!guiFactory ()) {

Modified: trunk/rkward/rkward/rkward.h
===================================================================
--- trunk/rkward/rkward/rkward.h	2009-08-05 20:01:26 UTC (rev 2600)
+++ trunk/rkward/rkward/rkward.h	2009-08-06 15:02:00 UTC (rev 2601)
@@ -95,8 +95,6 @@
 	void initStatusBar();
 	/** reimplemented from KMainWindow to call our doQueryClose (), and then (if quitting was not cancelled), invoke an RKQuitAgent to wait for the R-backend to finish up before actually quitting. */
 	virtual void closeEvent (QCloseEvent *e);
-/** may need to reload the active window's XMLGUI definition */
-	void changeEvent (QEvent *);
 signals:
 	void aboutToQuitRKWard ();
 public slots:

Modified: trunk/rkward/rkward/windows/detachedwindowcontainer.cpp
===================================================================
--- trunk/rkward/rkward/windows/detachedwindowcontainer.cpp	2009-08-05 20:01:26 UTC (rev 2600)
+++ trunk/rkward/rkward/windows/detachedwindowcontainer.cpp	2009-08-06 15:02:00 UTC (rev 2601)
@@ -30,6 +30,7 @@
 #include "rktoplevelwindowgui.h"
 #include "../rkward.h"
 #include "../misc/rkstandardicons.h"
+#include "../misc/rkxmlguisyncer.h"
 #include "rkworkplace.h"
 #include "../rkglobals.h"
 #include "../debug.h"
@@ -50,6 +51,7 @@
 	insertChildClient (toplevel_actions = new RKTopLevelWindowGUI (this));
 	statusBar ()->hide ();
 	createShellGUI ();
+	RKXMLGUISyncer::self ()->watchXMLGUIClientUIrc (this);
 
 // copy main window toolbar settings
 	QMap<QString, Qt::ToolButtonStyle> main_window_toolbar_styles;
@@ -125,19 +127,4 @@
 	}
 }
 
-void DetachedWindowContainer::changeEvent (QEvent *e) {
-	RK_TRACE (APP);
-
-	// see RKWardMainWindow::partChanged() for a detailed comment
-	if ((e->type () == QEvent::ActivationChange) && isActiveWindow () && isVisible ()) {
-		captured->fixupPartGUI (true);
-		toplevel_actions->reloadXML ();
-		createGUI (0);
-		createGUI (captured->getPart ());
-		// see RKWardMainWindow::changeEvent() for why KXMLGUIFactory::refreshActionProperties () is not used, instead.
-	}
-
-	KParts::MainWindow::changeEvent (e);
-}
-
 #include "detachedwindowcontainer.moc"

Modified: trunk/rkward/rkward/windows/detachedwindowcontainer.h
===================================================================
--- trunk/rkward/rkward/windows/detachedwindowcontainer.h	2009-08-05 20:01:26 UTC (rev 2600)
+++ trunk/rkward/rkward/windows/detachedwindowcontainer.h	2009-08-06 15:02:00 UTC (rev 2601)
@@ -48,8 +48,6 @@
 protected:
 /** when receiving a close event, dispatch to the embedded window */
 	void closeEvent (QCloseEvent *e);
-/** may need to reload embedded window's XMLGUI definition */
-	void changeEvent (QEvent *e);
 private:
 	RKMDIWindow *captured;
 	RKTopLevelWindowGUI *toplevel_actions;

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2009-08-05 20:01:26 UTC (rev 2600)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2009-08-06 15:02:00 UTC (rev 2601)
@@ -50,6 +50,7 @@
 #include "../misc/rkcommonfunctions.h"
 #include "../misc/rkstandardicons.h"
 #include "../misc/rkstandardactions.h"
+#include "../misc/rkxmlguisyncer.h"
 #include "../core/robjectlist.h"
 #include "../settings/rksettings.h"
 #include "../settings/rksettingsmodulecommandeditor.h"
@@ -97,9 +98,10 @@
 	RKCommandEditorWindowPart* part = new RKCommandEditorWindowPart (m_view);
 	part->insertChildClient (m_view);
 	setPart (part);
-	fixupPartGUI (false);
+	fixupPartGUI ();
 	initializeActions (part->actionCollection ());
 	initializeActivationSignals ();
+	RKXMLGUISyncer::self()->registerChangeListener (m_view, this, SLOT (fixupPartGUI()));
 
 	QHBoxLayout *layout = new QHBoxLayout (this);
 	layout->setContentsMargins (0, 0, 0, 0);
@@ -144,11 +146,9 @@
 	delete m_doc;
 }
 
-void RKCommandEditorWindow::fixupPartGUI (bool reload) {
+void RKCommandEditorWindow::fixupPartGUI () {
 	RK_TRACE (COMMANDEDITOR);
 
-	RKMDIWindow::fixupPartGUI (reload);
-
 	// strip down the katepart's GUI. remove some stuff we definitely don't need.
 	RKCommonFunctions::removeContainers (m_view, QString ("bookmarks,tools_spelling,tools_spelling_from_cursor,tools_spelling_selection,switch_to_cmd_line").split (','), true);
 	RKCommonFunctions::moveContainer (m_view, "Menu", "tools", "edit", true);

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2009-08-05 20:01:26 UTC (rev 2600)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2009-08-06 15:02:00 UTC (rev 2601)
@@ -158,8 +158,6 @@
 
 	bool provideContext (unsigned int line_rev, QString *context, int *cursor_position);
 	QString currentCompletionWord () const;
-/** reimplemented from RKMDIWindow */
-	void fixupPartGUI (bool reload);
 public slots:
 /** update Tab caption according to the current url. Display the filename-component of the URL, or - if not available - a more elaborate description of the url. Also appends a "[modified]" if appropriate */
 	void updateCaption (KTextEditor::Document* = 0);
@@ -184,6 +182,9 @@
 	void selectionChanged (KTextEditor::View* view);
 /** change to the directory of the current script */
 	void setWDToScript ();
+
+/** apply our customizations to the katepart GUI */
+	void fixupPartGUI ();
 protected:
 /** reimplemented from RKMDIWindow: give the editor window a chance to object to being closed (if unsaved) */
 	void closeEvent (QCloseEvent *e);

Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2009-08-05 20:01:26 UTC (rev 2600)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2009-08-06 15:02:00 UTC (rev 2601)
@@ -41,6 +41,7 @@
 #include "../misc/rkstandardactions.h"
 #include "../misc/rkstandardicons.h"
 #include "../misc/xmlhelper.h"
+#include "../misc/rkxmlguisyncer.h"
 #include "../plugin/rkcomponentmap.h"
 #include "../windows/rkworkplace.h"
 #include "../windows/rkworkplaceview.h"
@@ -57,8 +58,9 @@
 
 	khtmlpart = new KHTMLPart (this, 0, KHTMLPart::BrowserViewGUI);
 	setPart (khtmlpart);
-	fixupPartGUI (false);
+	fixupPartGUI ();
 	initializeActivationSignals ();
+	RKXMLGUISyncer::self()->registerChangeListener (khtmlpart, this, SLOT (fixupPartGUI()));
 	khtmlpart->setSelectable (true);
 	setFocusProxy (khtmlpart->widget ());
 	
@@ -90,11 +92,9 @@
 	delete khtmlpart;
 }
 
-void RKHTMLWindow::fixupPartGUI (bool reload) {
+void RKHTMLWindow::fixupPartGUI () {
 	RK_TRACE (APP);
 
-	RKMDIWindow::fixupPartGUI (reload);
-
 	// strip down the khtmlpart's GUI. remove some stuff we definitely don't need.
 	RKCommonFunctions::removeContainers (khtmlpart, QString ("tools,security,extraToolBar,saveBackground,saveFrame,printFrame,kget_menu").split (','), true);
 }

Modified: trunk/rkward/rkward/windows/rkhtmlwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.h	2009-08-05 20:01:26 UTC (rev 2600)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.h	2009-08-06 15:02:00 UTC (rev 2601)
@@ -73,8 +73,6 @@
 @param show Show the window, if not currently shown (this actually means: it is created if not currently existant)
 @param raise Raise the window (if currently shown, or show==true) */
 	static RKHTMLWindow* refreshOutput (bool show, bool raise);
-/** reimplemented from RKMDIWindow */
-	void fixupPartGUI (bool reload);
 public slots:
 /** this is used for browsing only. Use openURL instead, when calling from outside. */
 	void slotOpenUrl (const KUrl & url, const KParts::OpenUrlArguments &, const KParts::BrowserArguments &);
@@ -87,6 +85,8 @@
 	void flushOutput ();
 /** Reload current page.*/
 	void refresh ();
+/** apply our customizations to the khtmlpart GUI */
+	void fixupPartGUI ();
 private slots:
 /** This slot is called when the new page has finished loading. Sets scroll position to scroll_position */
 	void loadDone ();

Modified: trunk/rkward/rkward/windows/rkmdiwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkmdiwindow.cpp	2009-08-05 20:01:26 UTC (rev 2600)
+++ trunk/rkward/rkward/windows/rkmdiwindow.cpp	2009-08-06 15:02:00 UTC (rev 2601)
@@ -31,6 +31,7 @@
 #include "rktoolwindowbar.h"
 #include "../settings/rksettingsmodulegeneral.h"
 #include "../misc/rkstandardicons.h"
+#include "../misc/rkxmlguisyncer.h"
 
 #include "../debug.h"
 
@@ -81,20 +82,6 @@
 	return standard_client->actionCollection ();
 }
 
-void RKMDIWindow::fixupPartGUI (bool reload) {
-	RK_TRACE (APP);
-	RK_ASSERT (part);
-
-	if (reload) {
-		// needed esp. to apply changed shortcut settings
-		part->reloadXML ();
-		foreach (KXMLGUIClient *client, part->childClients ()) {
-			// no further recursion needed in our case
-			client->reloadXML ();
-		}
-	}
-}
-
 //virtual
 QString RKMDIWindow::fullCaption () {
 	RK_TRACE (APP);
@@ -224,6 +211,8 @@
 
 	RK_ASSERT (getPart ());
 	getPart ()->installEventFilter (this);
+
+	RKXMLGUISyncer::self ()->watchXMLGUIClientUIrc (getPart ());
 }
 
 void RKMDIWindow::paintEvent (QPaintEvent *e) {

Modified: trunk/rkward/rkward/windows/rkmdiwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkmdiwindow.h	2009-08-05 20:01:26 UTC (rev 2600)
+++ trunk/rkward/rkward/windows/rkmdiwindow.h	2009-08-06 15:02:00 UTC (rev 2601)
@@ -106,9 +106,6 @@
 	bool isActive ();
 /** Returns a pointer to an action collection suitable to place RKStandardAction in. This collection (and the corresponding KXMLGUIClient) is created on the fly. */
 	KActionCollection *standardActionCollection ();
-/** Used to update the part gui after some aspects of it have changed (most importantly, after keyboard shortcuts were changed). This also takes care of updating the child clients. Reimplemented
-in some classes to re-apply customizations of the part GUI. */
-	virtual void fixupPartGUI (bool reload);
 signals:
 /** This signal is emitted, whenever the window caption was changed.
 @param RKMDIWindow* a pointer to this window */


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list