[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r1474: If we're building with Qt >= 4.2.0, then use its handy dandy (trunk/src/gui/common)



Author: edmanm
Date: 2006-11-23 15:11:56 -0500 (Thu, 23 Nov 2006)
New Revision: 1474

Modified:
   trunk/src/gui/common/vidaliawindow.cpp
Log:
If we're building with Qt >= 4.2.0, then use its handy dandy new
saveGeometry() and restoreGeometry() functions to save and restore window size
and position. If we're still using an old Qt, make sure the window fits on
screen (Ticket #207).


Modified: trunk/src/gui/common/vidaliawindow.cpp
===================================================================
--- trunk/src/gui/common/vidaliawindow.cpp	2006-11-23 15:43:28 UTC (rev 1473)
+++ trunk/src/gui/common/vidaliawindow.cpp	2006-11-23 20:11:56 UTC (rev 1474)
@@ -29,7 +29,9 @@
 #include <QSize>
 #include <QPalette>
 #include <QShortcut>
+#include <QByteArray>
 #include <QKeySequence>
+#include <QDesktopWidget>
 #include "vidaliawindow.h"
 
 
@@ -61,25 +63,37 @@
 void
 VidaliaWindow::saveWindowState()
 {
+#if QT_VERSION >= 0x040200
+  saveSetting("Geometry", saveGeometry());
+#else
   saveSetting("Size", size());
   saveSetting("Position", pos());
+#endif
 }
 
 /** Restores the last size and location of the window. */
 void
 VidaliaWindow::restoreWindowState()
 {
+#if QT_VERSION >= 0x040200
+  QByteArray geometry = getSetting("Geometry", QByteArray()).toByteArray();
+  restoreGeometry(geometry);
+#else
+  QRect screen = QDesktopWidget().availableGeometry();
+
   /* Restore the window size. */
   QSize size = getSetting("Size", QSize()).toSize();
   if (!size.isEmpty()) {
+    size = size.boundedTo(screen.size());
     resize(size);
   }
 
   /* Restore the window position. */
   QPoint pos = getSetting("Position", QPoint()).toPoint();
-  if (!pos.isNull()) {
+  if (!pos.isNull() && screen.contains(pos)) {
     move(pos);
   }
+#endif
 }
 
 /** Gets the saved value of a property associated with this window object.