File indexing completed on 2024-04-28 16:54:47
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 0040 KDBusService service(KDBusService::Unique); 0041 0042 QCommandLineParser parser; 0043 parser.setApplicationDescription(i18n("Plasma Windowed")); 0044 #if QT_CONFIG(qml_debug) 0045 parser.addOption(QCommandLineOption(QStringList{QStringLiteral("d"), QStringLiteral("qmljsdebugger"), i18n("Enable QML Javascript debugger")})); 0046 #endif 0047 parser.addOption( 0048 QCommandLineOption(QStringLiteral("statusnotifier"), i18n("Makes the plasmoid stay alive in the Notification Area, even when the window is closed."))); 0049 QCommandLineOption shellPluginOption(QStringList() << QStringLiteral("p") << QStringLiteral("shell-plugin"), 0050 i18n("Force loading the given shell plugin"), 0051 QStringLiteral("plugin"), 0052 QStringLiteral("org.kde.plasma.desktop")); 0053 parser.addOption(shellPluginOption); 0054 parser.addPositionalArgument(QStringLiteral("applet"), i18n("The applet to open.")); 0055 parser.addPositionalArgument(QStringLiteral("args"), i18n("Arguments to pass to the plasmoid."), QStringLiteral("[args...]")); 0056 parser.addVersionOption(); 0057 parser.addHelpOption(); 0058 parser.process(app); 0059 0060 if (parser.positionalArguments().isEmpty()) { 0061 parser.showHelp(1); 0062 } 0063 0064 PlasmaWindowedCorona *corona = new PlasmaWindowedCorona(parser.value(shellPluginOption)); 0065 0066 const QStringList arguments = parser.positionalArguments(); 0067 QVariantList args; 0068 QStringList::const_iterator constIterator = arguments.constBegin() + 1; 0069 for (; constIterator != arguments.constEnd(); ++constIterator) { 0070 args << (*constIterator); 0071 } 0072 corona->setHasStatusNotifier(parser.isSet(QStringLiteral("statusnotifier"))); 0073 corona->loadApplet(arguments.first(), args); 0074 0075 QObject::connect(&service, &KDBusService::activateRequested, corona, &PlasmaWindowedCorona::activateRequested); 0076 0077 const int ret = app.exec(); 0078 delete corona; 0079 return ret; 0080 }