From 06794b6a16187fd1a0f947188f0f5988b80c380b Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 10 Aug 2012 15:31:03 +0200 Subject: Clean up remove tab window mechanism --- src/application.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/application.cpp') diff --git a/src/application.cpp b/src/application.cpp index 4f1b623b..7004a901 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -333,7 +333,7 @@ TabWindow *Application::newTabWindow() // set object name int n = m_tabWindows.count() + 1; w->setObjectName( QL1S("win") + QString::number(n) ); - + // This is used to track which window was activated most recently w->installEventFilter(this); @@ -344,17 +344,6 @@ TabWindow *Application::newTabWindow() } -void Application::removeTabWindow(TabWindow *window) -{ - m_tabWindows.removeOne(window); - kDebug() << "Removing Window from app window list..."; - - // bye bye... - if (m_tabWindows.count() == 0) - quit(); -} - - TabWindowList Application::tabWindowList() { return m_tabWindows; @@ -379,6 +368,17 @@ bool Application::eventFilter(QObject* watched, QEvent* event) } } + // As we are filtering the events occurred to the tabwindows, check also + // when we close one of them, remove from tab window list and check if it was last... + if (event->type() == QEvent::Close) + { + TabWindow *window = qobject_cast(watched); + m_tabWindows.removeOne(window); + + if (m_tabWindows.count() == 0) + quit(); + } + return QObject::eventFilter(watched, event); } -- cgit v1.2.1