make the PackageStructures into Package subclasses
This commit is contained in:
parent
889c9e7bd3
commit
abf1b8510f
@ -29,17 +29,24 @@
|
||||
#include <klocale.h>
|
||||
#include <kmessagebox.h>
|
||||
|
||||
#ifndef PLASMA_NO_KNEWSTUFF
|
||||
#include <knewstuff3/downloaddialog.h>
|
||||
#endif
|
||||
|
||||
#include "plasma/private/wallpaper_p.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
PlasmoidPackage::PlasmoidPackage(QObject *parent)
|
||||
: Plasma::PackageStructure(parent, QString("Plasmoid"))
|
||||
void ChangeableMainScriptPackage::pathChanged()
|
||||
{
|
||||
KDesktopFile config(path() + "/metadata.desktop");
|
||||
KConfigGroup cg = config.desktopGroup();
|
||||
QString mainScript = cg.readEntry("X-Plasma-MainScript", QString());
|
||||
if (!mainScript.isEmpty()) {
|
||||
addFileDefinition("mainscript", mainScript, i18n("Main Script File"));
|
||||
setRequired("mainscript", true);
|
||||
}
|
||||
}
|
||||
|
||||
PlasmoidPackage::PlasmoidPackage()
|
||||
: ChangeableMainScriptPackage()
|
||||
{
|
||||
QString pathsString(getenv("PLASMA_CUSTOM_PREFIX_PATHS"));
|
||||
if (!pathsString.isEmpty()) {
|
||||
@ -49,6 +56,9 @@ PlasmoidPackage::PlasmoidPackage(QObject *parent)
|
||||
}
|
||||
}
|
||||
|
||||
setServicePrefix("plasma-applet-");
|
||||
setDefaultPackageRoot("plasma/plasmoids");
|
||||
|
||||
addDirectoryDefinition("images", "images", i18n("Images"));
|
||||
QStringList mimetypes;
|
||||
mimetypes << "image/svg+xml" << "image/png" << "image/jpeg";
|
||||
@ -79,26 +89,11 @@ PlasmoidPackage::PlasmoidPackage(QObject *parent)
|
||||
setRequired("mainscript", true);
|
||||
}
|
||||
|
||||
PlasmoidPackage::~PlasmoidPackage()
|
||||
{
|
||||
}
|
||||
|
||||
void PlasmoidPackage::pathChanged()
|
||||
{
|
||||
KDesktopFile config(path() + "/metadata.desktop");
|
||||
KConfigGroup cg = config.desktopGroup();
|
||||
QString mainScript = cg.readEntry("X-Plasma-MainScript", QString());
|
||||
if (!mainScript.isEmpty()) {
|
||||
addFileDefinition("mainscript", mainScript, i18n("Main Script File"));
|
||||
setRequired("mainscript", true);
|
||||
}
|
||||
}
|
||||
|
||||
DataEnginePackage::DataEnginePackage(QObject *parent)
|
||||
: Plasma::PackageStructure(parent, QString("DataEngine"))
|
||||
DataEnginePackage::DataEnginePackage()
|
||||
: ChangeableMainScriptPackage()
|
||||
{
|
||||
setServicePrefix("plasma-dataengine-");
|
||||
setDefaultPackageRoot("plasma/dataengine/");
|
||||
setDefaultPackageRoot("plasma/dataengines/");
|
||||
|
||||
addDirectoryDefinition("data", "data", i18n("Data Files"));
|
||||
|
||||
@ -116,23 +111,27 @@ DataEnginePackage::DataEnginePackage(QObject *parent)
|
||||
setRequired("mainscript", true);
|
||||
}
|
||||
|
||||
DataEnginePackage::~DataEnginePackage()
|
||||
RunnerPackage::RunnerPackage()
|
||||
: ChangeableMainScriptPackage()
|
||||
{
|
||||
setServicePrefix("plasma-runner-");
|
||||
setDefaultPackageRoot("plasma/runners/");
|
||||
|
||||
addDirectoryDefinition("data", "data", i18n("Data Files"));
|
||||
|
||||
addDirectoryDefinition("scripts", "code", i18n("Executable Scripts"));
|
||||
QStringList mimetypes;
|
||||
mimetypes << "text/plain";
|
||||
setMimeTypes("scripts", mimetypes);
|
||||
|
||||
addDirectoryDefinition("translations", "locale", i18n("Translations"));
|
||||
|
||||
addFileDefinition("mainscript", "code/main", i18n("Main Script File"));
|
||||
setRequired("mainscript", true);
|
||||
}
|
||||
|
||||
void DataEnginePackage::pathChanged()
|
||||
{
|
||||
KDesktopFile config(path() + "/metadata.desktop");
|
||||
KConfigGroup cg = config.desktopGroup();
|
||||
QString mainScript = cg.readEntry("X-Plasma-MainScript", QString());
|
||||
if (!mainScript.isEmpty()) {
|
||||
addFileDefinition("mainscript", mainScript, i18n("Main Script File"));
|
||||
setRequired("mainscript", true);
|
||||
}
|
||||
}
|
||||
|
||||
ThemePackage::ThemePackage(QObject *parent)
|
||||
: Plasma::PackageStructure(parent, QString("Plasma Theme"))
|
||||
ThemePackage::ThemePackage()
|
||||
: Package()
|
||||
{
|
||||
addDirectoryDefinition("dialogs", "dialogs/", i18n("Images for dialogs"));
|
||||
addFileDefinition("dialogs/background", "dialogs/background.svg",
|
||||
@ -193,8 +192,8 @@ ThemePackage::ThemePackage(QObject *parent)
|
||||
setDefaultMimeTypes(mimetypes);
|
||||
}
|
||||
|
||||
WallpaperPackage::WallpaperPackage(Wallpaper *paper, QObject *parent)
|
||||
: PackageStructure(parent, "Background"),
|
||||
WallpaperPackage::WallpaperPackage(Wallpaper *paper)
|
||||
: Package(),
|
||||
m_paper(paper),
|
||||
m_fullPackage(true),
|
||||
m_targetSize(100000, 100000),
|
||||
@ -302,7 +301,7 @@ void WallpaperPackage::findBestPaper()
|
||||
}
|
||||
|
||||
//kDebug() << "best image" << bestImage;
|
||||
addFileDefinition("preferred", path("images") + bestImage, i18n("Recommended wallpaper file"));
|
||||
addFileDefinition("preferred", filePath("images") + bestImage, i18n("Recommended wallpaper file"));
|
||||
}
|
||||
|
||||
float WallpaperPackage::distance(const QSize& size, const QSize& desired,
|
||||
@ -340,12 +339,16 @@ void WallpaperPackage::paperDestroyed()
|
||||
m_paper = 0;
|
||||
}
|
||||
|
||||
ContainmentActionsPackage::ContainmentActionsPackage(QObject *parent)
|
||||
: Plasma::PackageStructure(parent, QString("ContainmentActions"))
|
||||
ContainmentActionsPackage::ContainmentActionsPackage()
|
||||
{
|
||||
//FIXME how do I do the mimetypes stuff?
|
||||
}
|
||||
|
||||
GenericPackage::GenericPackage()
|
||||
{
|
||||
setDefaultPackageRoot("plasma/packages");
|
||||
}
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
#include "packages_p.moc"
|
||||
|
@ -20,63 +20,51 @@
|
||||
#ifndef LIBS_PLASMA_PACKAGES_P_H
|
||||
#define LIBS_PLASMA_PACKAGES_P_H
|
||||
|
||||
#include "plasma/packagestructure.h"
|
||||
#include "plasma/wallpaper.h"
|
||||
#include "plasma/package.h"
|
||||
#include "plasma/plasma.h"
|
||||
#include "plasma/wallpaper.h"
|
||||
|
||||
#include "config-plasma.h"
|
||||
|
||||
#ifndef PLASMA_NO_KNEWSTUFF
|
||||
namespace KNS3
|
||||
{
|
||||
class DownloadDialog;
|
||||
} // namespace KNS
|
||||
#endif
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class PlasmoidPackage : public PackageStructure
|
||||
class ChangeableMainScriptPackage : public Package
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PlasmoidPackage(QObject *parent = 0);
|
||||
~PlasmoidPackage();
|
||||
void createNewWidgetBrowser(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
void pathChanged();
|
||||
|
||||
private:
|
||||
#ifndef PLASMA_NO_KNEWSTUFF
|
||||
QWeakPointer<KNS3::DownloadDialog> m_knsDialog;
|
||||
#endif
|
||||
};
|
||||
|
||||
class DataEnginePackage : public PackageStructure
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DataEnginePackage(QObject *parent = 0);
|
||||
~DataEnginePackage();
|
||||
|
||||
protected:
|
||||
void pathChanged();
|
||||
};
|
||||
|
||||
class ThemePackage : public PackageStructure
|
||||
class PlasmoidPackage : public ChangeableMainScriptPackage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ThemePackage(QObject *parent = 0);
|
||||
explicit PlasmoidPackage();
|
||||
};
|
||||
|
||||
class WallpaperPackage : public PackageStructure
|
||||
class DataEnginePackage : public ChangeableMainScriptPackage
|
||||
{
|
||||
public:
|
||||
explicit DataEnginePackage();
|
||||
} ;
|
||||
|
||||
class RunnerPackage : public ChangeableMainScriptPackage
|
||||
{
|
||||
public:
|
||||
explicit RunnerPackage();
|
||||
};
|
||||
|
||||
class ThemePackage : public Package
|
||||
{
|
||||
public:
|
||||
explicit ThemePackage();
|
||||
};
|
||||
|
||||
class WallpaperPackage : public QObject, public Package
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WallpaperPackage(Wallpaper *paper = 0, QObject *parent = 0);
|
||||
explicit WallpaperPackage(Wallpaper *paper = 0);
|
||||
|
||||
protected:
|
||||
void pathChanged();
|
||||
@ -98,15 +86,17 @@ private:
|
||||
Wallpaper::ResizeMethod m_resizeMethod;
|
||||
};
|
||||
|
||||
class ContainmentActionsPackage : public PackageStructure
|
||||
class ContainmentActionsPackage : public Package
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ContainmentActionsPackage(QObject *parent = 0);
|
||||
explicit ContainmentActionsPackage();
|
||||
};
|
||||
|
||||
PackageStructure::Ptr defaultPackageStructure(ComponentType type);
|
||||
class GenericPackage : public Package
|
||||
{
|
||||
public:
|
||||
explicit GenericPackage();
|
||||
};
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user