/* SPDX-FileCopyrightText: 2019 Aleix Pol Gonzalez SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "config-workspace.h" int main(int argc, char **argv) { QCoreApplication::setAttribute(Qt::AA_DisableSessionManager); QApplication app(argc, argv); app.setWindowIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-emoticons"))); KCrash::initialize(); KLocalizedString::setApplicationDomain(QByteArrayLiteral("org.kde.plasma.emojier")); KAboutData about(QStringLiteral("plasma.emojier"), i18n("Emoji Selector"), QStringLiteral(WORKSPACE_VERSION_STRING), i18n("Emoji Selector"), KAboutLicense::GPL, i18n("(C) 2019 Aleix Pol i Gonzalez")); about.addAuthor(QStringLiteral("Aleix Pol i Gonzalez"), QString(), QStringLiteral("aleixpol@kde.org")); about.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails")); // about.setProductName(""); about.setProgramLogo(app.windowIcon()); KAboutData::setApplicationData(about); KDBusService::StartupOptions startup = {}; { QCommandLineParser parser; QCommandLineOption replaceOption({QStringLiteral("replace")}, i18n("Replace an existing instance")); parser.addOption(replaceOption); about.setupCommandLine(&parser); parser.process(app); about.processCommandLine(&parser); if (parser.isSet(replaceOption)) { startup |= KDBusService::Replace; } } KDBusService *service = new KDBusService(KDBusService::Unique | startup, &app); // Clean up old window geometry data from before using WindowStateSaver KSharedConfig::openConfig()->deleteGroup(QStringLiteral("Window")); // Move old recent emojis to state config KConfigGroup oldStateGroup = KSharedConfig::openConfig()->group(QStringLiteral("Emojier")); KConfigGroup newStateGroup = KSharedConfig::openStateConfig()->group(QStringLiteral("Emojier")); oldStateGroup.moveValuesTo({"recent", "recentDescriptions"}, newStateGroup); QQmlApplicationEngine engine; engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); engine.loadFromModule("org.kde.plasma.emoji.app", "Emojier"); QObject::connect(service, &KDBusService::activateRequested, &engine, [&engine](const QStringList & /*arguments*/, const QString & /*workingDirectory*/) { for (QObject *object : engine.rootObjects()) { auto w = qobject_cast(object); if (!w) continue; KWindowSystem::updateStartupId(w); KWindowSystem::activateWindow(w); w->setVisible(true); w->raise(); } }); return app.exec(); }