diff --git a/src/Part.cpp b/src/Part.cpp index ba3e82c51..a630d3809 100644 --- a/src/Part.cpp +++ b/src/Part.cpp @@ -73,11 +73,6 @@ Part::Part(QWidget* parentWidget , QObject* parent) setupActions(); - // FIXME we need this for the context menu and KPart ctor doesn't call the - // necessary KXMLGUIClient ctor - if (KXMLGUIClient *parentClient = dynamic_cast(parent)) - parentClient->insertChildClient(this); - // setup global managers if ( SessionManager::instance() == 0 ) SessionManager::setInstance( new SessionManager() ); @@ -204,23 +199,8 @@ void Part::activeViewChanged(SessionController* controller) if ( controller == _pluggedController ) return; - qDebug() << "Looking for factory"; - - // find client with the necessary factory - KXMLGUIClient* client = this; - qDebug() << "First parent" << client->parentClient(); - while ( client->parentClient() ) - { - qDebug() << "Next parent" << client->parentClient(); - qDebug() << "Factory" << client->factory(); - client = client->parentClient(); - } - - if ( client->factory() ) - { - client->factory()->removeClient(_pluggedController); - client->factory()->addClient(controller); - } + if (_pluggedController) removeChildClient (_pluggedController); + insertChildClient (controller); _pluggedController = controller; } diff --git a/src/SessionController.cpp b/src/SessionController.cpp index e1764c98d..276546d50 100644 --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -899,6 +900,16 @@ void SessionController::showDisplayContextMenu(TerminalDisplay* /*display*/ , in { QMenu* popup = 0; + // needed to make sure the popup menu is available, even if a hosting + // application did not merge our GUI. + if (!factory()) { + if (!clientBuilder()) { + setClientBuilder(new KXMLGUIBuilder(_view)); + } + KXMLGUIFactory* f = new KXMLGUIFactory(clientBuilder(), this); + f->addClient(this); + } + if ( factory() ) popup = qobject_cast(factory()->container("session-popup-menu",this));