tags 582065 + patch
thanks

Christoph Pfister wrote:
> Can you please elaborate a bit? You can't resize at all or you can't
> make the window smaller than some size?

I personally cannot really answer that question, but I have the problem that I 
could not resize the window bellow a "magic" size. This was the maximum size 
of all (visible or not) minimal sizes widgets inside the QStackedLayout.

My workaround is currently to provide a own layout. The only difference is the 
calculation of the minimal size of the main layout using only the visible 
layout inside the QStackedLayout.

Now I can resize it again in the minimal size of 92x62 pixel (more than small 
enough for me - I just wanted to get it to something like 320x240 instead of 
~800x200).

Maybe it is what he wanted - otherwise just ignore it.

This maybe fixes upsteam bug #226183 and #240068

Best regards,
        Sven
From f0f9ffa6e1f729497478b7bba8a80aea6e591eb2 Mon Sep 17 00:00:00 2001
From: Sven Eckelmann <sven.eckelm...@gmx.de>
Date: Wed, 15 Sep 2010 21:10:30 +0200
Subject: [PATCH] Allow to resize window according to visible widgets

Currently the biggest widget/layout in a QStackedLayout determines what
the minimum size is. Kaffeine usually wants only the current visible
widgets/layout to set the limits of the complete window. This is
especially important when Kaffeine runs in the minimal mode which only
has the mediawidget visible and should not have the minimum size of the
relative big start tab.

Signed-off-by: Sven Eckelmann <sven.eckelm...@gmx.de>
---
 src/mainwindow.cpp |   50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 49 insertions(+), 1 deletions(-)

diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 7e534c2..50586e9 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -53,6 +53,51 @@ private:
 	QAbstractButton *addShortcut(const QString &name, const KIcon &icon, QWidget *parent);
 };
 
+class KaffeineLayout : public QStackedLayout
+{
+public:
+	explicit KaffeineLayout(QWidget *widget) : QStackedLayout(widget) {};
+	~KaffeineLayout() { }
+
+	virtual QSize minimumSize() const
+	{
+		QWidget *w = this->currentWidget();
+		QSize s(0, 0);
+
+		if (!w)
+			return s;
+
+		const QSize sizeHint = w->sizeHint();
+		const QSize minSizeHint = w->minimumSizeHint();
+		const QSize minSize =  w->minimumSize();
+		const QSize maxSize = w->maximumSize();
+		const QSizePolicy sizePolicy =  w->sizePolicy();
+
+		if (sizePolicy.horizontalPolicy() != QSizePolicy::Ignored) {
+			if (sizePolicy.horizontalPolicy() & QSizePolicy::ShrinkFlag)
+				s.setWidth(minSizeHint.width());
+			else
+				s.setWidth(qMax(sizeHint.width(), minSizeHint.width()));
+		}
+
+		if (sizePolicy.verticalPolicy() != QSizePolicy::Ignored) {
+			if (sizePolicy.verticalPolicy() & QSizePolicy::ShrinkFlag) {
+				s.setHeight(minSizeHint.height());
+			} else {
+				s.setHeight(qMax(sizeHint.height(), minSizeHint.height()));
+			}
+		}
+
+		s = s.boundedTo(maxSize);
+		if (minSize.width() > 0)
+			s.setWidth(minSize.width());
+		if (minSize.height() > 0)
+			s.setHeight(minSize.height());
+
+		return s.expandedTo(QSize(0,0));
+	}
+};
+
 StartTab::StartTab(MainWindow *mainWindow)
 {
 	setBackgroundRole(QPalette::Base);
@@ -273,7 +318,7 @@ MainWindow::MainWindow()
 	// main area
 
 	QWidget *widget = new QWidget(this);
-	stackedLayout = new QStackedLayout(widget);
+	stackedLayout = new KaffeineLayout(widget);
 	setCentralWidget(widget);
 
 	mediaWidget = new MediaWidget(playerMenu, controlBar, collection, widget);
@@ -556,6 +601,9 @@ void MainWindow::resizeToVideo(int factor)
 			setWindowState(windowState() & ~Qt::WindowMaximized);
 		}
 
+		if (mediaWidget->sizeHint().isEmpty())
+			return;
+
 		resize(size() - centralWidget()->size() + factor * mediaWidget->sizeHint());
 	}
 }
-- 
1.7.2.3

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
pkg-kde-extras mailing list
pkg-kde-extras@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/pkg-kde-extras

Reply via email to