2007-11-15 09:22:58 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2007 Aaron Seigo <aseigo@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2008-08-06 11:19:29 +02:00
|
|
|
#ifndef PLASMA_VIEW_H
|
|
|
|
#define PLASMA_VIEW_H
|
2007-11-15 09:22:58 +01:00
|
|
|
|
2008-05-12 11:18:47 +02:00
|
|
|
#include <QtGui/QApplication>
|
2007-11-15 09:22:58 +01:00
|
|
|
#include <QtGui/QGraphicsView>
|
|
|
|
|
2008-04-07 11:17:10 +02:00
|
|
|
#include <KDE/KConfigGroup>
|
|
|
|
|
2007-11-15 09:22:58 +01:00
|
|
|
#include <plasma/plasma_export.h>
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class Containment;
|
|
|
|
class Corona;
|
2008-07-01 20:56:43 +02:00
|
|
|
class ViewPrivate;
|
2007-11-15 09:22:58 +01:00
|
|
|
|
|
|
|
/**
|
2008-04-07 11:17:10 +02:00
|
|
|
* @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.
|
2007-11-15 09:22:58 +01:00
|
|
|
*/
|
|
|
|
class PLASMA_EXPORT View : public QGraphicsView
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2008-04-07 11:17:10 +02:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2007-11-15 09:22:58 +01:00
|
|
|
explicit View(Containment *containment, QWidget *parent = 0);
|
2008-04-07 11:17:10 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2007-11-15 09:22:58 +01:00
|
|
|
~View();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets whether or not to draw the containment wallpaper when painting
|
|
|
|
* on this item
|
|
|
|
*/
|
2008-04-18 19:40:57 +02:00
|
|
|
void setWallpaperEnabled(bool draw);
|
2007-11-15 09:22:58 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return whether or not containments should draw wallpaper
|
|
|
|
*/
|
2008-04-18 19:40:57 +02:00
|
|
|
bool isWallpaperEnabled() const;
|
2007-11-15 09:22:58 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets which screen this view is associated with, if any.
|
|
|
|
* This will also set the containment if a valid screen is specified
|
|
|
|
*
|
|
|
|
* @arg screen the xinerama screen number; -1 for no screen
|
|
|
|
*/
|
|
|
|
void setScreen(int screen);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the screen this view is associated with
|
|
|
|
*
|
|
|
|
* @return the xinerama screen number, or -1 for none
|
|
|
|
*/
|
|
|
|
int screen() const;
|
|
|
|
|
2008-02-23 00:41:44 +01:00
|
|
|
/**
|
|
|
|
* Sets which virtual desktop this view is asociated with, if any.
|
|
|
|
*
|
|
|
|
* @arg desktop a valid desktop number, -1 for all desktops, less than -1 for none
|
|
|
|
*/
|
|
|
|
void setDesktop(int desktop);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The virtual desktop this view is associated with
|
|
|
|
*
|
|
|
|
* @return the desktop number, -1 for all desktops and less than -1 for none
|
|
|
|
*/
|
|
|
|
int desktop() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The virtual desktop this view is actually being viewed on
|
|
|
|
*
|
|
|
|
* @return the desktop number (always valid, never < 0)
|
|
|
|
*/
|
|
|
|
int effectiveDesktop() const;
|
|
|
|
|
2007-11-15 09:22:58 +01:00
|
|
|
/**
|
|
|
|
* @return the containment associated with this view, or 0 if none is
|
|
|
|
*/
|
|
|
|
Containment* containment() const;
|
|
|
|
|
2008-08-20 10:07:09 +02:00
|
|
|
/**
|
|
|
|
* Swap the containment for this view, which will also cause the view
|
|
|
|
* to track the geometry of the containment.
|
|
|
|
*
|
|
|
|
* @param name the plugin name for the new containment.
|
|
|
|
* @param args argument list to pass to the containment
|
|
|
|
*/
|
2008-08-20 15:13:03 +02:00
|
|
|
Containment* swapContainment(const QString& name,
|
2008-08-20 10:07:09 +02:00
|
|
|
const QVariantList& args = QVariantList());
|
|
|
|
|
2008-04-28 21:14:28 +02:00
|
|
|
/**
|
2008-05-23 17:43:49 +02:00
|
|
|
* Set whether or not the view should adjust its size when the associated
|
|
|
|
* containment does.
|
|
|
|
* @arg trackChanges true to syncronize the view's size with the containment's
|
|
|
|
* (this is the default behaviour), false to ignore containment size changes
|
2008-04-28 21:14:28 +02:00
|
|
|
*/
|
|
|
|
void setTrackContainmentChanges(bool trackChanges);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return whether or not the view tracks changes to the containment
|
|
|
|
*/
|
|
|
|
bool trackContainmentChanges();
|
|
|
|
|
2008-05-12 00:02:35 +02:00
|
|
|
/**
|
|
|
|
* @param pos the position in screen coordinates.
|
|
|
|
* @return the Plasma::View that is at position pos.
|
|
|
|
*/
|
|
|
|
static View * topLevelViewAt(const QPoint & pos);
|
|
|
|
|
2008-04-07 11:17:10 +02:00
|
|
|
/**
|
|
|
|
* @return the id of the View set in the constructor
|
|
|
|
*/
|
|
|
|
int id() const;
|
|
|
|
|
2008-03-05 01:02:37 +01:00
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
|
|
|
* This signal is emitted whenever the containment being viewed has
|
|
|
|
* changed its geometry, but before the View has shifted the viewd scene rect
|
|
|
|
* to the new geometry. This is useful for Views which want to keep
|
|
|
|
* their rect() in sync with the containment'sa
|
|
|
|
*/
|
|
|
|
void sceneRectAboutToChange();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This signal is emitted whenever the containment being viewed has
|
|
|
|
* changed its geometry, and after the View has shifted the viewd scene rect
|
|
|
|
* to the new geometry. This is useful for Views which want to keep
|
|
|
|
* their rect() in sync with the containment's.
|
|
|
|
*/
|
|
|
|
void sceneRectChanged();
|
|
|
|
|
2008-05-21 08:16:45 +02:00
|
|
|
public Q_SLOTS:
|
|
|
|
/**
|
|
|
|
* Sets the containment for this view, which will also cause the view
|
|
|
|
* to track the geometry of the containment.
|
|
|
|
*
|
|
|
|
* @arg containment the containment to center the view on
|
|
|
|
*/
|
|
|
|
virtual void setContainment(Containment *containment);
|
|
|
|
|
2008-04-18 19:40:57 +02:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* @return a KConfigGroup in the application's config file unique to the view
|
|
|
|
*/
|
|
|
|
KConfigGroup config() const;
|
2007-11-15 10:15:53 +01:00
|
|
|
|
2007-11-15 09:22:58 +01:00
|
|
|
private:
|
2008-07-01 20:56:43 +02:00
|
|
|
ViewPrivate * const d;
|
2008-04-18 19:40:57 +02:00
|
|
|
|
|
|
|
Q_PRIVATE_SLOT(d, void updateSceneRect())
|
2008-07-01 20:56:43 +02:00
|
|
|
|
|
|
|
friend class ViewPrivate;
|
2007-11-15 09:22:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|