diff options
author | Thanos Doukoudakis <thanos.doukoudakis@isode.com> | 2017-03-10 15:55:13 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2017-04-04 14:43:24 (GMT) |
commit | bd5c623c6e54c1f449b7af06177a9a5c7fbcb4a7 (patch) | |
tree | 1d2d8dba2650f8bdf1eaf3fa649cb82b2a5713ab /Swift/QtUI | |
parent | ac40889c5466314dd22def238449352a2a4cc67e (diff) | |
download | swift-bd5c623c6e54c1f449b7af06177a9a5c7fbcb4a7.zip swift-bd5c623c6e54c1f449b7af06177a9a5c7fbcb4a7.tar.bz2 |
Open 1:1 chat to real JIDs from MUC rooms (not PMs) when possible
Opens the chat with the user JID instead of the MUC JID.
Does not affect existing behaviour on normal one2one chats.
Test-Information:
Builds on Windows and unit test pass.
Tested the behaviour on single chats from contacts list (roster), start new chat with
one and multiple users. Also tested on MUC rooms that are non-anonymous,
semi-anonymous and anonymous.
Change-Id: I2b8fbacb1fa640167ec196d4215a13ad4905d45c
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 3 | ||||
-rw-r--r-- | Swift/QtUI/Roster/QtTreeWidget.cpp | 1 |
2 files changed, 1 insertions, 3 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index ca615f3..c509ab3 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -87,61 +87,61 @@ QtChatWindow::QtChatWindow(const QString& contact, QtChatTheme* theme, UIEventSt layout->setContentsMargins(0,0,0,0); layout->setSpacing(2); alertLayout_ = new QVBoxLayout(); layout->addLayout(alertLayout_); subjectLayout_ = new QBoxLayout(QBoxLayout::LeftToRight); subject_ = new QLineEdit(this); subjectLayout_->addWidget(subject_); setSubject(""); subject_->setReadOnly(true); QPushButton* actionButton_ = new QPushButton(this); actionButton_->setIcon(QIcon(":/icons/actions.png")); connect(actionButton_, SIGNAL(clicked()), this, SLOT(handleActionButtonClicked())); subject_->hide(); layout->addLayout(subjectLayout_); logRosterSplitter_ = new QSplitter(this); logRosterSplitter_->setAutoFillBackground(true); layout->addWidget(logRosterSplitter_); if (settings_->getSetting(QtUISettingConstants::USE_PLAIN_CHATS) || settings_->getSetting(QtUISettingConstants::USE_SCREENREADER)) { messageLog_ = new QtPlainChatView(this, eventStream_); } else { messageLog_ = new QtWebKitChatView(this, eventStream_, theme, this); // I accept that passing the ChatWindow in so that the view can call the signals is somewhat inelegant, but it saves a lot of boilerplate. This patch is unpleasant enough already. So let's fix this soon (it at least needs fixing by the time history is sorted), but not now. } logRosterSplitter_->addWidget(messageLog_); - treeWidget_ = new QtOccupantListWidget(eventStream_, settings_, QtTreeWidget::MessageDefaultJID, this); + treeWidget_ = new QtOccupantListWidget(eventStream_, settings_, QtTreeWidget::MessageDisplayJID, this); treeWidget_->hide(); logRosterSplitter_->addWidget(treeWidget_); logRosterSplitter_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); connect(logRosterSplitter_, SIGNAL(splitterMoved(int, int)), this, SLOT(handleSplitterMoved(int, int))); midBar_ = new QWidget(this); //layout->addWidget(midBar); midBar_->setAutoFillBackground(true); QHBoxLayout *midBarLayout = new QHBoxLayout(midBar_); midBarLayout->setContentsMargins(0,0,0,0); midBarLayout->setSpacing(2); //midBarLayout->addStretch(); labelsWidget_ = new QComboBox(this); labelsWidget_->setFocusPolicy(Qt::NoFocus); labelsWidget_->hide(); labelsWidget_->setSizeAdjustPolicy(QComboBox::AdjustToContents); midBarLayout->addWidget(labelsWidget_,0); connect(labelsWidget_, SIGNAL(currentIndexChanged(int)), this, SLOT(handleCurrentLabelChanged(int))); defaultLabelsPalette_ = labelsWidget_->palette(); QHBoxLayout* inputBarLayout = new QHBoxLayout(); inputBarLayout->setContentsMargins(0,0,0,0); inputBarLayout->setSpacing(2); input_ = new QtTextEdit(settings_, this); input_->setAcceptRichText(false); inputBarLayout->addWidget(midBar_); inputBarLayout->addWidget(input_); correctingLabel_ = new QLabel(tr("Correcting"), this); inputBarLayout->addWidget(correctingLabel_); @@ -432,61 +432,60 @@ void QtChatWindow::setSecurityLabelsEnabled(bool enabled) { labelsWidget_->setEnabled(true); labelsWidget_->show(); } else { labelsWidget_->hide(); } } void QtChatWindow::setCorrectionEnabled(Tristate enabled) { correctionEnabled_ = enabled; } void QtChatWindow::setFileTransferEnabled(Tristate enabled) { fileTransferEnabled_ = enabled; } SecurityLabelsCatalog::Item QtChatWindow::getSelectedSecurityLabel() { assert(labelsWidget_->isEnabled()); assert(labelsWidget_->currentIndex() >= 0 && static_cast<size_t>(labelsWidget_->currentIndex()) < labelModel_->availableLabels_.size()); return labelModel_->availableLabels_[labelsWidget_->currentIndex()]; } void QtChatWindow::closeEvent(QCloseEvent* event) { event->accept(); emit windowClosing(); onClosed(); } void QtChatWindow::convertToMUC(MUCType mucType) { impromptu_ = (mucType == ImpromptuMUC); - treeWidget_->setMessageTarget(impromptu_ ? QtTreeWidget::MessageDisplayJID : QtTreeWidget::MessageDefaultJID); isMUC_ = true; treeWidget_->show(); subject_->setVisible(!impromptu_); } void QtChatWindow::setOnline(bool online) { isOnline_ = online; if (!online) { if (mucConfigurationWindow_) { delete mucConfigurationWindow_.data(); } if (affiliationEditor_) { delete affiliationEditor_.data(); } } } void QtChatWindow::showEvent(QShowEvent* event) { emit windowOpening(); QWidget::showEvent(event); } void QtChatWindow::setUnreadMessageCount(int count) { if (unreadCount_ != count) { unreadCount_ = count; updateTitleWithUnreadCount(); emit countUpdated(); } } diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp index 1264a09..ac9f541 100644 --- a/Swift/QtUI/Roster/QtTreeWidget.cpp +++ b/Swift/QtUI/Roster/QtTreeWidget.cpp @@ -213,55 +213,54 @@ void QtTreeWidget::handleCollapsed(const QModelIndex& index) { item->setExpanded(false); } } void QtTreeWidget::handleModelItemExpanded(const QModelIndex& index, bool shouldExpand) { if (!index.isValid()) { return; } bool alreadyRight = this->isExpanded(index) == shouldExpand; if (alreadyRight) { return; } setExpanded(index, shouldExpand); } void QtTreeWidget::drawBranches(QPainter*, const QRect&, const QModelIndex&) const { } void QtTreeWidget::show() { QWidget::show(); } void QtTreeWidget::setMessageTarget(MessageTarget messageTarget) { messageTarget_ = messageTarget; } JID QtTreeWidget::jidFromIndex(const QModelIndex& index) const { JID target; if (messageTarget_ == MessageDisplayJID) { target = JID(Q2PSTRING(index.data(DisplayJIDRole).toString())); - target = target.toBare(); } if (!target.isValid()) { target = JID(Q2PSTRING(index.data(JIDRole).toString())); } return target; } JID QtTreeWidget::selectedJID() const { QModelIndexList list = selectedIndexes(); if (list.size() != 1) { return JID(); } return jidFromIndex(list[0]); } void QtTreeWidget::setOnline(bool isOnline) { isOnline_ = isOnline; } bool QtTreeWidget::isOnline() const { return isOnline_; } } |