summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-07-04 21:13:56 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-07-04 21:13:56 (GMT)
commita5853e88be12bce08b84f76452e5d2576cf9d10b (patch)
treedd3ff7e5a33b0f6b7526b4c398c4d94c3fb19144
parent83ca0f4806ed30fb974420db4171201c451fb583 (diff)
downloadswift-a5853e88be12bce08b84f76452e5d2576cf9d10b.zip
swift-a5853e88be12bce08b84f76452e5d2576cf9d10b.tar.bz2
Notify chat tabs even if the parent tabset has focus. issue#150.
-rw-r--r--Swift/QtUI/QtChatWindow.cpp8
-rw-r--r--Swift/QtUI/QtTabbable.cpp12
-rw-r--r--Swift/QtUI/QtTabbable.h2
-rw-r--r--Swift/QtUI/Swift.pro1
4 files changed, 19 insertions, 4 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index e6e0100..6328156 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -106,7 +106,7 @@ void QtChatWindow::convertToMUC() {
void QtChatWindow::qAppFocusChanged(QWidget *old, QWidget *now) {
Q_UNUSED(old);
- if (now == this || now == messageLog_ || now == input_) {
+ if (isWidgetSelected()) {
onAllMessagesRead();
}
@@ -133,7 +133,7 @@ void QtChatWindow::updateTitleWithUnreadCount() {
}
void QtChatWindow::addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath) {
- if (isActiveWindow()) {
+ if (isWidgetSelected()) {
onAllMessagesRead();
}
@@ -156,7 +156,7 @@ void QtChatWindow::addMessage(const String &message, const String &senderName, b
}
void QtChatWindow::addErrorMessage(const String& errorMessage) {
- if (isActiveWindow()) {
+ if (isWidgetSelected()) {
onAllMessagesRead();
}
@@ -169,7 +169,7 @@ void QtChatWindow::addErrorMessage(const String& errorMessage) {
}
void QtChatWindow::addSystemMessage(const String& message) {
- if (isActiveWindow()) {
+ if (isWidgetSelected()) {
onAllMessagesRead();
}
diff --git a/Swift/QtUI/QtTabbable.cpp b/Swift/QtUI/QtTabbable.cpp
new file mode 100644
index 0000000..8473529
--- /dev/null
+++ b/Swift/QtUI/QtTabbable.cpp
@@ -0,0 +1,12 @@
+#include "QtTabbable.h"
+
+#include <QApplication>
+
+namespace Swift {
+
+bool QtTabbable::isWidgetSelected() {
+ /*isActiveWindow() shouldn't be necessary, but I don't trust it as far as I can throw it*/
+ return isActiveWindow() && isAncestorOf(QApplication::focusWidget());
+}
+
+}
diff --git a/Swift/QtUI/QtTabbable.h b/Swift/QtUI/QtTabbable.h
index 96348b3..ebd495e 100644
--- a/Swift/QtUI/QtTabbable.h
+++ b/Swift/QtUI/QtTabbable.h
@@ -6,6 +6,8 @@
namespace Swift {
class QtTabbable : public QWidget {
Q_OBJECT
+ public:
+ bool isWidgetSelected();
protected:
QtTabbable() : QWidget() {};
diff --git a/Swift/QtUI/Swift.pro b/Swift/QtUI/Swift.pro
index da5f4e8..0af8216 100644
--- a/Swift/QtUI/Swift.pro
+++ b/Swift/QtUI/Swift.pro
@@ -84,6 +84,7 @@ SOURCES += \
QtChatTabs.cpp \
QtSoundPlayer.cpp \
QtSystemTray.cpp \
+ QtTabbable.cpp \
ChatSnippet.cpp \
MessageSnippet.cpp \
SystemMessageSnippet.cpp