File indexing completed on 2024-04-28 16:49:43

0001 /*
0002  * SPDX-FileCopyrightText: 2014 Daniel Vratil <dvratil@redhat.com>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-or-later
0005  *
0006  */
0007 
0008 #include <QDBusConnection>
0009 #include <QGuiApplication>
0010 
0011 #include "backendloader.h"
0012 #include "kscreen_backendLauncher_debug.h"
0013 #include "log.h"
0014 
0015 int main(int argc, char **argv)
0016 {
0017     KScreen::Log::instance();
0018     QGuiApplication::setDesktopSettingsAware(false);
0019     QCoreApplication::setAttribute(Qt::AA_DisableSessionManager);
0020     QGuiApplication app(argc, argv);
0021 
0022     if (!QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.KScreen"))) {
0023         qCWarning(KSCREEN_BACKEND_LAUNCHER) << "Cannot register org.kde.KScreen service. Another launcher already running?";
0024         return -1;
0025     }
0026 
0027     BackendLoader *loader = new BackendLoader;
0028     if (!loader->init()) {
0029         return -2;
0030     }
0031 
0032     const int ret = app.exec();
0033 
0034     // Make sure the backend is destroyed and unloaded before we return (i.e.
0035     // as long as QApplication object and it's XCB connection still exist
0036     delete loader;
0037 
0038     return ret;
0039 }