[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: [Panel-devel] Plasma panel
From: Alex Merry <huntedhacker () tiscali ! co ! uk>
Date: 2007-09-29 11:07:53
Message-ID: 200709291208.04083.huntedhacker () tiscali ! co ! uk
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
This is an implementation of panels in Plasma.
It uses a Containment subclass, Panel. PanelView (which was previously
called Panel) attaches to a Panel and displays it.
To get the panel, you need to delete
~/.kde4/share/config/plasma-appletsrc, so that it will be regenerated.
Current issues:
* the layout is not working properly
* the applets get backgrounds when the panel is reloaded from
plasma-appletsrc (we have no hook into addApplet from subclasses of
Containment in which to do this)
* actually, the restore code doesn't even get the geometry right
any more (it worked a couple of days ago)
* You can add a Panel to the desktop, but no corresponding PanelView
will be created. Also, it probably won't be attached to the side of
the screen (I haven't tested this)
* drag-and-drop on to the panel doesn't workissues:
I don't know how much time I'll have to work on this in the next week or
so.
Alex
--
KDE: http://www.kde.org
Ubuntu/Kubuntu: http://www.ubuntu.org http://www.kubuntu.org
["plasma-panel.diff" (text/x-diff)]
Index: libs/plasma/corona.cpp
===================================================================
--- libs/plasma/corona.cpp (revision 718619)
+++ libs/plasma/corona.cpp (working copy)
@@ -147,16 +147,19 @@ void Corona::loadApplets(const QString&
foreach (const QString& group, cg.groupList()) {
KConfigGroup appletConfig(&cg, group);
if (group.contains("containment")) {
+ kDebug() << "Loading" << group;
int cid = group.left(group.indexOf('-')).toUInt();
Containment *c = addContainment(appletConfig.readEntry("plugin", \
QString()), QVariantList(), cid, true);
if (c) {
+ kDebug() << group << "loaded successfully";
containments.insert(c->id(), c);
+ c->setGeometry(appletConfig.readEntry("geometry", QRectF()));
c->initConstraints(&appletConfig);
}
} else {
// it's an applet, let's grab the containment association
- kDebug() << "insert multi " << group;
+ kDebug() << "insert multi" << group;
applets.append(appletConfig);
}
}
@@ -218,6 +221,30 @@ void Corona::loadDefaultSetup()
c->setScreen(i);
c->setFormFactor(Plasma::Planar);
}
+
+ // make a panel at the bottom
+ Containment* panel = addContainment("panel");
+ panel->setFormFactor(Plasma::Horizontal);
+ panel->setLocation(Plasma::BottomEdge);
+ // just use the bit the panel covers on the first desktop
+ const int width = desktop.screenGeometry().width();
+ const int height = 48;
+ const int x = 0;
+ const int y = desktop.screenGeometry().height() - height;
+ panel->setGeometry(QRectF(x, y, width, height));
+
+ // some default applets to get a usable UI
+ QList<Plasma::Applet*> applets;
+ Plasma::Applet *tasksApplet = panel->addApplet("tasks");
+ Plasma::Applet *systemTrayApplet = panel->addApplet("systemtray");
+ Plasma::Applet *clockApplet = panel->addApplet("digital-clock");
+
+ applets << tasksApplet << systemTrayApplet << clockApplet;
+
+ foreach (Plasma::Applet* applet , applets) {
+ // If we have a Panel class (is a Container), this should move there
+ applet->setDrawStandardBackground(false);
+ }
}
Containment* Corona::containmentForScreen(int screen) const
@@ -231,6 +258,11 @@ Containment* Corona::containmentForScree
return 0;
}
+QList<Containment*> Corona::containments() const
+{
+ return d->containments;
+}
+
void Corona::clearApplets()
{
foreach (Containment* containment, d->containments) {
@@ -243,6 +275,8 @@ Containment* Corona::addContainment(cons
Containment* containment = 0;
Applet* applet = 0;
+ kDebug() << "Loading" << name << args << id;
+
if (!name.isEmpty()) {
applet = Applet::loadApplet(name, id, args);
containment = dynamic_cast<Containment*>(applet);
Index: libs/plasma/containment.cpp
===================================================================
--- libs/plasma/containment.cpp (revision 718619)
+++ libs/plasma/containment.cpp (working copy)
@@ -138,7 +138,6 @@ void Containment::init()
void Containment::initConstraints(KConfigGroup* group)
{
- //kDebug() << "initConstraints" << group->group();
setScreen(group->readEntry("screen", -1));
setFormFactor((Plasma::FormFactor)group->readEntry("formfactor", \
(int)Plasma::Planar));
setLocation((Plasma::Location)group->readEntry("location", \
(int)Plasma::Desktop)); @@ -497,6 +496,9 @@ Applet* Containment::addApplet(const QSt
applet->updateConstraints();
+ kDebug() << applet->name() << "sizehint:" << applet->sizeHint()
+ << "geometry:" << applet->geometry();
+
if (!delayInit) {
applet->init();
}
Index: libs/plasma/corona.h
===================================================================
--- libs/plasma/corona.h (revision 718619)
+++ libs/plasma/corona.h (working copy)
@@ -141,6 +141,11 @@ public Q_SLOTS:
Containment* containmentForScreen(int screen) const;
/**
+ * Returns all containments on this Corona
+ */
+ QList<Containment*> containments() const;
+
+ /**
* Adds a SuperKaramba theme to the scene
*
* @param path the path to the theme file
Index: plasma/applets/panel/plasma-containment-panel.desktop
===================================================================
--- plasma/applets/panel/plasma-containment-panel.desktop (revision 0)
+++ plasma/applets/panel/plasma-containment-panel.desktop (revision 0)
@@ -0,0 +1,18 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=Panel
+Comment=A containment for a panel
+Icon=
+Type=Service
+ServiceTypes=Plasma/Applet,Plasma/Containment
+
+X-KDE-Library=plasma_containment_panel
+X-KDE-PluginInfo-Author=The Plasma Team
+X-KDE-PluginInfo-Email=panel-devel@kde.org
+X-KDE-PluginInfo-Name=panel
+X-KDE-PluginInfo-Version=pre0.1
+X-KDE-PluginInfo-Website=http://plasma.kde.org/
+X-KDE-PluginInfo-Category=Miscellaneous
+X-KDE-PluginInfo-Depends=
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=true
Index: plasma/applets/panel/panel.cpp
===================================================================
--- plasma/applets/panel/panel.cpp (revision 0)
+++ plasma/applets/panel/panel.cpp (revision 0)
@@ -0,0 +1,89 @@
+/*
+* Copyright 2007 by Alex Merry <huntedhacker@tiscali.co.uk>
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Library General Public License 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 "panel.h"
+
+#include <QPainter>
+#include <QDesktopWidget>
+
+#include <KDebug>
+
+#include <plasma/svg.h>
+
+using namespace Plasma;
+
+Panel::Panel(QObject *parent, const QVariantList &args)
+ : Containment(parent, args)
+{
+ m_background = new Plasma::Svg("widgets/panel-background", this);
+ setZValue(150);
+ QDesktopWidget desktop;
+ setMaximumSize(desktop.screenGeometry().size());
+}
+
+Panel::~Panel()
+{
+ delete m_background;
+}
+
+void Panel::setLocation(Plasma::Location location)
+{
+ Containment::setLocation(location);
+ if (location == BottomEdge || location == TopEdge) {
+ setFormFactor(Plasma::Horizontal);
+ } else if (location == LeftEdge || location == RightEdge) {
+ setFormFactor(Plasma::Vertical);
+ }
+}
+
+Qt::Orientations Panel::expandingDirections() const
+{
+ if (formFactor() == Plasma::Horizontal) {
+ return Qt::Horizontal;
+ } else {
+ return Qt::Vertical;
+ }
+}
+
+void Panel::paintInterface(QPainter *painter,
+ const QStyleOptionGraphicsItem *option,
+ const QRect& contentsRect)
+{
+ kDebug() << "I am a panel";
+ // draw the background untransformed (saves lots of per-pixel-math)
+ painter->save();
+ painter->resetTransform();
+
+ // blit the background (saves all the per-pixel-products that blending does)
+ painter->setCompositionMode(QPainter::CompositionMode_Source);
+
+ if (m_background) {
+ m_background->resize(contentsRect.size());
+ // Plasma::Svg doesn't support drawing only part of the image (it only
+ // supports drawing the whole image to a rect), so we blit to 0,0-w,h
+ m_background->paint(painter, 0, 0);
+ }
+
+ // restore transformation and composition mode
+ painter->restore();
+}
+
+K_EXPORT_PLASMA_APPLET(panel, Panel)
+
+#include "panel.moc"
+
Index: plasma/applets/panel/panel.h
===================================================================
--- plasma/applets/panel/panel.h (revision 0)
+++ plasma/applets/panel/panel.h (revision 0)
@@ -0,0 +1,58 @@
+/*
+* Copyright 2007 by Alex Merry <huntedhacker@tiscali.co.uk>
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Library General Public License 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 PLASMA_PANEL_H
+#define PLASMA_PANEL_H
+
+#include <plasma/containment.h>
+
+namespace Plasma
+{
+ class Svg;
+
+ class Panel : public Containment
+ {
+ Q_OBJECT
+ public:
+ Panel(QObject *parent, const QVariantList &args);
+ ~Panel();
+
+ /**
+ * Sets the location (screen edge) where this panel is positioned.
+ *
+ * Valid values are TopEdge, RightEdge, BottomEdge and LeftEdge.
+ * This will set the correct FormFactor.
+ *
+ * @param location the location to place the panel at
+ */
+ void setLocation(Plasma::Location location);
+
+ virtual Qt::Orientations expandingDirections() const;
+
+ virtual void paintInterface(QPainter *painter,
+ const QStyleOptionGraphicsItem *option,
+ const QRect& contentsRect);
+
+ private:
+ Plasma::Svg *m_background;
+ };
+
+} // namespace Plasma
+
+
+#endif // PLASMA_PANEL_H
Index: plasma/applets/panel/CMakeLists.txt
===================================================================
--- plasma/applets/panel/CMakeLists.txt (revision 0)
+++ plasma/applets/panel/CMakeLists.txt (revision 0)
@@ -0,0 +1,9 @@
+
+set(panel_SRCS
+ panel.cpp)
+
+kde4_add_plugin(plasma_containment_panel ${panel_SRCS})
+target_link_libraries(plasma_containment_panel plasma ${KDE4_KIO_LIBS})
+
+install(TARGETS plasma_containment_panel DESTINATION ${PLUGIN_INSTALL_DIR})
+install(FILES plasma-containment-panel.desktop DESTINATION ${SERVICES_INSTALL_DIR})
Index: plasma/applets/tasks/tasks.cpp
===================================================================
--- plasma/applets/tasks/tasks.cpp (revision 718619)
+++ plasma/applets/tasks/tasks.cpp (working copy)
@@ -49,7 +49,7 @@ Tasks::Tasks(QObject* parent , const QVa
{
setDrawStandardBackground(true);
- Plasma::BoxLayout *layout = new \
Plasma::BoxLayout(Plasma::BoxLayout::LeftToRight,0); + Plasma::BoxLayout *layout = \
new Plasma::BoxLayout(Plasma::BoxLayout::LeftToRight,this); layout->setMargin(0);
_rootTaskGroup = new TaskGroupItem(this,this);
@@ -343,7 +343,7 @@ TaskGroupItem::TaskGroupItem(QGraphicsIt
{
setAcceptDrops(true);
- setLayout(new Plasma::BoxLayout(Plasma::BoxLayout::LeftToRight,0));
+ setLayout(new Plasma::BoxLayout(Plasma::BoxLayout::LeftToRight,this));
layout()->setMargin(0);
layout()->setSpacing(5);
}
Index: plasma/applets/CMakeLists.txt
===================================================================
--- plasma/applets/CMakeLists.txt (revision 718619)
+++ plasma/applets/CMakeLists.txt (working copy)
@@ -1,4 +1,5 @@
add_subdirectory(clock)
add_subdirectory(tasks)
add_subdirectory(systemtray)
+add_subdirectory(panel)
Index: plasma/plasma/panelview.h
===================================================================
--- plasma/plasma/panelview.h (revision 717501)
+++ plasma/plasma/panelview.h (working copy)
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef PLASMA_PANEL_H
-#define PLASMA_PANEL_H
+#ifndef PLASMA_PANELVIEW_H
+#define PLASMA_PANELVIEW_H
#include <QGraphicsView>
@@ -27,17 +27,18 @@
namespace Plasma
{
-class Panel : public QGraphicsView
+class Containment;
+
+class PanelView : public QGraphicsView
{
Q_OBJECT
public:
/**
- * Constructs a new panel.
+ * Constructs a new panelview.
* @arg parent the QWidget this panel is parented to
*/
- Panel(QWidget *parent = 0);
- ~Panel();
+ PanelView(Containment *containment, QWidget *parent = 0);
/**
* Sets the location (screen edge) where this panel is positioned.
@@ -51,28 +52,23 @@ public:
Plasma::Location location() const;
/**
- * Sets the Corona (scene) to be used for this panels items.
- * @param corona the corona to use for this panel.
+ * @return the Containment associated with this panel.
*/
- void setCorona(Plasma::Corona* corona);
+ Plasma::Containment *containment() const;
/**
* @return the Corona (scene) associated with this panel.
*/
Plasma::Corona *corona() const;
- /**
- * @return this panel's layout.
- */
- Plasma::Layout *layout() const;
-
protected:
virtual void drawBackground(QPainter *painter, const QRectF& rect);
private:
- class Private;
- Private *const d;
+ void updatePanelGeometry();
+ Plasma::Containment *m_containment;
+ Plasma::Svg *m_background;
};
} // Namespace
Index: plasma/plasma/panel.cpp
===================================================================
--- plasma/plasma/panel.cpp (revision 718619)
+++ plasma/plasma/panel.cpp (working copy)
@@ -1,220 +0,0 @@
-/*
-* Copyright 2007 by Matt Broadstone <mbroadst@kde.org>
-* Copyright 2007 by Robert Knight <robertknight@gmail.com>
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU Library General Public License 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 <QApplication>
-#include <QDesktopWidget>
-#include <QTimeLine>
-
-#include <KWindowSystem>
-#include <KDebug>
-
-#include <plasma/corona.h>
-#include <plasma/plasma.h>
-#include <plasma/svg.h>
-#include <plasma/widgets/layoutitem.h>
-#include <plasma/widgets/boxlayout.h>
-#include <plasma/widgets/layoutanimator.h>
-
-#include "panel.h"
-#include "panel.moc"
-
-namespace Plasma
-{
-
-class PanelLayoutItem : public Plasma::LayoutItem
-{
-public:
- PanelLayoutItem(Panel* parent)
- : m_panel(parent)
- {
- }
-
- virtual Qt::Orientations expandingDirections() const
- {
- return 0;
- }
-
- virtual QSizeF minimumSize() const { return geometry().size(); }
- virtual QSizeF maximumSize() const { return geometry().size(); }
- virtual QSizeF sizeHint() const { return geometry().size(); }
-
- virtual void setGeometry(const QRectF&) {}
- virtual QRectF geometry() const
- {
- return m_panel->sceneRect();
- }
-
-private:
- Panel* const m_panel;
-};
-
-class Panel::Private
-{
-public:
- Private(Panel* parent)
- : panel(parent),
- location(Plasma::BottomEdge),
- layout(0),
- scene(0),
- layoutItem(0),
- background(0)
- {}
-
- void createApplets();
- void updatePanelGeometry();
-
- Panel *const panel;
- Plasma::Location location;
- Plasma::BoxLayout *layout;
- Plasma::Corona *scene;
- PanelLayoutItem *layoutItem;
- Plasma::Svg *background;
-};
-
-Panel::Panel(QWidget *parent)
- : QGraphicsView(parent),
- d(new Private(this))
-{
- // Graphics view setup
- setFrameStyle(QFrame::NoFrame);
- setAutoFillBackground(true);
- // setDragMode(QGraphicsView::RubberBandDrag);
- setCacheMode(QGraphicsView::CacheBackground);
- setInteractive(true);
- setAcceptDrops(true);
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-
- // Create layout to arrange applets
- d->layoutItem = new PanelLayoutItem(this);
- if (d->location == Plasma::BottomEdge || d->location == Plasma::TopEdge) {
- d->layout = new \
Plasma::BoxLayout(Plasma::BoxLayout::LeftToRight,d->layoutItem);
- }
- else {
- d->layout = new \
Plasma::BoxLayout(Plasma::BoxLayout::TopToBottom,d->layoutItem);
- }
- d->layout->setMargin(0);
- d->layout->setSpacing(0);
-
- // testing
- Plasma::LayoutAnimator *animator = new Plasma::LayoutAnimator(this);
- animator->setTimeLine( new QTimeLine(300,this) );
- animator->setEffect( Plasma::LayoutAnimator::StandardState , \
Plasma::LayoutAnimator::MoveEffect );
- d->layout->setAnimator(animator);
-
- // KWin setup
- KWindowSystem::setType(winId(), NET::Dock);
- KWindowSystem::setState(winId(), NET::Sticky | NET::StaysOnTop);
-
- // Highly questionable behavior used in kicker..
- // KWindowSystem::setOnAllDesktops(winId(), true);
-}
-
-Panel::~Panel()
-{
- delete d;
-}
-
-
-Plasma::Layout* Panel::layout() const
-{
- return d->layout;
-}
-
-void Panel::setCorona(Plasma::Corona *corona)
-{
- d->scene = corona;
- setScene(d->scene);
-}
-
-Plasma::Corona* Panel::corona() const
-{
- return d->scene;
-}
-
-Plasma::Location Panel::location() const
-{
- return d->location;
-}
-
-void Panel::setLocation(Plasma::Location loc)
-{
- d->location = loc;
- d->updatePanelGeometry();
-}
-
-void Panel::Private::updatePanelGeometry()
-{
- // FIXME:Hardcoded 60 in as the height of the panel, change this later.
- QDesktopWidget *desktop = QApplication::desktop();
- int x=0, y=0, width=0, height=0;
- switch (location) {
- case Plasma::TopEdge:
- case Plasma::BottomEdge:
- height = 48;
- width = desktop->screenGeometry().width();
- break;
-
- case Plasma::LeftEdge:
- case Plasma::RightEdge:
- default:
- width = 48;
- height = desktop->screenGeometry().height();
- break;
- }
-
- switch (location) {
- case Plasma::TopEdge:
- y = 0;
- break;
-
- case Plasma::LeftEdge:
- x = 0;
- break;
-
- case Plasma::RightEdge:
- x = desktop->screenGeometry().width() - width;
- break;
-
- case Plasma::BottomEdge:
- default:
- y = desktop->screenGeometry().height() - height;
- break;
- }
-
- const QRectF newGeometry(0,0,width,height);
- panel->setGeometry(x,y,width,height);
- panel->setSceneRect(newGeometry);
- layout->setGeometry(newGeometry);
-}
-
-void Panel::drawBackground( QPainter *painter , const QRectF& rect )
-{
- if (!d->background) {
- d->background = new Plasma::Svg("widgets/panel-background",this);
- }
-
- if (d->background->size() != rect.size().toSize()) {
- d->background->resize((int)rect.width(),(int)rect.height());
- }
-
- painter->setCompositionMode(QPainter::CompositionMode_Source);
- d->background->paint(painter,0,0);
-}
-
-} // Namespace
Index: plasma/plasma/panel.h
===================================================================
--- plasma/plasma/panel.h (revision 718619)
+++ plasma/plasma/panel.h (working copy)
@@ -1,80 +0,0 @@
-/*
-* Copyright 2007 by Matt Broadstone <mbroadst@kde.org>
-* Copyright 2007 by Robert Knight <robertknight@gmail.com>
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU Library General Public License 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 PLASMA_PANEL_H
-#define PLASMA_PANEL_H
-
-#include <QGraphicsView>
-
-#include <plasma/plasma.h>
-
-namespace Plasma
-{
-
-class Panel : public QGraphicsView
-{
- Q_OBJECT
-public:
-
- /**
- * Constructs a new panel.
- * @arg parent the QWidget this panel is parented to
- */
- Panel(QWidget *parent = 0);
- ~Panel();
-
- /**
- * Sets the location (screen edge) where this panel is positioned.
- * @param location the location to place the panel at
- */
- void setLocation(Plasma::Location location);
-
- /**
- * @return the location (screen edge) where this panel is positioned.
- */
- Plasma::Location location() const;
-
- /**
- * Sets the Corona (scene) to be used for this panels items.
- * @param corona the corona to use for this panel.
- */
- void setCorona(Plasma::Corona* corona);
-
- /**
- * @return the Corona (scene) associated with this panel.
- */
- Plasma::Corona *corona() const;
-
- /**
- * @return this panel's layout.
- */
- Plasma::Layout *layout() const;
-
-protected:
- virtual void drawBackground(QPainter *painter, const QRectF& rect);
-
-private:
- class Private;
- Private *const d;
-
-};
-
-} // Namespace
-#endif
-
Index: plasma/plasma/plasmaapp.cpp
===================================================================
--- plasma/plasma/plasmaapp.cpp (revision 718619)
+++ plasma/plasma/plasmaapp.cpp (working copy)
@@ -36,16 +36,12 @@
#include <ksmserver_interface.h>
#include <plasma/corona.h>
-#include <plasma/widgets/layout.h>
+#include <plasma/containment.h>
#include "appadaptor.h"
#include "rootwidget.h"
#include "desktopview.h"
-#include "panel.h"
-
-// testing
-#include <KIcon>
-#include <plasma/widgets/icon.h>
+#include "panelview.h"
PlasmaApp* PlasmaApp::self()
{
@@ -93,9 +89,9 @@ PlasmaApp::PlasmaApp()
m_root->show();
connect(this, SIGNAL(aboutToQuit()), corona(), SLOT(saveApplets()));
- notifyStartup(true);
+ createPanels();
- createDefaultPanels();
+ notifyStartup(true);
}
PlasmaApp::~PlasmaApp()
@@ -153,37 +149,21 @@ void PlasmaApp::notifyStartup(bool compl
}
}
-// for testing purposes
-// this layout should be saved and loaded to a config source
-// soon
-void PlasmaApp::createDefaultPanels()
+void PlasmaApp::createPanels()
{
- return;
- Plasma::Panel *defaultPanel = new Plasma::Panel;
- Plasma::Corona *panelScene = new Plasma::Corona;
- defaultPanel->setCorona(panelScene);
-
- // place-holder for the launcher menu
- Plasma::Icon *launcherPlaceholder = new Plasma::Icon(KIcon("kmenu"),QString());
- panelScene->addItem(launcherPlaceholder);
- defaultPanel->layout()->addItem(launcherPlaceholder);
-
- // some default applets to get a usable UI
- QList<Plasma::Applet*> applets;
- Plasma::Applet *tasksApplet = panelScene->addApplet("tasks");
- Plasma::Applet *systemTrayApplet = panelScene->addApplet("systemtray");
- Plasma::Applet *clockApplet = panelScene->addApplet("digital-clock");
-
- applets << tasksApplet << systemTrayApplet << clockApplet;
-
- foreach (Plasma::Applet* applet , applets) {
- applet->setDrawStandardBackground(false);
- defaultPanel->layout()->addItem(applet);
- }
-
- defaultPanel->setLocation(Plasma::BottomEdge);
- defaultPanel->show();
- m_panels << defaultPanel;
+ foreach (Plasma::Containment *containment, corona()->containments()) {
+#ifdef __GNU__
+#warning "There must be a better way of picking out the panels"
+#endif
+ kDebug() << "Containment screen:" << containment->screen()
+ << "| geometry:" << containment->geometry()
+ << "| zValue:" << containment->zValue();
+ if (containment->screen() == -1) {
+ Plasma::PanelView *panel = new Plasma::PanelView(containment);
+ m_panels << panel;
+ panel->show();
+ }
+ }
}
#include "plasmaapp.moc"
Index: plasma/plasma/plasmaapp.h
===================================================================
--- plasma/plasma/plasmaapp.h (revision 718619)
+++ plasma/plasma/plasmaapp.h (working copy)
@@ -27,11 +27,11 @@
namespace Plasma
{
class Corona;
- class Panel;
+ class PanelView;
} // namespace Plasma
class RootWidget;
-class Panel;
+class PanelView;
class PlasmaApp : public KUniqueApplication
{
@@ -55,12 +55,11 @@ private slots:
private:
static void crashHandler(int signal);
- // for testing purposes
- void createDefaultPanels();
+ void createPanels();
RootWidget *m_root;
Plasma::Corona *m_corona;
- QList<Plasma::Panel*> m_panels;
+ QList<Plasma::PanelView*> m_panels;
};
#endif // multiple inclusion guard
Index: plasma/plasma/panelview.cpp
===================================================================
--- plasma/plasma/panelview.cpp (revision 717501)
+++ plasma/plasma/panelview.cpp (working copy)
@@ -23,76 +23,31 @@
#include <KWindowSystem>
#include <KDebug>
+#include <plasma/containment.h>
#include <plasma/corona.h>
#include <plasma/plasma.h>
#include <plasma/svg.h>
-#include <plasma/widgets/layoutitem.h>
-#include <plasma/widgets/boxlayout.h>
-#include <plasma/widgets/layoutanimator.h>
-#include "panel.h"
-#include "panel.moc"
+#include "panelview.h"
+#include "panelview.moc"
namespace Plasma
{
-class PanelLayoutItem : public Plasma::LayoutItem
-{
-public:
- PanelLayoutItem(Panel* parent)
- : m_panel(parent)
- {
- }
- virtual Qt::Orientations expandingDirections() const
- {
- return 0;
- }
- virtual QSizeF minimumSize() const { return geometry().size(); }
- virtual QSizeF maximumSize() const { return geometry().size(); }
- virtual QSizeF sizeHint() const { return geometry().size(); }
-
- virtual void setGeometry(const QRectF&) {}
- virtual QRectF geometry() const
- {
- return m_panel->sceneRect();
- }
-
-private:
- Panel* const m_panel;
-};
-
-class Panel::Private
-{
-public:
- Private(Panel* parent)
- : panel(parent),
- location(Plasma::BottomEdge),
- layout(0),
- scene(0),
- layoutItem(0),
- background(0)
- {}
-
- void createApplets();
- void updatePanelGeometry();
-
- Panel *const panel;
- Plasma::Location location;
- Plasma::BoxLayout *layout;
- Plasma::Corona *scene;
- PanelLayoutItem *layoutItem;
- Plasma::Svg *background;
-};
-
-Panel::Panel(QWidget *parent)
+PanelView::PanelView(Containment *containment, QWidget *parent)
: QGraphicsView(parent),
- d(new Private(this))
+ m_containment(containment)
{
+ Q_ASSERT(qobject_cast<Corona*>(m_containment->scene()));
+ setScene(m_containment->scene());
+ updatePanelGeometry();
+
// Graphics view setup
setFrameStyle(QFrame::NoFrame);
setAutoFillBackground(true);
+ setCacheMode(QGraphicsView::CacheBackground);
// setDragMode(QGraphicsView::RubberBandDrag);
setCacheMode(QGraphicsView::CacheBackground);
setInteractive(true);
@@ -100,23 +55,6 @@ Panel::Panel(QWidget *parent)
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- // Create layout to arrange applets
- d->layoutItem = new PanelLayoutItem(this);
- if (d->location == Plasma::BottomEdge || d->location == Plasma::TopEdge) {
- d->layout = new \
Plasma::BoxLayout(Plasma::BoxLayout::LeftToRight,d->layoutItem);
- }
- else {
- d->layout = new \
Plasma::BoxLayout(Plasma::BoxLayout::TopToBottom,d->layoutItem);
- }
- d->layout->setMargin(0);
- d->layout->setSpacing(0);
-
- // testing
- Plasma::LayoutAnimator *animator = new Plasma::LayoutAnimator(this);
- animator->setTimeLine( new QTimeLine(300,this) );
- animator->setEffect( Plasma::LayoutAnimator::StandardState , \
Plasma::LayoutAnimator::MoveEffect );
- d->layout->setAnimator(animator);
-
// KWin setup
KWindowSystem::setType(winId(), NET::Dock);
KWindowSystem::setState(winId(), NET::Sticky | NET::StaysOnTop);
@@ -125,96 +63,48 @@ Panel::Panel(QWidget *parent)
// KWindowSystem::setOnAllDesktops(winId(), true);
}
-Panel::~Panel()
-{
- delete d;
-}
-
-
-Plasma::Layout* Panel::layout() const
-{
- return d->layout;
-}
-void Panel::setCorona(Plasma::Corona *corona)
+void PanelView::setLocation(Plasma::Location loc)
{
- d->scene = corona;
- setScene(d->scene);
+ m_containment->setLocation(loc);
+ updatePanelGeometry();
}
-Plasma::Corona* Panel::corona() const
+Plasma::Location PanelView::location() const
{
- return d->scene;
+ return m_containment->location();
}
-Plasma::Location Panel::location() const
+Plasma::Containment *PanelView::containment() const
{
- return d->location;
+ return m_containment;
}
-void Panel::setLocation(Plasma::Location loc)
+Plasma::Corona *PanelView::corona() const
{
- d->location = loc;
- d->updatePanelGeometry();
+ return qobject_cast<Corona*>(scene());
}
-void Panel::Private::updatePanelGeometry()
+void PanelView::drawBackground( QPainter *painter , const QRectF& rect )
{
- // FIXME:Hardcoded 60 in as the height of the panel, change this later.
- QDesktopWidget *desktop = QApplication::desktop();
- int x=0, y=0, width=0, height=0;
- switch (location) {
- case Plasma::TopEdge:
- case Plasma::BottomEdge:
- height = 48;
- width = desktop->screenGeometry().width();
- break;
-
- case Plasma::LeftEdge:
- case Plasma::RightEdge:
- default:
- width = 48;
- height = desktop->screenGeometry().height();
- break;
+ /*
+ if (!m_background) {
+ m_background = new Plasma::Svg("widgets/panel-background",this);
}
- switch (location) {
- case Plasma::TopEdge:
- y = 0;
- break;
-
- case Plasma::LeftEdge:
- x = 0;
- break;
-
- case Plasma::RightEdge:
- x = desktop->screenGeometry().width() - width;
- break;
-
- case Plasma::BottomEdge:
- default:
- y = desktop->screenGeometry().height() - height;
- break;
+ if (m_background->size() != rect.size().toSize()) {
+ m_background->resize((int)rect.width(),(int)rect.height());
}
- const QRectF newGeometry(0,0,width,height);
- panel->setGeometry(x,y,width,height);
- panel->setSceneRect(newGeometry);
- layout->setGeometry(newGeometry);
+ painter->setCompositionMode(QPainter::CompositionMode_Source);
+ m_background->paint(painter,0,0);
+ */
}
-void Panel::drawBackground( QPainter *painter , const QRectF& rect )
+void PanelView::updatePanelGeometry()
{
- if (!d->background) {
- d->background = new Plasma::Svg("widgets/panel-background",this);
- }
-
- if (d->background->size() != rect.size().toSize()) {
- d->background->resize((int)rect.width(),(int)rect.height());
- }
-
- painter->setCompositionMode(QPainter::CompositionMode_Source);
- d->background->paint(painter,0,0);
+ setGeometry(m_containment->geometry().toRect());
+ setSceneRect(m_containment->geometry().toRect());
}
} // Namespace
Index: plasma/plasma/CMakeLists.txt
===================================================================
--- plasma/plasma/CMakeLists.txt (revision 718619)
+++ plasma/plasma/CMakeLists.txt (working copy)
@@ -6,7 +6,7 @@ set(plasma_SRCS
main.cpp
plasmaapp.cpp
rootwidget.cpp
- panel.cpp
+ panelview.cpp
)
set(plasmaapp_dbusXML org.kde.plasma.App.xml)
["signature.asc" (application/pgp-signature)]
_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic