use a different qml file for the panel view

This commit is contained in:
Marco Martin 2013-02-14 21:14:04 +01:00
parent 7f368317ca
commit 9089947ace
6 changed files with 80 additions and 58 deletions

View File

@ -21,10 +21,10 @@ import QtQuick 2.0
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.components 0.1 as PlasmaComponents
Item {
Row {
id: root
width: 640
height: 480
height: 48
property Item toolBox
@ -33,7 +33,7 @@ Item {
onAppletAdded: {
var container = appletContainerComponent.createObject(root)
container.visible = true
print("Applet added: " + applet)
print("Applet added in test panel: " + applet)
applet.parent = container
container.applet = applet
applet.anchors.fill= applet.parent
@ -43,59 +43,17 @@ Item {
Component {
id: appletContainerComponent
PlasmaCore.FrameSvgItem {
id: frame
x: 50
y: 50
Item {
id: container
width: large + frame.margins.left + frame.margins.right
height: large + frame.margins.top + frame.margins.bottom
property alias applet: appletContainer.children
property int small: 90
property int large: 400
property int tm: 0
property int lm: 0
imagePath: applet.length > 0 && applet[0].backgroundHints == 0 ? "" : "widgets/background"
onImagePathChanged: {
// Reposition applet so it fits into the frame
if (imagePath == "") {
frame.x = frame.x + lm;
frame.y = frame.y + tm;
} else {
// Cache values, so we can subtract them when the background is removed
frame.lm = frame.margins.left;
frame.tm = frame.margins.top;
frame.x = frame.x - frame.margins.left;
frame.y = frame.y - frame.margins.top;
}
}
MouseArea {
anchors.fill: parent
drag.target: parent
onClicked: {
var s = (frame.width == frame.large) ? frame.small : frame.large;
frame.x = s
frame.height = s
frame.width = s
}
anchors {
top: parent.top
bottom: parent.bottom
}
width: height
property Item applet
Item {
id: appletContainer
anchors {
fill: parent
leftMargin: frame.margins.left
rightMargin: parent.margins.right
topMargin: parent.margins.top
bottomMargin: parent.margins.bottom
}
}
PlasmaComponents.BusyIndicator {
z: 1000
@ -107,7 +65,7 @@ Item {
}
Component.onCompleted: {
print("Test Containment loaded")
print("Test Panel loaded")
print(plasmoid)
}
}

View File

@ -18,17 +18,19 @@
#include "panelview.h"
#include <QDebug>
#include <Plasma/Package>
PanelView::PanelView(Plasma::Corona *corona, QWindow *parent)
: View(corona, parent)
{
//FIXME: this works only if done in View
QSurfaceFormat format;
/*QSurfaceFormat format;
format.setAlphaBufferSize(8);
setFormat(format);
setClearBeforeRendering(true);
setColor(QColor(Qt::transparent));
setColor(QColor(Qt::transparent));*/
setFlags(Qt::FramelessWindowHint);
}
@ -37,6 +39,15 @@ PanelView::~PanelView()
}
void PanelView::init()
{
if (!corona()->package().isValid()) {
qWarning() << "Invalid home screen package";
}
setResizeMode(View::SizeRootObjectToView);
setSource(QUrl::fromLocalFile(corona()->package().filePath("ui", "PanelView.qml")));
}
#include "moc_panelview.cpp"

View File

@ -31,6 +31,7 @@ public:
explicit PanelView(Plasma::Corona *corona, QWindow *parent = 0);
virtual ~PanelView();
virtual void init();
private:
};

View File

@ -0,0 +1,43 @@
/*
* Copyright 2012 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.0
//import org.kde.plasma 2.0
import org.kde.plasma.core 0.1 as PlasmaCore
PlasmaCore.FrameSvgItem {
id: root
width: 640
height: 32
imagePath: "widgets/panel-background"
property Item containment
onContainmentChanged: {
print("New Containment: " + containment)
//containment.parent = root
containment.visible = true
containment.anchors.fill = root
}
Component.onCompleted: {
print("PanelView QML loaded")
}
}

View File

@ -35,6 +35,11 @@ View::~View()
}
Plasma::Corona *View::corona() const
{
return m_corona;
}
void View::init()
{
if (!m_corona->package().isValid()) {
@ -67,7 +72,9 @@ void View::setContainment(Plasma::Containment *cont)
qDebug() << "using as graphic containment" << graphicObject << m_containment.data();
//graphicObject->setProperty("visible", false);
graphicObject->setProperty("drawWallpaper", true);
graphicObject->setProperty("drawWallpaper",
(cont->containmentType() == Plasma::Containment::DesktopContainment ||
cont->containmentType() == Plasma::Containment::CustomContainment));
graphicObject->setProperty("parent", QVariant::fromValue(rootObject()));
rootObject()->setProperty("containment", QVariant::fromValue(graphicObject));
} else {

View File

@ -34,8 +34,10 @@ public:
explicit View(Plasma::Corona *corona, QWindow *parent = 0);
virtual ~View();
Plasma::Corona *corona() const;
//FIXME: not super nice, but we have to be sure qml assignment is done after window flags
void init();
virtual void init();
void setContainment(Plasma::Containment *cont);
Plasma::Containment *containment() const;