From 577fffec4a1da6909740a392cf76617bdcbe5570 Mon Sep 17 00:00:00 2001 From: dknn Date: Tue, 7 Aug 2012 15:42:27 +0200 Subject: Add frame around the remote screen viewer diff --git a/Swift/QtUI/ScreenSharing/QtRemoteScreenWindow.cpp b/Swift/QtUI/ScreenSharing/QtRemoteScreenWindow.cpp index a1f1a88..090ab6b 100644 --- a/Swift/QtUI/ScreenSharing/QtRemoteScreenWindow.cpp +++ b/Swift/QtUI/ScreenSharing/QtRemoteScreenWindow.cpp @@ -8,6 +8,7 @@ #include "RemoteScreenViewerWidget.h" #include +#include #include #include @@ -17,9 +18,14 @@ namespace Swift { QtRemoteScreenWindow::QtRemoteScreenWindow(boost::shared_ptr incScreenSharing, QWidget *parent) : QMainWindow(parent), RemoteScreenWindow(incScreenSharing), viewer(new RemoteScreenViewerWidget(iss)) { - QVBoxLayout* centralLayout = new QVBoxLayout; - centralLayout->addWidget(viewer); + QVBoxLayout* frameLayout = new QVBoxLayout; + frameLayout->addWidget(viewer); + QFrame* frame = new QFrame; + frame->setLayout(frameLayout); + frame->setContentsMargins(QMargins(0, 0, 0, 0)); + QVBoxLayout* centralLayout = new QVBoxLayout; + centralLayout->addWidget(frame); QWidget* central = new QWidget(this); central->setLayout(centralLayout); diff --git a/Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.cpp b/Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.cpp index 7bb3f26..899f335 100644 --- a/Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.cpp +++ b/Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.cpp @@ -18,7 +18,7 @@ namespace Swift { RemoteScreenViewerWidget::RemoteScreenViewerWidget(boost::shared_ptr incScreenSharing, QWidget *parent) : - QFrame(parent), iss(incScreenSharing) + QWidget(parent), iss(incScreenSharing) { iss->onNewImageReceived.connect(boost::bind(&RemoteScreenViewerWidget::handleNewImageReceived, this, _1)); } @@ -30,7 +30,6 @@ RemoteScreenViewerWidget::~RemoteScreenViewerWidget() void RemoteScreenViewerWidget::paintEvent(QPaintEvent* event) { - QFrame::paintEvent(event); if (!pixmap.isNull()) { QPainter painter(this); painter.translate(geometry().center()); @@ -41,19 +40,15 @@ void RemoteScreenViewerWidget::paintEvent(QPaintEvent* event) void RemoteScreenViewerWidget::resizeEvent(QResizeEvent *event) { if (!pixmap.isNull()) { - int frameWidth2 = frameWidth() * 2; - QSize borders(frameWidth2, frameWidth2); - pixmap = pixmap.scaled(event->size() - borders, Qt::KeepAspectRatio); + pixmap = pixmap.scaled(event->size(), Qt::KeepAspectRatio); } - QFrame::resizeEvent(event); + QWidget::resizeEvent(event); } void RemoteScreenViewerWidget::handleNewImageReceived(const Image& image) { QImage qImg(image.data.data(), image.width, image.height, QImage::Format_RGB888); - int frameWidth2 = frameWidth() * 2; - QSize borders(frameWidth2, frameWidth2); - pixmap = QPixmap::fromImage(qImg).scaled(size() - borders, Qt::KeepAspectRatio); + pixmap = QPixmap::fromImage(qImg).scaled(size(), Qt::KeepAspectRatio); update(); } diff --git a/Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.h b/Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.h index c074e9f..b0a377e 100644 --- a/Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.h +++ b/Swift/QtUI/ScreenSharing/RemoteScreenViewerWidget.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include @@ -14,7 +14,7 @@ namespace Swift { class IncomingScreenSharing; class Image; - class RemoteScreenViewerWidget : public QFrame { + class RemoteScreenViewerWidget : public QWidget { Q_OBJECT public: RemoteScreenViewerWidget(boost::shared_ptr incScreenSharing, QWidget *parent = 0); -- cgit v0.10.2-6-g49f6