Merge branch 'configdialog_in_shell'
This commit is contained in:
commit
5e906f24c7
@ -73,8 +73,8 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int
|
||||
} else if (appletId > s_maxAppletId) {
|
||||
s_maxAppletId = appletId;
|
||||
}
|
||||
QObject::connect(actions->action("configure"), SIGNAL(QAction::triggered()),
|
||||
q, SLOT(Applet::requestConfiguration));
|
||||
QObject::connect(actions->action("configure"), SIGNAL(triggered()),
|
||||
q, SLOT(requestConfiguration()));
|
||||
}
|
||||
|
||||
AppletPrivate::~AppletPrivate()
|
||||
|
@ -109,7 +109,7 @@ void PlasmoidPackage::initPackage(Package *package)
|
||||
package->setServicePrefix("plasma-applet-");
|
||||
package->setDefaultPackageRoot("plasma/plasmoids/");
|
||||
|
||||
package->addFileDefinition("configmodel", "ui/config.qml", i18n("Configuration UI pages model"));
|
||||
package->addFileDefinition("configmodel", "config/config.qml", i18n("Configuration UI pages model"));
|
||||
package->addFileDefinition("mainconfigxml", "config/main.xml", i18n("Configuration XML file"));
|
||||
}
|
||||
|
||||
|
@ -13,13 +13,9 @@ include_directories(${KDE4_INCLUDE_DIR}/KDE ${PHONON_INCLUDES} ${CMAKE_CURRENT_S
|
||||
|
||||
#DECLARATIVE APPLET
|
||||
set(declarative_appletscript_SRCS
|
||||
declarative/configpropertymap.cpp
|
||||
declarative/packageaccessmanager.cpp
|
||||
declarative/packageaccessmanagerfactory.cpp
|
||||
declarative/qmlobject.cpp
|
||||
plasmoid/appletinterface.cpp
|
||||
plasmoid/configview.cpp
|
||||
plasmoid/containmentconfigview.cpp
|
||||
plasmoid/containmentinterface.cpp
|
||||
plasmoid/declarativeappletscript.cpp
|
||||
plasmoid/wallpaperinterface.cpp
|
||||
|
@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Marco Martin <notmart@gmail.com>
|
||||
*
|
||||
* This program 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, 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 Library 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.
|
||||
*/
|
||||
|
||||
#include "configpropertymap.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <KConfigSkeletonItem>
|
||||
|
||||
|
||||
ConfigPropertyMap::ConfigPropertyMap(KConfigSkeleton *config, QObject *parent)
|
||||
: QQmlPropertyMap(parent),
|
||||
m_config(config)
|
||||
{
|
||||
connect(config, &KConfigSkeleton::configChanged,
|
||||
this, &ConfigPropertyMap::loadConfig);
|
||||
connect(this, &ConfigPropertyMap::valueChanged,
|
||||
this, &ConfigPropertyMap::writeConfigValue);
|
||||
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
ConfigPropertyMap::~ConfigPropertyMap()
|
||||
{
|
||||
writeConfig();
|
||||
}
|
||||
|
||||
void ConfigPropertyMap::loadConfig()
|
||||
{
|
||||
if (!m_config) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (KConfigSkeletonItem *item, m_config.data()->items()) {
|
||||
insert(item->key(), item->property());
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigPropertyMap::writeConfig()
|
||||
{
|
||||
if (!m_config) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (KConfigSkeletonItem *item, m_config.data()->items()) {
|
||||
item->setProperty(value(item->key()));
|
||||
}
|
||||
|
||||
m_config.data()->blockSignals(true);
|
||||
m_config.data()->writeConfig();
|
||||
m_config.data()->blockSignals(false);
|
||||
}
|
||||
|
||||
void ConfigPropertyMap::writeConfigValue(const QString &key, const QVariant &value)
|
||||
{
|
||||
KConfigSkeletonItem *item = m_config.data()->findItem(key);
|
||||
if (item) {
|
||||
item->setProperty(value);
|
||||
m_config.data()->blockSignals(true);
|
||||
m_config.data()->writeConfig();
|
||||
m_config.data()->blockSignals(false);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_configpropertymap.cpp"
|
||||
|
||||
|
||||
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Marco Martin <notmart@gmail.com>
|
||||
*
|
||||
* This program 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, 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 Library 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.
|
||||
*/
|
||||
|
||||
#ifndef CONFIGPROPERTYMAP_P
|
||||
#define CONFIGPROPERTYMAP_P
|
||||
|
||||
#include <QQmlPropertyMap>
|
||||
|
||||
#include <KConfigSkeleton>
|
||||
|
||||
|
||||
class ConfigPropertyMap : public QQmlPropertyMap
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConfigPropertyMap(KConfigSkeleton *config, QObject *parent = 0);
|
||||
~ConfigPropertyMap();
|
||||
|
||||
private Q_SLOTS:
|
||||
void loadConfig();
|
||||
void writeConfig();
|
||||
void writeConfigValue(const QString &key, const QVariant &value);
|
||||
|
||||
private:
|
||||
QWeakPointer<KConfigSkeleton>m_config;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,233 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 Marco Martin <mart@kde.org>
|
||||
*
|
||||
* This program 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, 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 Library 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.
|
||||
*/
|
||||
|
||||
#include "qmlobject.h"
|
||||
|
||||
|
||||
#include <QQmlComponent>
|
||||
#include <QQmlEngine>
|
||||
#include <QQmlContext>
|
||||
#include <QQmlIncubator>
|
||||
#include <QTimer>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <kdeclarative.h>
|
||||
|
||||
|
||||
#include "packageaccessmanagerfactory.h"
|
||||
//#include "private/declarative/dataenginebindings_p.h"
|
||||
|
||||
|
||||
class QmlObjectPrivate
|
||||
{
|
||||
public:
|
||||
QmlObjectPrivate(QmlObject *parent)
|
||||
: q(parent),
|
||||
engine(0),
|
||||
component(0),
|
||||
delay(false)
|
||||
{
|
||||
}
|
||||
|
||||
~QmlObjectPrivate()
|
||||
{
|
||||
delete root.data();
|
||||
}
|
||||
|
||||
void errorPrint(QQmlComponent *component);
|
||||
void execute(const QUrl &source);
|
||||
void scheduleExecutionEnd();
|
||||
void minimumWidthChanged();
|
||||
void minimumHeightChanged();
|
||||
void maximumWidthChanged();
|
||||
void maximumHeightChanged();
|
||||
void preferredWidthChanged();
|
||||
void preferredHeightChanged();
|
||||
|
||||
|
||||
QmlObject *q;
|
||||
|
||||
QUrl source;
|
||||
QQmlEngine* engine;
|
||||
QQmlIncubator incubator;
|
||||
QQmlComponent* component;
|
||||
QWeakPointer<QObject> root;
|
||||
bool delay : 1;
|
||||
};
|
||||
|
||||
void QmlObjectPrivate::errorPrint(QQmlComponent *component)
|
||||
{
|
||||
QString errorStr = "Error loading QML file.\n";
|
||||
if(component->isError()){
|
||||
QList<QQmlError> errors = component->errors();
|
||||
foreach (const QQmlError &error, errors) {
|
||||
errorStr += (error.line()>0?QString(QString::number(error.line()) + QLatin1String(": ")):QLatin1String(""))
|
||||
+ error.description() + '\n';
|
||||
}
|
||||
}
|
||||
kWarning() << component->url().toString() + '\n' + errorStr;
|
||||
}
|
||||
|
||||
void QmlObjectPrivate::execute(const QUrl &source)
|
||||
{
|
||||
if (source.isEmpty()) {
|
||||
#ifndef NDEBUG
|
||||
kDebug() << "File name empty!";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
delete component;
|
||||
component = new QQmlComponent(engine, q);
|
||||
delete root.data();
|
||||
|
||||
KDeclarative kdeclarative;
|
||||
kdeclarative.setDeclarativeEngine(engine);
|
||||
kdeclarative.initialize();
|
||||
//binds things like kconfig and icons
|
||||
kdeclarative.setupBindings();
|
||||
|
||||
component->loadUrl(source);
|
||||
|
||||
if (delay) {
|
||||
QTimer::singleShot(0, q, SLOT(scheduleExecutionEnd()));
|
||||
} else {
|
||||
scheduleExecutionEnd();
|
||||
}
|
||||
}
|
||||
|
||||
void QmlObjectPrivate::scheduleExecutionEnd()
|
||||
{
|
||||
if (component->isReady() || component->isError()) {
|
||||
q->completeInitialization();
|
||||
} else {
|
||||
QObject::connect(component, SIGNAL(statusChanged(QQmlComponent::Status)), q, SLOT(completeInitialization()));
|
||||
}
|
||||
}
|
||||
|
||||
QmlObject::QmlObject(QObject *parent)
|
||||
: QObject(parent),
|
||||
d(new QmlObjectPrivate(this))
|
||||
{
|
||||
d->engine = new QQmlEngine(this);
|
||||
d->engine->setIncubationController(new QmlObjectIncubationController(0));
|
||||
//d->engine->setNetworkAccessManagerFactory(new PackageAccessManagerFactory());
|
||||
}
|
||||
|
||||
QmlObject::~QmlObject()
|
||||
{
|
||||
// QDeclarativeNetworkAccessManagerFactory *factory = d->engine->networkAccessManagerFactory();
|
||||
// d->engine->setNetworkAccessManagerFactory(0);
|
||||
// delete factory;
|
||||
delete d;
|
||||
}
|
||||
|
||||
void QmlObject::setSource(const QUrl &source)
|
||||
{
|
||||
qDebug() << "Opening" << source;
|
||||
d->source = source;
|
||||
d->execute(source);
|
||||
}
|
||||
|
||||
QUrl QmlObject::source() const
|
||||
{
|
||||
return d->source;
|
||||
}
|
||||
|
||||
void QmlObject::setInitializationDelayed(const bool delay)
|
||||
{
|
||||
d->delay = delay;
|
||||
}
|
||||
|
||||
bool QmlObject::isInitializationDelayed() const
|
||||
{
|
||||
return d->delay;
|
||||
}
|
||||
|
||||
QQmlEngine* QmlObject::engine()
|
||||
{
|
||||
return d->engine;
|
||||
}
|
||||
|
||||
QObject *QmlObject::rootObject() const
|
||||
{
|
||||
return d->root.data();
|
||||
}
|
||||
|
||||
QQmlComponent *QmlObject::mainComponent() const
|
||||
{
|
||||
return d->component;
|
||||
}
|
||||
|
||||
void QmlObject::completeInitialization()
|
||||
{
|
||||
if (d->root) {
|
||||
return;
|
||||
}
|
||||
if (d->component->status() != QQmlComponent::Ready || d->component->isError()) {
|
||||
d->errorPrint(d->component);
|
||||
return;
|
||||
}
|
||||
|
||||
d->component->create(d->incubator);
|
||||
|
||||
while (!d->incubator.isReady() && d->incubator.status() != QQmlIncubator::Error) {
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
|
||||
}
|
||||
|
||||
d->root = d->incubator.object();
|
||||
//d->root = d->component->create();
|
||||
|
||||
if (!d->root) {
|
||||
d->errorPrint(d->component);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
kDebug() << "Execution of QML done!";
|
||||
#endif
|
||||
|
||||
emit finished();
|
||||
}
|
||||
|
||||
QObject *QmlObject::createObjectFromSource(const QUrl &source)
|
||||
{
|
||||
QQmlComponent *component = new QQmlComponent(d->engine, this);
|
||||
component->loadUrl(source);
|
||||
component->create(d->incubator, d->engine->rootContext());
|
||||
while (!d->incubator.isReady() && d->incubator.status() != QQmlIncubator::Error) {
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
|
||||
}
|
||||
QObject *object = d->incubator.object();
|
||||
|
||||
if (!component->isError() && d->root && object) {
|
||||
//memory management
|
||||
component->setParent(object);
|
||||
object->setProperty("parent", QVariant::fromValue(d->root.data()));
|
||||
return object;
|
||||
|
||||
} else {
|
||||
d->errorPrint(component);
|
||||
delete component;
|
||||
delete object;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include "moc_qmlobject.cpp"
|
@ -1,190 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 Marco Martin <mart@kde.org>
|
||||
*
|
||||
* This program 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, 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 Library 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.
|
||||
*/
|
||||
|
||||
#ifndef QMLOBJECT_H
|
||||
#define QMLOBJECT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QQmlIncubationController>
|
||||
|
||||
#include <QWindow>
|
||||
#include <QAnimationDriver>
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
|
||||
class QQmlEngine;
|
||||
class QQmlComponent;
|
||||
|
||||
|
||||
class QmlObjectPrivate;
|
||||
|
||||
class QmlObjectIncubationController : public QObject, public QQmlIncubationController
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QmlObjectIncubationController(QObject *parent)
|
||||
: QObject(parent),
|
||||
QQmlIncubationController()
|
||||
{
|
||||
// Allow incubation for 1/3 of a frame.
|
||||
m_incubation_time = qMax(1, int(1000 / QGuiApplication::primaryScreen()->refreshRate()) / 3);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool event(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::User) {
|
||||
incubate();
|
||||
return true;
|
||||
}
|
||||
return QObject::event(e);
|
||||
}
|
||||
|
||||
public slots:
|
||||
void incubate()
|
||||
{
|
||||
if (incubatingObjectCount()) {
|
||||
incubateFor(m_incubation_time * 2);
|
||||
if (incubatingObjectCount()) {
|
||||
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void animationStopped() { incubate(); }
|
||||
|
||||
protected:
|
||||
virtual void incubatingObjectCountChanged(int count)
|
||||
{
|
||||
if (count) {
|
||||
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
|
||||
}
|
||||
}
|
||||
private:
|
||||
int m_incubation_time;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class QmlObject plasma/declarativewidget.h <Plasma/QmlObject>
|
||||
*
|
||||
* @author Marco Martin <mart@kde.org>
|
||||
*
|
||||
* @short An object that instantiates an entire QML context, with its own declarative engine
|
||||
*
|
||||
* Plasma::QmlObject provides a class for conveniently use QML based
|
||||
* declarative user interfaces inside Plasma widgets.
|
||||
* To one QmlObject corresponds one QML file (that can eventually include others)
|
||||
* tere will be its own QQmlEngine with a single root object,
|
||||
* described in the QML file.
|
||||
*/
|
||||
class QmlObject : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QUrl source READ source WRITE setSource)
|
||||
Q_PROPERTY(bool initializationDelayed READ isInitializationDelayed WRITE setInitializationDelayed)
|
||||
Q_PROPERTY(QObject * rootObject READ rootObject)
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructs a new QmlObject
|
||||
*
|
||||
* @param parent the parent of this object
|
||||
*/
|
||||
explicit QmlObject(QObject *parent = 0);
|
||||
~QmlObject();
|
||||
|
||||
/**
|
||||
* Sets the path of the QML file to parse and execute
|
||||
*
|
||||
* @param path the absolute path of a QML file
|
||||
*/
|
||||
void setSource(const QUrl &source);
|
||||
|
||||
/**
|
||||
* @return the absolute path of the current QML file
|
||||
*/
|
||||
QUrl source() const;
|
||||
|
||||
/**
|
||||
* Sets whether the execution of the QML file has to be delayed later in the event loop. It has to be called before setQmlPath().
|
||||
* In this case will be possible to assign new objects in the main engine context
|
||||
* before the main component gets initialized.
|
||||
* So it will be possible to access it immediately from the QML code.
|
||||
* The initialization will either be completed automatically asyncronously
|
||||
* or explicitly by calling completeInitialization()
|
||||
*
|
||||
* @param delay if true the initialization of the QML file will be delayed
|
||||
* at the end of the event loop
|
||||
*/
|
||||
void setInitializationDelayed(const bool delay);
|
||||
|
||||
/**
|
||||
* @return true if the initialization of the QML file will be delayed
|
||||
* at the end of the event loop
|
||||
*/
|
||||
bool isInitializationDelayed() const;
|
||||
|
||||
/**
|
||||
* @return the declarative engine that runs the qml file assigned to this widget.
|
||||
*/
|
||||
QQmlEngine* engine();
|
||||
|
||||
/**
|
||||
* @return the root object of the declarative object tree
|
||||
*/
|
||||
QObject *rootObject() const;
|
||||
|
||||
/**
|
||||
* @return the main QQmlComponent of the engine
|
||||
*/
|
||||
QQmlComponent *mainComponent() const;
|
||||
|
||||
/**
|
||||
* Creates and returns an object based on the provided url to a Qml file
|
||||
* with the same QQmlEngine and the same root context as the amin object,
|
||||
* that will be the parent of the newly created object
|
||||
* @param source url where the QML file is located
|
||||
*/
|
||||
QObject *createObjectFromSource(const QUrl &source);
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Finishes the process of initialization.
|
||||
* If isInitializationDelayed() is false, calling this will have no effect.
|
||||
*/
|
||||
void completeInitialization();
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* Emitted when the parsing and execution of the QML file is terminated
|
||||
*/
|
||||
void finished();
|
||||
|
||||
private:
|
||||
friend class QmlObjectPrivate;
|
||||
QmlObjectPrivate * const d;
|
||||
|
||||
Q_PRIVATE_SLOT(d, void scheduleExecutionEnd())
|
||||
};
|
||||
|
||||
|
||||
#endif // multiple inclusion guard
|
@ -46,10 +46,8 @@
|
||||
#include <Plasma/PluginLoader>
|
||||
|
||||
#include "containmentinterface.h"
|
||||
#include "configview.h"
|
||||
#include "containmentconfigview.h"
|
||||
#include "declarative/configpropertymap.h"
|
||||
#include "declarative/qmlobject.h"
|
||||
#include <kdeclarative/configpropertymap.h>
|
||||
#include <kdeclarative/qmlobject.h>
|
||||
#include "declarative/packageaccessmanagerfactory.h"
|
||||
|
||||
Q_DECLARE_METATYPE(AppletInterface*)
|
||||
@ -76,9 +74,6 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, QQuickItem *pa
|
||||
connect(m_appletScriptEngine, SIGNAL(contextChanged()),
|
||||
this, SIGNAL(contextChanged()));
|
||||
|
||||
connect(applet()->actions()->action("configure"), &QAction::triggered,
|
||||
this, &AppletInterface::configureTriggered);
|
||||
|
||||
m_qmlObject = new QmlObject(this);
|
||||
m_qmlObject->setInitializationDelayed(true);
|
||||
|
||||
@ -457,7 +452,8 @@ bool AppletInterface::immutable() const
|
||||
|
||||
bool AppletInterface::userConfiguring() const
|
||||
{
|
||||
return m_configView.data()->isVisible();
|
||||
//FIXME
|
||||
return false;
|
||||
}
|
||||
|
||||
int AppletInterface::apiVersion() const
|
||||
@ -620,37 +616,4 @@ QmlObject *AppletInterface::qmlObject()
|
||||
return m_qmlObject;
|
||||
}
|
||||
|
||||
void AppletInterface::configureTriggered()
|
||||
{
|
||||
setConfigurationInterfaceShown(true);
|
||||
}
|
||||
|
||||
void AppletInterface::setConfigurationInterfaceShown(bool show)
|
||||
{
|
||||
if (!applet()->containment() || !applet()->containment()->corona()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (show) {
|
||||
if (!m_configView) {
|
||||
ContainmentInterface *ci = qobject_cast<ContainmentInterface *>(this);
|
||||
|
||||
if (ci) {
|
||||
m_configView = new ContainmentConfigView(ci);
|
||||
} else {
|
||||
m_configView = new ConfigView(this);
|
||||
}
|
||||
m_configView.data()->init();
|
||||
}
|
||||
|
||||
m_configView.data()->show();
|
||||
|
||||
} else {
|
||||
if (m_configView) {
|
||||
m_configView.data()->hide();
|
||||
m_configView.data()->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_appletinterface.cpp"
|
||||
|
@ -231,15 +231,10 @@ Q_SIGNALS:
|
||||
void busyChanged();
|
||||
void expandedChanged();
|
||||
|
||||
//it's important those slots are private because must not be invokable by qml
|
||||
private Q_SLOTS:
|
||||
void configureTriggered();
|
||||
|
||||
protected:
|
||||
virtual void init();
|
||||
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
|
||||
void itemChange(ItemChange change, const ItemChangeData &value);
|
||||
void setConfigurationInterfaceShown(bool show);
|
||||
|
||||
DeclarativeAppletScript *m_appletScriptEngine;
|
||||
|
||||
@ -255,7 +250,6 @@ private:
|
||||
//UI-specific members ------------------
|
||||
QmlObject *m_qmlObject;
|
||||
QWeakPointer<QObject> m_compactUiObject;
|
||||
QWeakPointer<ConfigView> m_configView;
|
||||
|
||||
QTimer *m_creationTimer;
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "containmentinterface.h"
|
||||
#include "wallpaperinterface.h"
|
||||
#include "declarative/qmlobject.h"
|
||||
#include <kdeclarative/qmlobject.h>
|
||||
|
||||
#include <QQmlExpression>
|
||||
#include <QQmlProperty>
|
||||
|
@ -46,9 +46,9 @@
|
||||
#include "plasmoid/appletinterface.h"
|
||||
#include "plasmoid/containmentinterface.h"
|
||||
|
||||
#include "declarative/qmlobject.h"
|
||||
#include <kdeclarative/qmlobject.h>
|
||||
#include "declarative/packageaccessmanagerfactory.h"
|
||||
#include "declarative/configpropertymap.h"
|
||||
#include <kdeclarative/configpropertymap.h>
|
||||
|
||||
|
||||
K_EXPORT_PLASMA_APPLETSCRIPTENGINE(declarativeappletscript, DeclarativeAppletScript)
|
||||
|
@ -20,8 +20,8 @@
|
||||
#include "wallpaperinterface.h"
|
||||
|
||||
#include "containmentinterface.h"
|
||||
#include "declarative/configpropertymap.h"
|
||||
#include "declarative/qmlobject.h"
|
||||
#include <kdeclarative/configpropertymap.h>
|
||||
#include <kdeclarative/qmlobject.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QQmlExpression>
|
||||
|
@ -56,6 +56,8 @@ set(widgetexplorer_SRC
|
||||
|
||||
add_executable(plasma-shell
|
||||
main.cpp
|
||||
configview.cpp
|
||||
containmentconfigview.cpp
|
||||
desktopcorona.cpp
|
||||
panelview.cpp
|
||||
shellpluginloader.cpp
|
||||
@ -81,6 +83,7 @@ target_link_libraries(plasma-shell
|
||||
${KDE4_KDEUI_LIBS}
|
||||
KDE4__kde4support
|
||||
${Solid_LIBRARIES}
|
||||
kdeclarative
|
||||
)
|
||||
message("+++ kde4support : ${kde4support_LIBRARY}")
|
||||
|
||||
|
@ -18,16 +18,17 @@
|
||||
*/
|
||||
|
||||
#include "configview.h"
|
||||
#include "plasmoid/appletinterface.h"
|
||||
#include "plasmoid/containmentinterface.h"
|
||||
#include "plasmoid/wallpaperinterface.h"
|
||||
#include "declarative/configpropertymap.h"
|
||||
#include "Plasma/Applet"
|
||||
#include "Plasma/Containment"
|
||||
//#include "plasmoid/wallpaperinterface.h"
|
||||
#include "kdeclarative/configpropertymap.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QQmlComponent>
|
||||
#include <QQmlEngine>
|
||||
#include <QQmlContext>
|
||||
#include <QQuickItem>
|
||||
|
||||
#include <KGlobal>
|
||||
#include <KLocalizedString>
|
||||
@ -146,7 +147,7 @@ QVariant ConfigModel::data(const QModelIndex& index, int role) const
|
||||
return m_categories.at(index.row())->icon();
|
||||
case SourceRole:
|
||||
if (m_appletInterface) {
|
||||
return QUrl::fromLocalFile(m_appletInterface.data()->applet()->package().filePath("ui", m_categories.at(index.row())->source()));
|
||||
return QUrl::fromLocalFile(m_appletInterface.data()->package().filePath("ui", m_categories.at(index.row())->source()));
|
||||
} else {
|
||||
return m_categories.at(index.row())->source();
|
||||
}
|
||||
@ -167,7 +168,7 @@ QVariant ConfigModel::get(int row) const
|
||||
value["name"] = m_categories.at(row)->name();
|
||||
value["icon"] = m_categories.at(row)->icon();
|
||||
if (m_appletInterface) {
|
||||
value["source"] = QUrl::fromLocalFile(m_appletInterface.data()->applet()->package().filePath("components", m_categories.at(row)->source()));
|
||||
value["source"] = QUrl::fromLocalFile(m_appletInterface.data()->package().filePath("components", m_categories.at(row)->source()));
|
||||
} else {
|
||||
value["source"] = m_categories.at(row)->source();
|
||||
}
|
||||
@ -193,12 +194,12 @@ void ConfigModel::clear()
|
||||
emit countChanged();
|
||||
}
|
||||
|
||||
void ConfigModel::setAppletInterface(AppletInterface *interface)
|
||||
void ConfigModel::setApplet(Plasma::Applet *interface)
|
||||
{
|
||||
m_appletInterface = interface;
|
||||
}
|
||||
|
||||
AppletInterface *ConfigModel::appletInterface() const
|
||||
Plasma::Applet *ConfigModel::applet() const
|
||||
{
|
||||
return m_appletInterface.data();
|
||||
}
|
||||
@ -259,19 +260,19 @@ void ConfigModel::categories_clear(QQmlListProperty<ConfigCategory> *prop)
|
||||
|
||||
|
||||
//////////////////////////////ConfigView
|
||||
ConfigView::ConfigView(AppletInterface *interface, QWindow *parent)
|
||||
ConfigView::ConfigView(Plasma::Applet *interface, QWindow *parent)
|
||||
: QQuickView(parent),
|
||||
m_appletInterface(interface)
|
||||
m_applet(interface)
|
||||
{
|
||||
qmlRegisterType<ConfigModel>("org.kde.plasma.configuration", 2, 0, "ConfigModel");
|
||||
qmlRegisterType<ConfigCategory>("org.kde.plasma.configuration", 2, 0, "ConfigCategory");
|
||||
|
||||
//FIXME: problem on nvidia, all windows should be transparent or won't show
|
||||
setColor(Qt::transparent);
|
||||
setTitle(i18n("%1 Settings", m_appletInterface->applet()->title()));
|
||||
setTitle(i18n("%1 Settings", m_applet->title()));
|
||||
|
||||
|
||||
if (!m_appletInterface->applet()->containment()->corona()->package().isValid()) {
|
||||
if (!m_applet->containment()->corona()->package().isValid()) {
|
||||
qWarning() << "Invalid home screen package";
|
||||
}
|
||||
|
||||
@ -279,17 +280,17 @@ ConfigView::ConfigView(AppletInterface *interface, QWindow *parent)
|
||||
|
||||
|
||||
//config model local of the applet
|
||||
QQmlComponent *component = new QQmlComponent(engine(), QUrl::fromLocalFile(m_appletInterface->applet()->package().filePath("configmodel")), this);
|
||||
QQmlComponent *component = new QQmlComponent(engine(), QUrl::fromLocalFile(m_applet->package().filePath("configmodel")), this);
|
||||
QObject *object = component->create(engine()->rootContext());
|
||||
m_configModel = qobject_cast<ConfigModel *>(object);
|
||||
if (m_configModel) {
|
||||
m_configModel->setAppletInterface(m_appletInterface);
|
||||
m_configModel->setApplet(m_applet);
|
||||
} else {
|
||||
delete object;
|
||||
}
|
||||
delete component;
|
||||
|
||||
ContainmentInterface *cont = qobject_cast<ContainmentInterface *>(m_appletInterface);
|
||||
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(m_applet);
|
||||
|
||||
engine()->rootContext()->setContextProperty("plasmoid", interface);
|
||||
engine()->rootContext()->setContextProperty("configDialog", this);
|
||||
@ -301,7 +302,7 @@ ConfigView::~ConfigView()
|
||||
|
||||
void ConfigView::init()
|
||||
{
|
||||
setSource(QUrl::fromLocalFile(m_appletInterface->applet()->containment()->corona()->package().filePath("configurationui")));
|
||||
setSource(QUrl::fromLocalFile(m_applet->containment()->corona()->package().filePath("appletconfigurationui")));
|
||||
}
|
||||
|
||||
ConfigModel *ConfigView::configModel() const
|
@ -26,7 +26,10 @@
|
||||
#include <QQmlListProperty>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
class AppletInterface;
|
||||
namespace Plasma {
|
||||
class Applet;
|
||||
}
|
||||
|
||||
class ConfigPropertyMap;
|
||||
|
||||
|
||||
@ -87,8 +90,8 @@ public:
|
||||
void appendCategory(ConfigCategory *c);
|
||||
void clear();
|
||||
|
||||
void setAppletInterface(AppletInterface *interface);
|
||||
AppletInterface *appletInterface() const;
|
||||
void setApplet(Plasma::Applet *interface);
|
||||
Plasma::Applet *applet() const;
|
||||
|
||||
int count() {return rowCount();}
|
||||
virtual int rowCount(const QModelIndex &index = QModelIndex()) const;
|
||||
@ -107,7 +110,7 @@ Q_SIGNALS:
|
||||
|
||||
private:
|
||||
QList<ConfigCategory*>m_categories;
|
||||
QWeakPointer<AppletInterface> m_appletInterface;
|
||||
QWeakPointer<Plasma::Applet> m_appletInterface;
|
||||
};
|
||||
|
||||
|
||||
@ -119,10 +122,10 @@ class ConfigView : public QQuickView
|
||||
Q_PROPERTY(ConfigModel *configModel READ configModel CONSTANT)
|
||||
|
||||
public:
|
||||
ConfigView(AppletInterface *scriptEngine, QWindow *parent = 0);
|
||||
ConfigView(Plasma::Applet *applet, QWindow *parent = 0);
|
||||
virtual ~ConfigView();
|
||||
|
||||
void init();
|
||||
virtual void init();
|
||||
|
||||
ConfigModel *configModel() const;
|
||||
|
||||
@ -131,7 +134,7 @@ protected:
|
||||
void resizeEvent(QResizeEvent *re);
|
||||
|
||||
private:
|
||||
AppletInterface *m_appletInterface;
|
||||
Plasma::Applet *m_applet;
|
||||
ConfigModel *m_configModel;
|
||||
};
|
||||
|
@ -18,35 +18,50 @@
|
||||
*/
|
||||
|
||||
#include "containmentconfigview.h"
|
||||
#include "plasmoid/containmentinterface.h"
|
||||
#include "plasmoid/wallpaperinterface.h"
|
||||
#include "declarative/configpropertymap.h"
|
||||
#include <Plasma/Containment>
|
||||
//#include "plasmoid/wallpaperinterface.h"
|
||||
#include <kdeclarative/configpropertymap.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QQmlContext>
|
||||
#include <QQmlEngine>
|
||||
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include <Plasma/Corona>
|
||||
#include <Plasma/PluginLoader>
|
||||
|
||||
|
||||
//////////////////////////////ContainmentConfigView
|
||||
ContainmentConfigView::ContainmentConfigView(ContainmentInterface *interface, QWindow *parent)
|
||||
: ConfigView(interface, parent),
|
||||
m_containmentInterface(interface),
|
||||
ContainmentConfigView::ContainmentConfigView(Plasma::Containment *cont, QWindow *parent)
|
||||
: ConfigView(cont, parent),
|
||||
m_containment(cont),
|
||||
m_wallpaperConfigModel(0),
|
||||
m_currentWallpaperConfig(0)
|
||||
{
|
||||
engine()->rootContext()->setContextProperty("configDialog", this);
|
||||
setCurrentWallpaper(interface->containment()->wallpaper());
|
||||
setCurrentWallpaper(cont->containment()->wallpaper());
|
||||
|
||||
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic");
|
||||
pkg.setDefaultPackageRoot("plasma/wallpapers");
|
||||
pkg.setPath(m_containment->wallpaper());
|
||||
QFile file(pkg.filePath("config", "main.xml"));
|
||||
KConfigGroup cfg = m_containment->config();
|
||||
cfg = KConfigGroup(&cfg, "Wallpaper");
|
||||
m_currentWallpaperConfig = m_ownWallpaperConfig = new ConfigPropertyMap(new Plasma::ConfigLoader(&cfg, &file), this);
|
||||
}
|
||||
|
||||
ContainmentConfigView::~ContainmentConfigView()
|
||||
{
|
||||
}
|
||||
|
||||
void ContainmentConfigView::init()
|
||||
{
|
||||
setSource(QUrl::fromLocalFile(m_containment->containment()->corona()->package().filePath("containmentconfigurationui")));
|
||||
}
|
||||
|
||||
ConfigModel *ContainmentConfigView::wallpaperConfigModel()
|
||||
{
|
||||
if (!m_wallpaperConfigModel) {
|
||||
@ -98,13 +113,11 @@ void ContainmentConfigView::setCurrentWallpaper(const QString &wallpaper)
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_containmentInterface->containment()->wallpaper() == wallpaper) {
|
||||
if (m_containment->wallpaper() == wallpaper) {
|
||||
delete m_currentWallpaperConfig;
|
||||
if (m_containmentInterface->wallpaperInterface()) {
|
||||
m_currentWallpaperConfig = m_containmentInterface->wallpaperInterface()->configuration();
|
||||
}
|
||||
m_currentWallpaperConfig = m_ownWallpaperConfig;
|
||||
} else {
|
||||
if (m_containmentInterface->containment()->wallpaper() != m_currentWallpaper) {
|
||||
if (m_containment->wallpaper() != m_currentWallpaper) {
|
||||
delete m_currentWallpaperConfig;
|
||||
}
|
||||
|
||||
@ -113,7 +126,7 @@ void ContainmentConfigView::setCurrentWallpaper(const QString &wallpaper)
|
||||
pkg.setDefaultPackageRoot("plasma/wallpapers");
|
||||
pkg.setPath(wallpaper);
|
||||
QFile file(pkg.filePath("config", "main.xml"));
|
||||
KConfigGroup cfg = m_containmentInterface->containment()->config();
|
||||
KConfigGroup cfg = m_containment->config();
|
||||
cfg = KConfigGroup(&cfg, "Wallpaper");
|
||||
m_currentWallpaperConfig = new ConfigPropertyMap(new Plasma::ConfigLoader(&cfg, &file), this);
|
||||
}
|
||||
@ -125,13 +138,14 @@ void ContainmentConfigView::setCurrentWallpaper(const QString &wallpaper)
|
||||
|
||||
void ContainmentConfigView::applyWallpaper()
|
||||
{
|
||||
m_containmentInterface->containment()->setWallpaper(m_currentWallpaper);
|
||||
m_containment->setWallpaper(m_currentWallpaper);
|
||||
|
||||
if (m_currentWallpaperConfig != m_containmentInterface->wallpaperInterface()->configuration()) {
|
||||
if (m_currentWallpaperConfig != m_ownWallpaperConfig) {
|
||||
delete m_currentWallpaperConfig;
|
||||
m_currentWallpaperConfig = m_containmentInterface->wallpaperInterface()->configuration();
|
||||
m_currentWallpaperConfig = m_ownWallpaperConfig;
|
||||
emit wallpaperConfigurationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include "moc_containmentconfigview.cpp"
|
@ -23,7 +23,9 @@
|
||||
|
||||
#include "configview.h"
|
||||
|
||||
class ContainmentInterface;
|
||||
namespace Plasma {
|
||||
class Containment;
|
||||
}
|
||||
class ConfigPropertyMap;
|
||||
|
||||
|
||||
@ -36,9 +38,11 @@ class ContainmentConfigView : public ConfigView
|
||||
Q_PROPERTY(QString currentWallpaper READ currentWallpaper WRITE setCurrentWallpaper NOTIFY currentWallpaperChanged)
|
||||
|
||||
public:
|
||||
ContainmentConfigView(ContainmentInterface *interface, QWindow *parent = 0);
|
||||
ContainmentConfigView(Plasma::Containment *interface, QWindow *parent = 0);
|
||||
virtual ~ContainmentConfigView();
|
||||
|
||||
virtual void init();
|
||||
|
||||
ConfigModel *wallpaperConfigModel();
|
||||
QString currentWallpaper() const;
|
||||
void setCurrentWallpaper(const QString &wallpaper);
|
||||
@ -51,10 +55,11 @@ Q_SIGNALS:
|
||||
void wallpaperConfigurationChanged();
|
||||
|
||||
private:
|
||||
ContainmentInterface *m_containmentInterface;
|
||||
Plasma::Containment *m_containment;
|
||||
ConfigModel *m_wallpaperConfigModel;
|
||||
QString m_currentWallpaper;
|
||||
ConfigPropertyMap *m_currentWallpaperConfig;
|
||||
ConfigPropertyMap *m_ownWallpaperConfig;
|
||||
};
|
||||
|
||||
#endif // multiple inclusion guard
|
@ -29,6 +29,7 @@
|
||||
#include <KLocalizedString>
|
||||
#include <Plasma/Package>
|
||||
|
||||
#include "containmentconfigview.h"
|
||||
#include "panelview.h"
|
||||
#include "view.h"
|
||||
#include "scripting/desktopscriptengine.h"
|
||||
@ -266,7 +267,8 @@ void DesktopCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Conta
|
||||
|
||||
void DesktopCorona::handleContainmentAdded(Plasma::Containment* c)
|
||||
{
|
||||
connect(c, &Plasma::Containment::showAddWidgetsInterface, this, &DesktopCorona::showWidgetExplorer);
|
||||
connect(c, &Plasma::Containment::showAddWidgetsInterface,
|
||||
this, &DesktopCorona::showWidgetExplorer);
|
||||
}
|
||||
|
||||
void DesktopCorona::showWidgetExplorer()
|
||||
|
@ -23,6 +23,8 @@ class * Free Software Foundation, Inc.,
|
||||
|
||||
#include "plasma/corona.h"
|
||||
|
||||
#include "configview.h"
|
||||
|
||||
class QDesktopWidget;
|
||||
class QQuickView;
|
||||
class PanelView;
|
||||
|
@ -36,27 +36,15 @@
|
||||
|
||||
//////////////////////////////PanelConfigView
|
||||
PanelConfigView::PanelConfigView(Plasma::Containment *containment, PanelView *panelView, QWindow *parent)
|
||||
: QQuickView(parent),
|
||||
: ConfigView(containment, parent),
|
||||
m_containment(containment),
|
||||
m_panelView(panelView)
|
||||
{
|
||||
|
||||
setFlags(Qt::FramelessWindowHint);
|
||||
//FIXME: problem on nvidia, all windows should be transparent or won't show
|
||||
setColor(Qt::transparent);
|
||||
setTitle(i18n("%1 Settings", m_containment->title()));
|
||||
|
||||
|
||||
if (!m_containment->corona()->package().isValid()) {
|
||||
qWarning() << "Invalid home screen package";
|
||||
}
|
||||
|
||||
setResizeMode(QQuickView::SizeViewToRootObject);
|
||||
|
||||
engine()->rootContext()->setContextProperty("panel", panelView);
|
||||
engine()->rootContext()->setContextProperty("configDialog", this);
|
||||
setSource(QUrl::fromLocalFile(panelView->corona()->package().filePath("panelconfigurationui")));
|
||||
syncGeometry();
|
||||
connect(containment, &Plasma::Containment::formFactorChanged,
|
||||
this, &PanelConfigView::syncGeometry);
|
||||
}
|
||||
@ -65,6 +53,12 @@ PanelConfigView::~PanelConfigView()
|
||||
{
|
||||
}
|
||||
|
||||
void PanelConfigView::init()
|
||||
{
|
||||
setSource(QUrl::fromLocalFile(m_containment->corona()->package().filePath("panelconfigurationui")));
|
||||
syncGeometry();
|
||||
}
|
||||
|
||||
void PanelConfigView::syncGeometry()
|
||||
{
|
||||
if (!m_containment) {
|
||||
@ -91,22 +85,5 @@ void PanelConfigView::syncGeometry()
|
||||
}
|
||||
}
|
||||
|
||||
//To emulate Qt::WA_DeleteOnClose that QWindow doesn't have
|
||||
void PanelConfigView::hideEvent(QHideEvent *ev)
|
||||
{
|
||||
QQuickWindow::hideEvent(ev);
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
void PanelConfigView::resizeEvent(QResizeEvent *re)
|
||||
{
|
||||
if (!rootObject()) {
|
||||
return;
|
||||
}
|
||||
rootObject()->setWidth(re->size().width());
|
||||
rootObject()->setHeight(re->size().height());
|
||||
QQuickWindow::resizeEvent(re);
|
||||
}
|
||||
|
||||
|
||||
#include "moc_panelconfigview.cpp"
|
||||
|
@ -20,6 +20,8 @@
|
||||
#ifndef PANELCONFIGVIEW_H
|
||||
#define PANELCONFIGVIEW_H
|
||||
|
||||
#include "configview.h"
|
||||
|
||||
#include <QQuickItem>
|
||||
#include <QQuickView>
|
||||
#include <QJSValue>
|
||||
@ -36,7 +38,7 @@ namespace Plasma {
|
||||
|
||||
//TODO: this should be a subclass of ConfigView currently in the scriptengine
|
||||
//TODO: that class should be moved here
|
||||
class PanelConfigView : public QQuickView
|
||||
class PanelConfigView : public ConfigView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -44,13 +46,11 @@ public:
|
||||
PanelConfigView(Plasma::Containment *interface, PanelView *panelView, QWindow *parent = 0);
|
||||
virtual ~PanelConfigView();
|
||||
|
||||
void init();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void syncGeometry();
|
||||
|
||||
protected:
|
||||
void hideEvent(QHideEvent *ev);
|
||||
void resizeEvent(QResizeEvent *re);
|
||||
|
||||
private:
|
||||
Plasma::Containment *m_containment;
|
||||
PanelView *m_panelView;
|
||||
|
@ -167,6 +167,7 @@ void PanelView::showPanelController()
|
||||
{
|
||||
if (!m_panelConfigView) {
|
||||
m_panelConfigView = new PanelConfigView(containment(), this);
|
||||
m_panelConfigView->init();
|
||||
}
|
||||
m_panelConfigView->show();
|
||||
}
|
||||
|
@ -36,7 +36,8 @@ Rectangle {
|
||||
//END properties
|
||||
|
||||
//BEGIN model
|
||||
property ConfigModel globalConfigModel: plasmoid.containmentType !== undefined ? globalContainmentConfigModel : globalAppletConfigModel
|
||||
property ConfigModel globalConfigModel: globalAppletConfigModel
|
||||
|
||||
ConfigModel {
|
||||
id: globalAppletConfigModel
|
||||
ConfigCategory {
|
||||
@ -45,19 +46,6 @@ Rectangle {
|
||||
source: "ConfigurationShortcuts.qml"
|
||||
}
|
||||
}
|
||||
ConfigModel {
|
||||
id: globalContainmentConfigModel
|
||||
ConfigCategory {
|
||||
name: "Appearance"
|
||||
icon: "preferences-desktop-wallpaper"
|
||||
source: "ConfigurationContainmentAppearance.qml"
|
||||
}
|
||||
ConfigCategory {
|
||||
name: "Mouse Actions"
|
||||
icon: "preferences-desktop-mouse"
|
||||
source: "ConfigurationContainmentActions.qml"
|
||||
}
|
||||
}
|
||||
//END model
|
||||
|
||||
//BEGIN functions
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 2.010-1301, USA.
|
||||
*/
|
||||
|
||||
import QtQuick 2.0
|
||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.plasma.configuration 2.0
|
||||
|
||||
|
||||
AppletConfiguration {
|
||||
id: root
|
||||
|
||||
//BEGIN model
|
||||
globalConfigModel: globalContainmentConfigModel
|
||||
|
||||
ConfigModel {
|
||||
id: globalContainmentConfigModel
|
||||
ConfigCategory {
|
||||
name: "Appearance"
|
||||
icon: "preferences-desktop-wallpaper"
|
||||
source: "ConfigurationContainmentAppearance.qml"
|
||||
}
|
||||
ConfigCategory {
|
||||
name: "Mouse Actions"
|
||||
icon: "preferences-desktop-mouse"
|
||||
source: "ConfigurationContainmentActions.qml"
|
||||
}
|
||||
}
|
||||
//END model
|
||||
|
||||
}
|
@ -45,7 +45,8 @@ void ShellPackageStructure::initPackage(Plasma::Package *package)
|
||||
|
||||
package->addFileDefinition("appleterror", "components/AppletError.qml", i18n("Error message shown when an applet fails to load"));
|
||||
package->addFileDefinition("compactapplet", "components/CompactApplet.qml", i18n("QML component that shows an applet in a popup"));
|
||||
package->addFileDefinition("configurationui", "components/Configuration.qml", i18n("QML component for the configuration dialog"));
|
||||
package->addFileDefinition("appletconfigurationui", "components/AppletConfiguration.qml", i18n("QML component for the configuration dialog for applets"));
|
||||
package->addFileDefinition("containmentconfigurationui", "components/ContainmentConfiguration.qml", i18n("QML component for the configuration dialog for containments"));
|
||||
package->addFileDefinition("defaultcompactrepresentation", "components/DefaultCompactRepresentation.qml", i18n("Compact representation of an applet when collapsed in a popup, for instance as an icon. applets can override this component."));
|
||||
package->addFileDefinition("widgetexplorer", "explorer/WidgetExplorer.qml", i18n("Widgets explorer UI"));
|
||||
package->addFileDefinition("panelconfigurationui", "components/PanelConfiguration.qml", i18n("Panel configuration UI"));
|
||||
|
@ -17,6 +17,10 @@
|
||||
*/
|
||||
|
||||
#include "view.h"
|
||||
#include "containmentconfigview.h"
|
||||
#include "panelconfigview.h"
|
||||
#include "panelview.h"
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <QQuickItem>
|
||||
@ -99,6 +103,8 @@ void View::setContainment(Plasma::Containment *cont)
|
||||
this, &View::locationChanged);
|
||||
connect(cont, &Plasma::Containment::formFactorChanged,
|
||||
this, &View::formFactorChanged);
|
||||
connect(cont, &Plasma::Containment::configureRequested,
|
||||
this, &View::showConfigurationInterface);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -152,4 +158,30 @@ QRectF View::screenGeometry()
|
||||
return screen()->geometry();
|
||||
}
|
||||
|
||||
void View::showConfigurationInterface(Plasma::Applet *applet)
|
||||
{
|
||||
if (m_configView) {
|
||||
m_configView.data()->hide();
|
||||
m_configView.data()->deleteLater();
|
||||
}
|
||||
|
||||
if (!applet || !applet->containment()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(applet);
|
||||
PanelView *pv = qobject_cast< PanelView* >(this);
|
||||
|
||||
if (cont && pv) {
|
||||
m_configView = new PanelConfigView(cont, pv);
|
||||
} else if (cont) {
|
||||
m_configView = new ContainmentConfigView(cont);
|
||||
} else {
|
||||
m_configView = new ConfigView(applet);
|
||||
}
|
||||
m_configView.data()->init();
|
||||
|
||||
m_configView.data()->show();
|
||||
}
|
||||
|
||||
#include "moc_view.cpp"
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "plasma/corona.h"
|
||||
#include "plasma/containment.h"
|
||||
|
||||
#include "configview.h"
|
||||
|
||||
class View : public QQuickView
|
||||
{
|
||||
@ -54,6 +55,9 @@ public:
|
||||
|
||||
QRectF screenGeometry();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void showConfigurationInterface(Plasma::Applet *applet);
|
||||
|
||||
Q_SIGNALS:
|
||||
void locationChanged(Plasma::Location location);
|
||||
void formFactorChanged(Plasma::FormFactor formFactor);
|
||||
@ -63,6 +67,7 @@ Q_SIGNALS:
|
||||
private:
|
||||
Plasma::Corona *m_corona;
|
||||
QWeakPointer<Plasma::Containment> m_containment;
|
||||
QWeakPointer<ConfigView> m_configView;
|
||||
};
|
||||
|
||||
#endif // VIEW_H
|
||||
|
Loading…
Reference in New Issue
Block a user