preliminary list of wallpaper plugins

This commit is contained in:
Marco Martin 2013-02-28 21:24:30 +01:00
parent 552437ca62
commit 099319a911
8 changed files with 123 additions and 11 deletions

View File

@ -21,13 +21,16 @@
#include "plasmoid/appletinterface.h"
#include <QDebug>
#include <QDir>
#include <QQmlComponent>
#include <QQmlEngine>
#include <QQmlContext>
#include <KGlobal>
#include <KLocalizedString>
#include <Plasma/Corona>
#include <Plasma/PluginLoader>
///////////////////////ConfigCategory
@ -235,7 +238,8 @@ void ConfigModel::categories_clear(QQmlListProperty<ConfigCategory> *prop)
//////////////////////////////ConfigView
ConfigView::ConfigView(AppletInterface *interface, QWindow *parent)
: QQuickView(parent),
m_appletInterface(interface)
m_appletInterface(interface),
m_wallpaperConfigModel(0)
{
qmlRegisterType<ConfigModel>("org.kde.plasma.configuration", 0, 1, "ConfigModel");
qmlRegisterType<ConfigCategory>("org.kde.plasma.configuration", 0, 1, "ConfigCategory");
@ -252,6 +256,7 @@ ConfigView::ConfigView(AppletInterface *interface, QWindow *parent)
setResizeMode(QQuickView::SizeViewToRootObject);
//config model local of the applet
QQmlComponent *component = new QQmlComponent(engine(), QUrl::fromLocalFile(m_appletInterface->applet()->package().filePath("config", "config.qml")), this);
QObject *object = component->create(engine()->rootContext());
m_configModel = qobject_cast<ConfigModel *>(object);
@ -260,9 +265,9 @@ ConfigView::ConfigView(AppletInterface *interface, QWindow *parent)
} else {
delete object;
}
delete component;
engine()->rootContext()->setContextProperty("plasmoid", interface);
engine()->rootContext()->setContextProperty("configDialog", this);
setSource(QUrl::fromLocalFile(m_appletInterface->applet()->containment()->corona()->package().filePath("ui", "Configuration.qml")));
@ -273,11 +278,42 @@ ConfigView::~ConfigView()
}
QObject *ConfigView::configModel() const
ConfigModel *ConfigView::configModel() const
{
return m_configModel;
}
ConfigModel *ConfigView::wallpaperConfigModel()
{
if (!m_wallpaperConfigModel) {
m_wallpaperConfigModel = new ConfigModel(this);
QStringList dirs(QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "plasma/wallpapers", QStandardPaths::LocateDirectory));
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic");
foreach (const QString &dirPath, dirs) {
QDir dir(dirPath);
pkg.setDefaultPackageRoot(dirPath);
QStringList packages;
foreach (const QString &sdir, dir.entryList(QDir::AllDirs | QDir::Readable)) {
QString metadata = dirPath + '/' + sdir + "/metadata.desktop";
if (QFile::exists(metadata)) {
packages << sdir;
}
}
foreach (const QString &package, packages) {
pkg.setPath(package);
ConfigCategory *cat = new ConfigCategory(m_wallpaperConfigModel);
cat->setName(pkg.metadata().name());
cat->setIcon(pkg.metadata().icon());
cat->setSource(pkg.filePath("ui", "config.qml"));
m_wallpaperConfigModel->appendCategory(cat);
}
}
}
return m_wallpaperConfigModel;
}
//To emulate Qt::WA_DeleteOnClose that QWindow doesn't have
void ConfigView::hideEvent(QHideEvent *ev)
{

View File

@ -105,13 +105,15 @@ private:
class ConfigView : public QQuickView
{
Q_OBJECT
Q_PROPERTY(QObject *configModel READ configModel CONSTANT)
Q_PROPERTY(ConfigModel *configModel READ configModel CONSTANT)
Q_PROPERTY(ConfigModel *wallpaperConfigModel READ wallpaperConfigModel CONSTANT)
public:
ConfigView(AppletInterface *scriptEngine, QWindow *parent = 0);
virtual ~ConfigView();
QObject *configModel() const;
ConfigModel *configModel() const;
ConfigModel *wallpaperConfigModel();
protected:
void hideEvent(QHideEvent *ev);
@ -120,6 +122,7 @@ protected:
private:
AppletInterface *m_appletInterface;
ConfigModel *m_configModel;
ConfigModel *m_wallpaperConfigModel;
};
#endif // multiple inclusion guard

View File

@ -167,6 +167,7 @@ void ContainmentInterface::loadWallpaper()
}
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic");
pkg.setDefaultPackageRoot("plasma/wallpapers");
pkg.setPath("org.kde.wallpaper.image");
m_wallpaperQmlObject = new QmlObject(this);

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name=""/>
<group name="General">
<entry name="Test" type="String">
<label>This is a test</label>
<default>test</default>
</entry>
</group>
</kcfg>

View File

@ -18,13 +18,45 @@
import QtQuick 2.0
import org.kde.plasma.components 0.1 as PlasmaComponents
import org.kde.plasma.configuration 0.1
Item {
implicitWidth: childrenRect.width
implicitHeight: childrenRect.height
Column {
PlasmaComponents.Label {
text: "Wallpaper settings goes here"
text: "Plugins"
}
ListView {
id: categoriesView
anchors {
left: parent.left
right: parent.right
}
height: 100
orientation: ListView.Horizontal
model: configDialog.wallpaperConfigModel
delegate: ConfigCategoryDelegate {
anchors {
top: parent.top
bottom: parent.bottom
left: undefined
right: undefined
}
width: 64
}
}
PlasmaComponents.PageStack {
id: main
anchors {
left: parent.left
right: parent.right
}
height: 200
property string sourceFile
onSourceFileChanged: {
replace(Qt.resolvedUrl(sourceFile))
root.width = mainColumn.implicitWidth
root.height = mainColumn.implicitHeight
}
}
}

View File

@ -1,4 +1,4 @@
install(DIRECTORY . DESTINATION ${DATA_INSTALL_DIR}/plasma/packages/org.kde.wallpaper.image PATTERN .svn EXCLUDE PATTERN CMakeLists.txt EXCLUDE PATTERN Messages.sh EXCLUDE)
install(DIRECTORY . DESTINATION ${DATA_INSTALL_DIR}/plasma/wallpapers/org.kde.wallpaper.image PATTERN .svn EXCLUDE PATTERN CMakeLists.txt EXCLUDE PATTERN Messages.sh EXCLUDE)

View File

@ -0,0 +1,24 @@
/*
* Copyright 2013 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.0
Text {
id: root
text: "Image wallpaper configuration module"
}

View File

@ -10,6 +10,7 @@ Name[sv]=Skrivbordsunderlägg med bild
Name[uk]=Зображення тла стільниці
Name[x-test]=xxImage wallpaperxx
Type=Service
Icon=image-x-generic
X-KDE-ParentApp=
X-KDE-PluginInfo-Author=Marco Martin