diff --git a/src/Application.cpp b/src/Application.cpp index f2bdcfb39..f8bda52da 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -38,7 +38,6 @@ #include "SessionManager.h" #include "MainWindow.h" #include "Session.h" -#include "ViewManager.h" using namespace Konsole; @@ -75,7 +74,7 @@ MainWindow* Application::newMainWindow() connect(window, SIGNAL(newWindowRequest(Profile::Ptr,QString)), this, SLOT(createWindow(Profile::Ptr,QString))); - connect(window->viewManager(), SIGNAL(viewDetached(Session*)), + connect(window, SIGNAL(viewDetached(Session*)), this, SLOT(detachView(Session*))); return window; @@ -91,7 +90,7 @@ void Application::createWindow(Profile::Ptr profile, const QString& directory) void Application::detachView(Session* session) { MainWindow* window = newMainWindow(); - window->viewManager()->createView(session); + window->createView(session); window->show(); } @@ -425,7 +424,7 @@ void Application::toggleBackgroundInstance() // ensure that the active terminal display has the focus. Without // this, an odd problem occurred where the focus widget would change // each time the background instance was shown - _backgroundInstance->viewManager()->activeView()->setFocus(); + _backgroundInstance->setFocus(); } else { _backgroundInstance->hide(); } diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 033560e74..7b7ad18bf 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -97,6 +97,8 @@ MainWindow::MainWindow() this , SLOT(newFromProfile(Profile::Ptr))); connect(_viewManager , SIGNAL(newViewRequest()) , this , SLOT(newTab())); + connect(_viewManager , SIGNAL(viewDetached(Session*)) , + this , SIGNAL(viewDetached(Session*)) ); // create main window widgets setupWidgets(); @@ -454,7 +456,7 @@ Session* MainWindow::createSession(Profile::Ptr profile, const QString& director // doesn't suffer a change in terminal size right after the session // starts. Some applications such as GNU Screen and Midnight Commander // don't like this happening - _viewManager->createView(session); + createView(session); return session; } @@ -483,11 +485,21 @@ Session* MainWindow::createSSHSession(Profile::Ptr profile, const KUrl& url) // doesn't suffer a change in terminal size right after the session // starts. some applications such as GNU Screen and Midnight Commander // don't like this happening - _viewManager->createView(session); + createView(session); return session; } +void MainWindow::createView(Session* session) +{ + _viewManager->createView(session); +} + +void MainWindow::setFocus() +{ + _viewManager->activeView()->setFocus(); +} + void MainWindow::newWindow() { Profile::Ptr defaultProfile = SessionManager::instance()->defaultProfile(); diff --git a/src/MainWindow.h b/src/MainWindow.h index 7f74e3220..314871db5 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -89,6 +89,16 @@ public: */ Session* createSSHSession(Profile::Ptr profile, const KUrl& url); + /** + * create view for the specified session + */ + void createView(Session* session); + + /** + * Helper method to make this window get input focus + */ + void setFocus(); + signals: /** @@ -104,6 +114,10 @@ signals: void newWindowRequest(Profile::Ptr profile, const QString& directory); + /** + * Emitted when a view for one session is detached from this window + */ + void viewDetached(Session* session); protected: // Reimplemented for internal reasons.