bye bye GLApplet

This commit is contained in:
Aaron Seigo 2011-05-12 22:37:40 +02:00
parent d43e4c9066
commit 2aa942777e
3 changed files with 0 additions and 318 deletions

View File

@ -228,13 +228,6 @@ kde4_add_ui_files(plasma_LIB_SRCS
# TEST_INCLUDES
#)
if (QT_QTOPENGL_FOUND)
message(STATUS "Adding support for OpenGL applets to libplasma")
set(plasma_LIB_SRCS
${plasma_LIB_SRCS}
glapplet.cpp)
endif(QT_QTOPENGL_FOUND)
if (PHONON_FOUND)
message(STATUS "Adding support for Phonon to libplasma")
include_directories(${KDE4_PHONON_INCLUDES})
@ -265,10 +258,6 @@ if(DL_LIBRARY)
target_link_libraries(plasma ${DL_LIBRARY})
endif(DL_LIBRARY)
if(QT_QTOPENGL_FOUND)
target_link_libraries(plasma ${QT_QTOPENGL_LIBRARY})
endif(QT_QTOPENGL_FOUND)
target_link_libraries(plasma LINK_INTERFACE_LIBRARIES kdeui kdecore ${QT_QTGUI_LIBRARY})
#do NOT use GENERIC versioning -- the plasma team will take care of versioning
@ -348,12 +337,6 @@ if(NOT KDE_NO_DEPRECATED)
endif(NOT KDE_NO_DEPRECATED)
if(QT_QTOPENGL_FOUND)
set(plasma_LIB_INCLUDES
${plasma_LIB_INCLUDES}
glapplet.h)
endif(QT_QTOPENGL_FOUND)
install(FILES
${plasma_LIB_INCLUDES}
DESTINATION ${INCLUDE_INSTALL_DIR}/plasma COMPONENT Devel)

View File

@ -1,213 +0,0 @@
/*
* Copyright 2007 Zack Rusin <zack@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.
*/
#include "glapplet.h"
#include <QtOpenGL/QGLPixelBuffer>
#include <QtGui/QPainter>
#include <QtGui/QImage>
namespace Plasma {
class GLAppletPrivate
{
public:
GLAppletPrivate()
{
init();
}
~GLAppletPrivate()
{
delete pbuf;
delete dummy;
}
void init()
{
dummy = new QGLWidget((QWidget *) 0);
QGLFormat format = QGLFormat::defaultFormat();
format.setSampleBuffers(true);
format.setAlphaBufferSize(8);
//dummy size construction
pbuf = new QGLPixelBuffer(300, 300, format, dummy);
if (pbuf->isValid()) {
pbuf->makeCurrent();
}
}
void updateGlSize(const QSize &size)
{
if (size.width() > pbuf->width() ||
size.height() > pbuf->height()) {
QGLFormat format = pbuf->format();
delete pbuf;
pbuf = new QGLPixelBuffer(size, format, dummy);
}
}
public:
QGLPixelBuffer *pbuf;
QGLWidget *dummy;
};
GLApplet::GLApplet(QGraphicsItem *parent,
const QString &serviceId,
int appletId)
: Applet(parent, serviceId, appletId),
d(new GLAppletPrivate)
{
if (!d->dummy->isValid() ||
!QGLPixelBuffer::hasOpenGLPbuffers() ||
!d->pbuf->isValid()) {
setFailedToLaunch(true, i18n("This system does not support OpenGL widgets."));
}
}
GLApplet::GLApplet(QObject *parent, const QVariantList &args)
: Applet(parent, args),
d(new GLAppletPrivate)
{
if (!d->dummy->isValid() ||
!QGLPixelBuffer::hasOpenGLPbuffers() ||
!d->pbuf->isValid()) {
setFailedToLaunch(true, i18n("This system does not support OpenGL widgets."));
}
}
GLApplet::~GLApplet()
{
delete d;
}
GLuint GLApplet::bindTexture(const QImage &image, GLenum target)
{
Q_ASSERT(d->pbuf);
if (!d->dummy->isValid()) {
return 0;
}
return d->dummy->bindTexture(image, target);
}
void GLApplet::deleteTexture(GLuint textureId)
{
Q_ASSERT(d->pbuf);
d->dummy->deleteTexture(textureId);
}
void GLApplet::paintGLInterface(QPainter *painter,
const QStyleOptionGraphicsItem *option)
{
Q_UNUSED(painter)
Q_UNUSED(option)
}
static inline QPainterPath headerPath(const QRectF &r, int roundness,
int headerHeight=10)
{
QPainterPath path;
int xRnd = roundness;
int yRnd = roundness;
if (r.width() > r.height()) {
xRnd = int(roundness * r.height() / r.width());
} else {
yRnd = int(roundness * r.width() / r.height());
}
if(xRnd >= 100) { // fix ranges
xRnd = 99;
}
if(yRnd >= 100) {
yRnd = 99;
}
if(xRnd <= 0 || yRnd <= 0) { // add normal rectangle
path.addRect(r);
return path;
}
QRectF rect = r.normalized();
if (rect.isNull()) {
return path;
}
qreal x = rect.x();
qreal y = rect.y();
qreal w = rect.width();
qreal h = rect.height();
qreal rxx = w * xRnd / 200;
qreal ryy = h * yRnd / 200;
// were there overflows?
if (rxx < 0) {
rxx = w / 200 * xRnd;
}
if (ryy < 0) {
ryy = h / 200 * yRnd;
}
qreal rxx2 = 2 * rxx;
qreal ryy2 = 2 * ryy;
path.arcMoveTo(x, y, rxx2, ryy2, 90);
path.arcTo(x, y, rxx2, ryy2, 90, 90);
QPointF pt = path.currentPosition();
path.lineTo(x, pt.y() + headerHeight);
path.lineTo(x + w, pt.y() + headerHeight);
path.lineTo(x + w, pt.y());
path.arcTo(x + w - rxx2, y, rxx2, ryy2, 0, 90);
path.closeSubpath();
return path;
}
void GLApplet::paintInterface(QPainter *painter,
const QStyleOptionGraphicsItem *option,
const QRect &contentsRect)
{
Q_UNUSED(contentsRect)
Q_ASSERT(d->pbuf);
if ((!d->dummy->isValid() ||
!d->pbuf->isValid())) {
if (!hasFailedToLaunch()) {
setFailedToLaunch(true, i18n("Your machine does not support OpenGL widgets."));
}
return;
}
d->pbuf->makeCurrent();
QMatrix m = painter->worldMatrix();
QRect deviceRect = m.mapRect(QRect(QPoint(23, 25), boundingRect().size().toSize()));
d->updateGlSize(deviceRect.size());
// redirect this widget's painting into the pbuffer
QPainter p(d->pbuf);
paintGLInterface(&p, option);
// draw the pbuffer contents to the backingstore
QImage image = d->pbuf->toImage();
painter->drawImage(0, 0, image);
}
void GLApplet::makeCurrent()
{
if (!d->dummy->isValid() || !d->pbuf->isValid()) {
d->dummy->makeCurrent();
}
}
} // Plasma namespace
#include "glapplet.moc"

View File

@ -1,88 +0,0 @@
/*
* Copyright 2007 Zack Rusin <zack@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.
*/
#ifndef PLASMA_GLAPPLET_H
#define PLASMA_GLAPPLET_H
#include <plasma/applet.h>
#include <QtOpenGL/QGLWidget>
namespace Plasma
{
class GLAppletPrivate;
/**
* @class GLApplet plasma/glapplet.h <Plasma/GLApplet>
*
* @short Plasma Applet that is fully rendered using OpengGL
*/
class PLASMA_EXPORT_DEPRECATED GLApplet : public Applet
{
Q_OBJECT
public:
/**
* @arg parent the QGraphicsItem this applet is parented to
* @arg serviceId the name of the .desktop file containing the
* information about the widget
* @arg appletId a unique id used to differentiate between multiple
* instances of the same Applet type
*/
GLApplet(QGraphicsItem *parent,
const QString &serviceId,
int appletId);
/**
* This constructor is to be used with the plugin loading systems
* found in KPluginInfo and KService. The argument list is expected
* to have two elements: the KService service ID for the desktop entry
* and an applet ID which must be a base 10 number.
*
* @arg parent a QObject parent; you probably want to pass in 0
* @arg args a list of strings containing two entries: the service id
* and the applet id
*/
GLApplet(QObject *parent, const QVariantList &args);
~GLApplet();
GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D);
void deleteTexture(GLuint texture_id);
/**
* Reimplement this method to render using OpenGL. QPainter passed
* to this method will always use OpenGL engine and rendering
* using OpenGL api directly is supported.
*/
virtual void paintGLInterface(QPainter *painter,
const QStyleOptionGraphicsItem *option);
void makeCurrent();
private:
virtual void paintInterface(QPainter *painter,
const QStyleOptionGraphicsItem *option,
const QRect &contentsRect);
private:
GLAppletPrivate *const d;
};
}
#endif