2 * Copyright 2007 Aaron Seigo <aseigo@kde.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include <KWindowSystem>
25 #include "containment.h"
27 using namespace Plasma
;
36 : drawWallpaper(true),
48 Plasma::Containment
*containment
;
51 View::View(int screen
, Corona
*corona
, QWidget
*parent
)
52 : QGraphicsView(parent
),
60 View::View(Containment
*containment
, QWidget
*parent
)
61 : QGraphicsView(parent
),
64 Q_ASSERT(containment
);
66 setScene(containment
->scene());
67 setContainment(containment
);
70 void View::initGraphicsView()
72 setFrameShape(QFrame::NoFrame
);
73 setAutoFillBackground(true);
74 setDragMode(QGraphicsView::NoDrag
);
75 //setCacheMode(QGraphicsView::CacheBackground);
78 setAlignment(Qt::AlignLeft
| Qt::AlignTop
);
79 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff
);
80 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff
);
88 void View::setScreen(int screen
)
91 Corona
*corona
= qobject_cast
<Corona
*>(scene());
97 setContainment(corona
->containmentForScreen(screen
));
98 if (d
->desktop
< -1) {
99 // we want to set it to "all desktops" if we get ownership of
100 // a screen but don't have a desktop set
106 int View::screen() const
108 return d
->containment
->screen();
111 void View::setDesktop(int desktop
)
113 // -1 == All desktops
114 if (desktop
< -1 || desktop
> KWindowSystem::numberOfDesktops() - 1) {
118 d
->desktop
= desktop
;
121 int View::desktop() const
126 int View::effectiveDesktop() const
128 return d
->desktop
> -1 ? d
->desktop
: KWindowSystem::currentDesktop();
131 void View::setContainment(Containment
*containment
)
137 if (d
->containment
) {
138 disconnect(d
->containment
, SIGNAL(geometryChanged()), this, SLOT(updateSceneRect()));
141 d
->containment
= containment
;
143 connect(containment
, SIGNAL(geometryChanged()), this, SLOT(updateSceneRect()));
146 Containment
* View::containment() const
148 return d
->containment
;
151 void View::setDrawWallpaper(bool draw
)
153 d
->drawWallpaper
= draw
;
156 bool View::drawWallpaper() const
158 return d
->drawWallpaper
;
161 void View::updateSceneRect()
163 setSceneRect(d
->containment
->sceneBoundingRect());
166 } // namespace Plasma