Applied some of the API changes to Plasma::View:
- renamed drawWallpaper - made config() protected - moved updateSceneRect() and initGraphicsView to pimpl svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=798623
This commit is contained in:
parent
1e77632048
commit
f27fb3fc1b
@ -1022,7 +1022,7 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
|
|||||||
if (widget && isContainment()) {
|
if (widget && isContainment()) {
|
||||||
// note that the widget we get is actually the viewport of the view, not the view itself
|
// note that the widget we get is actually the viewport of the view, not the view itself
|
||||||
View* v = qobject_cast<Plasma::View*>(widget->parent());
|
View* v = qobject_cast<Plasma::View*>(widget->parent());
|
||||||
if (!v || v->drawWallpaper()) {
|
if (!v || v->isWallpaperEnabled()) {
|
||||||
Containment::StyleOption coption(*option);
|
Containment::StyleOption coption(*option);
|
||||||
|
|
||||||
if (v) {
|
if (v) {
|
||||||
|
76
view.cpp
76
view.cpp
@ -33,10 +33,12 @@ namespace Plasma
|
|||||||
class View::Private
|
class View::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private(int uniqueId)
|
Private(View *view, int uniqueId)
|
||||||
: drawWallpaper(true),
|
: drawWallpaper(true),
|
||||||
desktop(-1),
|
desktop(-1),
|
||||||
containment(0)
|
containment(0),
|
||||||
|
q(view)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (uniqueId == 0) {
|
if (uniqueId == 0) {
|
||||||
viewId = ++s_maxViewId;
|
viewId = ++s_maxViewId;
|
||||||
@ -50,10 +52,39 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateSceneRect()
|
||||||
|
{
|
||||||
|
if (!containment) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
kDebug() << "!!!!!!!!!!!!!!!!! setting the scene rect to"
|
||||||
|
<< containment->sceneBoundingRect()
|
||||||
|
<< "associated screen is" << containment->screen();
|
||||||
|
|
||||||
|
emit q->sceneRectAboutToChange();
|
||||||
|
q->setSceneRect(containment->sceneBoundingRect());
|
||||||
|
emit q->sceneRectChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void initGraphicsView()
|
||||||
|
{
|
||||||
|
q->setFrameShape(QFrame::NoFrame);
|
||||||
|
q->setAutoFillBackground(true);
|
||||||
|
q->setDragMode(QGraphicsView::NoDrag);
|
||||||
|
//setCacheMode(QGraphicsView::CacheBackground);
|
||||||
|
q->setInteractive(true);
|
||||||
|
q->setAcceptDrops(true);
|
||||||
|
q->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||||
|
q->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
q->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
}
|
||||||
|
|
||||||
bool drawWallpaper;
|
bool drawWallpaper;
|
||||||
int desktop;
|
int desktop;
|
||||||
int viewId;
|
int viewId;
|
||||||
Plasma::Containment *containment;
|
Plasma::Containment *containment;
|
||||||
|
Plasma::View *q;
|
||||||
static int s_maxViewId;
|
static int s_maxViewId;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -61,36 +92,24 @@ int View::Private::s_maxViewId(0);
|
|||||||
|
|
||||||
View::View(Containment *containment, QWidget *parent)
|
View::View(Containment *containment, QWidget *parent)
|
||||||
: QGraphicsView(parent),
|
: QGraphicsView(parent),
|
||||||
d(new Private(0))
|
d(new Private(this, 0))
|
||||||
{
|
{
|
||||||
Q_ASSERT(containment);
|
Q_ASSERT(containment);
|
||||||
initGraphicsView();
|
d->initGraphicsView();
|
||||||
setScene(containment->scene());
|
setScene(containment->scene());
|
||||||
setContainment(containment);
|
setContainment(containment);
|
||||||
}
|
}
|
||||||
|
|
||||||
View::View(Containment *containment, int viewId, QWidget *parent)
|
View::View(Containment *containment, int viewId, QWidget *parent)
|
||||||
: QGraphicsView(parent),
|
: QGraphicsView(parent),
|
||||||
d(new Private(viewId))
|
d(new Private(this, viewId))
|
||||||
{
|
{
|
||||||
Q_ASSERT(containment);
|
Q_ASSERT(containment);
|
||||||
initGraphicsView();
|
d->initGraphicsView();
|
||||||
setScene(containment->scene());
|
setScene(containment->scene());
|
||||||
setContainment(containment);
|
setContainment(containment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::initGraphicsView()
|
|
||||||
{
|
|
||||||
setFrameShape(QFrame::NoFrame);
|
|
||||||
setAutoFillBackground(true);
|
|
||||||
setDragMode(QGraphicsView::NoDrag);
|
|
||||||
//setCacheMode(QGraphicsView::CacheBackground);
|
|
||||||
setInteractive(true);
|
|
||||||
setAcceptDrops(true);
|
|
||||||
setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
}
|
|
||||||
|
|
||||||
View::~View()
|
View::~View()
|
||||||
{
|
{
|
||||||
@ -171,7 +190,7 @@ void View::setContainment(Containment *containment)
|
|||||||
d->desktop = -1;
|
d->desktop = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSceneRect();
|
d->updateSceneRect();
|
||||||
connect(containment, SIGNAL(geometryChanged()), this, SLOT(updateSceneRect()));
|
connect(containment, SIGNAL(geometryChanged()), this, SLOT(updateSceneRect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,31 +210,16 @@ int View::id() const
|
|||||||
return d->viewId;
|
return d->viewId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::setDrawWallpaper(bool draw)
|
void View::setWallpaperEnabled(bool draw)
|
||||||
{
|
{
|
||||||
d->drawWallpaper = draw;
|
d->drawWallpaper = draw;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool View::drawWallpaper() const
|
bool View::isWallpaperEnabled() const
|
||||||
{
|
{
|
||||||
return d->drawWallpaper;
|
return d->drawWallpaper;
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::updateSceneRect()
|
|
||||||
{
|
|
||||||
if (!d->containment) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
kDebug() << "!!!!!!!!!!!!!!!!! setting the scene rect to"
|
|
||||||
<< d->containment->sceneBoundingRect()
|
|
||||||
<< "associated screen is" << d->containment->screen();
|
|
||||||
|
|
||||||
emit sceneRectAboutToChange();
|
|
||||||
setSceneRect(d->containment->sceneBoundingRect());
|
|
||||||
emit sceneRectChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
|
||||||
#include "view.moc"
|
#include "view.moc"
|
||||||
|
20
view.h
20
view.h
@ -68,12 +68,12 @@ public:
|
|||||||
* Sets whether or not to draw the containment wallpaper when painting
|
* Sets whether or not to draw the containment wallpaper when painting
|
||||||
* on this item
|
* on this item
|
||||||
*/
|
*/
|
||||||
void setDrawWallpaper(bool draw);
|
void setWallpaperEnabled(bool draw);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return whether or not containments should draw wallpaper
|
* @return whether or not containments should draw wallpaper
|
||||||
*/
|
*/
|
||||||
bool drawWallpaper() const;
|
bool isWallpaperEnabled() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets which screen this view is associated with, if any.
|
* Sets which screen this view is associated with, if any.
|
||||||
@ -124,11 +124,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
Containment* containment() const;
|
Containment* containment() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a KConfigGroup in the application's config file unique to the view
|
|
||||||
*/
|
|
||||||
KConfigGroup config() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the id of the View set in the constructor
|
* @return the id of the View set in the constructor
|
||||||
*/
|
*/
|
||||||
@ -151,14 +146,17 @@ Q_SIGNALS:
|
|||||||
*/
|
*/
|
||||||
void sceneRectChanged();
|
void sceneRectChanged();
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected:
|
||||||
void updateSceneRect();
|
/**
|
||||||
|
* @return a KConfigGroup in the application's config file unique to the view
|
||||||
|
*/
|
||||||
|
KConfigGroup config() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initGraphicsView();
|
|
||||||
|
|
||||||
class Private;
|
class Private;
|
||||||
Private * const d;
|
Private * const d;
|
||||||
|
|
||||||
|
Q_PRIVATE_SLOT(d, void updateSceneRect())
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
Loading…
Reference in New Issue
Block a user