Keyboard is not grabbed when panel is closed
authorSami Rämö <sami.ramo@ixonos.com>
Tue, 17 Aug 2010 06:25:51 +0000 (09:25 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Tue, 17 Aug 2010 06:25:51 +0000 (09:25 +0300)
src/ui/friendlistpanel.cpp
src/ui/friendlistpanel.h
src/ui/mainwindow.cpp

index b423b80..87bc1da 100644 (file)
@@ -39,7 +39,8 @@
 
 FriendListPanel::FriendListPanel(QWidget *parent)
     : QWidget(parent),
-      m_mainWindowIsTopmost(false)
+      m_mainWindowIsTopmost(false),
+      m_somePanelIsOpen(false)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -121,6 +122,22 @@ FriendListPanel::FriendListPanel(QWidget *parent)
             this, SLOT(topmostWindowChanged(bool)));
 }
 
+void FriendListPanel::anyPanelClosed()
+{
+    qWarning() << __PRETTY_FUNCTION__;
+
+    m_somePanelIsOpen = false;
+    updateKeyboardGrabbing();
+}
+
+void FriendListPanel::anyPanelOpened()
+{
+    qWarning() << __PRETTY_FUNCTION__;
+
+    m_somePanelIsOpen = true;
+    updateKeyboardGrabbing();
+}
+
 void FriendListPanel::clearFiltering()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -220,12 +237,12 @@ void FriendListPanel::updateKeyboardGrabbing()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if (!m_mainWindowIsTopmost || !isVisible()) {
+    if (!m_mainWindowIsTopmost || !m_somePanelIsOpen || !isVisible()) {
         if (QWidget::keyboardGrabber() == m_filterField) {
             m_filterField->releaseKeyboard();
             qWarning() << __PRETTY_FUNCTION__ << "released";
         }
-    } else if (m_mainWindowIsTopmost && isVisible()) {
+    } else if (m_mainWindowIsTopmost && m_somePanelIsOpen && isVisible()) {
         if (QWidget::keyboardGrabber() != m_filterField) {
             m_filterField->grabKeyboard();
             qWarning() << __PRETTY_FUNCTION__ << "grabbed";
index 685e73f..e0b3997 100644 (file)
@@ -116,6 +116,10 @@ private:
     void updateKeyboardGrabbing();
 
 private slots:
+    void anyPanelClosed();
+
+    void anyPanelOpened();
+
     /**
      * @brief Slot to clear friend list filter
      */
@@ -190,6 +194,7 @@ signals:
  ******************************************************************************/
 private:
     bool m_mainWindowIsTopmost;         ///< Is the MainWindow the topmost one
+    bool m_somePanelIsOpen;
 
     QLabel *m_friendListLabel;          ///< Friend list label
 
index 120a47e..4242c3b 100644 (file)
@@ -336,6 +336,12 @@ void MainWindow::buildPanels()
 
     connect(m_friendsListPanel, SIGNAL(showPanelRequested(QWidget*)),
             m_tabbedPanel, SLOT(showPanel(QWidget*)));
+
+    connect(m_tabbedPanel, SIGNAL(panelClosed()),
+            m_friendsListPanel, SLOT(anyPanelClosed()));
+
+    connect(m_tabbedPanel, SIGNAL(panelOpened()),
+            m_friendsListPanel, SLOT(anyPanelOpened()));
 }
 
 void MainWindow::buildRoutingPanel()