Revert "use d pointer in containmentconfigview"
This reverts commit 22fc5cebf449ec2a3d4f9ce8a40d11ffde1345f9. There is no need to export it since only the View is using it. Conflicts: src/plasmaview/containmentconfigview.cpp src/plasmaview/containmentconfigview.h
This commit is contained in:
parent
23ec4639c5
commit
4f435ccf85
@ -1,3 +1,22 @@
|
||||
/*
|
||||
* 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 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 "currentcontainmentactionsmodel_p.h"
|
||||
#include "containmentconfigview.h"
|
||||
|
||||
@ -15,80 +34,74 @@
|
||||
#include <Plasma/ContainmentActions>
|
||||
#include <Plasma/PluginLoader>
|
||||
|
||||
class ContainmentConfigViewPrivate
|
||||
//////////////////////////////ContainmentConfigView
|
||||
ContainmentConfigView::ContainmentConfigView(Plasma::Containment *cont, QWindow *parent)
|
||||
: ConfigView(cont, parent),
|
||||
m_containment(cont),
|
||||
m_wallpaperConfigModel(0),
|
||||
m_containmentActionConfigModel(0),
|
||||
m_currentContainmentActionsModel(0),
|
||||
m_currentWallpaperConfig(0),
|
||||
m_ownWallpaperConfig(0)
|
||||
{
|
||||
public:
|
||||
ContainmentConfigViewPrivate(Plasma::Containment *cont, ContainmentConfigView *view);
|
||||
~ContainmentConfigViewPrivate();
|
||||
|
||||
void syncWallpaperObjects();
|
||||
void applyWallpaper();
|
||||
ConfigModel *doWallpaperConfigModel();
|
||||
void setCurrentWallpaper(const QString &wallpaper);
|
||||
ConfigModel *doContainmentActionConfigModel();
|
||||
QStandardItemModel *doCurrentContainmentActionsModel();
|
||||
|
||||
|
||||
ContainmentConfigView *q;
|
||||
Plasma::Containment *containment;
|
||||
ConfigModel *wallpaperConfigModel;
|
||||
QString currentWallpaper;
|
||||
ConfigModel *containmentActionConfigModel;
|
||||
CurrentContainmentActionsModel *currentContainmentActionsModel;
|
||||
ConfigPropertyMap *currentWallpaperConfig;
|
||||
ConfigPropertyMap *ownWallpaperConfig;
|
||||
};
|
||||
|
||||
ContainmentConfigViewPrivate::ContainmentConfigViewPrivate(Plasma::Containment *cont, ContainmentConfigView *view)
|
||||
: q(view),
|
||||
containment(cont),
|
||||
wallpaperConfigModel(0),
|
||||
containmentActionConfigModel(0),
|
||||
currentContainmentActionsModel(0),
|
||||
currentWallpaperConfig(0),
|
||||
ownWallpaperConfig(0)
|
||||
{
|
||||
q->engine()->rootContext()->setContextProperty("configDialog", q);
|
||||
qmlRegisterType<QStandardItemModel>();
|
||||
engine()->rootContext()->setContextProperty("configDialog", this);
|
||||
setCurrentWallpaper(cont->containment()->wallpaper());
|
||||
|
||||
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic");
|
||||
pkg.setDefaultPackageRoot("plasma/wallpapers");
|
||||
pkg.setPath(containment->wallpaper());
|
||||
pkg.setPath(m_containment->wallpaper());
|
||||
QFile file(pkg.filePath("config", "main.xml"));
|
||||
KConfigGroup cfg = containment->config();
|
||||
KConfigGroup cfg = m_containment->config();
|
||||
cfg = KConfigGroup(&cfg, "Wallpaper");
|
||||
|
||||
syncWallpaperObjects();
|
||||
}
|
||||
|
||||
ContainmentConfigViewPrivate::~ContainmentConfigViewPrivate()
|
||||
ContainmentConfigView::~ContainmentConfigView()
|
||||
{
|
||||
}
|
||||
|
||||
void ContainmentConfigViewPrivate::syncWallpaperObjects()
|
||||
void ContainmentConfigView::init()
|
||||
{
|
||||
QObject *wallpaperGraphicsObject = containment->property("wallpaperGraphicsObject").value<QObject *>();
|
||||
q->engine()->rootContext()->setContextProperty("wallpaper", wallpaperGraphicsObject);
|
||||
|
||||
//FIXME: why m_wallpaperGraphicsObject->property("configuration").value<ConfigPropertyMap *>() doesn't work?
|
||||
currentWallpaperConfig = static_cast<ConfigPropertyMap *>(wallpaperGraphicsObject->property("configuration").value<QObject *>());
|
||||
setSource(QUrl::fromLocalFile(m_containment->containment()->corona()->package().filePath("containmentconfigurationui")));
|
||||
}
|
||||
|
||||
void ContainmentConfigViewPrivate::applyWallpaper()
|
||||
ConfigModel *ContainmentConfigView::containmentActionConfigModel()
|
||||
{
|
||||
containment->setWallpaper(currentWallpaper);
|
||||
if (!m_containmentActionConfigModel) {
|
||||
m_containmentActionConfigModel = new ConfigModel(this);
|
||||
|
||||
delete ownWallpaperConfig;
|
||||
ownWallpaperConfig = 0;
|
||||
KPluginInfo::List actions = Plasma::PluginLoader::self()->listContainmentActionsInfo(QString());
|
||||
|
||||
syncWallpaperObjects();
|
||||
emit q->wallpaperConfigurationChanged();
|
||||
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic");
|
||||
|
||||
foreach (const KPluginInfo &info, actions) {
|
||||
pkg.setDefaultPackageRoot(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "plasma/containmentactions", QStandardPaths::LocateDirectory));
|
||||
ConfigCategory *cat = new ConfigCategory(m_containmentActionConfigModel);
|
||||
cat->setName(info.name());
|
||||
cat->setIcon(info.icon());
|
||||
cat->setSource(pkg.filePath("ui", "config.qml"));
|
||||
cat->setPluginName(info.pluginName());
|
||||
m_containmentActionConfigModel->appendCategory(cat);
|
||||
}
|
||||
|
||||
}
|
||||
return m_containmentActionConfigModel;
|
||||
}
|
||||
|
||||
ConfigModel *ContainmentConfigViewPrivate::doWallpaperConfigModel()
|
||||
QStandardItemModel *ContainmentConfigView::currentContainmentActionsModel()
|
||||
{
|
||||
if (!wallpaperConfigModel) {
|
||||
wallpaperConfigModel = new ConfigModel(q);
|
||||
if (!m_currentContainmentActionsModel) {
|
||||
m_currentContainmentActionsModel = new CurrentContainmentActionsModel(m_containment, this);
|
||||
}
|
||||
return m_currentContainmentActionsModel;
|
||||
}
|
||||
|
||||
ConfigModel *ContainmentConfigView::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) {
|
||||
@ -108,134 +121,74 @@ ConfigModel *ContainmentConfigViewPrivate::doWallpaperConfigModel()
|
||||
if (!pkg.isValid()) {
|
||||
continue;
|
||||
}
|
||||
ConfigCategory *cat = new ConfigCategory(wallpaperConfigModel);
|
||||
ConfigCategory *cat = new ConfigCategory(m_wallpaperConfigModel);
|
||||
cat->setName(pkg.metadata().name());
|
||||
cat->setIcon(pkg.metadata().icon());
|
||||
cat->setSource(pkg.filePath("ui", "config.qml"));
|
||||
cat->setPluginName(package);
|
||||
wallpaperConfigModel->appendCategory(cat);
|
||||
m_wallpaperConfigModel->appendCategory(cat);
|
||||
}
|
||||
}
|
||||
}
|
||||
return wallpaperConfigModel;
|
||||
return m_wallpaperConfigModel;
|
||||
}
|
||||
|
||||
void ContainmentConfigViewPrivate::setCurrentWallpaper(const QString &wallpaper)
|
||||
ConfigPropertyMap *ContainmentConfigView::wallpaperConfiguration() const
|
||||
{
|
||||
if (currentWallpaper == wallpaper) {
|
||||
return m_currentWallpaperConfig;
|
||||
}
|
||||
|
||||
QString ContainmentConfigView::currentWallpaper() const
|
||||
{
|
||||
return m_currentWallpaper;
|
||||
}
|
||||
|
||||
void ContainmentConfigView::setCurrentWallpaper(const QString &wallpaper)
|
||||
{
|
||||
if (m_currentWallpaper == wallpaper) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete ownWallpaperConfig;
|
||||
ownWallpaperConfig = 0;
|
||||
delete m_ownWallpaperConfig;
|
||||
m_ownWallpaperConfig = 0;
|
||||
|
||||
if (containment->wallpaper() == wallpaper) {
|
||||
if (m_containment->wallpaper() == wallpaper) {
|
||||
syncWallpaperObjects();
|
||||
} else {
|
||||
|
||||
//we have to construct an independent ConfigPropertyMap when we want to configure wallpapers that are not the current one
|
||||
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic");
|
||||
pkg.setDefaultPackageRoot("plasma/wallpapers");
|
||||
pkg.setPath(wallpaper);
|
||||
QFile file(pkg.filePath("config", "main.xml"));
|
||||
KConfigGroup cfg = containment->config();
|
||||
KConfigGroup cfg = m_containment->config();
|
||||
cfg = KConfigGroup(&cfg, "Wallpaper");
|
||||
currentWallpaperConfig = ownWallpaperConfig = new ConfigPropertyMap(new Plasma::ConfigLoader(&cfg, &file), q);
|
||||
m_currentWallpaperConfig = m_ownWallpaperConfig = new ConfigPropertyMap(new Plasma::ConfigLoader(&cfg, &file), this);
|
||||
}
|
||||
|
||||
currentWallpaper = wallpaper;
|
||||
emit q->currentWallpaperChanged();
|
||||
emit q->wallpaperConfigurationChanged();
|
||||
}
|
||||
|
||||
ConfigModel *ContainmentConfigViewPrivate::doContainmentActionConfigModel()
|
||||
{
|
||||
if (!containmentActionConfigModel) {
|
||||
containmentActionConfigModel = new ConfigModel(q);
|
||||
|
||||
KPluginInfo::List actions = Plasma::PluginLoader::self()->listContainmentActionsInfo(QString());
|
||||
|
||||
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic");
|
||||
|
||||
foreach (const KPluginInfo &info, actions) {
|
||||
pkg.setDefaultPackageRoot(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "plasma/containmentactions", QStandardPaths::LocateDirectory));
|
||||
ConfigCategory *cat = new ConfigCategory(containmentActionConfigModel);
|
||||
cat->setName(info.name());
|
||||
cat->setIcon(info.icon());
|
||||
cat->setSource(pkg.filePath("ui", "config.qml"));
|
||||
cat->setPluginName(info.pluginName());
|
||||
containmentActionConfigModel->appendCategory(cat);
|
||||
}
|
||||
|
||||
}
|
||||
return containmentActionConfigModel;
|
||||
}
|
||||
|
||||
QStandardItemModel *ContainmentConfigViewPrivate::doCurrentContainmentActionsModel()
|
||||
{
|
||||
if (!currentContainmentActionsModel) {
|
||||
currentContainmentActionsModel = new CurrentContainmentActionsModel(containment, q);
|
||||
}
|
||||
return currentContainmentActionsModel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////ContainmentConfigView
|
||||
ContainmentConfigView::ContainmentConfigView(Plasma::Containment *cont, QWindow *parent)
|
||||
: ConfigView(cont, parent),
|
||||
d(new ContainmentConfigViewPrivate(cont, this))
|
||||
{
|
||||
qmlRegisterType<QStandardItemModel>();
|
||||
}
|
||||
|
||||
ContainmentConfigView::~ContainmentConfigView()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void ContainmentConfigView::init()
|
||||
{
|
||||
setSource(QUrl::fromLocalFile(d->containment->containment()->corona()->package().filePath("containmentconfigurationui")));
|
||||
}
|
||||
|
||||
ConfigModel *ContainmentConfigView::wallpaperConfigModel()
|
||||
{
|
||||
return d->doWallpaperConfigModel();
|
||||
}
|
||||
|
||||
ConfigPropertyMap *ContainmentConfigView::wallpaperConfiguration() const
|
||||
{
|
||||
return d->currentWallpaperConfig;
|
||||
}
|
||||
|
||||
QString ContainmentConfigView::currentWallpaper() const
|
||||
{
|
||||
return d->currentWallpaper;
|
||||
}
|
||||
|
||||
void ContainmentConfigView::setCurrentWallpaper(const QString &wallpaper)
|
||||
{
|
||||
d->setCurrentWallpaper(wallpaper);
|
||||
m_currentWallpaper = wallpaper;
|
||||
emit currentWallpaperChanged();
|
||||
emit wallpaperConfigurationChanged();
|
||||
}
|
||||
|
||||
void ContainmentConfigView::applyWallpaper()
|
||||
{
|
||||
d->applyWallpaper();
|
||||
m_containment->setWallpaper(m_currentWallpaper);
|
||||
|
||||
delete m_ownWallpaperConfig;
|
||||
m_ownWallpaperConfig = 0;
|
||||
|
||||
syncWallpaperObjects();
|
||||
emit wallpaperConfigurationChanged();
|
||||
}
|
||||
|
||||
void ContainmentConfigView::syncWallpaperObjects()
|
||||
{
|
||||
d->syncWallpaperObjects();
|
||||
}
|
||||
QObject *wallpaperGraphicsObject = m_containment->property("wallpaperGraphicsObject").value<QObject *>();
|
||||
engine()->rootContext()->setContextProperty("wallpaper", wallpaperGraphicsObject);
|
||||
|
||||
ConfigModel *ContainmentConfigView::containmentActionConfigModel()
|
||||
{
|
||||
return d->doContainmentActionConfigModel();
|
||||
}
|
||||
|
||||
QStandardItemModel *ContainmentConfigView::currentContainmentActionsModel()
|
||||
{
|
||||
return d->doCurrentContainmentActionsModel();
|
||||
//FIXME: why m_wallpaperGraphicsObject->property("configuration").value<ConfigPropertyMap *>() doesn't work?
|
||||
m_currentWallpaperConfig = static_cast<ConfigPropertyMap *>(wallpaperGraphicsObject->property("configuration").value<QObject *>());
|
||||
}
|
||||
|
||||
#include "moc_containmentconfigview.cpp"
|
||||
|
@ -30,7 +30,6 @@ namespace Plasma {
|
||||
|
||||
class ConfigPropertyMap;
|
||||
class CurrentContainmentActionsModel;
|
||||
class ContainmentConfigViewPrivate;
|
||||
|
||||
//TODO: is it possible to move this in the shell?
|
||||
class ContainmentConfigView : public ConfigView
|
||||
@ -65,7 +64,13 @@ protected:
|
||||
void syncWallpaperObjects();
|
||||
|
||||
private:
|
||||
ContainmentConfigViewPrivate *const d;
|
||||
Plasma::Containment *m_containment;
|
||||
ConfigModel *m_wallpaperConfigModel;
|
||||
ConfigModel *m_containmentActionConfigModel;
|
||||
CurrentContainmentActionsModel *m_currentContainmentActionsModel;
|
||||
QString m_currentWallpaper;
|
||||
ConfigPropertyMap *m_currentWallpaperConfig;
|
||||
ConfigPropertyMap *m_ownWallpaperConfig;
|
||||
};
|
||||
|
||||
#endif // multiple inclusion guard
|
||||
|
Loading…
x
Reference in New Issue
Block a user