summaryrefslogtreecommitdiffstats
blob: 2ac3dec8a1296aaae84d37c58a2789518ec6af69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * Copyright (c) 2010 Kevin Smith
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#include "QtLoginWindowFactory.h"
#include "QtLoginWindow.h"

#include <QDesktopWidget>

namespace Swift {

QtLoginWindowFactory::QtLoginWindowFactory(QSplitter* splitter, QtSystemTray* systemTray, QtSettingsProvider* settings) : QObject() {
	settings_ = settings;
	splitter_ = splitter;
	systemTray_ = systemTray;
}

LoginWindow* QtLoginWindowFactory::createLoginWindow(UIEventStream* uiEventStream) {
	window_ = new QtLoginWindow(uiEventStream);
	if (splitter_) {
		splitter_->insertWidget(0, window_);
		//return window_;
	}
	connect(systemTray_, SIGNAL(clicked()), window_, SLOT(bringToFront()));
	QVariant loginWindowGeometryVariant = settings_->getQSettings()->value("loginWindowGeometry");
	if (loginWindowGeometryVariant.isValid()) {
		window_->restoreGeometry(loginWindowGeometryVariant.toByteArray());
	}
	connect(window_, SIGNAL(geometryChanged()), this, SLOT(handleWindowGeometryChanged()));
	return window_;
}

void QtLoginWindowFactory::handleWindowGeometryChanged() {
	settings_->getQSettings()->setValue("loginWindowGeometry", window_->saveGeometry());
}

}