File indexing completed on 2024-09-08 09:41:01
0001 /* 0002 SPDX-FileCopyrightText: 2007-2009 Aaron Seigo <aseigo@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "packages_p.h" 0008 0009 #include <math.h> 0010 0011 #include <KLocalizedString> 0012 0013 #include "kpackage/package.h" 0014 0015 void ChangeableMainScriptPackage::initPackage(KPackage::Package *package) 0016 { 0017 package->addFileDefinition("mainscript", QStringLiteral("scripts/main.js"), i18n("Main Script File")); 0018 package->setRequired("mainscript", true); 0019 } 0020 0021 QString ChangeableMainScriptPackage::mainScriptConfigKey() const 0022 { 0023 return QStringLiteral("X-KPackage-MainScript"); 0024 } 0025 0026 void ChangeableMainScriptPackage::pathChanged(KPackage::Package *package) 0027 { 0028 if (package->path().isEmpty()) { 0029 return; 0030 } 0031 0032 QString mainScript = package->metadata().value(mainScriptConfigKey()); 0033 if (mainScript.isEmpty()) { 0034 mainScript = package->metadata().value(QStringLiteral("X-Plasma-MainScript")); 0035 } 0036 0037 if (!mainScript.isEmpty()) { 0038 package->addFileDefinition("mainscript", mainScript, i18n("Main Script File")); 0039 } 0040 } 0041 0042 void GenericPackage::initPackage(KPackage::Package *package) 0043 { 0044 ChangeableMainScriptPackage::initPackage(package); 0045 0046 package->setDefaultPackageRoot(QStringLiteral("kpackage/generic/")); 0047 0048 package->addDirectoryDefinition("images", QStringLiteral("images"), i18n("Images")); 0049 package->addDirectoryDefinition("theme", QStringLiteral("theme"), i18n("Themed Images")); 0050 QStringList mimetypes; 0051 mimetypes << QStringLiteral("image/svg+xml") << QStringLiteral("image/png") << QStringLiteral("image/jpeg"); 0052 package->setMimeTypes("images", mimetypes); 0053 package->setMimeTypes("theme", mimetypes); 0054 0055 package->addDirectoryDefinition("config", QStringLiteral("config"), i18n("Configuration Definitions")); 0056 mimetypes.clear(); 0057 mimetypes << QStringLiteral("text/xml"); 0058 package->setMimeTypes("config", mimetypes); 0059 0060 package->addDirectoryDefinition("ui", QStringLiteral("ui"), i18n("User Interface")); 0061 0062 package->addDirectoryDefinition("data", QStringLiteral("data"), i18n("Data Files")); 0063 0064 package->addDirectoryDefinition("scripts", QStringLiteral("code"), i18n("Executable Scripts")); 0065 mimetypes.clear(); 0066 mimetypes << QStringLiteral("text/plain"); 0067 package->setMimeTypes("scripts", mimetypes); 0068 0069 package->addDirectoryDefinition("translations", QStringLiteral("locale"), i18n("Translations")); 0070 } 0071 0072 void GenericQMLPackage::initPackage(KPackage::Package *package) 0073 { 0074 GenericPackage::initPackage(package); 0075 0076 package->addFileDefinition("mainscript", QStringLiteral("ui/main.qml"), i18n("Main UI File")); 0077 package->setRequired("mainscript", true); 0078 package->setDefaultPackageRoot( 0079 QStringLiteral("kpackage" 0080 "/genericqml/")); 0081 } 0082 0083 #include "moc_packages_p.cpp"