diff options
author | Kevin Smith <git@kismith.co.uk> | 2011-09-26 14:27:49 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2011-09-26 14:27:49 (GMT) |
commit | 2680416456d722a4779322949f6ed230de3d422b (patch) | |
tree | 7ed7f79ead222adbe0d978376967d9b508d5068f /Swift/QtUI | |
parent | 101053d01cf2274e8eb75c520cce0bfee4d15618 (diff) | |
download | swift-2680416456d722a4779322949f6ed230de3d422b.zip swift-2680416456d722a4779322949f6ed230de3d422b.tar.bz2 |
Allow setting of room topics
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 40 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.h | 4 |
2 files changed, 41 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 @@ -41,6 +41,7 @@ #include <QUrl> #include <QPushButton> #include <QFileDialog> +#include <QMenu> #include <QDebug> @@ -80,6 +81,21 @@ QtChatWindow::QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventSt 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_); @@ -330,11 +346,11 @@ void QtChatWindow::closeEvent(QCloseEvent* event) { 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(); @@ -669,4 +685,22 @@ void QtChatWindow::setAvailableOccupantActions(const std::vector<OccupantAction> 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)); + } + } +} + } diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index f0c078c..b8fa478 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -68,6 +68,7 @@ namespace Swift { void flash(); QByteArray getSplitterState(); virtual void setAvailableOccupantActions(const std::vector<OccupantAction>& actions); + void setSubject(const std::string& subject); public slots: void handleChangeSplitterState(QByteArray state); @@ -99,6 +100,7 @@ namespace Swift { void handleKeyPressEvent(QKeyEvent* event); void handleSplitterMoved(int pos, int index); void handleAlertButtonClicked(); + void handleActionButtonClicked(); void handleFileTransferCancel(QString id); @@ -129,6 +131,8 @@ namespace Swift { QWidget* alertWidget_; QPushButton* alertButton_; TabComplete* completer_; + QLineEdit* subject_; + QPushButton* actionButton_; std::vector<SecurityLabelsCatalog::Item> availableLabels_; bool isCorrection_; bool previousMessageWasSelf_; |