Merge branch 'plasmaview2' into plasmaview3

Conflicts:
	src/plasmaview/shellpackage_p.cpp
	src/plasmaview/shellpackage_p.h
	src/plasmaview/view.cpp
	src/plasmaview/view.h
	src/shell/CMakeLists.txt
	src/shell/desktopcorona.cpp
	src/shell/shellcorona.cpp
	src/shell/shellpluginloader.cpp
This commit is contained in:
Marco Martin 2013-09-10 20:59:47 +02:00
commit eccf797920
20 changed files with 657 additions and 301 deletions

View File

@ -4,4 +4,5 @@ add_subdirectory(declarativeimports)
add_subdirectory(plasmapkg)
add_subdirectory(platformstatus)
add_subdirectory(scriptengines)
add_subdirectory(plasmaview)
add_subdirectory(shell)

View File

@ -0,0 +1,68 @@
project(PlasmaView)
set(plasmaview_LIB_SRC
view.cpp
configview.cpp
containmentconfigview_p.cpp
currentcontainmentactionsmodel_p.cpp
shellpluginloader.cpp
shellpackage_p.cpp
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
add_library(PlasmaView SHARED ${plasmaview_LIB_SRC})
target_link_libraries(PlasmaView
${Qt5Quick_LIBRARIES}
${Qt5Qml_LIBRARIES}
${KWindowSystem_LIBRARIES}
${KI18n_LIBRARIES}
${KService_LIBRARIES}
${KCoreAddons_LIBRARIES}
${XmlGui_LIBRARIES}
plasma
kdeclarative
)
set_target_properties(PlasmaView PROPERTIES
VERSION 5.0.0
SOVERSION 5
)
install(TARGETS PlasmaView EXPORT PlasmaViewTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
generate_export_header(PlasmaView)
set(plasmaview_LIB_INCLUDES
${CMAKE_CURRENT_BINARY_DIR}/plasmaview_export.h
view.h
configview.h
)
install(FILES ${plasmaview_LIB_INCLUDES}
DESTINATION ${INCLUDE_INSTALL_DIR}/plasmaview COMPONENT Devel)
install(DIRECTORY
includes/PlasmaView
DESTINATION ${INCLUDE_INSTALL_DIR}/KDE/ COMPONENT Devel)
set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/PlasmaView")
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/PlasmaViewConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/PlasmaViewConfig.cmake"
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
PATH_VARS INCLUDE_INSTALL_DIR CMAKE_INSTALL_PREFIX
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/PlasmaViewConfig.cmake"
DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel
)
install(EXPORT PlasmaViewTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE PlasmaViewTargets.cmake NAMESPACE KF5:: )

View File

@ -0,0 +1,11 @@
@PACKAGE_INIT@
# Any changes in this ".cmake" file will be overwritten by CMake, the source is the ".cmake.in" file.
include("${CMAKE_CURRENT_LIST_DIR}/PlasmaViewTargets.cmake")
set(PlasmaView_INSTALL_PREFIX "@PACKAGE_CMAKE_INSTALL_PREFIX@")
set_and_check(PlasmaView_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
set(PlasmaView_LIBRARIES KF5::PlasmaView)

View File

@ -17,6 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "configview_p.h"
#include "configview.h"
#include "Plasma/Applet"
#include "Plasma/Containment"
@ -112,118 +113,47 @@ void ConfigCategory::setPluginName(const QString &name)
//////////////////////////////ConfigModel
ConfigModel::ConfigModel(QObject *parent)
: QAbstractListModel(parent)
{
QHash<int, QByteArray> roleNames;
roleNames[NameRole] = "name";
roleNames[IconRole] = "icon";
roleNames[SourceRole] = "source";
roleNames[PluginNameRole] = "pluginName";
setRoleNames(roleNames);
class ConfigModelPrivate
{
public:
ConfigModelPrivate(ConfigModel *model);
~ConfigModelPrivate();
ConfigModel *q;
QList<ConfigCategory*> categories;
QWeakPointer<Plasma::Applet> appletInterface;
void appendCategory(ConfigCategory *c);
void clear();
QVariant get(int row) const;
static ConfigCategory *categories_at(QQmlListProperty<ConfigCategory> *prop, int index);
static void categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o);
static int categories_count(QQmlListProperty<ConfigCategory> *prop);
static void categories_clear(QQmlListProperty<ConfigCategory> *prop);
};
ConfigModelPrivate::ConfigModelPrivate(ConfigModel *model)
: q(model)
{
}
ConfigModel::~ConfigModel()
{}
int ConfigModel::rowCount(const QModelIndex &index) const
ConfigModelPrivate::~ConfigModelPrivate()
{
if (index.column() > 0) {
return 0;
}
return m_categories.count();
}
QVariant ConfigModel::data(const QModelIndex& index, int role) const
{
if (index.row() < 0 || index.row() >= m_categories.count()) {
return QVariant();
}
switch (role) {
case NameRole:
return m_categories.at(index.row())->name();
case IconRole:
return m_categories.at(index.row())->icon();
case SourceRole:
if (m_appletInterface) {
return QUrl::fromLocalFile(m_appletInterface.data()->package().filePath("ui", m_categories.at(index.row())->source()));
} else {
return m_categories.at(index.row())->source();
}
case PluginNameRole:
return m_categories.at(index.row())->pluginName();
default:
return QVariant();
}
}
QVariant ConfigModel::get(int row) const
{
QVariantMap value;
if (row < 0 || row >= m_categories.count()) {
return value;
}
value["name"] = m_categories.at(row)->name();
value["icon"] = m_categories.at(row)->icon();
value["pluginName"] = m_categories.at(row)->pluginName();
if (m_appletInterface) {
value["source"] = QUrl::fromLocalFile(m_appletInterface.data()->package().filePath("ui", m_categories.at(row)->source()));
} else {
value["source"] = m_categories.at(row)->source();
}
return value;
}
void ConfigModel::appendCategory(ConfigCategory *c)
{
beginInsertRows(QModelIndex(), m_categories.size(), m_categories.size());
m_categories.append(c);
endInsertRows();
emit countChanged();
}
void ConfigModel::clear()
{
beginResetModel();
while (!m_categories.isEmpty()) {
m_categories.first()->setParent(0);
m_categories.pop_front();
}
endResetModel();
emit countChanged();
}
void ConfigModel::setApplet(Plasma::Applet *interface)
{
m_appletInterface = interface;
}
Plasma::Applet *ConfigModel::applet() const
{
return m_appletInterface.data();
}
QQmlListProperty<ConfigCategory> ConfigModel::categories()
{
return QQmlListProperty<ConfigCategory>(this, 0, ConfigModel::categories_append,
ConfigModel::categories_count,
ConfigModel::categories_at,
ConfigModel::categories_clear);
}
ConfigCategory *ConfigModel::categories_at(QQmlListProperty<ConfigCategory> *prop, int index)
ConfigCategory *ConfigModelPrivate::categories_at(QQmlListProperty<ConfigCategory> *prop, int index)
{
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
if (!model || index >= model->m_categories.count() || index < 0)
if (!model || index >= model->d->categories.count() || index < 0) {
return 0;
else
return model->m_categories.at(index);
} else {
return model->d->categories.at(index);
}
}
void ConfigModel::categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o)
void ConfigModelPrivate::categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o)
{
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
if (!o || !model) {
@ -238,17 +168,17 @@ void ConfigModel::categories_append(QQmlListProperty<ConfigCategory> *prop, Conf
model->appendCategory(o);
}
int ConfigModel::categories_count(QQmlListProperty<ConfigCategory> *prop)
int ConfigModelPrivate::categories_count(QQmlListProperty<ConfigCategory> *prop)
{
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
if (model) {
return model->m_categories.count();
return model->d->categories.count();
} else {
return 0;
}
}
void ConfigModel::categories_clear(QQmlListProperty<ConfigCategory> *prop)
void ConfigModelPrivate::categories_clear(QQmlListProperty<ConfigCategory> *prop)
{
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
if (!model) {
@ -258,66 +188,233 @@ void ConfigModel::categories_clear(QQmlListProperty<ConfigCategory> *prop)
model->clear();
}
void ConfigModelPrivate::clear()
{
q->beginResetModel();
while (!categories.isEmpty()) {
categories.first()->setParent(0);
categories.pop_front();
}
q->endResetModel();
emit q->countChanged();
}
void ConfigModelPrivate::appendCategory(ConfigCategory *c)
{
q->beginInsertRows(QModelIndex(), categories.size(), categories.size());
categories.append(c);
q->endInsertRows();
emit q->countChanged();
}
QVariant ConfigModelPrivate::get(int row) const
{
QVariantMap value;
if (row < 0 || row >= categories.count()) {
return value;
}
value["name"] = categories.at(row)->name();
value["icon"] = categories.at(row)->icon();
value["pluginName"] = categories.at(row)->pluginName();
if (appletInterface) {
value["source"] = QUrl::fromLocalFile(appletInterface.data()->package().filePath("ui", categories.at(row)->source()));
} else {
value["source"] = categories.at(row)->source();
}
return value;
}
ConfigModel::ConfigModel(QObject *parent)
: QAbstractListModel(parent),
d(new ConfigModelPrivate(this))
{
QHash<int, QByteArray> roleNames;
roleNames[NameRole] = "name";
roleNames[IconRole] = "icon";
roleNames[SourceRole] = "source";
roleNames[PluginNameRole] = "pluginName";
setRoleNames(roleNames);
}
ConfigModel::~ConfigModel()
{
delete d;
}
int ConfigModel::rowCount(const QModelIndex &index) const
{
if (index.column() > 0) {
return 0;
}
return d->categories.count();
}
QVariant ConfigModel::data(const QModelIndex& index, int role) const
{
if (index.row() < 0 || index.row() >= d->categories.count()) {
return QVariant();
}
switch (role) {
case NameRole:
return d->categories.at(index.row())->name();
case IconRole:
return d->categories.at(index.row())->icon();
case SourceRole:
if (d->appletInterface) {
return QUrl::fromLocalFile(d->appletInterface.data()->package().filePath("ui", d->categories.at(index.row())->source()));
} else {
return d->categories.at(index.row())->source();
}
case PluginNameRole:
return d->categories.at(index.row())->pluginName();
default:
return QVariant();
}
}
QVariant ConfigModel::get(int row) const
{
return d->get(row);
}
void ConfigModel::appendCategory(ConfigCategory *c)
{
d->appendCategory(c);
}
void ConfigModel::clear()
{
d->clear();
}
void ConfigModel::setApplet(Plasma::Applet *interface)
{
d->appletInterface = interface;
}
Plasma::Applet *ConfigModel::applet() const
{
return d->appletInterface.data();
}
QQmlListProperty<ConfigCategory> ConfigModel::categories()
{
return QQmlListProperty<ConfigCategory>(this, 0, ConfigModel::categories_append,
ConfigModel::categories_count,
ConfigModel::categories_at,
ConfigModel::categories_clear);
}
ConfigCategory *ConfigModel::categories_at(QQmlListProperty<ConfigCategory> *prop, int index)
{
return ConfigModelPrivate::categories_at(prop, index);
}
void ConfigModel::categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o)
{
ConfigModelPrivate::categories_append(prop, o);
}
int ConfigModel::categories_count(QQmlListProperty<ConfigCategory> *prop)
{
return ConfigModelPrivate::categories_count(prop);
}
void ConfigModel::categories_clear(QQmlListProperty<ConfigCategory> *prop)
{
ConfigModelPrivate::categories_clear(prop);
}
//////////////////////////////ConfigView
ConfigView::ConfigView(Plasma::Applet *applet, QWindow *parent)
: QQuickView(parent),
m_applet(applet)
class ConfigViewPrivate
{
public:
ConfigViewPrivate(Plasma::Applet *appl, ConfigView *view);
~ConfigViewPrivate();
void init();
ConfigView *q;
Plasma::Applet *applet;
ConfigModel *configModel;
};
ConfigViewPrivate::ConfigViewPrivate(Plasma::Applet *appl, ConfigView *view)
: q(view),
applet(appl)
{
}
void ConfigViewPrivate::init()
{
applet->setUserConfiguring(true);
KDeclarative kdeclarative;
kdeclarative.setDeclarativeEngine(engine());
kdeclarative.setDeclarativeEngine(q->engine());
kdeclarative.setupBindings();
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_applet->title()));
q->setColor(Qt::transparent);
q->setTitle(i18n("%1 Settings", applet->title()));
if (!m_applet->containment()->corona()->package().isValid()) {
if (!applet->containment()->corona()->package().isValid()) {
qWarning() << "Invalid home screen package";
}
setResizeMode(QQuickView::SizeViewToRootObject);
q->setResizeMode(QQuickView::SizeViewToRootObject);
//config model local of the applet
QQmlComponent *component = new QQmlComponent(engine(), QUrl::fromLocalFile(m_applet->package().filePath("configmodel")), this);
QObject *object = component->beginCreate(engine()->rootContext());
m_configModel = qobject_cast<ConfigModel *>(object);
if (m_configModel) {
m_configModel->setApplet(m_applet);
QQmlComponent *component = new QQmlComponent(q->engine(), QUrl::fromLocalFile(applet->package().filePath("configmodel")), q);
QObject *object = component->beginCreate(q->engine()->rootContext());
configModel = qobject_cast<ConfigModel *>(object);
if (configModel) {
configModel->setApplet(applet);
} else {
delete object;
}
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(m_applet);
engine()->rootContext()->setContextProperty("plasmoid", applet->property("graphicObject").value<QObject*>());
engine()->rootContext()->setContextProperty("configDialog", this);
q->engine()->rootContext()->setContextProperty("plasmoid", applet->property("graphicObject").value<QObject*>());
q->engine()->rootContext()->setContextProperty("configDialog", q);
component->completeCreate();
delete component;
}
ConfigView::ConfigView(Plasma::Applet *applet, QWindow *parent)
: QQuickView(parent),
d(new ConfigViewPrivate(applet, this))
{
d->init();
qmlRegisterType<ConfigModel>("org.kde.plasma.configuration", 2, 0, "ConfigModel");
qmlRegisterType<ConfigCategory>("org.kde.plasma.configuration", 2, 0, "ConfigCategory");
}
ConfigView::~ConfigView()
{
m_applet->setUserConfiguring(false);
d->applet->setUserConfiguring(false);
}
void ConfigView::init()
{
setSource(QUrl::fromLocalFile(m_applet->containment()->corona()->package().filePath("appletconfigurationui")));
setSource(QUrl::fromLocalFile(d->applet->containment()->corona()->package().filePath("appletconfigurationui")));
}
ConfigModel *ConfigView::configModel() const
{
return m_configModel;
return d->configModel;
}
//To emulate Qt::WA_DeleteOnClose that QWindow doesn't have
void ConfigView::hideEvent(QHideEvent *ev)
{

View File

@ -26,51 +26,20 @@
#include <QQmlListProperty>
#include <QStandardItemModel>
#include <plasmaview/plasmaview_export.h>
namespace Plasma {
class Applet;
}
class ConfigPropertyMap;
class ConfigCategoryPrivate;
class ConfigCategory : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged)
Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(QString pluginName READ pluginName WRITE setPluginName NOTIFY pluginNameChanged)
class ConfigModelPrivate;
class ConfigCategory;
public:
ConfigCategory(QObject *parent = 0);
~ConfigCategory();
QString name() const;
void setName(const QString &name);
QString icon() const;
void setIcon(const QString &icon);
QString source() const;
void setSource(const QString &source);
QString pluginName() const;
void setPluginName(const QString &pluginName);
Q_SIGNALS:
void nameChanged();
void iconChanged();
void sourceChanged();
void pluginNameChanged();
private:
QString m_name;
QString m_icon;
QString m_source;
QString m_pluginName;
};
class ConfigModel : public QAbstractListModel
class PLASMAVIEW_EXPORT ConfigModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(QQmlListProperty<ConfigCategory> categories READ categories CONSTANT)
@ -87,7 +56,15 @@ public:
ConfigModel(QObject *parent = 0);
~ConfigModel();
/**
* add a new category in the model
* @param ConfigCategory the new category
**/
void appendCategory(ConfigCategory *c);
/**
* clears the model
**/
void clear();
void setApplet(Plasma::Applet *interface);
@ -96,35 +73,57 @@ public:
int count() {return rowCount();}
virtual int rowCount(const QModelIndex &index = QModelIndex()) const;
virtual QVariant data(const QModelIndex&, int) const;
/**
* @param row the row for which the data will be returned
* @raturn the data of the specified row
**/
Q_INVOKABLE QVariant get(int row) const;
/**
* @return the categories of the model
**/
QQmlListProperty<ConfigCategory> categories();
static ConfigCategory *categories_at(QQmlListProperty<ConfigCategory> *prop, int index);
static void categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o);
static int categories_count(QQmlListProperty<ConfigCategory> *prop);
static void categories_clear(QQmlListProperty<ConfigCategory> *prop);
Q_SIGNALS:
/**
* emitted when the count is changed
**/
void countChanged();
private:
QList<ConfigCategory*>m_categories;
QWeakPointer<Plasma::Applet> m_appletInterface;
friend class ConfigModelPrivate;
ConfigModelPrivate *const d;
};
class ConfigView : public QQuickView
class ConfigViewPrivate;
//TODO: the config view for the containment should be a subclass
//TODO: is it possible to move this in the shell?
class PLASMAVIEW_EXPORT ConfigView : public QQuickView
{
Q_OBJECT
Q_PROPERTY(ConfigModel *configModel READ configModel CONSTANT)
public:
/**
* @param applet the applet of this ConfigView
* @param parent the QWindow in which this ConfigView is parented to
**/
ConfigView(Plasma::Applet *applet, QWindow *parent = 0);
virtual ~ConfigView();
virtual void init();
/**
* @return the ConfigModel of the ConfigView
**/
ConfigModel *configModel() const;
protected:
@ -132,8 +131,7 @@ protected:
void resizeEvent(QResizeEvent *re);
private:
Plasma::Applet *m_applet;
ConfigModel *m_configModel;
ConfigViewPrivate *const d;
};
#endif // multiple inclusion guard

View File

@ -0,0 +1,62 @@
/*
* 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.
*/
#ifndef CONFIGUILOADER_P_H
#define CONFIGUILOADER_P_H
#include <QObject>
class ConfigCategory : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged)
Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(QString pluginName READ pluginName WRITE setPluginName NOTIFY pluginNameChanged)
public:
ConfigCategory(QObject *parent = 0);
~ConfigCategory();
QString name() const;
void setName(const QString &name);
QString icon() const;
void setIcon(const QString &icon);
QString source() const;
void setSource(const QString &source);
QString pluginName() const;
void setPluginName(const QString &pluginName);
Q_SIGNALS:
void nameChanged();
void iconChanged();
void sourceChanged();
void pluginNameChanged();
private:
QString m_name;
QString m_icon;
QString m_source;
QString m_pluginName;
};
#endif // multiple inclusion guard

View File

@ -17,9 +17,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "containmentconfigview.h"
#include <Plasma/Containment>
#include "currentcontainmentactionsmodel.h"
#include "currentcontainmentactionsmodel_p.h"
#include "containmentconfigview_p.h"
#include "configview_p.h"
#include <kdeclarative/configpropertymap.h>
#include <QDebug>
@ -34,10 +35,6 @@
#include <Plasma/ContainmentActions>
#include <Plasma/PluginLoader>
//////////////////////////////ContainmentConfigView
ContainmentConfigView::ContainmentConfigView(Plasma::Containment *cont, QWindow *parent)
: ConfigView(cont, parent),
@ -194,4 +191,4 @@ void ContainmentConfigView::syncWallpaperObjects()
m_currentWallpaperConfig = static_cast<ConfigPropertyMap *>(wallpaperGraphicsObject->property("configuration").value<QObject *>());
}
#include "moc_containmentconfigview.cpp"
#include "moc_containmentconfigview_p.cpp"

View File

@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "currentcontainmentactionsmodel.h"
#include "currentcontainmentactionsmodel_p.h"
#include <QMouseEvent>
@ -259,4 +259,4 @@ void CurrentContainmentActionsModel::save()
}
}
#include "moc_currentcontainmentactionsmodel.cpp"
#include "moc_currentcontainmentactionsmodel_p.cpp"

View File

@ -0,0 +1,2 @@
#include "../../plasmaview/configview.h"

View File

@ -0,0 +1,2 @@
#include "../../plasmaview/containmentconfigview.h"

View File

@ -0,0 +1 @@
#include "../../plasmaview/shellpluginloader.h"

View File

@ -0,0 +1,2 @@
#include "../../plasmaview/view.h"

View File

@ -17,24 +17,50 @@
*/
#include "view.h"
#include "containmentconfigview.h"
#include "panelconfigview.h"
#include "panelview.h"
#include "containmentconfigview_p.h"
#include "configview.h"
#include <QDebug>
#include <QQuickItem>
#include <QQmlContext>
#include <QTimer>
#include <QScreen>
#include "plasma/pluginloader.h"
View::View(Plasma::Corona *corona, QWindow *parent)
: QQuickView(parent),
m_corona(corona)
class ViewPrivate
{
//FIXME: for some reason all windows must have alpha enable otherwise the ones that do won't paint.
public:
ViewPrivate(Plasma::Corona *corona, View *view);
~ViewPrivate();
void init();
void setContainment(Plasma::Containment *cont);
Plasma::Types::FormFactor formFactor() const;
int location() const;
void showConfigurationInterface(Plasma::Applet *applet);
View *q;
friend class View;
Plasma::Corona *corona;
QWeakPointer<Plasma::Containment> containment;
QWeakPointer<ConfigView> configView;
};
ViewPrivate::ViewPrivate(Plasma::Corona *cor, View *view)
: q(view),
corona(cor)
{
}
ViewPrivate::~ViewPrivate()
{
}
void ViewPrivate::init()
{
//FIXME: for some reason all windows must have alpha enable otherwise the ones that do won't paint.
//Probably is an architectural problem
QSurfaceFormat format;
format.setAlphaBufferSize(8);
@ -42,28 +68,141 @@ View::View(Plasma::Corona *corona, QWindow *parent)
setFormat(format);
setColor(Qt::transparent);
connect(screen(), &QScreen::virtualGeometryChanged,
this, &View::screenGeometryChanged);
if (!m_corona->package().isValid()) {
QObject::connect(q->screen(), &QScreen::virtualGeometryChanged,
q, &View::screenGeometryChanged);
if (!corona->package().isValid()) {
qWarning() << "Invalid home screen package";
}
setResizeMode(View::SizeRootObjectToView);
setSource(QUrl::fromLocalFile(m_corona->package().filePath("views", "Desktop.qml")));
q->setResizeMode(View::SizeRootObjectToView);
q->setSource(QUrl::fromLocalFile(corona->package().filePath("views", "Desktop.qml")));
connect(m_corona, &Plasma::Corona::packageChanged,
this, &View::coronaPackageChanged);
q, &View::coronaPackageChanged);
}
void ViewPrivate::setContainment(Plasma::Containment *cont)
{
if (containment.data() == cont) {
return;
}
Plasma::Types::Location oldLoc = (Plasma::Types::Location)location();
Plasma::Types::FormFactor oldForm = formFactor();
if (containment) {
QObject::disconnect(containment.data(), 0, q, 0);
QObject *oldGraphicObject = containment.data()->property("graphicObject").value<QObject *>();
if (oldGraphicObject) {
//make sure the graphic object won't die with us
oldGraphicObject->setParent(cont);
}
}
containment = cont;
if (oldLoc != location()) {
emit q->locationChanged((Plasma::Types::Location)location());
}
if (oldForm != formFactor()) {
emit q->formFactorChanged(formFactor());
}
emit q->containmentChanged();
if (cont) {
connect(cont, &Plasma::Containment::locationChanged,
this, &View::locationChanged);
connect(cont, &Plasma::Containment::formFactorChanged,
this, &View::formFactorChanged);
connect(cont, &Plasma::Containment::configureRequested,
this, &View::showConfigurationInterface);
} else {
return;
}
QObject::connect(cont, &Plasma::Containment::locationChanged,
q, &View::locationChanged);
QObject::connect(cont, &Plasma::Containment::formFactorChanged,
q, &View::formFactorChanged);
QObject::connect(cont, &Plasma::Containment::configureRequested,
q, &View::showConfigurationInterface);
QObject *graphicObject = containment.data()->property("graphicObject").value<QObject *>();
if (graphicObject) {
qDebug() << "using as graphic containment" << graphicObject << containment.data();
//graphicObject->setProperty("visible", false);
graphicObject->setProperty("drawWallpaper",
(cont->containmentType() == Plasma::Types::DesktopContainment ||
cont->containmentType() == Plasma::Types::CustomContainment));
graphicObject->setProperty("parent", QVariant::fromValue(q->rootObject()));
q->rootObject()->setProperty("containment", QVariant::fromValue(graphicObject));
} else {
qWarning() << "Containment graphic object not valid";
}
}
int ViewPrivate::location() const
{
if (!containment) {
return Plasma::Types::Desktop;
}
return containment.data()->location();
}
Plasma::Types::FormFactor ViewPrivate::formFactor() const
{
if (!containment) {
return Plasma::Types::Planar;
}
return containment.data()->formFactor();
}
void ViewPrivate::showConfigurationInterface(Plasma::Applet *applet)
{
if (configView) {
configView.data()->hide();
configView.data()->deleteLater();
}
if (!applet || !applet->containment()) {
return;
}
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(applet);
if (cont) {
configView = new ContainmentConfigView(cont);
} else {
configView = new ConfigView(applet);
}
configView.data()->init();
configView.data()->show();
}
View::View(Plasma::Corona *corona, QWindow *parent)
: QQuickView(parent),
d(new ViewPrivate(corona, this))
{
d->init();
}
View::~View()
{
delete d;
}
Plasma::Corona *View::corona() const
{
return m_corona;
return d->corona;
}
KConfigGroup View::config() const
@ -77,84 +216,27 @@ KConfigGroup View::config() const
void View::setContainment(Plasma::Containment *cont)
{
if (m_containment.data() == cont) {
return;
}
Plasma::Types::Location oldLoc = (Plasma::Types::Location)location();
Plasma::Types::FormFactor oldForm = formFactor();
if (m_containment) {
disconnect(m_containment.data(), 0, this, 0);
QObject *oldGraphicObject = m_containment.data()->property("graphicObject").value<QObject *>();
if (oldGraphicObject) {
//make sure the graphic object won't die with us
oldGraphicObject->setParent(cont);
}
}
m_containment = cont;
if (oldLoc != location()) {
emit locationChanged((Plasma::Types::Location)location());
}
if (oldForm != formFactor()) {
emit formFactorChanged(formFactor());
}
emit containmentChanged();
if (cont) {
connect(cont, &Plasma::Containment::locationChanged,
this, &View::locationChanged);
connect(cont, &Plasma::Containment::formFactorChanged,
this, &View::formFactorChanged);
connect(cont, &Plasma::Containment::configureRequested,
this, &View::showConfigurationInterface);
} else {
return;
}
QObject *graphicObject = m_containment.data()->property("graphicObject").value<QObject *>();
if (graphicObject) {
qDebug() << "using as graphic containment" << graphicObject << m_containment.data();
//graphicObject->setProperty("visible", false);
graphicObject->setProperty("drawWallpaper",
(cont->containmentType() == Plasma::Types::DesktopContainment ||
cont->containmentType() == Plasma::Types::CustomContainment));
graphicObject->setProperty("parent", QVariant::fromValue(rootObject()));
rootObject()->setProperty("containment", QVariant::fromValue(graphicObject));
} else {
qWarning() << "Containment graphic object not valid";
}
d->setContainment(cont);
}
Plasma::Containment *View::containment() const
{
return m_containment.data();
return d->containment.data();
}
void View::setLocation(Plasma::Types::Location location)
{
m_containment.data()->setLocation(location);
d->containment.data()->setLocation(location);
}
Plasma::Types::Location View::location() const
{
if (!m_containment) {
return Plasma::Types::Desktop;
}
return m_containment.data()->location();
return d->location();
}
Plasma::Types::FormFactor View::formFactor() const
{
if (!m_containment) {
return Plasma::Types::Planar;
}
return m_containment.data()->formFactor();
return d->formFactor();
}
QRectF View::screenGeometry()
@ -164,28 +246,7 @@ QRectF View::screenGeometry()
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();
d->showConfigurationInterface(applet);
}
void View::coronaPackageChanged(const Plasma::Package &package)

View File

@ -21,52 +21,108 @@
#include <QtQuick/QQuickView>
#include <plasmaview/plasmaview_export.h>
#include "plasma/corona.h"
#include "plasma/containment.h"
#include "configview.h"
class ViewPrivate;
class View : public QQuickView
class PLASMAVIEW_EXPORT View : public QQuickView
{
Q_OBJECT
Q_PROPERTY(Plasma::Types::Location location READ location WRITE setLocation NOTIFY locationChanged)
Q_PROPERTY(QRectF screenGeometry READ screenGeometry NOTIFY screenGeometryChanged)
public:
/**
* @param corona the corona of this view
* @param parent the QWindow this View is parented to
**/
explicit View(Plasma::Corona *corona, QWindow *parent = 0);
virtual ~View();
/**
* @return the corona of this view
**/
Plasma::Corona *corona() const;
/**
* @return the KConfigGroup of this view
**/
virtual KConfigGroup config() const;
void setContainment(Plasma::Containment *cont);
/**
* sets the containment for this view
* @param cont the containment of this view
**/
virtual void setContainment(Plasma::Containment *cont);
/**
* @return the containment of this View
**/
Plasma::Containment *containment() const;
<<<<<<< HEAD:src/shell/view.h
Plasma::Types::Location location() const;
void setLocation(Plasma::Types::Location location);
=======
/**
* @return the location of this View
**/
//FIXME: Plasma::Types::Location should be something qml can understand
int location() const;
/**
* Sets the location of the View
* @param location the location of the View
**/
void setLocation(int location);
>>>>>>> plasmaview2:src/plasmaview/view.h
/**
* @return the formfactor of the View
**/
Plasma::Types::FormFactor formFactor() const;
/**
* @return the screenGeometry of the View
**/
QRectF screenGeometry();
protected Q_SLOTS:
void showConfigurationInterface(Plasma::Applet *applet);
/**
* It will be called when the configuration is requested
*/
virtual void showConfigurationInterface(Plasma::Applet *applet);
private Q_SLOTS:
void coronaPackageChanged(const Plasma::Package &package);
Q_SIGNALS:
/**
* emitted when the location is changed
**/
void locationChanged(Plasma::Types::Location location);
/**
* emitted when the formfactor is changed
**/
void formFactorChanged(Plasma::Types::FormFactor formFactor);
/**
* emitted when the containment is changed
**/
void containmentChanged();
/**
* emitted when the screenGeometry is changed
**/
void screenGeometryChanged();
private:
Plasma::Corona *m_corona;
QWeakPointer<Plasma::Containment> m_containment;
QWeakPointer<ConfigView> m_configView;
ViewPrivate *const d;
friend class ViewPrivate;
};
#endif // VIEW_H

View File

@ -57,18 +57,11 @@ set(widgetexplorer_SRC
add_executable(plasma-shell
main.cpp
configview.cpp
containmentconfigview.cpp
# desktopcorona.cpp
shellcorona.cpp
currentcontainmentactionsmodel.cpp
panelshadows.cpp
desktopcorona.cpp
panelview.cpp
shellpluginloader.cpp
shellmanager.cpp
packages.cpp
view.cpp
lookandfeelpackage.cpp
panelconfigview.cpp
shellpluginloader.cpp
${scripting_SRC}
${widgetexplorer_SRC}
)
@ -83,6 +76,7 @@ target_link_libraries(plasma-shell
${KWindowSystem_LIBRARIES}
${KCoreAddons_LIBRARIES}
plasma
PlasmaView
${Qt5Script_LIBRARIES}
${KDE4Support_LIBRARIES}
${Solid_LIBRARIES}

View File

@ -32,6 +32,7 @@
#include <Plasma/PluginLoader>
#include "containmentconfigview.h"
#include "panelview.h"
#include "view.h"
#include "scripting/desktopscriptengine.h"
@ -96,7 +97,6 @@ ShellCorona::ShellCorona(QObject *parent)
connect(d->scriptEngine, &WorkspaceScripting::ScriptEngine::print,
this, &ShellCorona::printScriptMessage);
//QTimer::singleShot(600, this, SLOT(showWidgetExplorer())); // just for easier debugging
}
ShellCorona::~ShellCorona()
@ -177,7 +177,9 @@ void ShellCorona::processUpdateScripts()
void ShellCorona::checkScreens(bool signalWhenExists)
{
checkViews();
// quick sanity check to ensure we have containments for each screen
int num = numScreens();
for (int i = 0; i < num; ++i) {
@ -297,6 +299,7 @@ void ShellCorona::checkViews()
if (d->shell.isEmpty()) {
return;
}
if (d->views.count() == d->desktopWidget->screenCount()) {
return;
} else if (d->views.count() < d->desktopWidget->screenCount()) {

View File

@ -18,8 +18,10 @@
*/
#include "shellpluginloader.h"
#include "packages.h"
#include <QDebug>
ShellPluginLoader::ShellPluginLoader()
@ -50,3 +52,4 @@ void ShellPluginLoader::init()
{
Plasma::PluginLoader::setPluginLoader(new ShellPluginLoader);
}

View File

@ -22,8 +22,7 @@
#include <Plasma/PluginLoader>
class ShellPluginLoader: public Plasma::PluginLoader
class ShellPluginLoader : public Plasma::PluginLoader
{
public:
ShellPluginLoader();
@ -33,7 +32,6 @@ public:
protected:
Plasma::Package internalLoadPackage(const QString &packageFormat, const QString &specialization);
};
#endif