Warning, file /plasma/latte-dock/app/package/lattepackage.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002 *  Copyright 2016  Smith AR <audoban@openmailbox.org>
0003 *                  Michail Vourlakos <mvourlakos@gmail.com>
0004 *
0005 *  This file is part of Latte-Dock
0006 *
0007 *  Latte-Dock is free software; you can redistribute it and/or
0008 *  modify it under the terms of the GNU General Public License as
0009 *  published by the Free Software Foundation; either version 2 of
0010 *  the License, or (at your option) any later version.
0011 *
0012 *  Latte-Dock is distributed in the hope that it will be useful,
0013 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0014 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015 *  GNU General Public License for more details.
0016 *
0017 *  You should have received a copy of the GNU General Public License
0018 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0019 */
0020 
0021 #include "lattepackage.h"
0022 
0023 // Qt
0024 #include <QDebug>
0025 
0026 // KDE
0027 #include <KPackage/PackageLoader>
0028 #include <KI18n/KLocalizedString>
0029 
0030 namespace Latte {
0031 
0032 Package::Package(QObject *parent, const QVariantList &args)
0033     : KPackage::PackageStructure(parent, args)
0034 {
0035 }
0036 
0037 Package::~Package()
0038 {
0039 }
0040 
0041 void Package::initPackage(KPackage::Package *package)
0042 {
0043     auto fallback = KPackage::PackageLoader::self()->loadPackage("Plasma/Shell", "org.kde.plasma.desktop");
0044     package->setDefaultPackageRoot(QStringLiteral("plasma/shells/"));
0045     package->setPath("org.kde.latte.shell");
0046     package->addFileDefinition("defaults", QStringLiteral("defaults"), i18n("Latte Dock defaults"));
0047     package->addFileDefinition("lattedockui", QStringLiteral("views/Panel.qml"), i18n("Latte Dock panel"));
0048     //Configuration
0049     package->addFileDefinition("lattedockconfigurationui", QStringLiteral("configuration/LatteDockConfiguration.qml"), i18n("Dock configuration UI"));
0050     package->addFileDefinition("lattedocksecondaryconfigurationui", QStringLiteral("configuration/LatteDockSecondaryConfiguration.qml"), i18n("Dock secondary configuration UI"));
0051     package->addFileDefinition("configmodel", QStringLiteral("configuration/config.qml"), i18n("Config model"));
0052     package->addFileDefinition("splitter", QStringLiteral("images/splitter.svgz"), i18n("Splitter"));
0053     package->addFileDefinition("trademark", QStringLiteral("images/trademark.svgz"), i18n("Latte Trademark"));
0054     package->addFileDefinition("infoviewui", QStringLiteral("views/InfoView.qml"), i18n("Info View Window"));
0055 
0056     package->addFileDefinition("layout1", QStringLiteral("layouts/Default.latterc"), i18n("default layout file"));
0057     package->addFileDefinition("layout2", QStringLiteral("layouts/Plasma.latterc"), i18n("plasma layout file"));
0058     package->addFileDefinition("layout3", QStringLiteral("layouts/Unity.latterc"), i18n("unity layout file"));
0059     package->addFileDefinition("layout4", QStringLiteral("layouts/Extended.latterc"), i18n("extended layout file"));
0060 
0061     package->addFileDefinition("preset1", QStringLiteral("presets/Default.layout.latte"), i18n("default preset file"));
0062     package->addFileDefinition("preset2", QStringLiteral("presets/Plasma.layout.latte"), i18n("plasma preset file"));
0063     package->addFileDefinition("preset3", QStringLiteral("presets/Unity.layout.latte"), i18n("unity preset file"));
0064     package->addFileDefinition("preset4", QStringLiteral("presets/Extended.layout.latte"), i18n("extended preset file"));
0065     package->addFileDefinition("preset10", QStringLiteral("presets/multiple-layouts_hidden.layout.latte"), i18n("multiple layouts hidden file"));
0066 
0067     package->addFileDefinition("backgroundTracer", QStringLiteral("scripting/BackgroundTracer.qml"), i18n("a qml file that is used to publish broadcasted backgrounds"));
0068 
0069     package->setFallbackPackage(fallback);
0070     qDebug() << "package is valid" << package->isValid();
0071 }
0072 
0073 void Package::pathChanged(KPackage::Package *package)
0074 {
0075     if (!package->metadata().isValid())
0076         return;
0077 
0078     const QString pluginName = package->metadata().pluginId();
0079 
0080     if (!pluginName.isEmpty() && pluginName != "org.kde.latte.shell") {
0081         auto fallback = KPackage::PackageLoader::self()->loadPackage("Plasma/Shell", "org.kde.latte.shell");
0082         package->setFallbackPackage(fallback);
0083     } else if (pluginName.isEmpty() || pluginName == "org.kde.latte.shell") {
0084         package->setFallbackPackage(KPackage::Package());
0085     }
0086 }
0087 
0088 }