summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
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();
+}
+
+
}