diff options
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 @@ -156,18 +156,21 @@ QtChatWindow::QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventSt messageLog_->addToJSEnvironment("filetransfer", fileTransferJS); connect(fileTransferJS, SIGNAL(setDescription(QString)), this, SLOT(handleFileTransferSetDescription(QString))); connect(fileTransferJS, SIGNAL(sendRequest(QString)), this, SLOT(handleFileTransferStart(QString))); connect(fileTransferJS, SIGNAL(acceptRequest(QString, QString)), this, SLOT(handleFileTransferAccept(QString, QString))); connect(fileTransferJS, SIGNAL(cancel(QString)), this, SLOT(handleFileTransferCancel(QString))); } QtChatWindow::~QtChatWindow() { delete fileTransferJS; + if (mucConfigurationWindow) { + delete mucConfigurationWindow.data(); + } } void QtChatWindow::handleOccupantSelectionChanged(RosterItem* item) { onOccupantSelectionChanged(dynamic_cast<ContactRosterItem*>(item)); } void QtChatWindow::handleFontResized(int fontSizeSteps) { messageLog_->resizeFont(fontSizeSteps); @@ -358,19 +361,21 @@ void QtChatWindow::qAppFocusChanged(QWidget* /*old*/, QWidget* /*now*/) { onAllMessagesRead(); } else { lastLineTracker_.setHasFocus(false); } } void QtChatWindow::setInputEnabled(bool enabled) { inputEnabled_ = enabled; -// input_->setEnabled(enabled); + if (!enabled && mucConfigurationWindow) { + delete mucConfigurationWindow.data(); + } } void QtChatWindow::showEvent(QShowEvent* event) { emit windowOpening(); QWidget::showEvent(event); } void QtChatWindow::setUnreadMessageCount(int count) { if (unreadCount_ != count) { @@ -688,24 +693,32 @@ void QtChatWindow::setAvailableOccupantActions(const std::vector<OccupantAction> 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* configure = contextMenu.addAction(tr("Configure room")); + QAction* configure = contextMenu.addAction(tr("Configure room")); 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)); } } - //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 @@ -1,26 +1,28 @@ /* * Copyright (c) 2010-2011 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #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; class QComboBox; class QLabel; class QSplitter; class QPushButton; namespace Swift { @@ -63,18 +65,19 @@ namespace Swift { void setRosterModel(Roster* roster); void setTabComplete(TabComplete* completer); int getCount(); void replaceLastMessage(const std::string& message); void setAckState(const std::string& id, AckState state); void flash(); 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); void handleFontResized(int fontSizeSteps); void setAlert(const std::string& alertText, const std::string& buttonText = ""); void cancelAlert(); void setCorrectionEnabled(Tristate enabled); signals: @@ -141,14 +144,14 @@ namespace Swift { bool previousMessageWasFileTransfer_; QString previousSenderName_; bool inputClearing_; UIEventStream* eventStream_; bool inputEnabled_; IDGenerator id_; 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 @@ -130,18 +130,19 @@ sources = [ "UserSearch/QtUserSearchWindow.cpp", "UserSearch/UserSearchModel.cpp", "UserSearch/UserSearchDelegate.cpp", "QtSubscriptionRequestWindow.cpp", "QtRosterHeader.cpp", "QtWebView.cpp", "qrc_DefaultTheme.cc", "qrc_Swift.cc", "QtFileTransferJSBridge.cpp", + "QtMUCConfigurationWindow.cpp", ] myenv["SWIFT_VERSION"] = Version.getBuildVersion(env.Dir("#").abspath, "swift") if env["PLATFORM"] == "win32" : res = myenv.RES("#/Swift/resources/Windows/Swift.rc") # For some reason, SCons isn't picking up the dependency correctly # Adding it explicitly until i figure out why myenv.Depends(res, "../Controllers/BuildVersion.h") |