changeset 168:875a21ad7a95

* Avoid resizing the window on file load to larger than the available screen size
author Chris Cannam
date Thu, 19 Mar 2009 15:50:59 +0000
parents 7fff1bb8cc3d
children e96f563b1cfd
files framework/MainWindowBase.cpp framework/MainWindowBase.h
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Fri Mar 13 11:06:11 2009 +0000
+++ b/framework/MainWindowBase.cpp	Thu Mar 19 15:50:59 2009 +0000
@@ -90,6 +90,7 @@
 #include <QCheckBox>
 #include <QRegExp>
 #include <QScrollArea>
+#include <QDesktopWidget>
 
 #include <iostream>
 #include <cstdio>
@@ -239,6 +240,16 @@
 }
 
 void
+MainWindowBase::resizeConstrained(QSize size)
+{
+    QDesktopWidget *desktop = QApplication::desktop();
+    QRect available = desktop->availableGeometry();
+    QSize actual(std::min(size.width(), available.width()),
+                 std::min(size.height(), available.height()));
+    resize(actual);
+}
+
+void
 MainWindowBase::oscReady()
 {
     if (m_oscQueue && m_oscQueue->isOK()) {
--- a/framework/MainWindowBase.h	Fri Mar 13 11:06:11 2009 +0000
+++ b/framework/MainWindowBase.h	Thu Mar 19 15:50:59 2009 +0000
@@ -151,6 +151,7 @@
 
 public slots:
     virtual void preferenceChanged(PropertyContainer::PropertyName);
+    virtual void resizeConstrained(QSize);
 
 protected slots:
     virtual void zoomIn();
@@ -334,7 +335,7 @@
 	PaneCallback(MainWindowBase *mw) : m_mw(mw) { }
 	virtual Pane *addPane() { return m_mw->addPaneToStack(); }
 	virtual void setWindowSize(int width, int height) {
-	    m_mw->resize(width, height);
+	    m_mw->resizeConstrained(QSize(width, height));
 	}
 	virtual void addSelection(int start, int end) {
 	    m_mw->m_viewManager->addSelection(Selection(start, end));