diff --git a/klipper/main.cpp b/klipper/main.cpp index 58a07783e..36539b637 100644 --- a/klipper/main.cpp +++ b/klipper/main.cpp @@ -1,99 +1,99 @@ /* This file is part of the KDE project Copyright (C) Andrew Stanley-Jones This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include #include #include #include #include "tray.h" #include "klipper.h" extern "C" int Q_DECL_EXPORT kdemain(int argc, char *argv[]) { - KLocalizedString::setApplicationDomain("klipper"); QApplication app(argc, argv); + KLocalizedString::setApplicationDomain("klipper"); KAboutData aboutData(QStringLiteral("klipper"), i18n("Klipper"), QStringLiteral(KLIPPER_VERSION_STRING), i18n("KDE cut & paste history utility"), KAboutLicense::GPL, i18n("(c) 1998, Andrew Stanley-Jones\n" "1998-2002, Carsten Pfeiffer\n" "2001, Patrick Dubroy")); aboutData.addAuthor(i18n("Carsten Pfeiffer"), i18n("Author"), QStringLiteral("pfeiffer@kde.org")); aboutData.addAuthor(i18n("Andrew Stanley-Jones"), i18n( "Original Author" ), QStringLiteral("asj@cban.com")); aboutData.addAuthor(i18n("Patrick Dubroy"), i18n("Contributor"), QStringLiteral("patrickdu@corel.com")); aboutData.addAuthor(i18n("Luboš Luňák"), i18n("Bugfixes and optimizations"), QStringLiteral("l.lunak@kde.org")); aboutData.addAuthor(i18n("Esben Mose Hansen"), i18n("Previous Maintainer"), QStringLiteral("kde@mosehansen.dk")); aboutData.addAuthor(i18n("Martin Gräßlin"), i18n("Maintainer"), QStringLiteral("mgraesslin@kde.org")); aboutData.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails")); KAboutData::setApplicationData(aboutData); QGuiApplication::setFallbackSessionManagementEnabled(false); auto disableSessionManagement = [](QSessionManager &sm) { sm.setRestartHint(QSessionManager::RestartNever); }; QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); app.setQuitOnLastWindowClosed( false ); QCommandLineParser parser; parser.addHelpOption(); parser.addVersionOption(); aboutData.setupCommandLine(&parser); parser.process(app); aboutData.processCommandLine(&parser); KDBusService service(KDBusService::Unique); // make KConfigDialog "know" when our actions page is changed KConfigDialogManager::changedMap()->insert(QStringLiteral("ActionsTreeWidget"), SIGNAL(changed())); KlipperTray klipper; return app.exec(); } diff --git a/krunner/main.cpp b/krunner/main.cpp index 41d0485f3..9342cd505 100644 --- a/krunner/main.cpp +++ b/krunner/main.cpp @@ -1,92 +1,91 @@ /* * Copyright 2012 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "view.h" static QCommandLineParser parser; int main(int argc, char **argv) { qunsetenv("QT_DEVICE_PIXEL_RATIO"); QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); - KLocalizedString::setApplicationDomain("krunner"); - QQuickWindow::setDefaultAlphaBuffer(true); QApplication app(argc, argv); + KLocalizedString::setApplicationDomain("krunner"); KQuickAddons::QtQuickSettings::init(); // TODO: Make it a QGuiApplication once we don't depend on KDELibs4Support // QGuiApplication app(argc, argv); KAboutData aboutData(QStringLiteral("krunner"), i18n("krunner"), QStringLiteral(PROJECT_VERSION), i18n("Run Command interface"), KAboutLicense::GPL); KAboutData::setApplicationData(aboutData); app.setQuitOnLastWindowClosed(false); aboutData.setupCommandLine(&parser); parser.addHelpOption(); parser.addVersionOption(); parser.process(app); aboutData.processCommandLine(&parser); if (!KAuthorized::authorize(QStringLiteral("run_command"))) { return -1; } KDBusService service(KDBusService::Unique); QGuiApplication::setFallbackSessionManagementEnabled(false); auto disableSessionManagement = [](QSessionManager &sm) { sm.setRestartHint(QSessionManager::RestartNever); }; QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); View view; view.setVisible(false); QObject::connect(&service, &KDBusService::activateRequested, &view, &View::display); return app.exec(); } diff --git a/shell/main.cpp b/shell/main.cpp index ed42ed408..22ef03882 100644 --- a/shell/main.cpp +++ b/shell/main.cpp @@ -1,167 +1,166 @@ /* * Copyright 2012 Marco Martin * Copyright 2013 Sebastian Kügler * Copyright 2015 David Edmundson * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include #include #include #include #include #include #include "shellcorona.h" #include "standaloneappcorona.h" #include "shellmanager.h" #include "coronatesthelper.h" #include int main(int argc, char *argv[]) { //Plasma scales itself to font DPI //on X, where we don't have compositor scaling, this generally works fine. //also there are bugs on older Qt, especially when it comes to fractional scaling //there's advantages to disabling, and (other than small context menu icons) few advantages in enabling //On wayland, it's different. Everything is simpler as all co-ordinates are in the same co-ordinate system //we don't have fractional scaling on the client so don't hit most the remaining bugs and //even if we don't use Qt scaling the compositor will try to scale us anyway so we have no choice if (!qEnvironmentVariableIsSet("PLASMA_USE_QT_SCALING")) { qunsetenv("QT_DEVICE_PIXEL_RATIO"); QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); } QQuickWindow::setDefaultAlphaBuffer(true); - KLocalizedString::setApplicationDomain("plasmashell"); - QApplication app(argc, argv); + KLocalizedString::setApplicationDomain("plasmashell"); // The executable's path is added to the library/plugin paths. // This does not make much sense for plasmashell. app.removeLibraryPath(QCoreApplication::applicationDirPath()); KQuickAddons::QtQuickSettings::init(); KAboutData aboutData(QStringLiteral("plasmashell"), i18n("Plasma"), QStringLiteral(PROJECT_VERSION), i18n("Plasma Shell"), KAboutLicense::GPL); KAboutData::setApplicationData(aboutData); app.setQuitOnLastWindowClosed(false); { QCommandLineParser cliOptions; QCommandLineOption dbgOption(QStringList() << QStringLiteral("d") << QStringLiteral("qmljsdebugger"), i18n("Enable QML Javascript debugger")); QCommandLineOption noRespawnOption(QStringList() << QStringLiteral("n") << QStringLiteral("no-respawn"), i18n("Do not restart plasma-shell automatically after a crash")); QCommandLineOption shellPluginOption(QStringList() << QStringLiteral("p") << QStringLiteral("shell-plugin"), i18n("Force loading the given shell plugin"), QStringLiteral("plugin")); QCommandLineOption standaloneOption(QStringList() << QStringLiteral("a") << QStringLiteral("standalone"), i18n("Load plasmashell as a standalone application, needs the shell-plugin option to be specified")); QCommandLineOption testOption(QStringList() << QStringLiteral("test"), i18n("Enables test mode and specifies the layout javascript file to set up the testing environment"), i18n("file"), QStringLiteral("layout.js")); cliOptions.addOption(dbgOption); cliOptions.addOption(noRespawnOption); cliOptions.addOption(shellPluginOption); cliOptions.addOption(standaloneOption); cliOptions.addOption(testOption); aboutData.setupCommandLine(&cliOptions); cliOptions.process(app); aboutData.processCommandLine(&cliOptions); QGuiApplication::setFallbackSessionManagementEnabled(false); auto disableSessionManagement = [](QSessionManager &sm) { sm.setRestartHint(QSessionManager::RestartNever); }; QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); ShellManager::s_fixedShell = cliOptions.value(shellPluginOption); if (!cliOptions.isSet(noRespawnOption) && !cliOptions.isSet(testOption)) { KCrash::setFlags(KCrash::AutoRestart); } if (cliOptions.isSet(testOption)) { const QUrl layoutUrl = QUrl::fromUserInput(cliOptions.value(testOption), {}, QUrl::AssumeLocalFile); if (!layoutUrl.isLocalFile()) { qWarning() << "ensure the layout file is local" << layoutUrl; cliOptions.showHelp(1); } QStandardPaths::setTestModeEnabled(true); QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)).removeRecursively(); ShellManager::s_testModeLayout = layoutUrl.toLocalFile(); qApp->setProperty("org.kde.KActivities.core.disableAutostart", true); QObject::connect(ShellManager::instance(), &ShellManager::shellChanged, ShellManager::instance(), [layoutUrl]() { new CoronaTestHelper(ShellManager::instance()->corona()); } ); } if (cliOptions.isSet(standaloneOption)) { if (cliOptions.isSet(shellPluginOption)) { ShellManager::s_standaloneOption = true; app.setApplicationName("plasmashell_"+cliOptions.value(shellPluginOption)); app.setQuitOnLastWindowClosed(true); KDBusService service(KDBusService::Unique); //This will not leak, because corona deletes itself on window close new StandaloneAppCorona(cliOptions.value(shellPluginOption)); return app.exec(); } else { cliOptions.showHelp(1); } } } KDBusService service(KDBusService::Unique); QObject::connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, ShellManager::instance(), &QObject::deleteLater); return app.exec(); } diff --git a/startkde/kcminit/main.cpp b/startkde/kcminit/main.cpp index 6d6692b92..7181281cc 100644 --- a/startkde/kcminit/main.cpp +++ b/startkde/kcminit/main.cpp @@ -1,242 +1,242 @@ /* Copyright (c) 1999 Matthias Hoelzer-Kluepfel This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include "main.h" #include "klauncher_iface.h" #ifdef XCB_FOUND #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include static int ready[ 2 ]; static bool startup = false; static void sendReady() { if( ready[ 1 ] == -1 ) return; char c = 0; write( ready[ 1 ], &c, 1 ); close( ready[ 1 ] ); ready[ 1 ] = -1; } static void waitForReady() { char c = 1; close( ready[ 1 ] ); read( ready[ 0 ], &c, 1 ); close( ready[ 0 ] ); } bool KCMInit::runModule(const QString &libName, KService::Ptr service) { QString KCMINIT_PREFIX=QStringLiteral("kcminit_"); const QVariant tmp = service->property(QStringLiteral("X-KDE-Init-Symbol"), QVariant::String); QString kcminit; if( tmp.isValid() ) { kcminit = tmp.toString(); if( !kcminit.startsWith( KCMINIT_PREFIX ) ) kcminit = KCMINIT_PREFIX + kcminit; } else kcminit = KCMINIT_PREFIX + libName; // get the kcminit_ function QFunctionPointer init = QLibrary::resolve(KPluginLoader::findPlugin(libName), kcminit.toUtf8().constData()); if (init) { // initialize the module qDebug() << "Initializing " << libName << ": " << kcminit; init(); return true; } else { qWarning() << "Module" << libName << "was not found or does not actually have a kcminit function"; } return false; } void KCMInit::runModules( int phase ) { QString KCMINIT_PREFIX=QStringLiteral("kcminit_"); foreach (const KService::Ptr & service, list) { const QVariant tmp = service->property(QStringLiteral("X-KDE-Init-Library"), QVariant::String); QString library; if( tmp.isValid() ) { library = tmp.toString(); if( !library.startsWith( KCMINIT_PREFIX ) ) library = KCMINIT_PREFIX + library; } else { library = service->library(); } if (library.isEmpty()) { qWarning() << Q_FUNC_INFO << "library is empty, skipping"; continue; // Skip } // see ksmserver's README for the description of the phases const QVariant vphase = service->property(QStringLiteral("X-KDE-Init-Phase"), QVariant::Int ); int libphase = 1; if( vphase.isValid() ) libphase = vphase.toInt(); if( phase != -1 && libphase != phase ) continue; // try to load the library if (!alreadyInitialized.contains(library)) { runModule(library, service); alreadyInitialized.insert(library); } } } KCMInit::KCMInit( const QCommandLineParser& args ) { QString arg; if (args.positionalArguments().size() == 1) { arg = args.positionalArguments().first(); } if (args.isSet(QStringLiteral("list"))) { list = KServiceTypeTrader::self()->query( QStringLiteral("KCModuleInit") ); foreach (const KService::Ptr & service, list) { if (service->library().isEmpty()) continue; // Skip printf("%s\n", QFile::encodeName(service->desktopEntryName()).data()); } return; } if (!arg.isEmpty()) { QString module = arg; if (!module.endsWith(QLatin1String(".desktop"))) module += QLatin1String(".desktop"); KService::Ptr serv = KService::serviceByStorageId( module ); if ( !serv || serv->library().isEmpty() ) { qCritical() << i18n("Module %1 not found", module); return; } else { list.append(serv); } } else { // locate the desktop files list = KServiceTypeTrader::self()->query( QStringLiteral("KCModuleInit") ); } if( startup ) { runModules( 0 ); // Tell KSplash that KCMInit has started QDBusMessage ksplashProgressMessage = QDBusMessage::createMethodCall(QStringLiteral("org.kde.KSplash"), QStringLiteral("/KSplash"), QStringLiteral("org.kde.KSplash"), QStringLiteral("setStage")); ksplashProgressMessage.setArguments(QList() << QStringLiteral("kcminit")); QDBusConnection::sessionBus().asyncCall(ksplashProgressMessage); sendReady(); QTimer::singleShot( 300 * 1000, qApp, &QCoreApplication::quit); // just in case QDBusConnection::sessionBus().registerObject(QStringLiteral("/kcminit"), this, QDBusConnection::ExportScriptableContents); QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.kcminit")); qApp->exec(); // wait for runPhase1() and runPhase2() } else runModules( -1 ); // all phases } KCMInit::~KCMInit() { sendReady(); } void KCMInit::runPhase1() { runModules( 1 ); emit phase1Done(); } void KCMInit::runPhase2() { runModules( 2 ); emit phase2Done(); qApp->exit( 0 ); } extern "C" Q_DECL_EXPORT int kdemain(int argc, char *argv[]) { // kdeinit waits for kcminit to finish, but during KDE startup // only important kcm's are started very early in the login process, // the rest is delayed, so fork and make parent return after the initial phase pipe( ready ); if( fork() != 0 ) { waitForReady(); return 0; } close( ready[ 0 ] ); startup = ( strcmp( argv[ 0 ], "kcminit_startup" ) == 0 ); // started from startkde? - KLocalizedString::setApplicationDomain("kcminit"); QGuiApplication::setDesktopSettingsAware(false); QGuiApplication app(argc, argv); //gui is needed for several modules + KLocalizedString::setApplicationDomain("kcminit"); KAboutData about(QStringLiteral("kcminit"), i18n("KCMInit"), QString(), i18n("KCMInit - runs startup initialization for Control Modules."), KAboutLicense::GPL); KAboutData::setApplicationData(about); QCommandLineParser parser; about.setupCommandLine(&parser); parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("list"), i18n("List modules that are run at startup"))); parser.addPositionalArgument(QStringLiteral("module"), i18n("Configuration module to run")); parser.process(app); about.processCommandLine(&parser); KCMInit kcminit( parser ); return 0; } diff --git a/systemmonitor/main.cpp b/systemmonitor/main.cpp index 5e6be4f8d..ccf6cae72 100644 --- a/systemmonitor/main.cpp +++ b/systemmonitor/main.cpp @@ -1,42 +1,41 @@ /* * Copyright (C) 2014 Vishesh Handa * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include #include #include "ksystemactivitydialog.h" int main(int argc, char** argv) { - KLocalizedString::setApplicationDomain("systemmonitor"); - QApplication app(argc, argv); + KLocalizedString::setApplicationDomain("systemmonitor"); app.setOrganizationDomain(QStringLiteral("kde.org")); app.setDesktopFileName(QStringLiteral("org.kde.systemmonitor")); QDBusConnection con = QDBusConnection::sessionBus(); if (!con.registerService(QStringLiteral("org.kde.systemmonitor"))) { return 0; } KSystemActivityDialog dialog; return dialog.exec(); }