diff options
Diffstat (limited to 'Swift/QtUI/QtChatWindow.cpp')
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 0b9b1af..ffcbf15 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -140,12 +140,14 @@ QtChatWindow::QtChatWindow(const QString& contact, QtChatTheme* theme, UIEventSt inputBarLayout->addWidget(midBar_); inputBarLayout->addWidget(input_); correctingLabel_ = new QLabel(tr("Correcting"), this); inputBarLayout->addWidget(correctingLabel_); correctingLabel_->hide(); + connect(input_, SIGNAL(receivedFocus()), this, SLOT(handleTextInputReceivedFocus())); + connect(input_, SIGNAL(lostFocus()), this, SLOT(handleTextInputLostFocus())); QPushButton* emoticonsButton_ = new QPushButton(this); emoticonsButton_->setIcon(QIcon(":/emoticons/smile.png")); connect(emoticonsButton_, SIGNAL(clicked()), this, SLOT(handleEmoticonsButtonClicked())); emoticonsMenu_ = new QMenu(this); QtEmoticonsGrid* emoticonsGrid = new QtEmoticonsGrid(emoticons, emoticonsMenu_); @@ -168,13 +170,12 @@ QtChatWindow::QtChatWindow(const QString& contact, QtChatTheme* theme, UIEventSt connect(input_, SIGNAL(textChanged()), this, SLOT(handleInputChanged())); connect(input_, SIGNAL(cursorPositionChanged()), this, SLOT(handleCursorPositionChanged())); setFocusProxy(input_); logRosterSplitter_->setFocusProxy(input_); midBar_->setFocusProxy(input_); messageLog_->setFocusProxy(input_); - connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(qAppFocusChanged(QWidget*, QWidget*))); connect(messageLog_, SIGNAL(gotFocus()), input_, SLOT(setFocus())); resize(400,300); connect(messageLog_, SIGNAL(fontResized(int)), this, SIGNAL(fontResized(int))); connect(messageLog_, SIGNAL(logCleared()), this, SLOT(handleLogCleared())); treeWidget_->onSomethingSelectedChanged.connect(boost::bind(&QtChatWindow::handleOccupantSelectionChanged, this, _1)); @@ -455,23 +456,12 @@ void QtChatWindow::convertToMUC(MUCType mucType) { treeWidget_->setMessageTarget(impromptu_ ? QtTreeWidget::MessageDisplayJID : QtTreeWidget::MessageDefaultJID); isMUC_ = true; treeWidget_->show(); subject_->setVisible(!impromptu_); } -void QtChatWindow::qAppFocusChanged(QWidget* /*old*/, QWidget* now) { - if (now && isWidgetSelected()) { - lastLineTracker_.setHasFocus(true); - input_->setFocus(); - onAllMessagesRead(); - } - else { - lastLineTracker_.setHasFocus(false); - } -} - void QtChatWindow::setOnline(bool online) { isOnline_ = online; if (!online) { if (mucConfigurationWindow_) { delete mucConfigurationWindow_.data(); } @@ -654,12 +644,22 @@ void QtChatWindow::handleEmoticonsButtonClicked() { } void QtChatWindow::handleEmoticonClicked(QString emoticonAsText) { input_->textCursor().insertText(emoticonAsText); } +void QtChatWindow::handleTextInputReceivedFocus() { + lastLineTracker_.setHasFocus(true); + input_->setFocus(); + onAllMessagesRead(); +} + +void QtChatWindow::handleTextInputLostFocus() { + lastLineTracker_.setHasFocus(false); +} + void QtChatWindow::handleActionButtonClicked() { QMenu contextMenu; QAction* changeSubject = NULL; QAction* configure = NULL; QAction* affiliations = NULL; QAction* destroy = NULL; |