[rkward/work/kateintegration] rkward/windows: Emit the missing KTextEditor::MainWindow signals, clean up a bit.

Thomas Friedrichsmeier null at kde.org
Sat Jan 25 07:02:46 GMT 2020


Git commit d98b404c9e04d7cf841047400e70d75ca7ad5531 by Thomas Friedrichsmeier.
Committed on 25/01/2020 at 07:02.
Pushed by tfry into branch 'work/kateintegration'.

Emit the missing KTextEditor::MainWindow signals, clean up  a  bit.

M  +16   -21   rkward/windows/katepluginintegration.cpp
M  +1    -0    rkward/windows/katepluginintegration.h
M  +3    -0    rkward/windows/rkcommandeditorwindow.cpp
M  +2    -0    rkward/windows/rkworkplace.cpp
M  +2    -0    rkward/windows/rkworkplace.h

https://commits.kde.org/rkward/d98b404c9e04d7cf841047400e70d75ca7ad5531

diff --git a/rkward/windows/katepluginintegration.cpp b/rkward/windows/katepluginintegration.cpp
index 0a251132..804630ee 100644
--- a/rkward/windows/katepluginintegration.cpp
+++ b/rkward/windows/katepluginintegration.cpp
@@ -276,6 +276,8 @@ KatePluginIntegrationWindow::KatePluginIntegrationWindow (KatePluginIntegrationA
 	// While this one may be accessed from plugins via KTextEditor::Editor::instance()->application()
 	app = parent;
 	active_plugin = 0;
+
+	connect(RKWorkplace::getHistory(), &RKMDIWindowHistory::activeWindowChanged, this, &KatePluginIntegrationWindow::activeWindowChanged);
 }
 
 class KatePluginToolWindow : public RKMDIWindow {
@@ -359,6 +361,14 @@ QList<KTextEditor::View *> KatePluginIntegrationWindow::views() {
 	return ret;
 }
 
+void KatePluginIntegrationWindow::activeWindowChanged(RKMDIWindow* window) {
+	RK_TRACE (APP);
+
+	if (window->isType(RKMDIWindow::CommandEditorWindow)) {
+		emit main->viewChanged(static_cast<RKCommandEditorWindow *>(window)->getView());
+	}
+}
+
 KTextEditor::View *KatePluginIntegrationWindow::activeView() {
 	RK_TRACE (APP);
 
@@ -463,7 +473,7 @@ bool KatePluginIntegrationWindow::viewsInSameSplitView(KTextEditor::View* view1,
 	return false;
 }
 
-void KatePluginIntegrationWindow::fixupPluginUI(const QString &id, const PluginResources &resources) {
+void KatePluginIntegrationWindow::fixUpPluginUI(const QString &id, const PluginResources &resources) {
 	RK_TRACE (APP);
 
 	KXMLGUIClient* hacked_parent = this;
@@ -481,7 +491,7 @@ void KatePluginIntegrationWindow::fixupPluginUI(const QString &id, const PluginR
 			RKCommonFunctions::removeContainers(client, QStringList() << "search_in_files", true);
 			// TODO: Rename "Search more" to "Search in Scripts". These should still be accessible, globally.
 		} else if (i == 0 && id == QStringLiteral("kateprojectplugin")) {
-			RKCommonFunctions::moveContainer(client, "Menu", "project", "edit", true, false);
+			RKCommonFunctions::moveContainer(client, "Menu", "projects", "view", true, false);
 		}
 
 		RKCommonFunctions::moveContainer(client, "Menu", "tools", "edit", true, true);
@@ -490,13 +500,15 @@ void KatePluginIntegrationWindow::fixupPluginUI(const QString &id, const PluginR
 
 /* TODO: Ok, I guess we need even more specialization.
 kateprojectplugin:
- - "Project" menu should go to "View"?
  - Actions should probably be accessible, globally
 katesearchplugin:
  - should go to next / previous match be accessible, globally?
 katesnippetsplugin:
  - ok as is, I think
 */
+	// TODO: If child clients were added to the window, itself, we need to tell the main window to rebuild.
+	//       Right now, this is handled during startup, only.
+
 }
 
 QObject* KatePluginIntegrationWindow::createPluginView(KTextEditor::Plugin* plugin) {
@@ -511,21 +523,7 @@ QObject* KatePluginIntegrationWindow::createPluginView(KTextEditor::Plugin* plug
 	resources.view = plugin->createView(main);
 	active_plugin = 0;
 	disconnect(factory(), &KXMLGUIFactory::clientAdded, this, &KatePluginIntegrationWindow::catchXMLGUIClientsHack);
-	KXMLGUIClient* hacked_parent = this;
-	QString id = app->idForPlugin(plugin);
-	for (int i = 0; i < resources.clients.size(); ++i) {
-		KXMLGUIClient* client = resources.clients[i];
-		RKMDIWindow* window = resources.windows.value(i);
-		if (window) {
-			hacked_parent = window->getPart();;
-		}
-		factory()->removeClient(client);
-		fixupPluginUI(id, i, client, window);
-		hacked_parent->insertChildClient(client);
-	}
-	// TODO: If child clients were added to the window, itself, we need to tell the main window to rebuild.
-	//       Right now, this is handled during startup, only.
-
+	fixUpPluginUI(app->idForPlugin(plugin), resources);
 	connect(plugin, &QObject::destroyed, [&]() { plugin_resources.remove(plugin); });
 	return resources.view;
 }
@@ -540,9 +538,6 @@ void KatePluginIntegrationWindow::catchXMLGUIClientsHack(KXMLGUIClient* client)
 	}
 }
 
-// TODO: Don't forget to make sure to emit all the signals!
-//       - MainWindow signals
-// 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
 //       have everything to populate it.
diff --git a/rkward/windows/katepluginintegration.h b/rkward/windows/katepluginintegration.h
index 7ae8eb9b..f3abb307 100644
--- a/rkward/windows/katepluginintegration.h
+++ b/rkward/windows/katepluginintegration.h
@@ -114,6 +114,7 @@ friend class KatePluginIntegrationApp;
 	KatePluginIntegrationApp *app;
 private slots:
 	void catchXMLGUIClientsHack(KXMLGUIClient* client);
+	void activeWindowChanged(RKMDIWindow *window);
 private:
 	KTextEditor::Plugin* active_plugin;
 	void fixUpPluginUI(const QString &id, const PluginResources &resources);
diff --git a/rkward/windows/rkcommandeditorwindow.cpp b/rkward/windows/rkcommandeditorwindow.cpp
index 7beca4a9..fe4d5091 100644
--- a/rkward/windows/rkcommandeditorwindow.cpp
+++ b/rkward/windows/rkcommandeditorwindow.cpp
@@ -195,6 +195,9 @@ RKCommandEditorWindow::RKCommandEditorWindow (QWidget *parent, const QUrl _url,
 	if (em_iface) em_iface->setModifiedOnDiskWarning (true);
 	else RK_ASSERT (false);
 	m_view = m_doc->createView (this, RKWardMainWindow::getMain ()->katePluginIntegration ()->mainWindow ()->mainWindow());
+	if (visible_to_kateplugins) {
+		emit RKWardMainWindow::getMain ()->katePluginIntegration ()->mainWindow ()->mainWindow()->viewCreated (m_view);
+	}
 	preview = new RKXMLGUIPreviewArea (QString(), this);
 	preview_manager = new RKPreviewManager (this);
 	connect (preview_manager, &RKPreviewManager::statusChanged, [this]() { preview_timer.start (500); });
diff --git a/rkward/windows/rkworkplace.cpp b/rkward/windows/rkworkplace.cpp
index 228ef0e6..28de1f7e 100644
--- a/rkward/windows/rkworkplace.cpp
+++ b/rkward/windows/rkworkplace.cpp
@@ -1094,6 +1094,8 @@ void RKMDIWindowHistory::windowActivated (RKMDIWindow *window) {
 	recent_windows.append (window);
 
 	updateSwitcher ();
+
+	emit activeWindowChanged (window);
 }
 
 void RKMDIWindowHistory::next (QAction* prev_action, QAction *next_action) {
diff --git a/rkward/windows/rkworkplace.h b/rkward/windows/rkworkplace.h
index 25e5e7c6..52ec1c53 100644
--- a/rkward/windows/rkworkplace.h
+++ b/rkward/windows/rkworkplace.h
@@ -59,6 +59,8 @@ public:
 	void prev (QAction *prev_action, QAction *next_action);
 public slots:
 	void windowActivated (RKMDIWindow *window);
+signals:
+	void activeWindowChanged (RKMDIWindow *window);
 private slots:
 	void switcherDestroyed ();
 private:



More information about the rkward-tracker mailing list