[PATCH 3/4] qv4l2: fix CaptureWin mimimum size to match video fram size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



CaptureWin's setMinimumSize() sets the minimum size for the
video frame viewport and not for the window itself.
If the minimum size is larger than the monitor resolution,
it will reduce the minimum size to match this.

Signed-off-by: Bård Eirik Winther <bwinther@xxxxxxxxx>
---
 utils/qv4l2/capture-win.cpp | 26 ++++++++++++++++++++++++++
 utils/qv4l2/capture-win.h   |  1 +
 2 files changed, 27 insertions(+)

diff --git a/utils/qv4l2/capture-win.cpp b/utils/qv4l2/capture-win.cpp
index a94c73d..7ac3fa1 100644
--- a/utils/qv4l2/capture-win.cpp
+++ b/utils/qv4l2/capture-win.cpp
@@ -21,6 +21,8 @@
 #include <QImage>
 #include <QVBoxLayout>
 #include <QCloseEvent>
+#include <QApplication>
+#include <QDesktopWidget>
 
 #include "qv4l2.h"
 #include "capture-win.h"
@@ -36,6 +38,10 @@ CaptureWin::CaptureWin()
 	vbox->addWidget(m_label);
 	vbox->addWidget(m_msg);
 
+	int l, t, r, b;
+	vbox->getContentsMargins(&l, &t, &r, &b);
+	vbox->setSpacing(b);
+
 	hotkeyClose = new QShortcut(Qt::CTRL+Qt::Key_W, this);
 	QObject::connect(hotkeyClose, SIGNAL(activated()), this, SLOT(close()));
 }
@@ -45,6 +51,26 @@ CaptureWin::~CaptureWin()
 	delete hotkeyClose;
 }
 
+void CaptureWin::setMinimumSize(int minw, int minh)
+{
+	QDesktopWidget *screen = QApplication::desktop();
+	QRect resolution = screen->screenGeometry();
+
+	int l, t, r, b;
+	layout()->getContentsMargins(&l, &t, &r, &b);
+	minw += l + r;
+	minh += t + b + m_msg->minimumSizeHint().height() + layout()->spacing();
+
+	if (minw > resolution.width())
+		minw = resolution.width();
+
+	if (minh > resolution.height())
+		minh = resolution.height();
+
+	QWidget::setMinimumSize(minw, minh);
+	resize(minw, minh);
+}
+
 void CaptureWin::setImage(const QImage &image, const QString &status)
 {
 	m_label->setPixmap(QPixmap::fromImage(image));
diff --git a/utils/qv4l2/capture-win.h b/utils/qv4l2/capture-win.h
index 4115d56..3de3447 100644
--- a/utils/qv4l2/capture-win.h
+++ b/utils/qv4l2/capture-win.h
@@ -35,6 +35,7 @@ public:
 	CaptureWin();
 	~CaptureWin();
 
+	virtual void setMinimumSize(int minw, int minh);
 	void setImage(const QImage &image, const QString &status);
 
 protected:
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux