diff options
Diffstat (limited to 'Swift/QtUI/ScreenSharing')
-rw-r--r-- | Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp | 40 | ||||
-rw-r--r-- | Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.h | 19 | ||||
-rw-r--r-- | Swift/QtUI/ScreenSharing/QtRemoteScreenWindow.cpp | 34 | ||||
-rw-r--r-- | Swift/QtUI/ScreenSharing/QtRemoteScreenWindow.h | 31 | ||||
-rw-r--r-- | Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.cpp | 54 | ||||
-rw-r--r-- | Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.h | 34 |
6 files changed, 212 insertions, 0 deletions
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; + }; +} |