Do not paint anything inheriting Widget and do not paint LineEdit when in desktop view. LineEdit is currently just a temporary solution, because it doesn't inherit Widget for some reason.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=695323
This commit is contained in:
parent
8ccfa4e4dd
commit
d40669a2d2
@ -81,7 +81,7 @@ QPen Label::pen() const
|
||||
return d->textPen;
|
||||
}
|
||||
|
||||
void Label::paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
void Label::paintWidget(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
@ -101,7 +101,7 @@ class PLASMA_EXPORT Label : public Plasma::Widget
|
||||
/**
|
||||
* Paint function.
|
||||
*/
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include <QStyleOptionFrameV2>
|
||||
#include <QTextDocument>
|
||||
#include <QKeyEvent>
|
||||
#include <QPainter>
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
namespace Plasma
|
||||
@ -39,8 +41,15 @@ class LineEdit::Private
|
||||
bool styled;
|
||||
bool multiline;
|
||||
|
||||
bool shouldPaint(QPainter *painter, const QTransform &transform);
|
||||
};
|
||||
|
||||
bool LineEdit::Private::shouldPaint(QPainter *painter, const QTransform &transform)
|
||||
{
|
||||
qreal zoomLevel = painter->transform().m11() / transform.m11();
|
||||
return zoomLevel == scalingFactor(Plasma::DesktopZoom);
|
||||
}
|
||||
|
||||
LineEdit::LineEdit(QGraphicsItem *parent, QGraphicsScene *scene)
|
||||
: QGraphicsTextItem(parent, scene),
|
||||
d(new Private())
|
||||
@ -56,6 +65,15 @@ LineEdit::~LineEdit()
|
||||
}
|
||||
|
||||
void LineEdit::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
//TODO: Deal with paint and shouldPaint, since they are just copies of the ones in Widget
|
||||
if (d->shouldPaint(painter, transform())) {
|
||||
paintWidget(painter, option, widget);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void LineEdit::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
QStyleOptionFrameV2 panel;
|
||||
panel.initFrom(widget);
|
||||
|
@ -43,6 +43,7 @@ class PLASMA_EXPORT LineEdit : public QGraphicsTextItem, public LayoutItem
|
||||
~LineEdit();
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
|
||||
Qt::Orientations expandingDirections() const;
|
||||
|
||||
|
@ -81,7 +81,7 @@ void PushButton::updated(const QString&, const DataEngine::Data &data)
|
||||
Q_UNUSED(data)
|
||||
}
|
||||
|
||||
void PushButton::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
void PushButton::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
QStyleOptionButton options;
|
||||
options.initFrom(widget);
|
||||
|
@ -90,7 +90,7 @@ class PLASMA_EXPORT PushButton : public QObject,
|
||||
/**
|
||||
* Paint function.
|
||||
*/
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
virtual void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
|
||||
/**
|
||||
* Reimplemented from Plasma::Widget.
|
||||
|
@ -38,7 +38,7 @@ Qt::Orientations Rectangle::expandingDirections() const
|
||||
return Qt::Horizontal | Qt::Vertical;
|
||||
}
|
||||
|
||||
void Rectangle::paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
void Rectangle::paintWidget(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
@ -31,7 +31,7 @@ class PLASMA_EXPORT Rectangle : public Plasma::Widget
|
||||
|
||||
Qt::Orientations expandingDirections() const;
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
@ -23,8 +23,10 @@
|
||||
#include <KDebug>
|
||||
|
||||
#include <QtCore/QList>
|
||||
#include <QPainter>
|
||||
|
||||
#include "layout.h"
|
||||
#include "plasma/plasma.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
@ -43,8 +45,16 @@ class Widget::Private
|
||||
|
||||
Widget *parent;
|
||||
QList<Widget *> childList;
|
||||
|
||||
bool shouldPaint(QPainter *painter, const QTransform &transform);
|
||||
};
|
||||
|
||||
bool Widget::Private::shouldPaint(QPainter *painter, const QTransform &transform)
|
||||
{
|
||||
qreal zoomLevel = painter->transform().m11() / transform.m11();
|
||||
return zoomLevel == scalingFactor(Plasma::DesktopZoom);
|
||||
}
|
||||
|
||||
Widget::Widget(QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent),
|
||||
d(new Private)
|
||||
@ -199,13 +209,20 @@ void Widget::addChild(Widget *w)
|
||||
}
|
||||
|
||||
void Widget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
if (d->shouldPaint(painter, transform())) {
|
||||
paintWidget(painter, option, widget);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void Widget::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
// do nothing, but we need to reimp so we can create Widget items as this method
|
||||
// is pure virtual in QGraphicsItem
|
||||
// Replaced by widget's own function
|
||||
}
|
||||
|
||||
void Widget::reparent(Widget *w)
|
||||
|
@ -177,9 +177,14 @@ class PLASMA_EXPORT Widget : public QGraphicsItem,
|
||||
void addChild(Widget *w);
|
||||
|
||||
/**
|
||||
* Paint function. Reimplement to draw on this Widget.
|
||||
* Paint function.
|
||||
*/
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
|
||||
/**
|
||||
* Paints the widget. Called by the paint function under correct conditions.
|
||||
*/
|
||||
virtual void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
Loading…
Reference in New Issue
Block a user