#include "friendlistpanel.h"
FriendListPanel::FriendListPanel(QWidget *parent)
- : QWidget(parent)
+ : QWidget(parent),
+ m_mainWindowIsTopmost(false)
{
qDebug() << __PRETTY_FUNCTION__;
this, SLOT(clearFiltering()));
connect(qApp, SIGNAL(topmostWindowChanged(bool)),
- this, SLOT(setKeyboardGrabbing(bool)));
+ this, SLOT(topmostWindowChanged(bool)));
}
void FriendListPanel::clearFiltering()
m_friendListView->clearUnused(newUserIDs);
}
+void FriendListPanel::hideEvent(QHideEvent *event)
+{
+ qWarning() << __PRETTY_FUNCTION__;
+
+ QWidget::hideEvent(event);
+}
+
void FriendListPanel::setFilteringLayoutVisible(bool visible)
{
qDebug() << __PRETTY_FUNCTION__;
m_filterClearButton->setVisible(visible);
}
-void FriendListPanel::setKeyboardGrabbing(bool grab)
+void FriendListPanel::updateKeyboardGrabbing()
{
- qWarning() << __PRETTY_FUNCTION__ << grab;
+ qWarning() << __PRETTY_FUNCTION__;
+
- if (grab)
- m_filterField->grabKeyboard();
- else
- m_filterField->releaseKeyboard();
}
void FriendListPanel::showEvent(QShowEvent *event)
QWidget::showEvent(event);
- if (QWidget::keyboardGrabber() != qobject_cast<QWidget *>(m_filterField)) {
-// qWarning() << __PRETTY_FUNCTION__ << "grabbing the keyboard for filter text field";
-// m_filterField->grabKeyboard();
+ if (m_mainWindowIsTopmost
+ && (QWidget::keyboardGrabber() != qobject_cast<QWidget *>(m_filterField))) {
+
+ qWarning() << __PRETTY_FUNCTION__ << "grabbed";
+ m_filterField->grabKeyboard();
setFilteringLayoutVisible(false);
+ } else {
+ qWarning() << __PRETTY_FUNCTION__ << "DID NOT GRAB!";
}
}
m_friendListHeaderWidget->show();
m_friendListView->filter(userIDs);
}
+
+void FriendListPanel::topmostWindowChanged(bool grab)
+{
+ qWarning() << __PRETTY_FUNCTION__ << grab;
+
+ m_mainWindowIsTopmost = grab;
+
+ if (grab && isVisible() && (QWidget::keyboardGrabber() != m_filterField)) {
+ m_filterField->grabKeyboard();
+ qWarning() << __PRETTY_FUNCTION__ << "grabbed";
+ } else if (!grab && (QWidget::keyboardGrabber() == m_filterField)) {
+ m_filterField->releaseKeyboard();
+ qWarning() << __PRETTY_FUNCTION__ << "released";
+ }
+}
* BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
******************************************************************************/
protected:
+ void hideEvent(QHideEvent *event);
+
/**
* @brief Used for grabbing the keyboard after the text field is fully initiated.
*
*/
void setFilteringLayoutVisible(bool visible);
+ void updateKeyboardGrabbing();
+
private slots:
/**
* @brief Slot to clear friend list filter.
*/
void filterTextChanged(const QString &text);
- void setKeyboardGrabbing(bool grab);
+ void topmostWindowChanged(bool grab);
/**
* @brief Slot to show friends in list.
* DATA MEMBERS
******************************************************************************/
private:
+ bool m_mainWindowIsTopmost;
+
QLabel *m_friendListLabel; ///< Friend list label
QLineEdit *m_filterField; ///< Text field for the filter text
QPushButton *m_clearFilterButton; ///< Button to clear list filtering