summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-02-16 09:05:37 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-02-17 08:05:08 (GMT)
commit5a334fd9b676564a8915baad312d92bd86358eec (patch)
treeaaecbbccd9cddcb843c126b8c022f1d1e667efde /Swift/QtUI/QtChatWindow.cpp
parent231c2cb6d00061e70860626467107f4c63f359a0 (diff)
downloadswift-5a334fd9b676564a8915baad312d92bd86358eec.zip
swift-5a334fd9b676564a8915baad312d92bd86358eec.tar.bz2
Preliminary Chat State Notifications support.
Only covers Active and Composing (Which is very possibly all we care about).
Diffstat (limited to 'Swift/QtUI/QtChatWindow.cpp')
-rw-r--r--Swift/QtUI/QtChatWindow.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index e982b21..6765e8a 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -56,7 +56,11 @@ QtChatWindow::QtChatWindow(const QString &contact, QtTreeWidgetFactory *treeWidg
input_->setAcceptRichText(false);
layout->addWidget(input_);
+ inputClearing_ = false;
+ contactIsTyping_ = false;
+
connect(input_, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
+ connect(input_, SIGNAL(textChanged()), this, SLOT(handleInputChanged()));
setFocusProxy(input_);
connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(qAppFocusChanged(QWidget*, QWidget*)));
@@ -134,8 +138,20 @@ void QtChatWindow::setUnreadMessageCount(int count) {
updateTitleWithUnreadCount();
}
-bool QtChatWindow::isWidgetAlerting() {
- return unreadCount_ > 0;
+void QtChatWindow::setContactChatState(ChatState::ChatStateType state) {
+ contactIsTyping_ = (state == ChatState::Composing);
+ printf("Hay, composing %d, %d!\n", state, contactIsTyping_);
+ emit titleUpdated();
+}
+
+QtTabbable::AlertType QtChatWindow::getWidgetAlertState() {
+ if (contactIsTyping_) {
+ return ImpendingActivity;
+ }
+ if (unreadCount_ > 0) {
+ return WaitingActivity;
+ }
+ return NoActivity;
}
void QtChatWindow::setName(const String& name) {
@@ -205,7 +221,20 @@ void QtChatWindow::addSystemMessage(const String& message) {
void QtChatWindow::returnPressed() {
onSendMessageRequest(Q2PSTRING(input_->toPlainText()));
messageLog_->scrollToBottom();
+ inputClearing_ = true;
input_->clear();
+ inputClearing_ = false;
+}
+
+void QtChatWindow::handleInputChanged() {
+ if (inputClearing_) {
+ return;
+ }
+ if (input_->toPlainText().isEmpty()) {
+ onUserCancelsTyping();
+ } else {
+ onUserTyping();
+ }
}
void QtChatWindow::show() {