summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtUIFactory.cpp8
-rw-r--r--Swift/QtUI/QtUIFactory.h1
-rw-r--r--Swift/QtUI/Roster/QtRosterWidget.cpp8
-rw-r--r--Swift/QtUI/SConscript5
-rw-r--r--Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp40
-rw-r--r--Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.h19
-rw-r--r--Swift/QtUI/ScreenSharing/QtRemoteScreenWindow.cpp34
-rw-r--r--Swift/QtUI/ScreenSharing/QtRemoteScreenWindow.h31
-rw-r--r--Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.cpp54
-rw-r--r--Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.h34
10 files changed, 233 insertions, 1 deletions
diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp
index a154fb0..ba9cbc9 100644
--- a/Swift/QtUI/QtUIFactory.cpp
+++ b/Swift/QtUI/QtUIFactory.cpp
@@ -26,6 +26,7 @@
#include "QtAdHocCommandWindow.h"
#include "QtFileTransferListWidget.h"
#include "Whiteboard/QtWhiteboardWindow.h"
+#include <Swift/QtUI/ScreenSharing/QtRemoteScreenWindow.h>
#include <Swift/Controllers/Settings/SettingsProviderHierachy.h>
#include <Swift/QtUI/QtUISettingConstants.h>
#include <QtHistoryWindow.h>
@@ -77,6 +78,13 @@ FileTransferListWidget* QtUIFactory::createFileTransferListWidget() {
return widget;
}
+RemoteScreenWindow* QtUIFactory::createRemoteScreenViewer(boost::shared_ptr<IncomingScreenSharing> iss)
+{
+ QtRemoteScreenWindow* rsv = new QtRemoteScreenWindow(iss);
+ rsv->show();
+ return rsv;
+}
+
MainWindow* QtUIFactory::createMainWindow(UIEventStream* eventStream) {
lastMainWindow = new QtMainWindow(settings, eventStream, loginWindow->getMenus(), emoticonsExist_);
return lastMainWindow;
diff --git a/Swift/QtUI/QtUIFactory.h b/Swift/QtUI/QtUIFactory.h
index 30f0101..8d4be81 100644
--- a/Swift/QtUI/QtUIFactory.h
+++ b/Swift/QtUI/QtUIFactory.h
@@ -46,6 +46,7 @@ namespace Swift {
virtual ContactEditWindow* createContactEditWindow();
virtual FileTransferListWidget* createFileTransferListWidget();
virtual WhiteboardWindow* createWhiteboardWindow(boost::shared_ptr<WhiteboardSession> whiteboardSession);
+ virtual RemoteScreenWindow* createRemoteScreenViewer(boost::shared_ptr<IncomingScreenSharing> iss);
virtual void createAdHocCommandWindow(boost::shared_ptr<OutgoingAdHocCommandSession> command);
private slots:
diff --git a/Swift/QtUI/Roster/QtRosterWidget.cpp b/Swift/QtUI/Roster/QtRosterWidget.cpp
index 1cf073b..0e75057 100644
--- a/Swift/QtUI/Roster/QtRosterWidget.cpp
+++ b/Swift/QtUI/Roster/QtRosterWidget.cpp
@@ -16,6 +16,7 @@
#include "Swift/Controllers/UIEvents/RenameGroupUIEvent.h"
#include "Swift/Controllers/UIEvents/SendFileUIEvent.h"
#include "Swift/Controllers/UIEvents/RequestWhiteboardUIEvent.h"
+#include "Swift/Controllers/UIEvents/ShareScreenUIEvent.h"
#include "QtContactEditWindow.h"
#include "Swift/Controllers/Roster/ContactRosterItem.h"
#include "Swift/Controllers/Roster/GroupRosterItem.h"
@@ -62,6 +63,10 @@ void QtRosterWidget::contextMenuEvent(QContextMenuEvent* event) {
if (contact->supportsFeature(ContactRosterItem::FileTransferFeature)) {
sendFile = contextMenu.addAction(tr("Send File"));
}
+ QAction* shareScreen = NULL;
+ if (contact->supportsFeature(ContactRosterItem::ScreenSharingFeature)) {
+ shareScreen = contextMenu.addAction(tr("Share my screen"));
+ }
#endif
#ifdef SWIFT_EXPERIMENTAL_WB
QAction* startWhiteboardChat = NULL;
@@ -85,6 +90,9 @@ void QtRosterWidget::contextMenuEvent(QContextMenuEvent* event) {
eventStream_->send(boost::make_shared<SendFileUIEvent>(contact->getJID(), Q2PSTRING(fileName)));
}
}
+ else if (shareScreen && result == shareScreen) {
+ eventStream_->send(boost::make_shared<ShareScreenUIEvent>(contact->getJID()));
+ }
#endif
#ifdef SWIFT_EXPERIMENTAL_WB
else if (startWhiteboardChat && result == startWhiteboardChat) {
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index c940d49..9d8f42b 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -161,7 +161,10 @@ sources = [
"QtChatWindowJSBridge.cpp",
"QtMUCConfigurationWindow.cpp",
"QtAffiliationEditor.cpp",
- "QtUISettingConstants.cpp"
+ "QtUISettingConstants.cpp",
+ "ScreenSharing/RemoteScreenViewerWidget.cpp",
+ "ScreenSharing/QtRemoteScreenWindow.cpp",
+ "ScreenSharing/QtDesktopScreenGrabber.cpp",
]
myenv["SWIFT_VERSION"] = Version.getBuildVersion(env.Dir("#").abspath, "swift")
diff --git a/Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp b/Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp
new file mode 100644
index 0000000..a5eeafd
--- /dev/null
+++ b/Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2012 Yoann Blein
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include "QtDesktopScreenGrabber.h"
+
+#include <QImage>
+#include <QPixmap>
+#include <QApplication>
+#include <QDesktopWidget>
+
+#include <Swiften/ScreenSharing/Image.h>
+
+/*#include <QImage>
+#include <QLabel>*/
+
+namespace Swift {
+
+QtDesktopScreenGrabber::QtDesktopScreenGrabber()
+{
+ /*Image img = grab();
+ QImage qImg(img.data.data(), img.width, img.height, QImage::Format_RGB888);
+ QLabel *label = new QLabel;
+ label->setPixmap(QPixmap::fromImage(qImg));
+ label->show();*/
+}
+
+QtDesktopScreenGrabber::~QtDesktopScreenGrabber()
+{
+}
+
+Image QtDesktopScreenGrabber::grab() const
+{
+ QImage qImg = QPixmap::grabWindow(QApplication::desktop()->winId()).toImage().convertToFormat(QImage::Format_RGB888);
+ return Image(qImg.width(), qImg.height(), qImg.constBits());
+}
+
+}
diff --git a/Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.h b/Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.h
new file mode 100644
index 0000000..55a7842
--- /dev/null
+++ b/Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2012 Yoann Blein
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include "Swift/Controllers/ScreenSharing/DesktopScreenGrabber.h"
+
+namespace Swift {
+ class QtDesktopScreenGrabber : public DesktopScreenGrabber {
+ public:
+ QtDesktopScreenGrabber();
+ virtual ~QtDesktopScreenGrabber();
+
+ virtual Image grab() const;
+ };
+}
diff --git a/Swift/QtUI/ScreenSharing/QtRemoteScreenWindow.cpp b/Swift/QtUI/ScreenSharing/QtRemoteScreenWindow.cpp
new file mode 100644
index 0000000..e6cd291
--- /dev/null
+++ b/Swift/QtUI/ScreenSharing/QtRemoteScreenWindow.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012 Yoann Blein
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include "QtRemoteScreenWindow.h"
+#include "RemoteScreenViewerWidget.h"
+
+#include <QToolBar>
+
+#include <Swiften/ScreenSharing/IncomingScreenSharing.h>
+
+namespace Swift {
+
+QtRemoteScreenWindow::QtRemoteScreenWindow(boost::shared_ptr<IncomingScreenSharing> incScreenSharing, QWidget *parent)
+ : QMainWindow(parent), RemoteScreenWindow(incScreenSharing)
+{
+ setCentralWidget(new RemoteScreenViewerWidget(iss));
+
+ controlToolBar = addToolBar(tr("Control"));
+ closeAction = controlToolBar->addAction(QIcon::fromTheme("window-close"), tr("&Terminate session"), this, SLOT(handleCloseTriggered()));
+}
+
+QtRemoteScreenWindow::~QtRemoteScreenWindow()
+{
+}
+
+void QtRemoteScreenWindow::handleCloseTriggered()
+{
+ iss->stop();
+}
+
+}
diff --git a/Swift/QtUI/ScreenSharing/QtRemoteScreenWindow.h b/Swift/QtUI/ScreenSharing/QtRemoteScreenWindow.h
new file mode 100644
index 0000000..00ac803
--- /dev/null
+++ b/Swift/QtUI/ScreenSharing/QtRemoteScreenWindow.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012 Yoann Blein
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include "Swift/Controllers/UIInterfaces/RemoteScreenWindow.h"
+
+#include <QMainWindow>
+
+class QToolBar;
+
+namespace Swift {
+
+ class QtRemoteScreenWindow : public QMainWindow, public RemoteScreenWindow {
+ Q_OBJECT
+
+ public:
+ QtRemoteScreenWindow(boost::shared_ptr<IncomingScreenSharing> incScreenSharing, QWidget *parent = 0);
+ virtual ~QtRemoteScreenWindow();
+
+ private slots:
+ void handleCloseTriggered();
+
+ private:
+ QAction* closeAction;
+ QToolBar* controlToolBar;
+ };
+}
diff --git a/Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.cpp b/Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.cpp
new file mode 100644
index 0000000..f601f1b
--- /dev/null
+++ b/Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2012 Yoann Blein
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include "RemoteScreenViewerWidget.h"
+
+#include <QResizeEvent>
+#include <QPainter>
+
+#include <boost/bind.hpp>
+
+#include <Swiften/ScreenSharing/IncomingScreenSharing.h>
+#include <Swiften/ScreenSharing/Image.h>
+
+
+namespace Swift {
+
+RemoteScreenViewerWidget::RemoteScreenViewerWidget(boost::shared_ptr<IncomingScreenSharing> incScreenSharing, QWidget *parent) :
+ QWidget(parent), iss(incScreenSharing)
+{
+ iss->onNewImageReceived.connect(boost::bind(&RemoteScreenViewerWidget::handleNewImageReceived, this, _1));
+}
+
+RemoteScreenViewerWidget::~RemoteScreenViewerWidget()
+{
+ iss->onNewImageReceived.disconnect(boost::bind(&RemoteScreenViewerWidget::handleNewImageReceived, this, _1));
+}
+
+void RemoteScreenViewerWidget::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+ if (!pixmap.isNull()) {
+ painter.translate(geometry().center());
+ painter.drawPixmap(-pixmap.rect().center(), pixmap);
+ }
+}
+
+void RemoteScreenViewerWidget::resizeEvent(QResizeEvent *event)
+{
+ if (!pixmap.isNull())
+ pixmap = pixmap.scaled(event->size(), Qt::KeepAspectRatio);
+ QWidget::resizeEvent(event);
+}
+
+void RemoteScreenViewerWidget::handleNewImageReceived(const Image& image)
+{
+ QImage qImg(image.data.data(), image.width, image.height, QImage::Format_RGB888);
+ pixmap = QPixmap::fromImage(qImg).scaled(size(), Qt::KeepAspectRatio);
+ update();
+}
+
+}
diff --git a/Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.h b/Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.h
new file mode 100644
index 0000000..622bd26
--- /dev/null
+++ b/Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012 Yoann Blein
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <QWidget>
+
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class IncomingScreenSharing;
+ class Image;
+
+ class RemoteScreenViewerWidget : public QWidget {
+ Q_OBJECT
+ public:
+ RemoteScreenViewerWidget(boost::shared_ptr<IncomingScreenSharing> incScreenSharing, QWidget *parent = 0);
+ ~RemoteScreenViewerWidget();
+
+ protected:
+ void paintEvent(QPaintEvent *);
+ void resizeEvent(QResizeEvent *event);
+
+ private:
+ void handleNewImageReceived(const Image& image);
+
+ private:
+ boost::shared_ptr<IncomingScreenSharing> iss;
+ QPixmap pixmap;
+ };
+}