actually show the containment's qml
This commit is contained in:
parent
624817e9f3
commit
7912da6072
@ -203,6 +203,20 @@ uint Applet::id() const
|
|||||||
return d->appletId;
|
return d->appletId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject *Applet::graphicObject() const
|
||||||
|
{
|
||||||
|
return d->graphicObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Applet::setGraphicObject(QObject *obj)
|
||||||
|
{
|
||||||
|
if (d->graphicObject == obj) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
d->graphicObject = obj;
|
||||||
|
emit graphicObjectChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void Applet::save(KConfigGroup &g) const
|
void Applet::save(KConfigGroup &g) const
|
||||||
{
|
{
|
||||||
if (d->transient) {
|
if (d->transient) {
|
||||||
|
@ -94,6 +94,13 @@ class PLASMA_EXPORT Applet : public QObject
|
|||||||
*/
|
*/
|
||||||
uint id() const;
|
uint id() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since: 5.0
|
||||||
|
* A pointer to the graphical representation of this applet
|
||||||
|
*/
|
||||||
|
QObject *graphicObject() const;
|
||||||
|
void setGraphicObject(QObject *obj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the KConfigGroup to access the applets configuration.
|
* Returns the KConfigGroup to access the applets configuration.
|
||||||
*
|
*
|
||||||
@ -569,6 +576,11 @@ class PLASMA_EXPORT Applet : public QObject
|
|||||||
bool hasValidAssociatedApplication() const;
|
bool hasValidAssociatedApplication() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
/**
|
||||||
|
* emitted when/if the graphic representation of the applet changes
|
||||||
|
*/
|
||||||
|
void graphicObjectChanged();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This signal indicates that an application launch, window
|
* This signal indicates that an application launch, window
|
||||||
* creation or window focus event was triggered. This is used, for instance,
|
* creation or window focus event was triggered. This is used, for instance,
|
||||||
|
@ -71,6 +71,7 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int
|
|||||||
itemStatus(UnknownStatus),
|
itemStatus(UnknownStatus),
|
||||||
preferredSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored),
|
preferredSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored),
|
||||||
modificationsTimer(0),
|
modificationsTimer(0),
|
||||||
|
graphicObject(0),
|
||||||
hasConfigurationInterface(false),
|
hasConfigurationInterface(false),
|
||||||
failed(false),
|
failed(false),
|
||||||
isContainment(false),
|
isContainment(false),
|
||||||
|
@ -173,6 +173,9 @@ public:
|
|||||||
QBasicTimer constraintsTimer;
|
QBasicTimer constraintsTimer;
|
||||||
QBasicTimer *modificationsTimer;
|
QBasicTimer *modificationsTimer;
|
||||||
|
|
||||||
|
// Everything graphics related that remains in Applet
|
||||||
|
QObject *graphicObject;
|
||||||
|
|
||||||
// a great green field of booleans :)
|
// a great green field of booleans :)
|
||||||
bool hasConfigurationInterface : 1;
|
bool hasConfigurationInterface : 1;
|
||||||
bool failed : 1;
|
bool failed : 1;
|
||||||
|
@ -104,8 +104,6 @@ bool DeclarativeAppletScript::init()
|
|||||||
Plasma::Applet *a = applet();
|
Plasma::Applet *a = applet();
|
||||||
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(a);
|
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(a);
|
||||||
|
|
||||||
//TODO: assign the graphical root object
|
|
||||||
|
|
||||||
if (cont) {
|
if (cont) {
|
||||||
m_interface = new ContainmentInterface(this);
|
m_interface = new ContainmentInterface(this);
|
||||||
//fail? so it's a normal Applet
|
//fail? so it's a normal Applet
|
||||||
@ -125,6 +123,8 @@ void DeclarativeAppletScript::qmlCreationFinished()
|
|||||||
{
|
{
|
||||||
//If it's a popupapplet and the root object has a "compactRepresentation" component, use that instead of the icon
|
//If it's a popupapplet and the root object has a "compactRepresentation" component, use that instead of the icon
|
||||||
Plasma::Applet *a = applet();
|
Plasma::Applet *a = applet();
|
||||||
|
a->setGraphicObject(m_qmlObject->rootObject());
|
||||||
|
|
||||||
//TODO: access rootItem from m_interface
|
//TODO: access rootItem from m_interface
|
||||||
//m_self->setProperty("rootItem", QVariant::fromValue(m_qmlObject->rootObject()));
|
//m_self->setProperty("rootItem", QVariant::fromValue(m_qmlObject->rootObject()));
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@ DesktopCorona::DesktopCorona(QObject *parent)
|
|||||||
connect(m_desktopWidget, SIGNAL(workAreaResized(int)),
|
connect(m_desktopWidget, SIGNAL(workAreaResized(int)),
|
||||||
this, SLOT(workAreaResized(int)));
|
this, SLOT(workAreaResized(int)));
|
||||||
|
|
||||||
|
connect(this, SIGNAL(screenOwnerChanged(int, int, Plasma::Containment *)),
|
||||||
|
this, SLOT(updateScreenOwner(int, int, Plasma::Containment *)));
|
||||||
checkViews();
|
checkViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,8 +51,11 @@ DesktopCorona::~DesktopCorona()
|
|||||||
void DesktopCorona::loadDefaultLayout()
|
void DesktopCorona::loadDefaultLayout()
|
||||||
{
|
{
|
||||||
Plasma::Containment *cont = addContainment("org.kde.testcontainment");
|
Plasma::Containment *cont = addContainment("org.kde.testcontainment");
|
||||||
Plasma::Applet *appl = cont->addApplet("foo");
|
cont->setScreen(0);
|
||||||
qDebug() << "Containment:" << cont->name() << "Applet:" << appl->name() << appl;
|
qDebug() << containmentForScreen(0);
|
||||||
|
//Plasma::Applet *appl = cont->addApplet("foo");
|
||||||
|
qDebug() << "Containment:" << cont << cont->name();
|
||||||
|
//qDebug() << "Applet:" << appl->name() << appl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesktopCorona::checkScreens(bool signalWhenExists)
|
void DesktopCorona::checkScreens(bool signalWhenExists)
|
||||||
@ -79,7 +84,7 @@ void DesktopCorona::checkScreen(int screen, bool signalWhenExists)
|
|||||||
//TODO: restore activities
|
//TODO: restore activities
|
||||||
//Activity *currentActivity = activity(m_activityController->currentActivity());
|
//Activity *currentActivity = activity(m_activityController->currentActivity());
|
||||||
//ensure the desktop(s) have a containment and view
|
//ensure the desktop(s) have a containment and view
|
||||||
checkDesktop(/*currentActivity,*/ signalWhenExists, screen, 0);
|
checkDesktop(/*currentActivity,*/ signalWhenExists, screen, -1);
|
||||||
|
|
||||||
|
|
||||||
//ensure the panels get views too
|
//ensure the panels get views too
|
||||||
@ -184,5 +189,16 @@ void DesktopCorona::checkViews()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DesktopCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Containment *containment)
|
||||||
|
{
|
||||||
|
qDebug() << "Was screen" << wasScreen << "Is screen" << isScreen <<"Containment" << containment;
|
||||||
|
if (isScreen < 0 || m_views.count() < isScreen + 1) {
|
||||||
|
qWarning() << "Invalid screen";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_views[isScreen]->setContainment(containment);
|
||||||
|
}
|
||||||
|
|
||||||
#include "desktopcorona.moc"
|
#include "desktopcorona.moc"
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ protected Q_SLOTS:
|
|||||||
void workAreaResized(int screen);
|
void workAreaResized(int screen);
|
||||||
|
|
||||||
void checkViews();
|
void checkViews();
|
||||||
|
void updateScreenOwner(int wasScreen, int isScreen, Plasma::Containment *containment);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDesktopWidget *m_desktopWidget;
|
QDesktopWidget *m_desktopWidget;
|
||||||
|
@ -21,79 +21,20 @@ import QtQuick 2.0
|
|||||||
|
|
||||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||||
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
color: "darkblue"
|
color: "red"
|
||||||
width: 640
|
width: 640
|
||||||
height: 480
|
height: 480
|
||||||
|
|
||||||
PlasmaCore.Svg {
|
property Item containment
|
||||||
id: actionssvg
|
|
||||||
imagePath: "widgets/configuration-icons"
|
onContainmentChanged: {
|
||||||
|
print("New Containment: " + containment + containment.parent)
|
||||||
|
//containment.parent = root
|
||||||
|
containment.visible = true
|
||||||
|
containment.anchors.fill = root
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaCore.FrameSvgItem {
|
Component.onCompleted: print("View QML loaded")
|
||||||
id: frame
|
}
|
||||||
x: 50
|
|
||||||
y: 50
|
|
||||||
width: txt.paintedWidth + 80
|
|
||||||
height: txt.paintedHeight + 80 * 2
|
|
||||||
property int small: 100
|
|
||||||
property int large: parent.width - width - 150
|
|
||||||
imagePath: "widgets/background"
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
drag.target: parent
|
|
||||||
onClicked: {
|
|
||||||
var s = (frame.x == frame.large) ? frame.small : frame.large;
|
|
||||||
frame.x = s
|
|
||||||
frame.height = s
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Behavior on x { PropertyAnimation { easing.type: Easing.OutElastic; duration: 800 } }
|
|
||||||
//Behavior on y { PropertyAnimation { easing.type: Easing.OutElastic; duration: 800 } }
|
|
||||||
Behavior on height { PropertyAnimation { easing.type: Easing.InOutDouble; duration: 300 } }
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: txt
|
|
||||||
text: "Click or Drag";
|
|
||||||
anchors.centerIn: parent
|
|
||||||
}
|
|
||||||
PlasmaCore.SvgItem {
|
|
||||||
svg: actionssvg
|
|
||||||
elementId: "rotate"
|
|
||||||
width: 16
|
|
||||||
height: width
|
|
||||||
anchors.margins: frame.margins.left
|
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
left: parent.left
|
|
||||||
}
|
|
||||||
//Rectangle { color: "white"; opacity: 0.2; anchors.fill: parent; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// PlasmaCore.SvgItem {
|
|
||||||
// svg: actionssvg
|
|
||||||
// elementId: "rotate"
|
|
||||||
// width: 128
|
|
||||||
// height: width
|
|
||||||
// }
|
|
||||||
PlasmaCore.IconItem {
|
|
||||||
source: "accessories-dictionary"
|
|
||||||
x: 50
|
|
||||||
y: 350
|
|
||||||
width: 48
|
|
||||||
height: 48
|
|
||||||
Rectangle { color: "white"; opacity: 0.2; anchors.fill: parent; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Svg {
|
|
||||||
// x: 200
|
|
||||||
// y: 200
|
|
||||||
// width: 100
|
|
||||||
// height: 100
|
|
||||||
// MouseArea {
|
|
||||||
// anchors.fill: parent
|
|
||||||
// drag.target: parent
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
@ -17,14 +17,76 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
//import org.kde.plasma 2.0
|
|
||||||
|
|
||||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
color: "red"
|
id: root
|
||||||
|
color: "darkblue"
|
||||||
width: 640
|
width: 640
|
||||||
height: 480
|
height: 480
|
||||||
|
|
||||||
|
property Item containment
|
||||||
|
|
||||||
|
PlasmaCore.Svg {
|
||||||
|
id: actionssvg
|
||||||
|
imagePath: "widgets/configuration-icons"
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaCore.FrameSvgItem {
|
||||||
|
id: frame
|
||||||
|
x: 50
|
||||||
|
y: 50
|
||||||
|
width: txt.paintedWidth + 80
|
||||||
|
height: txt.paintedHeight + 80 * 2
|
||||||
|
property int small: 100
|
||||||
|
property int large: parent.width - width - 150
|
||||||
|
imagePath: "widgets/background"
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
drag.target: parent
|
||||||
|
onClicked: {
|
||||||
|
var s = (frame.x == frame.large) ? frame.small : frame.large;
|
||||||
|
frame.x = s
|
||||||
|
frame.height = s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on x { PropertyAnimation { easing.type: Easing.OutElastic; duration: 800 } }
|
||||||
|
//Behavior on y { PropertyAnimation { easing.type: Easing.OutElastic; duration: 800 } }
|
||||||
|
Behavior on height { PropertyAnimation { easing.type: Easing.InOutDouble; duration: 300 } }
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: txt
|
||||||
|
text: "Click or Drag";
|
||||||
|
anchors.centerIn: parent
|
||||||
|
}
|
||||||
|
PlasmaCore.SvgItem {
|
||||||
|
svg: actionssvg
|
||||||
|
elementId: "rotate"
|
||||||
|
width: 16
|
||||||
|
height: width
|
||||||
|
anchors.margins: frame.margins.left
|
||||||
|
anchors {
|
||||||
|
top: parent.top
|
||||||
|
left: parent.left
|
||||||
|
}
|
||||||
|
//Rectangle { color: "white"; opacity: 0.2; anchors.fill: parent; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// PlasmaCore.SvgItem {
|
||||||
|
// svg: actionssvg
|
||||||
|
// elementId: "rotate"
|
||||||
|
// width: 128
|
||||||
|
// height: width
|
||||||
|
// }
|
||||||
|
PlasmaCore.IconItem {
|
||||||
|
source: "accessories-dictionary"
|
||||||
|
x: 50
|
||||||
|
y: 350
|
||||||
|
width: 48
|
||||||
|
height: 48
|
||||||
|
Rectangle { color: "white"; opacity: 0.2; anchors.fill: parent; }
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: print("Test Containment loaded")
|
Component.onCompleted: print("Test Containment loaded")
|
||||||
}
|
}
|
@ -19,7 +19,8 @@
|
|||||||
#include "view.h"
|
#include "view.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QQuickItem>
|
||||||
|
#include <QTimer>
|
||||||
#include "plasma/pluginloader.h"
|
#include "plasma/pluginloader.h"
|
||||||
|
|
||||||
View::View(QWindow *parent)
|
View::View(QWindow *parent)
|
||||||
@ -44,4 +45,41 @@ View::~View()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void View::setContainment(Plasma::Containment *cont)
|
||||||
|
{
|
||||||
|
if (m_containment) {
|
||||||
|
disconnect(m_containment.data(), 0, this, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_containment = cont;
|
||||||
|
|
||||||
|
if (!cont) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(cont, SIGNAL(graphicObjectChanged()), this, SLOT(syncGraphicObject()));
|
||||||
|
|
||||||
|
if (m_containment.data()->graphicObject()) {
|
||||||
|
syncGraphicObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Plasma::Containment *View::containment() const
|
||||||
|
{
|
||||||
|
return m_containment.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::syncGraphicObject()
|
||||||
|
{
|
||||||
|
qDebug() << "using as graphic containment" << m_containment.data()->graphicObject()<<m_containment.data();
|
||||||
|
if (!m_containment || !m_containment.data()->graphicObject()) {
|
||||||
|
qWarning() << "Containment not valid (yet?)";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_containment.data()->graphicObject()->setProperty("visible", false);
|
||||||
|
m_containment.data()->graphicObject()->setProperty("parent", QVariant::fromValue(rootObject()));
|
||||||
|
rootObject()->setProperty("containment", QVariant::fromValue(m_containment.data()->graphicObject()));
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_view.cpp"
|
#include "moc_view.cpp"
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "plasma/package.h"
|
#include "plasma/package.h"
|
||||||
|
#include "plasma/containment.h"
|
||||||
|
|
||||||
|
|
||||||
class View : public QQuickView
|
class View : public QQuickView
|
||||||
@ -33,8 +34,15 @@ public:
|
|||||||
View(QWindow *parent = 0);
|
View(QWindow *parent = 0);
|
||||||
virtual ~View();
|
virtual ~View();
|
||||||
|
|
||||||
|
void setContainment(Plasma::Containment *cont);
|
||||||
|
Plasma::Containment *containment() const;
|
||||||
|
|
||||||
|
protected Q_SLOTS:
|
||||||
|
void syncGraphicObject();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Plasma::Package m_package;
|
Plasma::Package m_package;
|
||||||
|
QWeakPointer<Plasma::Containment> m_containment;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VIEW_H
|
#endif // VIEW_H
|
||||||
|
Loading…
Reference in New Issue
Block a user