[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: Re: [Panel-devel] Plasma panel
From: Alex Merry <huntedhacker () tiscali ! co ! uk>
Date: 2007-09-30 18:28:24
Message-ID: 200709301928.29189.huntedhacker () tiscali ! co ! uk
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
On Sunday 30 Sep 2007, Aaron J. Seigo wrote:
> Panel
> Panel
> Panel
> ------------- 0 -----------
> Screen 1 Screen 2 Screen 3
The problem here is knowing where on the screen to put the PanelView...
>
> the trick will be preventing users from accidently moving objects
> into the negative coordinate space themselves, but i think this is
> pretty easy to do, really (mostly by controling what the views are
> showing).
It actually is fine, as long as the panels have a z-value higher than
the desktops. Anything moved into the panel space will just slide
under the panels
I've got another version with signals for updates here. See what you
think. Note that PanelViews are created on demand now, so you can now
add panels from the desktop context menu.
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 719257)
+++ libs/plasma/corona.cpp (working copy)
@@ -292,6 +292,8 @@ Containment* Corona::addContainment(cons
connect(containment, SIGNAL(destroyed(QObject*)),
this, SLOT(containmentDestroyed(QObject*)));
+ emit containmentAdded(containment);
+
return containment;
}
Index: libs/plasma/containment.h
===================================================================
--- libs/plasma/containment.h (revision 719257)
+++ libs/plasma/containment.h (working copy)
@@ -220,6 +220,18 @@ class PLASMA_EXPORT Containment : public
*/
void setFormFactor(Plasma::FormFactor formFactor);
+ Q_SIGNALS:
+ /**
+ * Emitted when an applet was added
+ *
+ * Note that the Applet may not have been
+ * initialised yet.
+ *
+ * @param host the Containment that the applet was added to
+ * @param applet the applet that was added. Always a valid Applet
+ */
+ void appletAdded(Plasma::Applet *applet);
+
protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent * event);
@@ -230,6 +242,10 @@ class PLASMA_EXPORT Containment : public
void appletDestroyed(QObject*);
void launchExplorer();
void launchAppletBrowser();
+ void addSouthPanel();
+ void addWestPanel();
+ void addNorthPanel();
+ void addEastPanel();
void runCommand();
void lockScreen();
void logout();
Index: libs/plasma/containment.cpp
===================================================================
--- libs/plasma/containment.cpp (revision 719257)
+++ libs/plasma/containment.cpp (working copy)
@@ -65,6 +65,10 @@ public:
bitmapBackground(0),
engineExplorerAction(0),
appletBrowserAction(0),
+ southPanelAction(0),
+ northPanelAction(0),
+ eastPanelAction(0),
+ westPanelAction(0),
runCommandAction(0),
lockAction(0),
logoutAction(0),
@@ -92,6 +96,10 @@ public:
QString wallpaperPath;
QAction *engineExplorerAction;
QAction *appletBrowserAction;
+ QAction *southPanelAction;
+ QAction *northPanelAction;
+ QAction *eastPanelAction;
+ QAction *westPanelAction;
QAction *runCommandAction;
QAction *lockAction;
QAction *logoutAction;
@@ -269,6 +277,18 @@ QList<QAction*> Containment::contextActi
d->appletBrowserAction = new QAction(i18n("Add applet"), this);
connect(d->appletBrowserAction, SIGNAL(triggered(bool)), this, \
SLOT(launchAppletBrowser()));
+ d->southPanelAction = new QAction(i18n("Add south panel"), this);
+ connect(d->southPanelAction, SIGNAL(triggered(bool)), this, \
SLOT(addSouthPanel())); +
+ d->westPanelAction = new QAction(i18n("Add west panel"), this);
+ connect(d->westPanelAction, SIGNAL(triggered(bool)), this, \
SLOT(addWestPanel())); +
+ d->northPanelAction = new QAction(i18n("Add north panel"), this);
+ connect(d->northPanelAction, SIGNAL(triggered(bool)), this, \
SLOT(addNorthPanel())); +
+ d->eastPanelAction = new QAction(i18n("Add east panel"), this);
+ connect(d->eastPanelAction, SIGNAL(triggered(bool)), this, \
SLOT(addEastPanel())); +
d->runCommandAction = new QAction(i18n("Run Command..."), this);
connect(d->runCommandAction, SIGNAL(triggered(bool)), this, \
SLOT(runCommand()));
@@ -285,6 +305,10 @@ QList<QAction*> Containment::contextActi
actions.append(d->engineExplorerAction);
actions.append(d->appletBrowserAction);
+ actions.append(d->southPanelAction);
+ actions.append(d->westPanelAction);
+ actions.append(d->northPanelAction);
+ actions.append(d->eastPanelAction);
if (KAuthorized::authorizeKAction("run_command")) {
actions.append(d->runCommandAction);
@@ -491,6 +515,8 @@ Applet* Containment::addApplet(const QSt
if (d->layout) {
d->layout->addItem(applet);
+ //kDebug() << "Layout geometry is" << d->layout->geometry();
+ //kDebug() << "Applet geometry is" << applet->geometry() << "after adding to \
layout"; }
applet->updateConstraints();
@@ -507,6 +533,8 @@ Applet* Containment::addApplet(const QSt
this, SLOT(appletDestroyed(QObject*)));
Phase::self()->animateItem(applet, Phase::Appear);
+ emit appletAdded(applet);
+
return applet;
}
@@ -633,6 +661,38 @@ void Containment::dropEvent(QGraphicsSce
}
}
+void Containment::addSouthPanel()
+{
+ Corona *corona = dynamic_cast<Corona*>(scene());
+ if (corona) {
+ corona->addContainment("panel", QVariantList() << (int)Plasma::BottomEdge);
+ }
+}
+
+void Containment::addNorthPanel()
+{
+ Corona *corona = dynamic_cast<Corona*>(scene());
+ if (corona) {
+ corona->addContainment("panel", QVariantList() << (int)Plasma::TopEdge);
+ }
+}
+
+void Containment::addWestPanel()
+{
+ Corona *corona = dynamic_cast<Corona*>(scene());
+ if (corona) {
+ corona->addContainment("panel", QVariantList() << (int)Plasma::LeftEdge);
+ }
+}
+
+void Containment::addEastPanel()
+{
+ Corona *corona = dynamic_cast<Corona*>(scene());
+ if (corona) {
+ corona->addContainment("panel", QVariantList() << (int)Plasma::RightEdge);
+ }
+}
+
}
#include "containment.moc"
Index: libs/plasma/applet.cpp
===================================================================
--- libs/plasma/applet.cpp (revision 719257)
+++ libs/plasma/applet.cpp (working copy)
@@ -1096,6 +1096,8 @@ void Applet::setGeometry(const QRectF& g
setPos(geometry.topLeft());
update();
+
+ emit positionChanged(geometry.topLeft());
}
void Applet::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
Index: libs/plasma/widgets/widget.h
===================================================================
--- libs/plasma/widgets/widget.h (revision 719257)
+++ libs/plasma/widgets/widget.h (working copy)
@@ -247,6 +247,25 @@ TODO: implement once we decide how to ha
virtual QGraphicsItem* graphicsItem();
+Q_SIGNALS:
+ /**
+ * Emitted when the size of the Widget has changed
+ *
+ * Note that the applet may not have been repainted yet,
+ * but the size property will have been updated.
+ *
+ * @param size the new size
+ */
+ void sizeChanged(const QSizeF &size);
+
+ /**
+ * Emitted when the position of the Widget (relative to
+ * the parent) has changed
+ *
+ * @param position the new position (relative to the parent)
+ */
+ void positionChanged(const QPointF &position);
+
protected:
/**
* Paints the widget
@@ -256,6 +275,7 @@ protected:
*/
virtual void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem \
*option, QWidget *widget = 0); void setSize(const QSizeF& size);
+ virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget \
*widget = 0);
Index: libs/plasma/widgets/widget.cpp
===================================================================
--- libs/plasma/widgets/widget.cpp (revision 719257)
+++ libs/plasma/widgets/widget.cpp (working copy)
@@ -216,15 +216,19 @@ void Widget::setGeometry(const QRectF& g
if (layout()) {
layout()->setGeometry(boundingRect());
}
+ emit sizeChanged(d->size);
}
setPos(geometry.topLeft());
update();
+
+ emit positionChanged(geometry.topLeft());
}
void Widget::setSize(const QSizeF& size)
{
d->size = size;
+ emit sizeChanged(d->size);
}
void Widget::updateGeometry()
@@ -416,5 +420,13 @@ void Widget::reparent(Widget *w)
update();
}
+QVariant Widget::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+ if (change == ItemPositionHasChanged) {
+ emit positionChanged(value.toPointF());
+ }
+ return QGraphicsItem::itemChange(change, value);
+}
+
} // Plasma namespace
Index: libs/plasma/corona.h
===================================================================
--- libs/plasma/corona.h (revision 719257)
+++ libs/plasma/corona.h (working copy)
@@ -157,6 +157,18 @@ public Q_SLOTS:
*/
void setImmutable(bool immutable_);
+Q_SIGNALS:
+ /**
+ * Emitted when a containment was added
+ *
+ * Note that the Containment may not have been
+ * initialised yet.
+ *
+ * @param containment the Containment that was added.
+ * Always a valid Containment
+ */
+ void containmentAdded(Plasma::Containment *containment);
+
protected:
void dragEnterEvent(QGraphicsSceneDragDropEvent* event);
void dragLeaveEvent(QGraphicsSceneDragDropEvent* event);
Index: plasma/plasma/panelview.h
===================================================================
--- plasma/plasma/panelview.h (revision 719254)
+++ plasma/plasma/panelview.h (working copy)
@@ -77,6 +77,10 @@ private:
Plasma::Containment *m_containment;
Plasma::Svg *m_background;
+
+private Q_SLOTS:
+ void panelSizeChanged(const QSizeF &newSize);
+ void panelPosChanged(const QPointF &newPos);
};
} // Namespace
Index: plasma/plasma/plasmaapp.cpp
===================================================================
--- plasma/plasma/plasmaapp.cpp (revision 719254)
+++ plasma/plasma/plasmaapp.cpp (working copy)
@@ -89,8 +89,6 @@ PlasmaApp::PlasmaApp()
m_root->show();
connect(this, SIGNAL(aboutToQuit()), corona(), SLOT(saveApplets()));
- createPanels();
-
notifyStartup(true);
}
@@ -129,6 +127,10 @@ Plasma::Corona* PlasmaApp::corona()
{
if (!m_corona) {
m_corona = new Plasma::Corona(this);
+
+ connect(corona(), SIGNAL(containmentAdded(Plasma::Containment*)),
+ this, SLOT(newContainment(Plasma::Containment*)));
+
m_corona->setItemIndexMethod(QGraphicsScene::NoIndex);
//TODO: Figure out a way to use rubberband and ScrollHandDrag
m_corona->loadApplets();
@@ -149,9 +151,8 @@ void PlasmaApp::notifyStartup(bool compl
}
}
-void PlasmaApp::createPanels()
+void PlasmaApp::newContainment(Plasma::Containment *containment)
{
- foreach (Plasma::Containment *containment, corona()->containments()) {
kDebug() << "Containment name:" << containment->name()
<< "| screen:" << containment->screen()
<< "| geometry:" << containment->geometry()
@@ -161,7 +162,6 @@ void PlasmaApp::createPanels()
m_panels << panelView;
panelView->show();
}
- }
}
#include "plasmaapp.moc"
Index: plasma/plasma/plasmaapp.h
===================================================================
--- plasma/plasma/plasmaapp.h (revision 719254)
+++ plasma/plasma/plasmaapp.h (working copy)
@@ -52,10 +52,10 @@ public Q_SLOTS:
private Q_SLOTS:
void setCrashHandler();
+ void newContainment(Plasma::Containment *containment);
private:
static void crashHandler(int signal);
- void createPanels();
RootWidget *m_root;
Plasma::Corona *m_corona;
Index: plasma/plasma/panelview.cpp
===================================================================
--- plasma/plasma/panelview.cpp (revision 719254)
+++ plasma/plasma/panelview.cpp (working copy)
@@ -45,6 +45,10 @@ PanelView::PanelView(Plasma::Containment
setScene(m_containment->scene());
updatePanelGeometry();
kDebug() << "Panel geometry is" << m_containment->geometry();
+ connect(m_containment, SIGNAL(sizeChanged(QSizeF)),
+ this, SLOT(panelSizeChanged(QSizeF)));
+ connect(m_containment, SIGNAL(positionChanged(QPointF)),
+ this, SLOT(panelPosChanged(QPointF)));
// Graphics view setup
setFrameStyle(QFrame::NoFrame);
@@ -159,5 +163,16 @@ void PanelView::resizeEvent(QResizeEvent
updateStruts();
}
+void PanelView::panelSizeChanged(const QSizeF &)
+{
+ kDebug() << "panel size changed";
+ updatePanelGeometry();
+}
+
+void PanelView::panelPosChanged(const QPointF &)
+{
+ kDebug() << "panel position changed";
+ updatePanelGeometry();
+}
} // Namespace
["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