summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-10-15 20:26:00 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-10-15 20:26:00 (GMT)
commit87775c50a1c9a223f554c37e549ea8a2b03c9a89 (patch)
tree030ca4b9919f48cadaf1a7822d1f3e8917af119b /Swift/QtUI/QtLoginWindow.cpp
parent47f27c607a7fb04495d402c6059664250d452a81 (diff)
downloadswift-87775c50a1c9a223f554c37e549ea8a2b03c9a89.zip
swift-87775c50a1c9a223f554c37e549ea8a2b03c9a89.tar.bz2
Save the geometry of the chat and roster windows.
Diffstat (limited to 'Swift/QtUI/QtLoginWindow.cpp')
-rw-r--r--Swift/QtUI/QtLoginWindow.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp
index 23eece6..e84e316 100644
--- a/Swift/QtUI/QtLoginWindow.cpp
+++ b/Swift/QtUI/QtLoginWindow.cpp
@@ -4,9 +4,12 @@
#include "QtSwiftUtil.h"
#include "QtMainWindow.h"
+#include <algorithm>
+
#include <QApplication>
#include <QBoxLayout>
#include <QComboBox>
+#include <QDesktopWidget>
#include <QFileDialog>
#include <QStatusBar>
#include <QToolButton>
@@ -101,6 +104,29 @@ QtLoginWindow::QtLoginWindow() : QMainWindow() {
this->show();
}
+/**
+ * Move and resize the window, but respect minimum sizes.
+ * (Like QWidget::setGeometry, only that will truncate the window
+ * the setGeometry docs say that it shouldn't do this, but I've just seen it
+ * maybe we can remove this method if that's a Qt bug (or I'm misusing it)).
+ */
+void QtLoginWindow::setGentleGeometry(const QRect& rect) {
+ resize(rect.size());
+ move(rect.topLeft());
+}
+
+QRect QtLoginWindow::defaultPosition() {
+ QDesktopWidget desktop;
+ int windowWidth = 200;
+ int windowHeight = 500;
+ QRect screen = desktop.screenGeometry(-1); //appear on default screen
+ windowWidth = std::min(windowWidth, screen.width());
+ windowHeight = std::min(windowHeight, screen.height());
+ int left = (screen.width() - windowWidth) / 2;
+ int height = (screen.height() - windowHeight) / 2;
+ return QRect(left, height, windowWidth, windowHeight);
+}
+
void QtLoginWindow::addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) {
QString username = P2QSTRING(defaultJID);
int index = -1;
@@ -216,4 +242,13 @@ void QtLoginWindow::bringToFront() {
}
}
+void QtLoginWindow::resizeEvent(QResizeEvent* event) {
+ emit geometryChanged();
+}
+
+void QtLoginWindow::moveEvent(QMoveEvent* event) {
+ emit geometryChanged();
+}
+
+
}