add view id and config (the latter relying on the former)
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=794394
This commit is contained in:
parent
0cee130c4e
commit
30b0cef28a
35
view.cpp
35
view.cpp
@ -19,6 +19,7 @@
|
||||
|
||||
#include "view.h"
|
||||
|
||||
#include <KGlobal>
|
||||
#include <KWindowSystem>
|
||||
|
||||
#include "corona.h"
|
||||
@ -32,11 +33,16 @@ namespace Plasma
|
||||
class View::Private
|
||||
{
|
||||
public:
|
||||
Private()
|
||||
Private(int uniqueId)
|
||||
: drawWallpaper(true),
|
||||
desktop(-1),
|
||||
containment(0)
|
||||
{
|
||||
if (uniqueId == 0) {
|
||||
viewId = ++s_maxViewId;
|
||||
} else if (uniqueId > s_maxViewId) {
|
||||
s_maxViewId = uniqueId;
|
||||
}
|
||||
}
|
||||
|
||||
~Private()
|
||||
@ -45,12 +51,26 @@ public:
|
||||
|
||||
bool drawWallpaper;
|
||||
int desktop;
|
||||
int viewId;
|
||||
Plasma::Containment *containment;
|
||||
static int s_maxViewId;
|
||||
};
|
||||
|
||||
int View::Private::s_maxViewId(0);
|
||||
|
||||
View::View(Containment *containment, QWidget *parent)
|
||||
: QGraphicsView(parent),
|
||||
d(new Private)
|
||||
d(new Private(0))
|
||||
{
|
||||
Q_ASSERT(containment);
|
||||
initGraphicsView();
|
||||
setScene(containment->scene());
|
||||
setContainment(containment);
|
||||
}
|
||||
|
||||
View::View(Containment *containment, int viewId, QWidget *parent)
|
||||
: QGraphicsView(parent),
|
||||
d(new Private(viewId))
|
||||
{
|
||||
Q_ASSERT(containment);
|
||||
initGraphicsView();
|
||||
@ -159,6 +179,17 @@ Containment* View::containment() const
|
||||
return d->containment;
|
||||
}
|
||||
|
||||
KConfigGroup View::config() const
|
||||
{
|
||||
KConfigGroup views(KGlobal::config(), "PlasmaViews");
|
||||
return KConfigGroup(&views, QString::number(d->viewId));
|
||||
}
|
||||
|
||||
int View::id() const
|
||||
{
|
||||
return d->viewId;
|
||||
}
|
||||
|
||||
void View::setDrawWallpaper(bool draw)
|
||||
{
|
||||
d->drawWallpaper = draw;
|
||||
|
35
view.h
35
view.h
@ -22,6 +22,8 @@
|
||||
|
||||
#include <QtGui/QGraphicsView>
|
||||
|
||||
#include <KDE/KConfigGroup>
|
||||
|
||||
#include <plasma/plasma_export.h>
|
||||
|
||||
namespace Plasma
|
||||
@ -31,14 +33,35 @@ class Containment;
|
||||
class Corona;
|
||||
|
||||
/**
|
||||
* @short A QGraphicsView for Plasma::Applets
|
||||
* @short A QGraphicsView for Plasma::Applets. Each View is associated with
|
||||
* a Plasma::Containment and tracks geometry changes, maps to the current desktop
|
||||
* (if any) among other helpful utilities. It isn't stricly required to use
|
||||
* a Plasma::View with Plasma enabled applications, but it can make some
|
||||
* things easier.
|
||||
*/
|
||||
class PLASMA_EXPORT View : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructs a view for a given contanment. An Id is automatically
|
||||
* assigned to the View.
|
||||
*
|
||||
* @arg containment the containment to center the view on
|
||||
* @arg parent the parent object for this view
|
||||
*/
|
||||
explicit View(Containment *containment, QWidget *parent = 0);
|
||||
|
||||
/**
|
||||
* Constructs a view for a given contanment.
|
||||
*
|
||||
* @arg containment the containment to center the view on
|
||||
* @arg viewId the id to assign to this view
|
||||
* @arg parent the parent object for this view
|
||||
*/
|
||||
View(Containment *containment, int viewId, QWidget *parent = 0);
|
||||
|
||||
~View();
|
||||
|
||||
/**
|
||||
@ -101,6 +124,16 @@ public:
|
||||
*/
|
||||
Containment* containment() const;
|
||||
|
||||
/**
|
||||
* @return a KConfigGroup for this application unique to the view
|
||||
*/
|
||||
KConfigGroup config() const;
|
||||
|
||||
/**
|
||||
* @return the id of the View set in the constructor
|
||||
*/
|
||||
int id() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted whenever the containment being viewed has
|
||||
|
Loading…
x
Reference in New Issue
Block a user