From 9089947ace6eee43c0d4ea5e7386ac1da1d36ffc Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 14 Feb 2013 21:14:04 +0100 Subject: [PATCH] use a different qml file for the panel view --- .../testpanel/contents/ui/main.qml | 66 ++++--------------- src/shell/panelview.cpp | 15 ++++- src/shell/panelview.h | 1 + .../desktop/contents/ui/PanelView.qml | 43 ++++++++++++ src/shell/view.cpp | 9 ++- src/shell/view.h | 4 +- 6 files changed, 80 insertions(+), 58 deletions(-) create mode 100644 src/shell/qmlpackages/desktop/contents/ui/PanelView.qml diff --git a/src/shell/containments/testpanel/contents/ui/main.qml b/src/shell/containments/testpanel/contents/ui/main.qml index 8708aefdc..be36ebe34 100644 --- a/src/shell/containments/testpanel/contents/ui/main.qml +++ b/src/shell/containments/testpanel/contents/ui/main.qml @@ -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) } } \ No newline at end of file diff --git a/src/shell/panelview.cpp b/src/shell/panelview.cpp index 7c1129406..ac50388d0 100644 --- a/src/shell/panelview.cpp +++ b/src/shell/panelview.cpp @@ -18,17 +18,19 @@ #include "panelview.h" +#include +#include 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" diff --git a/src/shell/panelview.h b/src/shell/panelview.h index 8692d7f24..87b5fce6f 100644 --- a/src/shell/panelview.h +++ b/src/shell/panelview.h @@ -31,6 +31,7 @@ public: explicit PanelView(Plasma::Corona *corona, QWindow *parent = 0); virtual ~PanelView(); + virtual void init(); private: }; diff --git a/src/shell/qmlpackages/desktop/contents/ui/PanelView.qml b/src/shell/qmlpackages/desktop/contents/ui/PanelView.qml new file mode 100644 index 000000000..601fc8c9a --- /dev/null +++ b/src/shell/qmlpackages/desktop/contents/ui/PanelView.qml @@ -0,0 +1,43 @@ +/* + * Copyright 2012 Marco Martin + * + * 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") + } +} diff --git a/src/shell/view.cpp b/src/shell/view.cpp index eacfbe77e..367225c78 100644 --- a/src/shell/view.cpp +++ b/src/shell/view.cpp @@ -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 { diff --git a/src/shell/view.h b/src/shell/view.h index 25651f90a..25e0072e2 100644 --- a/src/shell/view.h +++ b/src/shell/view.h @@ -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;