diff options
author | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-06-12 10:52:03 (GMT) |
---|---|---|
committer | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-06-12 10:52:03 (GMT) |
commit | edd726abb1d0f7532218efbb8067a75a313e9e98 (patch) | |
tree | 7eec4f7912a59bb9a383a61c2c96616d5b5847b6 /Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp | |
parent | 6e9fb4e4a3aeee8c40617a4dda6e5e0892ceebad (diff) | |
download | swift-contrib-edd726abb1d0f7532218efbb8067a75a313e9e98.zip swift-contrib-edd726abb1d0f7532218efbb8067a75a313e9e98.tar.bz2 |
Improved whiteboard session handling
Diffstat (limited to 'Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp')
-rw-r--r-- | Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp index e0e68ba..3527eba 100644 --- a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp +++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp @@ -13,10 +13,11 @@ #include <Swiften/Whiteboard/WhiteboardSession.h> #include <Swiften/Elements/WhiteboardPayload.h> +#include <QMessageBox> using namespace std; namespace Swift { - QtWhiteboardWindow::QtWhiteboardWindow(WhiteboardSession* whiteboardSession) : QWidget(), whiteboardSession_(whiteboardSession) { + QtWhiteboardWindow::QtWhiteboardWindow(WhiteboardSession::ref whiteboardSession) : QWidget() { layout = new QVBoxLayout(this); hLayout = new QHBoxLayout; sidebarLayout = new QVBoxLayout; @@ -121,7 +122,7 @@ namespace Swift { layout->addLayout(hLayout); this->setLayout(layout); - whiteboardSession_->onDataReceived.connect(boost::bind(&QtWhiteboardWindow::addItem, this, _1)); + setSession(whiteboardSession); } void QtWhiteboardWindow::addItem(const std::string& item) { @@ -222,10 +223,19 @@ namespace Swift { { graphicsView->setMode(GView::Select); } + void QtWhiteboardWindow::show() { QWidget::show(); } + + void QtWhiteboardWindow::setSession(WhiteboardSession::ref session) { + whiteboardSession_ = session; + whiteboardSession_->onDataReceived.connect(boost::bind(&QtWhiteboardWindow::addItem, this, _1)); + whiteboardSession_->onRequestAccepted.connect(boost::bind(&QWidget::show, this)); + whiteboardSession_->onSessionTerminateReceived.connect(boost::bind(&QtWhiteboardWindow::handleSessionTerminate, this)); + } + void QtWhiteboardWindow::handleLastItemChanged(QGraphicsItem* item) { std::string serialized; QGraphicsLineItem* lineItem = qgraphicsitem_cast<QGraphicsLineItem*>(item); @@ -261,6 +271,25 @@ namespace Swift { // stanzaChannel_->sendMessage(mes);*/ whiteboardSession_->sendData(serialized); } + } + void QtWhiteboardWindow::handleSessionTerminate() { + QMessageBox box(this); + box.setText(tr("Session was terminated by other user")); + box.setIcon(QMessageBox::Information); + box.exec(); + hide(); + } + + void QtWhiteboardWindow::closeEvent(QCloseEvent* event) { + QMessageBox box(this); + box.setText(tr("Closing window is equivalent closing the session. Are you sure you want to do this?")); + box.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + box.setIcon(QMessageBox::Question); + if (box.exec() == QMessageBox::Yes) { + whiteboardSession_->cancel(); + } else { + event->ignore(); + } } } |