2008-11-03 23:08:39 +00:00
/******************************************************************************
2009-04-07 05:43:44 +00:00
* Copyright 2007 - 2009 by Aaron Seigo < aseigo @ kde . org > *
2008-11-03 23:08:39 +00: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 . *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2013-10-12 21:47:07 +02:00
# include "plasma/private/packages_p.h"
2009-04-07 05:43:44 +00:00
# include <math.h>
# include <float.h> // FLT_MAX
2011-12-03 21:22:45 +01:00
# include <QCoreApplication>
2009-04-07 05:43:44 +00:00
# include <QFileInfo>
2008-11-03 23:08:39 +00:00
2008-11-04 02:39:56 +00:00
# include <kconfiggroup.h>
# include <kdesktopfile.h>
2012-12-01 10:11:55 +01:00
# include <klocalizedstring.h>
2008-11-04 02:39:56 +00:00
# include <kmessagebox.h>
2008-11-03 23:08:39 +00:00
2013-04-26 17:36:45 +02:00
# include <kdeclarative/kdeclarative.h>
2012-12-01 10:11:55 +01:00
# include "package.h"
# include "config-plasma.h"
2009-04-07 05:43:44 +00:00
2008-11-03 23:08:39 +00:00
namespace Plasma
{
2012-12-01 10:11:55 +01:00
void ChangeableMainScriptPackage : : initPackage ( Package * package )
{
2013-02-14 14:46:49 +01:00
package - > addFileDefinition ( " mainscript " , " ui/main.qml " , i18n ( " Main Script File " ) ) ;
2012-12-01 10:11:55 +01:00
package - > setRequired ( " mainscript " , true ) ;
}
QString ChangeableMainScriptPackage : : mainScriptConfigKey ( ) const
2008-11-03 23:08:39 +00: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 ( ) ) {
package - > addFileDefinition ( " mainscript " , mainScript , i18n ( " Main Script File " ) ) ;
}
}
2013-02-14 14:46:49 +01:00
void GenericPackage : : initPackage ( Package * package )
2012-12-01 10:11:55 +01:00
{
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 21:16:12 +00:00
}
2013-02-14 14:46:49 +01:00
package - > setDefaultPackageRoot ( " plasma/packages/ " ) ;
2012-12-01 10:11:55 +01:00
package - > addDirectoryDefinition ( " images " , " images " , i18n ( " Images " ) ) ;
2013-05-11 12:25:35 +01:00
package - > addDirectoryDefinition ( " theme " , " theme " , i18n ( " Themed Images " ) ) ;
2008-11-03 23:08:39 +00:00
QStringList mimetypes ;
mimetypes < < " image/svg+xml " < < " image/png " < < " image/jpeg " ;
2012-12-01 10:11:55 +01:00
package - > setMimeTypes ( " images " , mimetypes ) ;
2013-05-11 12:25:35 +01:00
package - > setMimeTypes ( " theme " , mimetypes ) ;
2008-11-03 23:08:39 +00:00
2012-12-01 10:11:55 +01:00
package - > addDirectoryDefinition ( " config " , " config " , i18n ( " Configuration Definitions " ) ) ;
2008-11-03 23:08:39 +00:00
mimetypes . clear ( ) ;
2009-09-02 02:36:12 +00:00
mimetypes < < " text/xml " ;
2012-12-01 10:11:55 +01:00
package - > setMimeTypes ( " config " , mimetypes ) ;
2008-11-03 23:08:39 +00:00
2012-12-01 10:11:55 +01:00
package - > addDirectoryDefinition ( " ui " , " ui " , i18n ( " User Interface " ) ) ;
2008-11-03 23:08:39 +00:00
2012-12-01 10:11:55 +01:00
package - > addDirectoryDefinition ( " data " , " data " , i18n ( " Data Files " ) ) ;
2010-02-28 17:03:21 +00:00
2012-12-01 10:11:55 +01:00
package - > addDirectoryDefinition ( " scripts " , " code " , i18n ( " Executable Scripts " ) ) ;
2008-11-03 23:08:39 +00:00
mimetypes . clear ( ) ;
2009-05-18 12:16:21 +00:00
mimetypes < < " text/plain " ;
2012-12-01 10:11:55 +01:00
package - > setMimeTypes ( " scripts " , mimetypes ) ;
2008-11-03 23:08:39 +00:00
2012-12-01 10:11:55 +01:00
package - > addDirectoryDefinition ( " translations " , " locale " , i18n ( " Translations " ) ) ;
2013-02-14 14:46:49 +01:00
}
void PlasmoidPackage : : initPackage ( Package * package )
{
GenericPackage : : initPackage ( package ) ;
package - > setServicePrefix ( " plasma-applet- " ) ;
package - > setDefaultPackageRoot ( " plasma/plasmoids/ " ) ;
2009-05-01 18:31:14 +00:00
2013-04-25 11:43:00 +02:00
package - > addFileDefinition ( " configmodel " , " config/config.qml " , i18n ( " Configuration UI pages model " ) ) ;
2012-12-01 10:11:55 +01:00
package - > addFileDefinition ( " mainconfigxml " , " config/main.xml " , i18n ( " Configuration XML file " ) ) ;
2008-11-03 23:08:39 +00:00
}
2012-12-01 10:11:55 +01:00
QString ContainmentPackage : : mainScriptConfigKey ( ) const
2009-07-03 02:17:25 +00:00
{
2012-12-01 10:11:55 +01:00
return QLatin1String ( " X-Plasma-Containment-MainScript " ) ;
2008-11-03 23:08:39 +00:00
}
2012-12-01 10:11:55 +01:00
void DataEnginePackage : : initPackage ( Package * package )
2008-11-03 23:08:39 +00:00
{
2012-12-01 10:11:55 +01:00
ChangeableMainScriptPackage : : initPackage ( package ) ;
package - > setServicePrefix ( " plasma-dataengine- " ) ;
package - > setDefaultPackageRoot ( " plasma/dataengines/ " ) ;
2008-11-03 23:08:39 +00:00
2012-12-01 10:11:55 +01:00
package - > addDirectoryDefinition ( " data " , " data " , i18n ( " Data Files " ) ) ;
2010-09-16 07:35:35 +00:00
2012-12-01 10:11:55 +01:00
package - > addDirectoryDefinition ( " scripts " , " code " , i18n ( " Executable Scripts " ) ) ;
2010-08-06 01:28:09 +00:00
QStringList mimetypes ;
mimetypes < < " text/plain " ;
2012-12-01 10:11:55 +01:00
package - > setMimeTypes ( " scripts " , mimetypes ) ;
2010-08-06 01:28:09 +00:00
2012-12-01 10:11:55 +01:00
package - > addDirectoryDefinition ( " services " , " services/ " , i18n ( " Service Descriptions " ) ) ;
package - > setMimeTypes ( " services " , mimetypes ) ;
2010-08-06 01:28:09 +00:00
2012-12-01 10:11:55 +01:00
package - > addDirectoryDefinition ( " translations " , " locale " , i18n ( " Translations " ) ) ;
2010-08-06 01:28:09 +00:00
}
2012-12-01 10:11:55 +01:00
void RunnerPackage : : initPackage ( Package * package )
2010-08-06 01:28:09 +00:00
{
2012-12-01 10:11:55 +01:00
ChangeableMainScriptPackage : : initPackage ( package ) ;
package - > setServicePrefix ( " plasma-runner- " ) ;
package - > setDefaultPackageRoot ( " plasma/runners/ " ) ;
2010-08-06 01:28:09 +00: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 01:28:09 +00:00
}
2012-12-01 10:11:55 +01:00
void ThemePackage : : initPackage ( Package * package )
2008-11-03 23:08:39 +00: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-03 23:08:39 +00:00
i18n ( " Generic dialog background " ) ) ;
2012-12-01 10:11:55 +01:00
package - > addFileDefinition ( " dialogs/background " , " dialogs/background.svgz " ,
2012-09-25 00:59:31 +03:00
i18n ( " Generic dialog background " ) ) ;
2012-12-01 10:11:55 +01:00
package - > addFileDefinition ( " dialogs/shutdowndialog " , " dialogs/shutdowndialog.svg " ,
2008-11-03 23:08:39 +00:00
i18n ( " Theme for the logout dialog " ) ) ;
2012-12-01 10:11:55 +01:00
package - > addFileDefinition ( " dialogs/shutdowndialog " , " dialogs/shutdowndialog.svgz " ,
2012-09-25 00:59:31 +03:00
i18n ( " Theme for the logout dialog " ) ) ;
2008-11-03 23:08:39 +00:00
2012-12-01 10:11:55 +01:00
package - > addDirectoryDefinition ( " wallpapers " , " wallpapers/ " , i18n ( " Wallpaper packages " ) ) ;
2012-09-25 00:59:31 +03: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 00:10:33 +00:00
i18n ( " Background image for widgets " ) ) ;
2012-12-01 10:11:55 +01:00
package - > addFileDefinition ( " widgets/background " , " widgets/background.svgz " ,
2012-09-25 00:59:31 +03:00
i18n ( " Background image for widgets " ) ) ;
2012-12-01 10:11:55 +01:00
package - > addFileDefinition ( " widgets/clock " , " widgets/clock.svg " ,
2008-11-03 23:08:39 +00:00
i18n ( " Analog clock face " ) ) ;
2012-12-01 10:11:55 +01:00
package - > addFileDefinition ( " widgets/clock " , " widgets/clock.svgz " ,
2012-09-25 00:59:31 +03:00
i18n ( " Analog clock face " ) ) ;
2012-12-01 10:11:55 +01:00
package - > addFileDefinition ( " widgets/panel-background " , " widgets/panel-background.svg " ,
2008-11-03 23:08:39 +00: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-25 00:59:31 +03: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-25 00:59:31 +03: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-03 23:08:39 +00:00
i18n ( " Background for graphing widgets " ) ) ;
2012-12-01 10:11:55 +01:00
package - > addFileDefinition ( " widgets/tooltip " , " widgets/tooltip.svg " ,
2008-11-03 23:08:39 +00:00
i18n ( " Background image for tooltips " ) ) ;
2012-12-01 10:11:55 +01:00
package - > addFileDefinition ( " widgets/tooltip " , " widgets/tooltip.svgz " ,
2012-09-25 00:59:31 +03:00
i18n ( " Background image for tooltips " ) ) ;
2008-11-03 23:08:39 +00: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-03 23:08:39 +00: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-25 00:59:31 +03: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-03 23:08:39 +00: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-25 00:59:31 +03:00
i18n ( " Opaque theme for the logout dialog " ) ) ;
2008-11-03 23:08:39 +00: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-03 23:08:39 +00: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-25 00:59:31 +03: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-03 23:08:39 +00: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-25 00:59:31 +03:00
i18n ( " Opaque background image for tooltips " ) ) ;
2008-11-03 23:08:39 +00:00
2012-12-01 10:11:55 +01:00
package - > addDirectoryDefinition ( " locolor/dialogs " , " locolor/dialogs/ " ,
2008-11-03 23:08:39 +00: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-03 23:08:39 +00: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-25 00:59:31 +03: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-03 23:08:39 +00: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-25 00:59:31 +03:00
i18n ( " Low color theme for the logout dialog " ) ) ;
2008-11-03 23:08:39 +00: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 00:10:33 +00: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-25 00:59:31 +03: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-03 23:08:39 +00: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-25 00:59:31 +03: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-03 23:08:39 +00: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-25 00:59:31 +03: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-03 23:08:39 +00: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-25 00:59:31 +03: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-03 23:08:39 +00: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-25 00:59:31 +03:00
i18n ( " Low color background image for tooltips " ) ) ;
2008-11-03 23:08:39 +00:00
2012-12-01 10:11:55 +01:00
package - > addFileDefinition ( " colors " , " colors " , i18n ( " KColorScheme configuration file " ) ) ;
2008-11-03 23:08:39 +00:00
QStringList mimetypes ;
mimetypes < < " image/svg+xml " ;
2012-12-01 10:11:55 +01:00
package - > setDefaultMimeTypes ( mimetypes ) ;
2009-04-07 05:43:44 +00:00
}
2012-12-01 10:11:55 +01:00
void ContainmentActionsPackage : : initPackage ( Package * package )
2009-04-07 05:43:44 +00:00
{
2012-12-01 10:11:55 +01:00
ChangeableMainScriptPackage : : initPackage ( package ) ;
package - > setDefaultPackageRoot ( " plasma/containmentactions/ " ) ;
2009-04-02 06:29:46 +00:00
}
2013-09-02 19:25:03 +02:00
void ShellPackage : : initPackage ( Plasma : : Package * package )
{
package - > setDefaultPackageRoot ( " plasma/shells/ " ) ;
//Directories
package - > addDirectoryDefinition ( " applet " , " applet " , i18n ( " Applets furniture " ) ) ;
package - > addDirectoryDefinition ( " configuration " , " configuration " , i18n ( " Applets furniture " ) ) ;
package - > addDirectoryDefinition ( " explorer " , " explorer " , i18n ( " Explorer UI for adding widgets " ) ) ;
package - > addDirectoryDefinition ( " views " , " views " , i18n ( " User interface for the views that will show containments " ) ) ;
package - > setMimeTypes ( " applet " , QStringList ( ) < < " text/x-qml " ) ;
package - > setMimeTypes ( " configuration " , QStringList ( ) < < " text/x-qml " ) ;
package - > setMimeTypes ( " views " , QStringList ( ) < < " text/x-qml " ) ;
//Files
//Default layout
package - > addFileDefinition ( " defaultlayout " , " layout.js " , i18n ( " Default layout file " ) ) ;
package - > addFileDefinition ( " defaults " , " defaults " , i18n ( " Default plugins for containments, containmentActions etc " ) ) ;
package - > setMimeTypes ( " defaultlayout " , QStringList ( ) < < " application/javascript " ) ;
package - > setMimeTypes ( " defaults " , QStringList ( ) < < " text/plain " ) ;
//Applet furniture
package - > addFileDefinition ( " appleterror " , " applet/AppletError.qml " , i18n ( " Error message shown when an applet fails to load " ) ) ;
package - > addFileDefinition ( " compactapplet " , " applet/CompactApplet.qml " , i18n ( " QML component that shows an applet in a popup " ) ) ;
package - > addFileDefinition ( " defaultcompactrepresentation " , " applet/DefaultCompactRepresentation.qml " , i18n ( " Compact representation of an applet when collapsed in a popup, for instance as an icon. applets can override this component. " ) ) ;
//Configuration
package - > addFileDefinition ( " appletconfigurationui " , " configuration/AppletConfiguration.qml " , i18n ( " QML component for the configuration dialog for applets " ) ) ;
package - > addFileDefinition ( " containmentconfigurationui " , " configuration/ContainmentConfiguration.qml " , i18n ( " QML component for the configuration dialog for containments " ) ) ;
package - > addFileDefinition ( " panelconfigurationui " , " configuration/PanelConfiguration.qml " , i18n ( " Panel configuration UI " ) ) ;
//Widget explorer
package - > addFileDefinition ( " widgetexplorer " , " explorer/WidgetExplorer.qml " , i18n ( " Widgets explorer UI " ) ) ;
//package->setRequired("mainscript", true);
}
2008-11-03 23:08:39 +00:00
} // namespace Plasma