File indexing completed on 2022-12-06 15:16:09

0001 /*
0002     SPDX-FileCopyrightText: 2016 Smith AR <audoban@openmailbox.org>
0003     SPDX-FileCopyrightText: 2016 Michail Vourlakos <mvourlakos@gmail.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #include "lattepackage.h"
0009 
0010 // Qt
0011 #include <QDebug>
0012 #include <QLatin1String>
0013 
0014 // KDE
0015 #include <KPackage/PackageLoader>
0016 #include <KI18n/KLocalizedString>
0017 
0018 namespace Latte {
0019 
0020 Package::Package(QObject *parent, const QVariantList &args)
0021     : KPackage::PackageStructure(parent, args)
0022 {
0023 }
0024 
0025 Package::~Package()
0026 {
0027 }
0028 
0029 void Package::initPackage(KPackage::Package *package)
0030 {
0031     auto fallback = KPackage::PackageLoader::self()->loadPackage("Plasma/Shell", "org.kde.plasma.desktop");
0032     package->setDefaultPackageRoot(QStringLiteral("plasma/shells/"));
0033     package->setPath("org.kde.latte.shell");
0034     package->addFileDefinition("defaults", QStringLiteral("defaults"), i18n("Latte Dock defaults"));
0035     package->addFileDefinition("lattedockui", QStringLiteral("views/Panel.qml"), i18n("Latte Dock panel"));
0036     package->addFileDefinition("widgetexplorerui", QStringLiteral("views/WidgetExplorer.qml"), i18n("Widget Explorer"));
0037     //Configuration
0038     package->addFileDefinition("lattedockconfigurationui", QStringLiteral("configuration/LatteDockConfiguration.qml"), i18n("Dock configuration UI"));
0039     package->addFileDefinition("lattedocksecondaryconfigurationui", QStringLiteral("configuration/LatteDockSecondaryConfiguration.qml"), i18n("Dock secondary configuration UI"));
0040     package->addFileDefinition("canvasconfigurationui", QStringLiteral("configuration/CanvasConfiguration.qml"), i18n("Dock canvas configuration UI"));
0041     package->addFileDefinition("configmodel", QStringLiteral("configuration/config.qml"), i18n("Config model"));
0042     package->addFileDefinition("splitter", QStringLiteral("images/splitter.svgz"), i18n("Splitter"));
0043     package->addFileDefinition("trademark", QStringLiteral("images/trademark.svgz"), i18n("Latte Trademark"));
0044     package->addFileDefinition("trademarkicon", QStringLiteral("images/trademarkicon.svgz"), i18n("Latte Trademark Icon"));
0045     package->addFileDefinition("infoviewui", QStringLiteral("views/InfoView.qml"), i18n("Info View Window"));
0046 
0047     package->addFileDefinition("layout1", QStringLiteral("layouts/Default.latterc"), i18n("default layout file"));
0048     package->addFileDefinition("layout2", QStringLiteral("layouts/Plasma.latterc"), i18n("plasma layout file"));
0049     package->addFileDefinition("layout3", QStringLiteral("layouts/Unity.latterc"), i18n("unity layout file"));
0050     package->addFileDefinition("layout4", QStringLiteral("layouts/Extended.latterc"), i18n("extended layout file"));
0051 
0052     package->addFileDefinition("templates", QStringLiteral("templates"), i18n("system templates directory"));
0053 
0054     package->addFileDefinition("preset1", QStringLiteral("presets/Default.layout.latte"), i18n("default preset file"));
0055     package->addFileDefinition("preset2", QStringLiteral("presets/Plasma.layout.latte"), i18n("plasma preset file"));
0056     package->addFileDefinition("preset3", QStringLiteral("presets/Unity.layout.latte"), i18n("unity preset file"));
0057     package->addFileDefinition("preset4", QStringLiteral("presets/Extended.layout.latte"), i18n("extended preset file"));
0058     package->addFileDefinition("preset10", QStringLiteral("presets/multiple-layouts_hidden.layout.latte"), i18n("multiple layouts hidden file"));
0059 
0060     //! applets
0061     package->addFileDefinition("compactapplet", QStringLiteral("applet/CompactApplet.qml"), i18n("QML component that shows an applet in a popup"));
0062 
0063     package->setFallbackPackage(fallback);
0064     qDebug() << "package is valid" << package->isValid();
0065 }
0066 
0067 void Package::pathChanged(KPackage::Package *package)
0068 {
0069     if (!package->metadata().isValid())
0070         return;
0071 
0072     const QString pluginName = package->metadata().pluginId();
0073 
0074     if (!pluginName.isEmpty() && pluginName != "org.kde.latte.shell") {
0075         auto fallback = KPackage::PackageLoader::self()->loadPackage("Plasma/Shell", "org.kde.latte.shell");
0076         package->setFallbackPackage(fallback);
0077     } else if (pluginName.isEmpty() || pluginName == QLatin1String("org.kde.latte.shell")) {
0078         package->setFallbackPackage(KPackage::Package());
0079     }
0080 }
0081 
0082 }