diff options
author | Kevin Smith <git@kismith.co.uk> | 2011-09-27 16:13:56 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2011-09-27 16:38:45 (GMT) |
commit | 41854ebf8c3376d6ee430efe3a9fdd25610bb2f5 (patch) | |
tree | 81e918793afb16accb29af46ccd99eefa204930c /Swift/QtUI | |
parent | 24e53876500f0f5497a84b239d9350676e95751a (diff) | |
download | swift-41854ebf8c3376d6ee430efe3a9fdd25610bb2f5.zip swift-41854ebf8c3376d6ee430efe3a9fdd25610bb2f5.tar.bz2 |
Allow room configuration.
Resolves: #989
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 23 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.h | 13 | ||||
-rw-r--r-- | Swift/QtUI/QtMUCConfigurationWindow.cpp | 56 | ||||
-rw-r--r-- | Swift/QtUI/QtMUCConfigurationWindow.h | 34 | ||||
-rw-r--r-- | Swift/QtUI/SConscript | 1 |
5 files changed, 117 insertions, 10 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 2e3a225..1576880 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -162,6 +162,9 @@ QtChatWindow::QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventSt QtChatWindow::~QtChatWindow() { delete fileTransferJS; + if (mucConfigurationWindow) { + delete mucConfigurationWindow.data(); + } } @@ -364,7 +367,9 @@ void QtChatWindow::qAppFocusChanged(QWidget* /*old*/, QWidget* /*now*/) { void QtChatWindow::setInputEnabled(bool enabled) { inputEnabled_ = enabled; -// input_->setEnabled(enabled); + if (!enabled && mucConfigurationWindow) { + delete mucConfigurationWindow.data(); + } } void QtChatWindow::showEvent(QShowEvent* event) { @@ -694,7 +699,7 @@ void QtChatWindow::setSubject(const std::string& subject) { void QtChatWindow::handleActionButtonClicked() { QMenu contextMenu; QAction* changeSubject = contextMenu.addAction(tr("Change subject")); - //QAction* configure = contextMenu.addAction(tr("Configure room")); + QAction* configure = contextMenu.addAction(tr("Configure room")); QAction* result = contextMenu.exec(QCursor::pos()); if (result == changeSubject) { bool ok; @@ -703,9 +708,17 @@ void QtChatWindow::handleActionButtonClicked() { onChangeSubjectRequest(Q2PSTRING(subject)); } } - //else if (result == configure) { - // onConfigureRequest(); - //} + else if (result == configure) { + onConfigureRequest(Form::ref()); + } +} + +void QtChatWindow::showRoomConfigurationForm(Form::ref form) { + if (mucConfigurationWindow) { + delete mucConfigurationWindow.data(); + } + mucConfigurationWindow = new QtMUCConfigurationWindow(form); + mucConfigurationWindow->onFormComplete.connect(boost::bind(boost::ref(onConfigureRequest), _1)); } } diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index b8fa478..b011427 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -6,15 +6,17 @@ #pragma once -#include "Swift/Controllers/UIInterfaces/ChatWindow.h" +#include <Swift/Controllers/UIInterfaces/ChatWindow.h> +#include <Swift/QtUI/QtMUCConfigurationWindow.h> -#include "QtTabbable.h" +#include <QtTabbable.h> -#include "SwifTools/LastLineTracker.h" +#include <SwifTools/LastLineTracker.h> -#include "Swiften/Base/IDGenerator.h" +#include <Swiften/Base/IDGenerator.h> #include <map> +#include <QPointer> class QTextEdit; class QLineEdit; @@ -69,6 +71,7 @@ namespace Swift { QByteArray getSplitterState(); virtual void setAvailableOccupantActions(const std::vector<OccupantAction>& actions); void setSubject(const std::string& subject); + void showRoomConfigurationForm(Form::ref); public slots: void handleChangeSplitterState(QByteArray state); @@ -147,8 +150,8 @@ namespace Swift { QSplitter *logRosterSplitter_; Tristate correctionEnabled_; QString alertStyleSheet_; - std::map<QString, QString> descriptions; QtFileTransferJSBridge* fileTransferJS; + QPointer<QtMUCConfigurationWindow> mucConfigurationWindow; }; } diff --git a/Swift/QtUI/QtMUCConfigurationWindow.cpp b/Swift/QtUI/QtMUCConfigurationWindow.cpp new file mode 100644 index 0000000..e6be9b7 --- /dev/null +++ b/Swift/QtUI/QtMUCConfigurationWindow.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2011 Kevin Smith + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include <Swift/QtUI/QtMUCConfigurationWindow.h> + +#include <boost/bind.hpp> +#include <QBoxLayout> +#include <Swift/QtUI/QtFormWidget.h> + +namespace Swift { +QtMUCConfigurationWindow::QtMUCConfigurationWindow(Form::ref form) { + + setAttribute(Qt::WA_DeleteOnClose); + + QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, this); + layout->setContentsMargins(0,0,0,0); + layout->setSpacing(2); + QLabel* label = new QLabel(this); + label->setText(tr("Room configuration")); + layout->addWidget(label); + + formWidget_ = NULL; + formWidget_ = new QtFormWidget(form, this); + layout->addWidget(formWidget_); + + QWidget* buttonsWidget = new QWidget(this); + layout->addWidget(buttonsWidget); + + QBoxLayout* buttonsLayout = new QBoxLayout(QBoxLayout::LeftToRight, buttonsWidget); + cancelButton_ = new QPushButton(tr("Cancel"), buttonsWidget); + buttonsLayout->addWidget(cancelButton_); + connect(cancelButton_, SIGNAL(clicked()), this, SLOT(handleCancelClicked())); + okButton_ = new QPushButton(tr("OK"), buttonsWidget); + buttonsLayout->addWidget(okButton_); + connect(okButton_, SIGNAL(clicked()), this, SLOT(handleOKClicked())); + show(); +} + +QtMUCConfigurationWindow::~QtMUCConfigurationWindow() { + +} + +void QtMUCConfigurationWindow::handleCancelClicked() { + close(); +} + +void QtMUCConfigurationWindow::handleOKClicked() { + onFormComplete(formWidget_->getCompletedForm()); + close(); +} + + +} diff --git a/Swift/QtUI/QtMUCConfigurationWindow.h b/Swift/QtUI/QtMUCConfigurationWindow.h new file mode 100644 index 0000000..2be126b --- /dev/null +++ b/Swift/QtUI/QtMUCConfigurationWindow.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2011 Kevin Smith + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include <QWidget> +#include <QPushButton> +#include <QLabel> + +#include <Swiften/Base/boost_bsignals.h> +#include <Swiften/Elements/Form.h> + +class QBoxLayout; + +namespace Swift { + class QtFormWidget; + class QtMUCConfigurationWindow : public QWidget { + Q_OBJECT + public: + QtMUCConfigurationWindow(Form::ref form); + virtual ~QtMUCConfigurationWindow(); + boost::signal<void (Form::ref)> onFormComplete; + private slots: + void handleCancelClicked(); + void handleOKClicked(); + private: + QtFormWidget* formWidget_; + QPushButton* okButton_; + QPushButton* cancelButton_; + }; +} diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index 1d7ab78..82e4490 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -136,6 +136,7 @@ sources = [ "qrc_DefaultTheme.cc", "qrc_Swift.cc", "QtFileTransferJSBridge.cpp", + "QtMUCConfigurationWindow.cpp", ] myenv["SWIFT_VERSION"] = Version.getBuildVersion(env.Dir("#").abspath, "swift") |