summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp')
-rw-r--r--Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp33
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();
+ }
}
}