2008-11-04 00:08:39 +01:00
|
|
|
/******************************************************************************
|
2009-04-07 07:43:44 +02:00
|
|
|
* Copyright 2007-2009 by Aaron Seigo <aseigo@kde.org> *
|
2008-11-04 00:08:39 +01:00
|
|
|
* *
|
|
|
|
* This library is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU Library General Public *
|
|
|
|
* License as published by the Free Software Foundation; either *
|
|
|
|
* version 2 of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This library is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
|
|
|
* Library General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Library General Public License *
|
|
|
|
* along with this library; see the file COPYING.LIB. If not, write to *
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
|
|
|
|
* Boston, MA 02110-1301, USA. *
|
|
|
|
*******************************************************************************/
|
|
|
|
|
2009-04-07 07:43:44 +02:00
|
|
|
#include "plasma/private/packages_p.h"
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <float.h> // FLT_MAX
|
|
|
|
|
2011-12-03 21:22:45 +01:00
|
|
|
#include <QCoreApplication>
|
2009-04-07 07:43:44 +02:00
|
|
|
#include <QFileInfo>
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2008-11-04 03:39:56 +01:00
|
|
|
#include <kconfiggroup.h>
|
|
|
|
#include <kdesktopfile.h>
|
2012-12-01 10:11:55 +01:00
|
|
|
#include <klocalizedstring.h>
|
2008-11-04 03:39:56 +01:00
|
|
|
#include <kmessagebox.h>
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2012-10-30 21:30:01 +01:00
|
|
|
#include "kdeclarative.h"
|
2012-12-01 10:11:55 +01:00
|
|
|
#include "package.h"
|
|
|
|
#include "config-plasma.h"
|
2009-04-07 07:43:44 +02:00
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
void ChangeableMainScriptPackage::initPackage(Package *package)
|
|
|
|
{
|
|
|
|
package->addFileDefinition("mainscript", "code/main", i18n("Main Script File"));
|
|
|
|
package->setRequired("mainscript", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ChangeableMainScriptPackage::findMainScript(Package *package) const
|
|
|
|
{
|
|
|
|
Q_UNUSED(package)
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ChangeableMainScriptPackage::mainScriptConfigKey() const
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2012-12-01 10:11:55 +01:00
|
|
|
return QLatin1String("X-Plasma-MainScript");
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChangeableMainScriptPackage::pathChanged(Package *package)
|
|
|
|
{
|
2013-02-08 13:37:19 +01:00
|
|
|
if (package->path().isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
KDesktopFile config(package->path() + "/metadata.desktop");
|
|
|
|
KConfigGroup cg = config.desktopGroup();
|
|
|
|
QString mainScript = cg.readEntry(mainScriptConfigKey(), QString());
|
|
|
|
if (mainScript.isEmpty()) {
|
|
|
|
mainScript = findMainScript(package);
|
|
|
|
|
|
|
|
if (mainScript.isEmpty()) {
|
|
|
|
mainScript = package->path() + "/code/main.js";
|
|
|
|
if (!QFile::exists(mainScript)) {
|
|
|
|
mainScript.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mainScript.isEmpty()) {
|
|
|
|
package->addFileDefinition("mainscript", mainScript, i18n("Main Script File"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString PlasmoidPackage::findMainScript(Package *package) const
|
|
|
|
{
|
|
|
|
const QString mainScript = package->path() + "/ui/main.qml";
|
|
|
|
if (QFile::exists(mainScript)) {
|
|
|
|
return mainScript;
|
|
|
|
}
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlasmoidPackage::initPackage(Package *package)
|
|
|
|
{
|
|
|
|
ChangeableMainScriptPackage::initPackage(package);
|
|
|
|
|
2012-10-30 21:30:01 +01:00
|
|
|
QStringList platform = KDeclarative::runtimePlatform();
|
|
|
|
if (!platform.isEmpty()) {
|
2012-10-31 15:59:01 +01:00
|
|
|
QMutableStringListIterator it(platform);
|
|
|
|
while (it.hasNext()) {
|
|
|
|
it.next();
|
|
|
|
it.setValue("platformcontents/" + it.value());
|
|
|
|
}
|
2012-12-01 10:11:55 +01:00
|
|
|
|
2012-10-30 21:30:01 +01:00
|
|
|
platform.append("contents");
|
2012-12-01 10:11:55 +01:00
|
|
|
package->setContentsPrefixPaths(platform);
|
2010-11-04 22:16:12 +01:00
|
|
|
}
|
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->setServicePrefix("plasma-applet-");
|
|
|
|
package->setDefaultPackageRoot("plasma/plasmoids");
|
|
|
|
|
|
|
|
package->addDirectoryDefinition("images", "images", i18n("Images"));
|
2008-11-04 00:08:39 +01:00
|
|
|
QStringList mimetypes;
|
|
|
|
mimetypes << "image/svg+xml" << "image/png" << "image/jpeg";
|
2012-12-01 10:11:55 +01:00
|
|
|
package->setMimeTypes("images", mimetypes);
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("config", "config", i18n("Configuration Definitions"));
|
2008-11-04 00:08:39 +01:00
|
|
|
mimetypes.clear();
|
2009-09-02 04:36:12 +02:00
|
|
|
mimetypes << "text/xml";
|
2012-12-01 10:11:55 +01:00
|
|
|
package->setMimeTypes("config", mimetypes);
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("ui", "ui", i18n("User Interface"));
|
|
|
|
package->setMimeTypes("ui", mimetypes);
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("data", "data", i18n("Data Files"));
|
2010-02-28 18:03:21 +01:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("scripts", "code", i18n("Executable Scripts"));
|
2008-11-04 00:08:39 +01:00
|
|
|
mimetypes.clear();
|
2009-05-18 14:16:21 +02:00
|
|
|
mimetypes << "text/plain";
|
2012-12-01 10:11:55 +01:00
|
|
|
package->setMimeTypes("scripts", mimetypes);
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("translations", "locale", i18n("Translations"));
|
2009-05-01 20:31:14 +02:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("mainconfigui", "ui/config.ui", i18n("Main Config UI File"));
|
|
|
|
package->addFileDefinition("mainconfigxml", "config/main.xml", i18n("Configuration XML file"));
|
|
|
|
package->addDirectoryDefinition("animations", "animations", i18n("Animation scripts"));
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
QString ContainmentPackage::mainScriptConfigKey() const
|
2009-07-03 04:17:25 +02:00
|
|
|
{
|
2012-12-01 10:11:55 +01:00
|
|
|
return QLatin1String("X-Plasma-Containment-MainScript");
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
void DataEnginePackage::initPackage(Package *package)
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2012-12-01 10:11:55 +01:00
|
|
|
ChangeableMainScriptPackage::initPackage(package);
|
|
|
|
package->setServicePrefix("plasma-dataengine-");
|
|
|
|
package->setDefaultPackageRoot("plasma/dataengines/");
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("data", "data", i18n("Data Files"));
|
2010-09-16 09:35:35 +02:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("scripts", "code", i18n("Executable Scripts"));
|
2010-08-06 03:28:09 +02:00
|
|
|
QStringList mimetypes;
|
|
|
|
mimetypes << "text/plain";
|
2012-12-01 10:11:55 +01:00
|
|
|
package->setMimeTypes("scripts", mimetypes);
|
2010-08-06 03:28:09 +02:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("services", "services/", i18n("Service Descriptions"));
|
|
|
|
package->setMimeTypes("services", mimetypes);
|
2010-08-06 03:28:09 +02:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("translations", "locale", i18n("Translations"));
|
2010-08-06 03:28:09 +02:00
|
|
|
}
|
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
void RunnerPackage::initPackage(Package *package)
|
2010-08-06 03:28:09 +02:00
|
|
|
{
|
2012-12-01 10:11:55 +01:00
|
|
|
ChangeableMainScriptPackage::initPackage(package);
|
|
|
|
package->setServicePrefix("plasma-runner-");
|
|
|
|
package->setDefaultPackageRoot("plasma/runners/");
|
2010-08-06 03:28:09 +02:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("data", "data", i18n("Data Files"));
|
|
|
|
|
|
|
|
package->addDirectoryDefinition("scripts", "code", i18n("Executable Scripts"));
|
|
|
|
QStringList mimetypes;
|
|
|
|
mimetypes << "text/plain";
|
|
|
|
package->setMimeTypes("scripts", mimetypes);
|
|
|
|
|
|
|
|
package->addDirectoryDefinition("translations", "locale", i18n("Translations"));
|
2010-08-06 03:28:09 +02:00
|
|
|
}
|
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
void ThemePackage::initPackage(Package *package)
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("dialogs", "dialogs/", i18n("Images for dialogs"));
|
|
|
|
package->addFileDefinition("dialogs/background", "dialogs/background.svg",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Generic dialog background"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("dialogs/background", "dialogs/background.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Generic dialog background"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("dialogs/shutdowndialog", "dialogs/shutdowndialog.svg",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Theme for the logout dialog"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("dialogs/shutdowndialog", "dialogs/shutdowndialog.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Theme for the logout dialog"));
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("wallpapers", "wallpapers/", i18n("Wallpaper packages"));
|
|
|
|
package->addDirectoryDefinition("animations", "animations/", i18n("Animation scripts"));
|
2012-09-24 23:59:31 +02:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("widgets", "widgets/", i18n("Images for widgets"));
|
|
|
|
package->addFileDefinition("widgets/background", "widgets/background.svg",
|
2009-01-10 01:10:33 +01:00
|
|
|
i18n("Background image for widgets"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("widgets/background", "widgets/background.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Background image for widgets"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("widgets/clock", "widgets/clock.svg",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Analog clock face"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("widgets/clock", "widgets/clock.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Analog clock face"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("widgets/panel-background", "widgets/panel-background.svg",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Background image for panels"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("widgets/panel-background", "widgets/panel-background.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Background image for panels"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("widgets/plot-background", "widgets/plot-background.svg",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Background for graphing widgets"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("widgets/plot-background", "widgets/plot-background.svgz",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Background for graphing widgets"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("widgets/tooltip", "widgets/tooltip.svg",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Background image for tooltips"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("widgets/tooltip", "widgets/tooltip.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Background image for tooltips"));
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("opaque/dialogs", "opaque/dialogs/", i18n("Opaque images for dialogs"));
|
|
|
|
package->addFileDefinition("opaque/dialogs/background", "opaque/dialogs/background.svg",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Opaque generic dialog background"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("opaque/dialogs/background", "opaque/dialogs/background.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Opaque generic dialog background"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("opaque/dialogs/shutdowndialog", "opaque/dialogs/shutdowndialog.svg",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Opaque theme for the logout dialog"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("opaque/dialogs/shutdowndialog", "opaque/dialogs/shutdowndialog.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Opaque theme for the logout dialog"));
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("opaque/widgets", "opaque/widgets/", i18n("Opaque images for widgets"));
|
|
|
|
package->addFileDefinition("opaque/widgets/panel-background", "opaque/widgets/panel-background.svg",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Opaque background image for panels"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("opaque/widgets/panel-background", "opaque/widgets/panel-background.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Opaque background image for panels"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("opaque/widgets/tooltip", "opaque/widgets/tooltip.svg",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Opaque background image for tooltips"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("opaque/widgets/tooltip", "opaque/widgets/tooltip.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Opaque background image for tooltips"));
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("locolor/dialogs", "locolor/dialogs/",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Low color images for dialogs"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("locolor/dialogs/background", "locolor/dialogs/background.svg",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Low color generic dialog background"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("locolor/dialogs/background", "locolor/dialogs/background.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Low color generic dialog background"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("locolor/dialogs/shutdowndialog", "locolor/dialogs/shutdowndialog.svg",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Low color theme for the logout dialog"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("locolor/dialogs/shutdowndialog", "locolor/dialogs/shutdowndialog.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Low color theme for the logout dialog"));
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addDirectoryDefinition("locolor/widgets", "locolor/widgets/", i18n("Images for widgets"));
|
|
|
|
package->addFileDefinition("locolor/widgets/background", "locolor/widgets/background.svg",
|
2009-01-10 01:10:33 +01:00
|
|
|
i18n("Low color background image for widgets"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("locolor/widgets/background", "locolor/widgets/background.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Low color background image for widgets"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("locolor/widgets/clock", "locolor/widgets/clock.svg",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Low color analog clock face"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("locolor/widgets/clock", "locolor/widgets/clock.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Low color analog clock face"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("locolor/widgets/panel-background", "locolor/widgets/panel-background.svg",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Low color background image for panels"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("locolor/widgets/panel-background", "locolor/widgets/panel-background.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Low color background image for panels"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("locolor/widgets/plot-background", "locolor/widgets/plot-background.svg",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Low color background for graphing widgets"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("locolor/widgets/plot-background", "locolor/widgets/plot-background.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Low color background for graphing widgets"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("locolor/widgets/tooltip", "locolor/widgets/tooltip.svg",
|
2008-11-04 00:08:39 +01:00
|
|
|
i18n("Low color background image for tooltips"));
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("locolor/widgets/tooltip", "locolor/widgets/tooltip.svgz",
|
2012-09-24 23:59:31 +02:00
|
|
|
i18n("Low color background image for tooltips"));
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
package->addFileDefinition("colors", "colors", i18n("KColorScheme configuration file"));
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
QStringList mimetypes;
|
|
|
|
mimetypes << "image/svg+xml";
|
2012-12-01 10:11:55 +01:00
|
|
|
package->setDefaultMimeTypes(mimetypes);
|
2009-04-07 07:43:44 +02:00
|
|
|
}
|
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
void ContainmentActionsPackage::initPackage(Package *package)
|
2009-04-07 07:43:44 +02:00
|
|
|
{
|
2012-12-01 10:11:55 +01:00
|
|
|
ChangeableMainScriptPackage::initPackage(package);
|
|
|
|
package->setDefaultPackageRoot("plasma/containmentactions/");
|
2009-04-02 08:29:46 +02:00
|
|
|
}
|
|
|
|
|
2012-12-01 10:11:55 +01:00
|
|
|
void GenericPackage::initPackage(Package *package)
|
2009-08-18 00:30:29 +02:00
|
|
|
{
|
2012-12-01 10:11:55 +01:00
|
|
|
package->setDefaultPackageRoot("plasma/packages/");
|
2009-08-18 00:30:29 +02:00
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
} // namespace Plasma
|
|
|
|
|