File indexing completed on 2024-04-28 05:35:49
0001 /* 0002 SPDX-FileCopyrightText: 2014 Bhushan Shah <bhush94@gmail.com> 0003 SPDX-FileCopyrightText: 2014 Marco Martin <notmart@gmail.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 */ 0007 0008 #include <QApplication> 0009 #include <QQmlDebuggingEnabler> 0010 #include <QSurfaceFormat> 0011 #include <qcommandlineoption.h> 0012 #include <qcommandlineparser.h> 0013 0014 #include <KDBusService> 0015 #include <KLocalizedString> 0016 0017 #include "plasmawindowedcorona.h" 0018 #include "plasmawindowedview.h" 0019 0020 static const char version[] = "1.0"; 0021 0022 int main(int argc, char **argv) 0023 { 0024 #if QT_CONFIG(qml_debug) 0025 if (qEnvironmentVariableIsSet("PLASMA_ENABLE_QML_DEBUG")) { 0026 QQmlDebuggingEnabler debugger; 0027 } 0028 #endif 0029 0030 QQuickWindow::setDefaultAlphaBuffer(true); 0031 0032 auto format = QSurfaceFormat::defaultFormat(); 0033 format.setOption(QSurfaceFormat::ResetNotification); 0034 QSurfaceFormat::setDefaultFormat(format); 0035 0036 QApplication app(argc, argv); 0037 app.setApplicationVersion(QLatin1String(version)); 0038 app.setOrganizationDomain(QStringLiteral("kde.org")); 0039 KLocalizedString::setApplicationDomain(QByteArrayLiteral("plasmawindowed")); 0040 0041 KDBusService service(KDBusService::Unique); 0042 0043 QCommandLineParser parser; 0044 parser.setApplicationDescription(i18n("Plasma Windowed")); 0045 #if QT_CONFIG(qml_debug) 0046 parser.addOption(QCommandLineOption(QStringList{QStringLiteral("d"), QStringLiteral("qmljsdebugger"), i18n("Enable QML Javascript debugger")})); 0047 #endif 0048 parser.addOption( 0049 QCommandLineOption(QStringLiteral("statusnotifier"), i18n("Makes the plasmoid stay alive in the Notification Area, even when the window is closed."))); 0050 QCommandLineOption shellPluginOption(QStringList() << QStringLiteral("p") << QStringLiteral("shell-plugin"), 0051 i18n("Force loading the given shell plugin"), 0052 QStringLiteral("plugin"), 0053 QStringLiteral("org.kde.plasma.desktop")); 0054 parser.addOption(shellPluginOption); 0055 parser.addPositionalArgument(QStringLiteral("applet"), i18n("The applet to open.")); 0056 parser.addPositionalArgument(QStringLiteral("args"), i18n("Arguments to pass to the plasmoid."), QStringLiteral("[args...]")); 0057 parser.addVersionOption(); 0058 parser.addHelpOption(); 0059 parser.process(app); 0060 0061 if (parser.positionalArguments().isEmpty()) { 0062 parser.showHelp(1); 0063 } 0064 0065 PlasmaWindowedCorona *corona = new PlasmaWindowedCorona(parser.value(shellPluginOption)); 0066 0067 const QStringList arguments = parser.positionalArguments(); 0068 QVariantList args; 0069 QStringList::const_iterator constIterator = arguments.constBegin() + 1; 0070 for (; constIterator != arguments.constEnd(); ++constIterator) { 0071 args << (*constIterator); 0072 } 0073 corona->setHasStatusNotifier(parser.isSet(QStringLiteral("statusnotifier"))); 0074 corona->loadApplet(arguments.first(), args); 0075 0076 QObject::connect(&service, &KDBusService::activateRequested, corona, &PlasmaWindowedCorona::activateRequested); 0077 0078 const int ret = app.exec(); 0079 delete corona; 0080 return ret; 0081 }