forked from surlykke/qt-lightdm-greeter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
57 lines (47 loc) · 1.45 KB
/
main.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* Copyright (c) 2012-2015 Christian Surlykke, Petr Vanek
*
* This file is part of qt-lightdm-greeter
* It is distributed under the LGPL 2.1 or later license.
* Please refer to the LICENSE file for a copy of the license.
*/
#include <QtWidgets/QApplication>
#include <QDesktopWidget>
#include <QtGlobal>
#include <QtDebug>
#include <QSettings>
#include <QIcon>
#include <iostream>
#include "settings.h"
#include "mainwindow.h"
QFile logfile;
QTextStream ts;
void messageHandler(QtMsgType type, const QMessageLogContext&, const QString& msg)
{
std::cerr << type << ": " << msg.toLatin1().data() << "\n";
}
int main(int argc, char *argv[])
{
// I have no idea why, but Qt's stock qDebug() output never makes it
// to /var/log/lightdm/x-0-greeter.log, so we use std::cerr instead..
qInstallMessageHandler(messageHandler);
Cache::prepare();
QApplication a(argc, argv);
if (! Settings().iconThemeName().isEmpty()) {
QIcon::setThemeName(Settings().iconThemeName());
}
MainWindow *focusWindow = 0;
for (int i = 0; i < QApplication::desktop()->screenCount(); ++i) {
MainWindow *w = new MainWindow(i);
w->show();
if (w->showLoginForm())
focusWindow = w;
}
// Ensure we set the primary screen's widget as active when there
// are more screens
if (focusWindow) {
focusWindow->setFocus(Qt::OtherFocusReason);
focusWindow->activateWindow();
}
return a.exec();
}