26 #include <kwindowsystem.h>
27 #include <kactioncollection.h>
31 #include "private/containment_p.h"
34 using namespace Plasma;
42 ViewPrivate(
View *view,
int uniqueId)
52 if (uniqueId > 0 && !viewIds.contains(uniqueId)) {
53 s_maxViewId = uniqueId;
60 viewId = ++s_maxViewId;
62 viewIds.insert(viewId);
71 q->setContainment(containment);
75 void updateSceneRect()
77 if (!containment || !trackChanges) {
81 kDebug() <<
"!!!!!!!!!!!!!!!!! setting the scene rect to"
82 << containment->sceneBoundingRect()
83 <<
"associated screen is" << containment->screen();
85 emit q->sceneRectAboutToChange();
86 if (q->transform().isIdentity()) {
87 q->setSceneRect(containment->sceneBoundingRect());
90 q->ensureVisible(containment->sceneBoundingRect());
93 emit q->sceneRectChanged();
96 void containmentDestroyed()
99 emit q->lostContainment();
102 void containmentScreenChanged(
int wasScreen,
int newScreen,
Plasma::Containment *containment)
105 lastScreen = newScreen;
106 lastDesktop = containment->desktop();
109 void initGraphicsView()
111 q->setFrameShape(QFrame::NoFrame);
112 q->setAttribute(Qt::WA_TranslucentBackground);
113 q->setAutoFillBackground(
true);
114 q->setDragMode(QGraphicsView::NoDrag);
115 q->setInteractive(
true);
116 q->setAcceptDrops(
true);
117 q->setAlignment(Qt::AlignLeft | Qt::AlignTop);
118 q->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
119 q->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
122 static int s_maxViewId;
124 static QSet<int> viewIds;
131 bool drawWallpaper : 1;
132 bool trackChanges : 1;
136 int ViewPrivate::s_maxViewId(0);
137 QSet<int> ViewPrivate::viewIds;
141 d(new ViewPrivate(this, 0))
143 d->initGraphicsView();
146 setScene(containment->scene());
148 QTimer::singleShot(0,
this, SLOT(privateInit()));
154 d(new ViewPrivate(this, viewId))
156 d->initGraphicsView();
159 setScene(containment->scene());
161 QTimer::singleShot(0,
this, SLOT(privateInit()));
181 if (desktop < -1 || desktop > KWindowSystem::numberOfDesktops() - 1) {
189 if (d->containment &&
192 d->containment->setScreen(screen, desktop);
209 return d->lastScreen;
214 if (d->containment) {
215 return d->containment->desktop();
218 return d->lastDesktop;
224 return desk > -1 ? desk : KWindowSystem::currentDesktop();
229 if (d->init && containment == d->containment) {
233 if (d->containment) {
234 disconnect(d->containment, SIGNAL(destroyed(
QObject*)),
this, SLOT(containmentDestroyed()));
235 disconnect(d->containment, SIGNAL(geometryChanged()),
this, SLOT(updateSceneRect()));
237 d->containment->removeAssociatedWidget(
this);
247 int screen = d->lastScreen;
248 int desktop = d->lastDesktop;
249 if (oldContainment && oldContainment != containment) {
250 screen = oldContainment->
screen();
251 desktop = oldContainment->
desktop();
254 if (scene() != containment->scene()) {
255 setScene(containment->scene());
261 d->containment->addAssociatedWidget(
this);
263 int otherScreen = containment->
screen();
264 int otherDesktop = containment->
desktop();
270 if (oldContainment && oldContainment != containment) {
274 if (screen != containment->
screen() || desktop != containment->
desktop()) {
278 d->lastScreen = otherScreen;
279 d->lastDesktop = otherDesktop;
282 if (oldContainment && oldContainment != containment && otherScreen > -1 &&
283 (!containment || otherScreen != containment->
screen() || otherDesktop != containment->
desktop())) {
286 oldContainment->
setScreen(otherScreen, otherDesktop);
297 d->updateSceneRect();
298 connect(containment, SIGNAL(destroyed(
QObject*)),
this, SLOT(containmentDestroyed()));
299 connect(containment, SIGNAL(geometryChanged()),
this, SLOT(updateSceneRect()));
305 return d->containment;
325 KConfigGroup oldConfig = old->
config();
326 KConfigGroup newConfig = c->
config();
329 old->
save(oldConfig);
332 oldConfig.copyTo(&newConfig);
337 newConfig.deleteEntry(
"formfactor");
340 if (old == d->containment) {
366 KConfigGroup views(KGlobal::config(),
"PlasmaViews");
367 return KConfigGroup(&views, QString::number(d->viewId));
376 KGlobal::config()->sync();
388 d->drawWallpaper = draw;
393 return d->drawWallpaper;
398 d->trackChanges = trackChanges;
403 return d->trackChanges;
408 QWidget *w = QApplication::topLevelAt(pos);