diff options
Diffstat (limited to 'Swift/QtUI/QtChatWindow.cpp')
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index fa039de..760e481 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -35,18 +35,19 @@ #include <QFileInfo> #include <QLineEdit> #include <QSplitter> #include <QString> #include <QTextEdit> #include <QTime> #include <QUrl> #include <QPushButton> #include <QFileDialog> +#include <QMenu> #include <QDebug> namespace Swift { QtChatWindow::QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventStream* eventStream) : QtTabbable(), contact_(contact), previousMessageWasSelf_(false), previousMessageWasSystem_(false), previousMessageWasPresence_(false), previousMessageWasFileTransfer_(false), eventStream_(eventStream) { unreadCount_ = 0; inputEnabled_ = true; completer_ = NULL; theme_ = theme; @@ -74,18 +75,33 @@ QtChatWindow::QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventSt connect (alertButton_, SIGNAL(clicked()), this, SLOT(handleAlertButtonClicked())); alertLayout->addWidget(alertButton_); QPalette palette = alertWidget_->palette(); palette.setColor(QPalette::Window, QColor(Qt::yellow)); palette.setColor(QPalette::WindowText, QColor(Qt::black)); alertWidget_->setStyleSheet(alertStyleSheet_); alertLabel_->setStyleSheet(alertStyleSheet_); alertWidget_->hide(); + QBoxLayout* subjectLayout = new QBoxLayout(QBoxLayout::LeftToRight); + subject_ = new QLineEdit(this); + subjectLayout->addWidget(subject_); + setSubject(""); + subject_->setReadOnly(true); + + actionButton_ = new QPushButton(tr("Actions"), this); + connect(actionButton_, SIGNAL(clicked()), this, SLOT(handleActionButtonClicked())); + subjectLayout->addWidget(actionButton_); + + subject_->hide(); + actionButton_->hide(); + + layout->addLayout(subjectLayout); + logRosterSplitter_ = new QSplitter(this); logRosterSplitter_->setAutoFillBackground(true); layout->addWidget(logRosterSplitter_); messageLog_ = new QtChatView(theme, this); logRosterSplitter_->addWidget(messageLog_); treeWidget_ = new QtOccupantListWidget(eventStream_, this); treeWidget_->hide(); logRosterSplitter_->addWidget(treeWidget_); @@ -324,23 +340,23 @@ SecurityLabelsCatalog::Item QtChatWindow::getSelectedSecurityLabel() { void QtChatWindow::closeEvent(QCloseEvent* event) { event->accept(); emit windowClosing(); onClosed(); } void QtChatWindow::convertToMUC() { setAcceptDrops(false); treeWidget_->show(); + subject_->show(); + actionButton_->show(); } -void QtChatWindow::qAppFocusChanged(QWidget *old, QWidget *now) { - Q_UNUSED(old); - Q_UNUSED(now); +void QtChatWindow::qAppFocusChanged(QWidget* /*old*/, QWidget* /*now*/) { if (isWidgetSelected()) { lastLineTracker_.setHasFocus(true); input_->setFocus(); onAllMessagesRead(); } else { lastLineTracker_.setHasFocus(false); } } @@ -663,10 +679,28 @@ void QtChatWindow::dropEvent(QDropEvent *event) { void QtChatWindow::replaceLastMessage(const std::string& message) { messageLog_->replaceLastMessage(P2QSTRING(Linkify::linkify(message))); } void QtChatWindow::setAvailableOccupantActions(const std::vector<OccupantAction>& actions) { treeWidget_->setAvailableOccupantActions(actions); } +void QtChatWindow::setSubject(const std::string& subject) { + //subject_->setVisible(!subject.empty()); + subject_->setText(P2QSTRING(subject)); +} + +void QtChatWindow::handleActionButtonClicked() { + QMenu contextMenu; + QAction* changeSubject = contextMenu.addAction(tr("Change subject")); + QAction* result = contextMenu.exec(QCursor::pos()); + if (result == changeSubject) { + bool ok; + QString subject = QInputDialog::getText(this, tr("Change room subject"), tr("New subject:"), QLineEdit::Normal, subject_->text(), &ok); + if (ok) { + onChangeSubjectRequest(Q2PSTRING(subject)); + } + } +} + } |