Changeset View
Changeset View
Standalone View
Standalone View
plasma-windowed/plasmawindowedcorona.cpp
Show All 17 Lines | |||||
18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program. If not, see <http://www.gnu.org/licenses/> | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/> | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #include "plasmawindowedcorona.h" | 22 | #include "plasmawindowedcorona.h" | ||
23 | #include "plasmawindowedview.h" | 23 | #include "plasmawindowedview.h" | ||
24 | #include <QDebug> | 24 | #include <QDebug> | ||
25 | #include <QAction> | 25 | #include <QAction> | ||
26 | #include <QCommandLineParser> | ||||
27 | | ||||
26 | #include <KActionCollection> | 28 | #include <KActionCollection> | ||
29 | #include <KLocalizedString> | ||||
27 | 30 | | |||
28 | #include <KPackage/Package> | 31 | #include <KPackage/Package> | ||
29 | #include <KPackage/PackageLoader> | 32 | #include <KPackage/PackageLoader> | ||
30 | #include <Plasma/PluginLoader> | 33 | #include <Plasma/PluginLoader> | ||
31 | 34 | | |||
32 | PlasmaWindowedCorona::PlasmaWindowedCorona(QObject *parent) | 35 | PlasmaWindowedCorona::PlasmaWindowedCorona(QObject *parent) | ||
33 | : Plasma::Corona(parent), | 36 | : Plasma::Corona(parent), | ||
34 | m_containment(0), | 37 | m_containment(0), | ||
Show All 18 Lines | 48 | { | |||
53 | for (Plasma::Applet *a : cont->applets()) { | 56 | for (Plasma::Applet *a : cont->applets()) { | ||
54 | if (a->pluginMetaData().pluginId() == applet) { | 57 | if (a->pluginMetaData().pluginId() == applet) { | ||
55 | return; | 58 | return; | ||
56 | } | 59 | } | ||
57 | } | 60 | } | ||
58 | PlasmaWindowedView *v = new PlasmaWindowedView(); | 61 | PlasmaWindowedView *v = new PlasmaWindowedView(); | ||
59 | v->setHasStatusNotifier(m_hasStatusNotifier); | 62 | v->setHasStatusNotifier(m_hasStatusNotifier); | ||
60 | v->show(); | 63 | v->show(); | ||
61 | 64 | | |||
apol: ! | |||||
62 | KConfigGroup appletsGroup(KSharedConfig::openConfig(), "Applets"); | 65 | KConfigGroup appletsGroup(KSharedConfig::openConfig(), "Applets"); | ||
63 | QString plugin; | 66 | QString plugin; | ||
64 | for (const QString &group : appletsGroup.groupList()) { | 67 | for (const QString &group : appletsGroup.groupList()) { | ||
65 | KConfigGroup cg(&appletsGroup, group); | 68 | KConfigGroup cg(&appletsGroup, group); | ||
66 | plugin = cg.readEntry("plugin", QString()); | 69 | plugin = cg.readEntry("plugin", QString()); | ||
67 | 70 | | |||
68 | if (plugin == applet) { | 71 | if (plugin == applet) { | ||
69 | Plasma::Applet *a = Plasma::PluginLoader::self()->loadApplet(applet, group.toInt(), arguments); | 72 | Plasma::Applet *a = Plasma::PluginLoader::self()->loadApplet(applet, group.toInt(), arguments); | ||
Show All 33 Lines | |||||
103 | 106 | | |||
104 | void PlasmaWindowedCorona::activateRequested(const QStringList &arguments, const QString &workingDirectory) | 107 | void PlasmaWindowedCorona::activateRequested(const QStringList &arguments, const QString &workingDirectory) | ||
105 | { | 108 | { | ||
106 | Q_UNUSED(workingDirectory) | 109 | Q_UNUSED(workingDirectory) | ||
107 | if (arguments.count() <= 1) { | 110 | if (arguments.count() <= 1) { | ||
108 | return; | 111 | return; | ||
109 | } | 112 | } | ||
110 | 113 | | |||
114 | QCommandLineParser parser; | ||||
115 | parser.setApplicationDescription(i18n("Plasma Windowed")); | ||||
116 | parser.addOption(QCommandLineOption(QStringLiteral("statusnotifier"), i18n("Makes the plasmoid stay alive in the Notification Area, even when the window is closed."))); | ||||
117 | parser.addPositionalArgument(QStringLiteral("applet"), i18n("The applet to open.")); | ||||
118 | parser.addPositionalArgument(QStringLiteral("args"), i18n("Arguments to pass to the plasmoid."), QStringLiteral("[args...]")); | ||||
119 | parser.addVersionOption(); | ||||
120 | parser.addHelpOption(); | ||||
121 | parser.process(arguments); | ||||
122 | | ||||
123 | if (parser.positionalArguments().isEmpty()) { | ||||
124 | parser.showHelp(1); | ||||
125 | } | ||||
126 | | ||||
127 | const QStringList positionalArguments = parser.positionalArguments(); | ||||
128 | | ||||
111 | QVariantList args; | 129 | QVariantList args; | ||
112 | QStringList::const_iterator constIterator; | 130 | QStringList::const_iterator constIterator = positionalArguments.constBegin() + 1; | ||
113 | constIterator = arguments.constBegin(); | 131 | for (; constIterator != positionalArguments.constEnd(); | ||
114 | ++constIterator; | | |||
115 | for (; constIterator != arguments.constEnd(); | | |||
116 | ++constIterator) { | 132 | ++constIterator) { | ||
117 | args << (*constIterator); | 133 | args << (*constIterator); | ||
118 | } | 134 | } | ||
119 | 135 | | |||
120 | loadApplet(arguments[1], args); | 136 | loadApplet(positionalArguments.first(), args); | ||
121 | } | 137 | } | ||
122 | 138 | | |||
123 | QRect PlasmaWindowedCorona::screenGeometry(int id) const | 139 | QRect PlasmaWindowedCorona::screenGeometry(int id) const | ||
124 | { | 140 | { | ||
125 | Q_UNUSED(id); | 141 | Q_UNUSED(id); | ||
126 | //TODO? | 142 | //TODO? | ||
127 | return QRect(); | 143 | return QRect(); | ||
128 | } | 144 | } | ||
Show All 39 Lines |
!