summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..c0ce7bc
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,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();
+}