coding style fixes.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=870205
This commit is contained in:
parent
a320742114
commit
eae853582b
@ -85,7 +85,7 @@ CheckBox::CheckBox(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new CheckBoxPrivate(this))
|
||||
{
|
||||
QCheckBox* native = new QCheckBox;
|
||||
QCheckBox *native = new QCheckBox;
|
||||
connect(native, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
|
||||
setWidget(native);
|
||||
d->setPalette();
|
||||
@ -151,7 +151,7 @@ QString CheckBox::styleSheet()
|
||||
return widget()->styleSheet();
|
||||
}
|
||||
|
||||
QCheckBox* CheckBox::nativeWidget() const
|
||||
QCheckBox *CheckBox::nativeWidget() const
|
||||
{
|
||||
return static_cast<QCheckBox*>(widget());
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_CHECKBOX_H
|
||||
#define PLASMA_CHECKBOX_H
|
||||
|
||||
@ -41,11 +40,11 @@ class PLASMA_EXPORT CheckBox : public QGraphicsProxyWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QGraphicsWidget* parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QGraphicsWidget *parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(QString image READ image WRITE setImage)
|
||||
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
||||
Q_PROPERTY(QCheckBox* nativeWidget READ nativeWidget)
|
||||
Q_PROPERTY(QCheckBox *nativeWidget READ nativeWidget)
|
||||
Q_PROPERTY(bool isChecked READ isChecked WRITE setChecked)
|
||||
|
||||
public:
|
||||
@ -54,7 +53,7 @@ public:
|
||||
|
||||
/**
|
||||
* Sets the display text for this CheckBox
|
||||
*
|
||||
*
|
||||
* @arg text the text to display; should be translated.
|
||||
*/
|
||||
void setText(const QString &text);
|
||||
@ -91,7 +90,7 @@ public:
|
||||
/**
|
||||
* @return the native widget wrapped by this CheckBox
|
||||
*/
|
||||
QCheckBox* nativeWidget() const;
|
||||
QCheckBox *nativeWidget() const;
|
||||
|
||||
/**
|
||||
* Sets the checked state.
|
||||
|
@ -61,7 +61,6 @@ public:
|
||||
QRectF activeRect;
|
||||
};
|
||||
|
||||
|
||||
void ComboBoxPrivate::syncActiveRect()
|
||||
{
|
||||
background->setElementPrefix("normal");
|
||||
@ -73,8 +72,9 @@ void ComboBoxPrivate::syncActiveRect()
|
||||
qreal activeLeft, activeTop, activeRight, activeBottom;
|
||||
background->getMargins(activeLeft, activeTop, activeRight, activeBottom);
|
||||
|
||||
activeRect = QRectF(QPointF(0,0), q->size());
|
||||
activeRect.adjust(left - activeLeft, top - activeTop, -(right - activeRight), -(bottom - activeBottom));
|
||||
activeRect = QRectF(QPointF(0, 0), q->size());
|
||||
activeRect.adjust(left - activeLeft, top - activeTop,
|
||||
-(right - activeRight), -(bottom - activeBottom));
|
||||
|
||||
background->setElementPrefix("normal");
|
||||
}
|
||||
@ -105,13 +105,11 @@ void ComboBoxPrivate::animationUpdate(qreal progress)
|
||||
q->update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
ComboBox::ComboBox(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new ComboBoxPrivate(this))
|
||||
{
|
||||
KComboBox* native = new KComboBox;
|
||||
KComboBox *native = new KComboBox;
|
||||
connect(native, SIGNAL(activated(const QString &)), this, SIGNAL(activated(const QString &)));
|
||||
setWidget(native);
|
||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||
@ -146,7 +144,7 @@ QString ComboBox::styleSheet()
|
||||
return widget()->styleSheet();
|
||||
}
|
||||
|
||||
KComboBox* ComboBox::nativeWidget() const
|
||||
KComboBox *ComboBox::nativeWidget() const
|
||||
{
|
||||
return static_cast<KComboBox*>(widget());
|
||||
}
|
||||
@ -177,12 +175,12 @@ void ComboBox::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
d->background->resizePanel(size());
|
||||
}
|
||||
|
||||
QGraphicsProxyWidget::resizeEvent(event);
|
||||
QGraphicsProxyWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void ComboBox::paint(QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
{
|
||||
if (!styleSheet().isNull() || nativeWidget()->isEditable()) {
|
||||
QGraphicsProxyWidget::paint(painter, option, widget);
|
||||
@ -206,9 +204,9 @@ void ComboBox::paint(QPainter *painter,
|
||||
QPainter buffPainter(&bufferPixmap);
|
||||
d->background->paintPanel(&buffPainter);
|
||||
buffPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||
buffPainter.fillRect(bufferPixmap.rect(), QColor(0,0,0,128));
|
||||
buffPainter.fillRect(bufferPixmap.rect(), QColor(0, 0, 0, 128));
|
||||
|
||||
painter->drawPixmap( 0, 0, bufferPixmap);
|
||||
painter->drawPixmap(0, 0, bufferPixmap);
|
||||
}
|
||||
|
||||
//if is under mouse draw the animated glow overlay
|
||||
@ -217,7 +215,9 @@ void ComboBox::paint(QPainter *painter,
|
||||
d->background->setElementPrefix("normal");
|
||||
QPixmap normalPix = d->background->panelPixmap();
|
||||
d->background->setElementPrefix("active");
|
||||
painter->drawPixmap(d->activeRect.topLeft(), PaintUtils::transition(d->background->panelPixmap(), normalPix, 1 - d->opacity));
|
||||
painter->drawPixmap(
|
||||
d->activeRect.topLeft(),
|
||||
PaintUtils::transition(d->background->panelPixmap(), normalPix, 1 - d->opacity));
|
||||
} else if (isUnderMouse()) {
|
||||
d->background->setElementPrefix("active");
|
||||
d->background->paintPanel(painter, d->activeRect.topLeft());
|
||||
@ -229,21 +229,26 @@ void ComboBox::paint(QPainter *painter,
|
||||
d->background->paintPanel(painter);
|
||||
}
|
||||
|
||||
|
||||
painter->setPen(Plasma::Theme::defaultTheme()->color(Theme::ButtonTextColor));
|
||||
|
||||
QStyleOptionComboBox comboOpt;
|
||||
|
||||
comboOpt.initFrom(nativeWidget());
|
||||
|
||||
comboOpt.palette.setColor(QPalette::ButtonText, Plasma::Theme::defaultTheme()->color(Plasma::Theme::ButtonTextColor));
|
||||
comboOpt.currentIcon = nativeWidget()->itemIcon(nativeWidget()->currentIndex());
|
||||
comboOpt.currentText = nativeWidget()->itemText(nativeWidget()->currentIndex());
|
||||
comboOpt.palette.setColor(
|
||||
QPalette::ButtonText, Plasma::Theme::defaultTheme()->color(Plasma::Theme::ButtonTextColor));
|
||||
comboOpt.currentIcon = nativeWidget()->itemIcon(
|
||||
nativeWidget()->currentIndex());
|
||||
comboOpt.currentText = nativeWidget()->itemText(
|
||||
nativeWidget()->currentIndex());
|
||||
comboOpt.editable = false;
|
||||
|
||||
nativeWidget()->style()->drawControl(QStyle::CE_ComboBoxLabel, &comboOpt, painter, nativeWidget());
|
||||
comboOpt.rect = nativeWidget()->style()->subControlRect(QStyle::CC_ComboBox, &comboOpt, QStyle::SC_ComboBoxArrow, nativeWidget());
|
||||
nativeWidget()->style()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &comboOpt, painter, nativeWidget());
|
||||
nativeWidget()->style()->drawControl(
|
||||
QStyle::CE_ComboBoxLabel, &comboOpt, painter, nativeWidget());
|
||||
comboOpt.rect = nativeWidget()->style()->subControlRect(
|
||||
QStyle::CC_ComboBox, &comboOpt, QStyle::SC_ComboBoxArrow, nativeWidget());
|
||||
nativeWidget()->style()->drawPrimitive(
|
||||
QStyle::PE_IndicatorArrowDown, &comboOpt, painter, nativeWidget());
|
||||
}
|
||||
|
||||
void ComboBox::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
@ -253,7 +258,9 @@ void ComboBox::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
if (d->animId != -1) {
|
||||
Plasma::Animator::self()->stopCustomAnimation(d->animId);
|
||||
}
|
||||
d->animId = Plasma::Animator::self()->customAnimation(40 / (1000 / FadeInDuration), FadeInDuration,Plasma::Animator::LinearCurve, this, "animationUpdate");
|
||||
d->animId = Plasma::Animator::self()->customAnimation(
|
||||
40 / (1000 / FadeInDuration), FadeInDuration,
|
||||
Plasma::Animator::LinearCurve, this, "animationUpdate");
|
||||
|
||||
d->background->setElementPrefix("active");
|
||||
|
||||
@ -269,7 +276,9 @@ void ComboBox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
}
|
||||
|
||||
d->fadeIn = false;
|
||||
d->animId = Plasma::Animator::self()->customAnimation(40 / (1000 / FadeOutDuration), FadeOutDuration,Plasma::Animator::LinearCurve, this, "animationUpdate");
|
||||
d->animId = Plasma::Animator::self()->customAnimation(
|
||||
40 / (1000 / FadeOutDuration),
|
||||
FadeOutDuration, Plasma::Animator::LinearCurve, this, "animationUpdate");
|
||||
|
||||
d->background->setElementPrefix("active");
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_COMBOBOX_H
|
||||
#define PLASMA_COMBOBOX_H
|
||||
|
||||
@ -41,10 +40,10 @@ class PLASMA_EXPORT ComboBox : public QGraphicsProxyWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QGraphicsWidget* parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QGraphicsWidget *parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QString text READ text)
|
||||
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
||||
Q_PROPERTY(KComboBox* nativeWidget READ nativeWidget)
|
||||
Q_PROPERTY(KComboBox *nativeWidget READ nativeWidget)
|
||||
|
||||
public:
|
||||
explicit ComboBox(QGraphicsWidget *parent = 0);
|
||||
@ -70,7 +69,7 @@ public:
|
||||
/**
|
||||
* @return the native widget wrapped by this ComboBox
|
||||
*/
|
||||
KComboBox* nativeWidget() const;
|
||||
KComboBox *nativeWidget() const;
|
||||
|
||||
/**
|
||||
* Adds an item to the combobox with the given text. The
|
||||
|
@ -37,8 +37,14 @@ using namespace Plasma;
|
||||
class Plasma::FlashPrivate
|
||||
{
|
||||
public:
|
||||
enum FlashType { Text, Pixmap };
|
||||
enum State { Visible, Invisible };
|
||||
enum FlashType {
|
||||
Text,
|
||||
Pixmap
|
||||
};
|
||||
enum State {
|
||||
Visible,
|
||||
Invisible
|
||||
};
|
||||
|
||||
FlashPrivate()
|
||||
: defaultDuration(3000),
|
||||
@ -76,7 +82,6 @@ class Plasma::FlashPrivate
|
||||
State state;
|
||||
};
|
||||
|
||||
|
||||
Flash::Flash(QGraphicsItem *parent)
|
||||
: QGraphicsWidget(parent),
|
||||
d(new FlashPrivate)
|
||||
@ -159,7 +164,8 @@ void Flash::fadeOut()
|
||||
}
|
||||
|
||||
d->state = FlashPrivate::Invisible;
|
||||
d->animId = Plasma::Animator::self()->animateElement(this, Plasma::Animator::DisappearAnimation);
|
||||
d->animId = Plasma::Animator::self()->animateElement(
|
||||
this, Plasma::Animator::DisappearAnimation);
|
||||
Plasma::Animator::self()->setInitialPixmap(d->animId, d->renderedPixmap);
|
||||
}
|
||||
|
||||
@ -199,7 +205,7 @@ void FlashPrivate::renderPixmap(const QSize &size)
|
||||
} else if (alignment & Qt::AlignRight) {
|
||||
p.setX(size.width() - pixmap.width());
|
||||
} else {
|
||||
p.setX((size.width() - pixmap.width())/2);
|
||||
p.setX((size.width() - pixmap.width()) / 2);
|
||||
}
|
||||
|
||||
if (alignment & Qt::AlignTop) {
|
||||
@ -207,7 +213,7 @@ void FlashPrivate::renderPixmap(const QSize &size)
|
||||
} else if (alignment & Qt::AlignRight) {
|
||||
p.setY(size.height() - pixmap.height());
|
||||
} else {
|
||||
p.setY((size.height() - pixmap.height())/2);
|
||||
p.setY((size.height() - pixmap.height()) / 2);
|
||||
}
|
||||
|
||||
painter.drawPixmap(p, pixmap);
|
||||
@ -236,5 +242,4 @@ void FlashPrivate::setupFlash(Flash *flash, int duration)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include "flash.moc"
|
||||
|
@ -45,12 +45,14 @@ class PLASMA_EXPORT Flash : public QGraphicsWidget
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
|
||||
void setFont( const QFont & );
|
||||
void setColor( const QColor & );
|
||||
void setDuration( int duration );
|
||||
void setFont(const QFont &);
|
||||
void setColor(const QColor &);
|
||||
void setDuration(int duration);
|
||||
|
||||
void flash( const QString &text, int duration = 0, const QTextOption &option = QTextOption(Qt::AlignCenter) );
|
||||
void flash( const QPixmap &pixmap, int duration = 0, Qt::Alignment align = Qt::AlignCenter );
|
||||
void flash(const QString &text, int duration = 0,
|
||||
const QTextOption &option = QTextOption(Qt::AlignCenter));
|
||||
void flash(const QPixmap &pixmap, int duration = 0,
|
||||
Qt::Alignment align = Qt::AlignCenter);
|
||||
|
||||
public Q_SLOTS:
|
||||
void kill();
|
||||
@ -60,7 +62,7 @@ class PLASMA_EXPORT Flash : public QGraphicsWidget
|
||||
void fadeOut();
|
||||
|
||||
private:
|
||||
FlashPrivate * const d;
|
||||
FlashPrivate *const d;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -65,7 +65,6 @@ public:
|
||||
QPixmap *pixmap;
|
||||
};
|
||||
|
||||
|
||||
void FramePrivate::syncBorders()
|
||||
{
|
||||
//set margins from the normal element
|
||||
@ -81,7 +80,6 @@ void FramePrivate::syncBorders()
|
||||
q->setContentsMargins(left, top, right, bottom);
|
||||
}
|
||||
|
||||
|
||||
Frame::Frame(QGraphicsWidget *parent)
|
||||
: QGraphicsWidget(parent),
|
||||
d(new FramePrivate(this))
|
||||
@ -147,7 +145,7 @@ void Frame::setImage(const QString &path)
|
||||
delete d->pixmap;
|
||||
d->pixmap = 0;
|
||||
|
||||
bool absolutePath = !path.isEmpty() &&
|
||||
bool absolutePath = !path.isEmpty() &&
|
||||
#ifdef Q_WS_WIN
|
||||
!QDir::isRelativePath(path)
|
||||
#else
|
||||
@ -192,7 +190,7 @@ QString Frame::styleSheet() const
|
||||
return d->styleSheet;
|
||||
}
|
||||
|
||||
QWidget* Frame::nativeWidget() const
|
||||
QWidget *Frame::nativeWidget() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -248,7 +246,6 @@ QSizeF Frame::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const
|
||||
return hint;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
#include <frame.moc>
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_FRAME_H
|
||||
#define PLASMA_FRAME_H
|
||||
|
||||
@ -110,7 +109,7 @@ public:
|
||||
/**
|
||||
* @return the native widget wrapped by this Label
|
||||
*/
|
||||
QWidget* nativeWidget() const;
|
||||
QWidget *nativeWidget() const;
|
||||
|
||||
protected:
|
||||
void paint(QPainter *painter,
|
||||
|
@ -46,7 +46,7 @@ GroupBox::GroupBox(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new GroupBoxPrivate)
|
||||
{
|
||||
QGroupBox* native = new QGroupBox;
|
||||
QGroupBox *native = new QGroupBox;
|
||||
setWidget(native);
|
||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||
}
|
||||
@ -76,7 +76,7 @@ QString GroupBox::styleSheet()
|
||||
return widget()->styleSheet();
|
||||
}
|
||||
|
||||
QGroupBox* GroupBox::nativeWidget() const
|
||||
QGroupBox *GroupBox::nativeWidget() const
|
||||
{
|
||||
return static_cast<QGroupBox*>(widget());
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_GROUPBOX_H
|
||||
#define PLASMA_GROUPBOX_H
|
||||
|
||||
@ -41,10 +40,10 @@ class PLASMA_EXPORT GroupBox : public QGraphicsProxyWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QGraphicsWidget* parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QGraphicsWidget *parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
||||
Q_PROPERTY(QGroupBox* nativeWidget READ nativeWidget)
|
||||
Q_PROPERTY(QGroupBox *nativeWidget READ nativeWidget)
|
||||
|
||||
public:
|
||||
explicit GroupBox(QGraphicsWidget *parent = 0);
|
||||
@ -52,7 +51,7 @@ public:
|
||||
|
||||
/**
|
||||
* Sets the display text for this GroupBox
|
||||
*
|
||||
*
|
||||
* @arg text the text to display; should be translated.
|
||||
*/
|
||||
void setText(const QString &text);
|
||||
@ -77,7 +76,7 @@ public:
|
||||
/**
|
||||
* @return the native widget wrapped by this GroupBox
|
||||
*/
|
||||
QGroupBox* nativeWidget() const;
|
||||
QGroupBox *nativeWidget() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
|
194
widgets/icon.cpp
194
widgets/icon.cpp
@ -64,7 +64,7 @@ IconPrivate::IconPrivate(Icon *i)
|
||||
iconSvg(0),
|
||||
m_fadeIn(false),
|
||||
m_hoverAnimId(-1),
|
||||
m_hoverAlpha(20/255),
|
||||
m_hoverAlpha(20 / 255),
|
||||
iconSize(48, 48),
|
||||
states(IconPrivate::NoState),
|
||||
orientation(Qt::Vertical),
|
||||
@ -81,14 +81,14 @@ IconPrivate::~IconPrivate()
|
||||
qDeleteAll(cornerActions);
|
||||
}
|
||||
|
||||
void Icon::readColors()
|
||||
void Icon::readColors()
|
||||
{
|
||||
d->textColor = Plasma::Theme::defaultTheme()->color(Theme::TextColor);
|
||||
d->shadowColor = Plasma::Theme::defaultTheme()->color(Theme::BackgroundColor);
|
||||
|
||||
}
|
||||
|
||||
IconAction::IconAction(Icon* icon, QAction *action)
|
||||
IconAction::IconAction(Icon *icon, QAction *action)
|
||||
: m_icon(icon),
|
||||
m_action(action),
|
||||
m_hovered(false),
|
||||
@ -186,27 +186,30 @@ void IconAction::rebuildPixmap()
|
||||
|
||||
bool IconAction::event(QEvent::Type type, const QPointF &pos)
|
||||
{
|
||||
if (m_icon->size().width() < m_rect.width()*2.0 ||
|
||||
m_icon->size().height() < m_rect.height()*2.0) {
|
||||
if (m_icon->size().width() < m_rect.width() * 2.0 ||
|
||||
m_icon->size().height() < m_rect.height() * 2.0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case QEvent::GraphicsSceneMousePress: {
|
||||
case QEvent::GraphicsSceneMousePress:
|
||||
{
|
||||
setSelected(m_rect.contains(pos));
|
||||
return isSelected();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case QEvent::GraphicsSceneMouseMove: {
|
||||
case QEvent::GraphicsSceneMouseMove:
|
||||
{
|
||||
bool wasSelected = isSelected();
|
||||
bool active = m_rect.contains(pos);
|
||||
setSelected(wasSelected && active);
|
||||
return (wasSelected != isSelected()) || active;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case QEvent::GraphicsSceneMouseRelease: {
|
||||
case QEvent::GraphicsSceneMouseRelease:
|
||||
{
|
||||
// kDebug() << "IconAction::event got a QEvent::MouseButtonRelease, " << isSelected();
|
||||
bool wasSelected = isSelected();
|
||||
setSelected(false);
|
||||
@ -215,8 +218,8 @@ bool IconAction::event(QEvent::Type type, const QPointF &pos)
|
||||
}
|
||||
|
||||
return wasSelected;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case QEvent::GraphicsSceneHoverEnter:
|
||||
m_pressed = false;
|
||||
@ -229,7 +232,7 @@ bool IconAction::event(QEvent::Type type, const QPointF &pos)
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -240,15 +243,15 @@ int IconAction::animationId() const
|
||||
return m_animationId;
|
||||
}
|
||||
|
||||
QAction* IconAction::action() const
|
||||
QAction *IconAction::action() const
|
||||
{
|
||||
return m_action;
|
||||
}
|
||||
|
||||
void IconAction::paint(QPainter *painter) const
|
||||
{
|
||||
if (m_icon->size().width() < m_rect.width()*2.0 ||
|
||||
m_icon->size().height() < m_rect.height()*2.0) {
|
||||
if (m_icon->size().width() < m_rect.width() * 2.0 ||
|
||||
m_icon->size().height() < m_rect.height() * 2.0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -323,7 +326,7 @@ void Icon::addIconAction(QAction *action)
|
||||
kDebug() << "no more room for more actions!";
|
||||
}
|
||||
|
||||
IconAction* iconAction = new IconAction(this, action);
|
||||
IconAction *iconAction = new IconAction(this, action);
|
||||
d->cornerActions.append(iconAction);
|
||||
connect(action, SIGNAL(destroyed(QObject*)), this, SLOT(actionDestroyed(QObject*)));
|
||||
|
||||
@ -344,12 +347,12 @@ void Icon::setAction(QAction *action)
|
||||
}
|
||||
}
|
||||
|
||||
QAction* Icon::action() const
|
||||
QAction *Icon::action() const
|
||||
{
|
||||
return d->action;
|
||||
}
|
||||
|
||||
void Icon::actionDestroyed(QObject* action)
|
||||
void Icon::actionDestroyed(QObject *action)
|
||||
{
|
||||
QList<IconAction*>::iterator it = d->cornerActions.begin();
|
||||
|
||||
@ -396,26 +399,27 @@ QPainterPath Icon::shape() const
|
||||
return QGraphicsItem::shape();
|
||||
}
|
||||
|
||||
return PaintUtils::roundedRectangle(QRectF(QPointF(0.0, 0.0), d->currentSize).adjusted(-2, -2, 2, 2), 10.0);
|
||||
return PaintUtils::roundedRectangle(
|
||||
QRectF(QPointF(0.0, 0.0), d->currentSize).adjusted(-2, -2, 2, 2), 10.0);
|
||||
}
|
||||
|
||||
QSizeF IconPrivate::displaySizeHint(const QStyleOptionGraphicsItem *option, const qreal width) const
|
||||
{
|
||||
if (text.isEmpty() && infoText.isEmpty()) {
|
||||
return QSizeF( .0, .0 );
|
||||
return QSizeF(.0, .0);
|
||||
}
|
||||
QString label = text;
|
||||
// const qreal maxWidth = (orientation == Qt::Vertical) ? iconSize.width() + 10 : 32757;
|
||||
// NOTE: find a way to use the other layoutText, it currently returns nominal width, when
|
||||
// we actually need the actual width.
|
||||
|
||||
|
||||
qreal textWidth = width -
|
||||
horizontalMargin[IconPrivate::TextMargin].left -
|
||||
horizontalMargin[IconPrivate::TextMargin].right;
|
||||
|
||||
//allow only five lines of text
|
||||
const qreal maxHeight = numDisplayLines*Plasma::Theme::defaultTheme()->fontMetrics().lineSpacing();
|
||||
const qreal maxHeight =
|
||||
numDisplayLines * Plasma::Theme::defaultTheme()->fontMetrics().lineSpacing();
|
||||
|
||||
// To compute the nominal size for the label + info, we'll just append
|
||||
// the information string to the label
|
||||
@ -451,7 +455,7 @@ void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
|
||||
d->verticalMargin[IconPrivate::TextMargin].top -
|
||||
d->verticalMargin[IconPrivate::TextMargin].bottom;
|
||||
//never make a label higher than half the total height
|
||||
heightAvail = qMax(heightAvail, d->currentSize.height()/2);
|
||||
heightAvail = qMax(heightAvail, d->currentSize.height() / 2);
|
||||
} else {
|
||||
heightAvail = d->currentSize.height();
|
||||
}
|
||||
@ -486,7 +490,7 @@ void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
|
||||
d->iconSize = QSizeF(iconWidth, iconWidth);
|
||||
|
||||
int count = 0;
|
||||
foreach (IconAction* iconAction, d->cornerActions) {
|
||||
foreach (IconAction *iconAction, d->cornerActions) {
|
||||
iconAction->setRect(d->actionRect((IconPrivate::ActionPosition)count));
|
||||
++count;
|
||||
}
|
||||
@ -515,12 +519,12 @@ void Icon::hoverEffect(bool show)
|
||||
if (d->m_hoverAnimId != -1) {
|
||||
Animator::self()->stopCustomAnimation(d->m_hoverAnimId);
|
||||
}
|
||||
d->m_hoverAnimId = Animator::self()->customAnimation(40 / (1000 / FadeInDuration), FadeInDuration,
|
||||
Animator::EaseOutCurve, this,
|
||||
"hoverAnimationUpdate");
|
||||
d->m_hoverAnimId = Animator::self()->customAnimation(
|
||||
40 / (1000 / FadeInDuration), FadeInDuration,
|
||||
Animator::EaseOutCurve, this, "hoverAnimationUpdate");
|
||||
}
|
||||
|
||||
void Icon::hoverAnimationUpdate(qreal progress)
|
||||
void Icon::hoverAnimationUpdate(qreal progress)
|
||||
{
|
||||
if (d->m_fadeIn) {
|
||||
d->m_hoverAlpha = progress;
|
||||
@ -533,7 +537,7 @@ void Icon::hoverAnimationUpdate(qreal progress)
|
||||
if (progress == 1) {
|
||||
d->m_hoverAnimId = -1;
|
||||
}
|
||||
if (!d->m_fadeIn && progress == 1 ) {
|
||||
if (!d->m_fadeIn && progress == 1) {
|
||||
d->states &= ~IconPrivate::HoverState;
|
||||
}
|
||||
update();
|
||||
@ -551,30 +555,37 @@ void IconPrivate::drawBackground(QPainter *painter, IconState state)
|
||||
|
||||
switch (state) {
|
||||
case IconPrivate::HoverState:
|
||||
shadow.setHsv(shadow.hue(),
|
||||
shadow.saturation(),
|
||||
shadow.value() + (int)(darkShadow ? 50 * m_hoverAlpha: -50 * m_hoverAlpha),
|
||||
200 + (int)m_hoverAlpha * 55); // opacity
|
||||
shadow.setHsv(
|
||||
shadow.hue(),
|
||||
shadow.saturation(),
|
||||
shadow.value() + (int)(darkShadow ? 50 * m_hoverAlpha: -50 * m_hoverAlpha),
|
||||
200 + (int)m_hoverAlpha * 55); // opacity
|
||||
break;
|
||||
case IconPrivate::PressedState:
|
||||
shadow.setHsv(shadow.hue(),
|
||||
shadow.saturation(),
|
||||
shadow.value() + (darkShadow?(int)(50*m_hoverAlpha):(int)(-50*m_hoverAlpha)),
|
||||
204); //80% opacity
|
||||
shadow.setHsv(
|
||||
shadow.hue(),
|
||||
shadow.saturation(),
|
||||
shadow.value() + (darkShadow ?
|
||||
(int)(50 * m_hoverAlpha) : (int)(-50 * m_hoverAlpha)),
|
||||
204); //80% opacity
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
border.setAlphaF(0.3*m_hoverAlpha);
|
||||
shadow.setAlphaF(0.6*m_hoverAlpha);
|
||||
|
||||
border.setAlphaF(0.3 * m_hoverAlpha);
|
||||
shadow.setAlphaF(0.6 * m_hoverAlpha);
|
||||
|
||||
painter->save();
|
||||
painter->translate(0.5, 0.5);
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->setBrush(shadow);
|
||||
painter->setPen(QPen(border, 1));
|
||||
painter->drawPath(PaintUtils::roundedRectangle(QRectF(QPointF(1, 1), QSize((int)currentSize.width()-2, (int)currentSize.height()-2)), 5.0));
|
||||
painter->drawPath(
|
||||
PaintUtils::roundedRectangle(
|
||||
QRectF(QPointF(1, 1), QSize((int)currentSize.width() - 2,
|
||||
(int)currentSize.height() - 2)),
|
||||
5.0));
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
@ -613,7 +624,10 @@ QPixmap IconPrivate::decoration(const QStyleOptionGraphicsItem *option, bool use
|
||||
if (qFuzzyCompare(qreal(1.0), m_hoverAlpha)) {
|
||||
result = effect->apply(result, KIconLoader::Desktop, KIconLoader::ActiveState);
|
||||
} else {
|
||||
result = PaintUtils::transition(result, effect->apply(result, KIconLoader::Desktop, KIconLoader::ActiveState), m_hoverAlpha);
|
||||
result = PaintUtils::transition(
|
||||
result,
|
||||
effect->apply(result, KIconLoader::Desktop,
|
||||
KIconLoader::ActiveState), m_hoverAlpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -621,7 +635,8 @@ QPixmap IconPrivate::decoration(const QStyleOptionGraphicsItem *option, bool use
|
||||
return result;
|
||||
}
|
||||
|
||||
QPointF IconPrivate::iconPosition(const QStyleOptionGraphicsItem *option, const QPixmap &pixmap) const
|
||||
QPointF IconPrivate::iconPosition(const QStyleOptionGraphicsItem *option,
|
||||
const QPixmap &pixmap) const
|
||||
{
|
||||
const QRectF itemRect = subtractMargin(option->rect, IconPrivate::ItemMargin);
|
||||
|
||||
@ -634,14 +649,16 @@ QPointF IconPrivate::iconPosition(const QStyleOptionGraphicsItem *option, const
|
||||
Qt::Alignment alignment;
|
||||
if (text.isEmpty() && infoText.isEmpty()) {
|
||||
alignment = Qt::AlignCenter;
|
||||
}else if (orientation == Qt::Vertical) {
|
||||
} else if (orientation == Qt::Vertical) {
|
||||
alignment = Qt::Alignment(Qt::AlignHCenter | Qt::AlignTop);
|
||||
//Horizontal
|
||||
}else{
|
||||
alignment = QStyle::visualAlignment(direction, Qt::Alignment(Qt::AlignLeft | Qt::AlignVCenter));
|
||||
} else {
|
||||
alignment = QStyle::visualAlignment(
|
||||
direction, Qt::Alignment(Qt::AlignLeft | Qt::AlignVCenter));
|
||||
}
|
||||
|
||||
const QRect iconRect = QStyle::alignedRect(direction, alignment, size.toSize(), itemRect.toRect());
|
||||
const QRect iconRect =
|
||||
QStyle::alignedRect(direction, alignment, size.toSize(), itemRect.toRect());
|
||||
|
||||
// Position the pixmap in the center of the rectangle
|
||||
QRect pixmapRect = pixmap.rect();
|
||||
@ -653,8 +670,9 @@ QPointF IconPrivate::iconPosition(const QStyleOptionGraphicsItem *option, const
|
||||
return QPointF(pixmapRect.topLeft());
|
||||
}
|
||||
|
||||
QRectF IconPrivate::labelRectangle(const QStyleOptionGraphicsItem *option, const QPixmap &icon,
|
||||
const QString &string) const
|
||||
QRectF IconPrivate::labelRectangle(const QStyleOptionGraphicsItem *option,
|
||||
const QPixmap &icon,
|
||||
const QString &string) const
|
||||
{
|
||||
Q_UNUSED(string)
|
||||
|
||||
@ -683,8 +701,7 @@ QSizeF IconPrivate::layoutText(QTextLayout &layout, const QStyleOptionGraphicsIt
|
||||
{
|
||||
const QSizeF size = layoutText(layout, text, constraints.width());
|
||||
|
||||
if (size.width() > constraints.width() || size.height() > constraints.height())
|
||||
{
|
||||
if (size.width() > constraints.width() || size.height() > constraints.height()) {
|
||||
const QString elided = elidedText(layout, option, constraints);
|
||||
return layoutText(layout, elided, constraints.width());
|
||||
}
|
||||
@ -705,8 +722,7 @@ QSizeF IconPrivate::layoutText(QTextLayout &layout, const QString &text, qreal m
|
||||
|
||||
layout.beginLayout();
|
||||
|
||||
while ((line = layout.createLine()).isValid())
|
||||
{
|
||||
while ((line = layout.createLine()).isValid()) {
|
||||
line.setLineWidth(maxWidth);
|
||||
height += leading;
|
||||
line.setPosition(QPointF(0.0, height));
|
||||
@ -737,27 +753,29 @@ QString IconPrivate::elidedText(QTextLayout &layout, const QStyleOptionGraphicsI
|
||||
QString elided;
|
||||
elided.reserve(text.length());
|
||||
|
||||
for (int i = 0; i < layout.lineCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < layout.lineCount(); i++) {
|
||||
QTextLine line = layout.lineAt(i);
|
||||
int start = line.textStart();
|
||||
int length = line.textLength();
|
||||
|
||||
height += metrics.leading();
|
||||
if (height + line.height() + metrics.lineSpacing() > maxHeight)
|
||||
{
|
||||
// Unfortunately, if the line ends because of a line separator, elidedText() will be too
|
||||
// clever and keep adding lines until it finds one that's too wide.
|
||||
if (line.naturalTextWidth() < maxWidth && start+length > 0 && text[start + length - 1] == QChar::LineSeparator)
|
||||
if (height + line.height() + metrics.lineSpacing() > maxHeight) {
|
||||
// Unfortunately, if the line ends because of a line separator,
|
||||
// elidedText() will be too clever and keep adding lines until
|
||||
// it finds one that's too wide.
|
||||
if (line.naturalTextWidth() < maxWidth &&
|
||||
start + length > 0 &&
|
||||
text[start + length - 1] == QChar::LineSeparator) {
|
||||
elided += text.mid(start, length - 1);
|
||||
else
|
||||
} else {
|
||||
elided += metrics.elidedText(text.mid(start), Qt::ElideRight, maxWidth);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (line.naturalTextWidth() > maxWidth)
|
||||
} else if (line.naturalTextWidth() > maxWidth) {
|
||||
elided += metrics.elidedText(text.mid(start, length), Qt::ElideRight, maxWidth);
|
||||
else
|
||||
} else {
|
||||
elided += text.mid(start, length);
|
||||
}
|
||||
|
||||
height += line.height();
|
||||
}
|
||||
@ -786,8 +804,7 @@ void IconPrivate::layoutTextItems(const QStyleOptionGraphicsItem *option,
|
||||
|
||||
// If we have additional info text, and there's space for at least two lines of text,
|
||||
// adjust the max label size to make room for at least one line of the info text
|
||||
if (!infoText.isEmpty() && textRect.height() >= fm.lineSpacing() * 2)
|
||||
{
|
||||
if (!infoText.isEmpty() && textRect.height() >= fm.lineSpacing() * 2) {
|
||||
infoLayout->setFont(labelLayout->font());
|
||||
infoLayout->setTextOption(labelLayout->textOption());
|
||||
|
||||
@ -807,8 +824,10 @@ void IconPrivate::layoutTextItems(const QStyleOptionGraphicsItem *option,
|
||||
}
|
||||
// Compute the bounding rect of the text
|
||||
const Qt::Alignment alignment = labelLayout->textOption().alignment();
|
||||
const QSizeF size(qMax(labelSize.width(), infoSize.width()), labelSize.height() + infoSize.height());
|
||||
*textBoundingRect = QStyle::alignedRect(iconDirection(option), alignment, size.toSize(), textRect.toRect());
|
||||
const QSizeF size(qMax(labelSize.width(), infoSize.width()),
|
||||
labelSize.height() + infoSize.height());
|
||||
*textBoundingRect =
|
||||
QStyle::alignedRect(iconDirection(option), alignment, size.toSize(), textRect.toRect());
|
||||
|
||||
// Compute the positions where we should draw the layouts
|
||||
labelLayout->setPosition(QPointF(textRect.x(), textBoundingRect->y()));
|
||||
@ -842,8 +861,10 @@ QBrush IconPrivate::backgroundBrush(const QStyleOptionGraphicsItem *option) cons
|
||||
return background;
|
||||
}
|
||||
|
||||
void IconPrivate::drawTextItems(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
const QTextLayout &labelLayout, const QTextLayout &infoLayout) const
|
||||
void IconPrivate::drawTextItems(QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
const QTextLayout &labelLayout,
|
||||
const QTextLayout &infoLayout) const
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
|
||||
@ -863,10 +884,9 @@ void IconPrivate::drawTextItems(QPainter *painter, const QStyleOptionGraphicsIte
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
void Icon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(widget)
|
||||
Q_UNUSED(widget);
|
||||
|
||||
#ifdef BACKINGSTORE_BLUR_HACK
|
||||
if (d->state == IconPrivate::HoverState && scene()) {
|
||||
@ -922,7 +942,8 @@ void Icon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
|
||||
QRectF textBoundingRect;
|
||||
d->layoutTextItems(option, icon, &labelLayout, &infoLayout, &textBoundingRect);
|
||||
|
||||
QImage shadow(textBoundingRect.size().toSize()+QSize(4,4), QImage::Format_ARGB32_Premultiplied);
|
||||
QImage shadow(textBoundingRect.size().toSize() + QSize(4, 4),
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
shadow.fill(Qt::transparent);
|
||||
{
|
||||
QPainter buffPainter(&shadow);
|
||||
@ -930,19 +951,19 @@ void Icon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
|
||||
d->drawTextItems(&buffPainter, option, labelLayout, infoLayout);
|
||||
}
|
||||
|
||||
QPoint shadowOffset = QPoint(1,2);
|
||||
QPoint shadowOffset = QPoint(1, 2);
|
||||
if (d->shadowColor.value() > 128) {
|
||||
shadowOffset = QPoint(0,1);
|
||||
shadowOffset = QPoint(0, 1);
|
||||
}
|
||||
|
||||
PaintUtils::shadowBlur(shadow, 2, d->shadowColor);
|
||||
painter->drawImage(textBoundingRect.topLeft()+shadowOffset, shadow);
|
||||
painter->drawImage(textBoundingRect.topLeft() + shadowOffset, shadow);
|
||||
d->drawTextItems(painter, option, labelLayout, infoLayout);
|
||||
}
|
||||
|
||||
void Icon::drawActionButtonBase(QPainter* painter, const QSize &size, int element)
|
||||
void Icon::drawActionButtonBase(QPainter *painter, const QSize &size, int element)
|
||||
{
|
||||
qreal radius = size.width()/2;
|
||||
qreal radius = size.width() / 2;
|
||||
QRadialGradient gradient(radius, radius, radius, radius, radius);
|
||||
int alpha;
|
||||
|
||||
@ -965,8 +986,7 @@ void Icon::drawActionButtonBase(QPainter* painter, const QSize &size, int elemen
|
||||
painter->drawEllipse(QRectF(QPointF(.0, .0), size));
|
||||
}
|
||||
|
||||
|
||||
void Icon::setText(const QString& text)
|
||||
void Icon::setText(const QString &text)
|
||||
{
|
||||
d->text = text;
|
||||
// cause a relayout
|
||||
@ -984,7 +1004,7 @@ QString Icon::text() const
|
||||
return d->text;
|
||||
}
|
||||
|
||||
void Icon::setInfoText(const QString& text)
|
||||
void Icon::setInfoText(const QString &text)
|
||||
{
|
||||
d->infoText = text;
|
||||
// cause a relayout
|
||||
@ -1006,7 +1026,7 @@ QIcon Icon::icon() const
|
||||
return d->icon;
|
||||
}
|
||||
|
||||
void Icon::setIcon(const QString& icon)
|
||||
void Icon::setIcon(const QString &icon)
|
||||
{
|
||||
if (icon.isEmpty()) {
|
||||
setIcon(QIcon());
|
||||
@ -1016,7 +1036,7 @@ void Icon::setIcon(const QString& icon)
|
||||
setIcon(KIcon(icon));
|
||||
}
|
||||
|
||||
void Icon::setIcon(const QIcon& icon)
|
||||
void Icon::setIcon(const QIcon &icon)
|
||||
{
|
||||
d->icon = icon;
|
||||
}
|
||||
@ -1137,7 +1157,7 @@ void Icon::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
action->hide();
|
||||
action->event(event->type(), event->pos());
|
||||
}
|
||||
// d->states &= ~IconPrivate::HoverState; // Will be set once progress is zero again ...
|
||||
// d->states &= ~IconPrivate::HoverState; // Will be set once progress is zero again ...
|
||||
hoverEffect(false);
|
||||
update();
|
||||
|
||||
|
@ -54,12 +54,13 @@ class IconPrivate;
|
||||
class PLASMA_EXPORT Icon : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( QString text READ text WRITE setText )
|
||||
Q_PROPERTY( QString infoText READ infoText WRITE setInfoText )
|
||||
Q_PROPERTY( QIcon icon READ icon WRITE setIcon )
|
||||
Q_PROPERTY( QSizeF iconSize READ iconSize )
|
||||
Q_PROPERTY( QString svg WRITE setSvg )
|
||||
// Q_PROPERTY( QAction action READ action WRITE setAction )
|
||||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(QString infoText READ infoText WRITE setInfoText)
|
||||
Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
|
||||
Q_PROPERTY(QSizeF iconSize READ iconSize)
|
||||
Q_PROPERTY(QString svg WRITE setSvg)
|
||||
// Q_PROPERTY(QAction action READ action WRITE setAction)
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a new Plasma::Icon.
|
||||
@ -126,14 +127,14 @@ public:
|
||||
* Sets the graphical icon for this Plasma::Icon.
|
||||
* @param icon the KIcon to associate with this icon.
|
||||
*/
|
||||
void setIcon(const QIcon& icon);
|
||||
void setIcon(const QIcon &icon);
|
||||
|
||||
/**
|
||||
* Convenience method to set the icon of this Plasma::Icon
|
||||
* using a QString path to the icon.
|
||||
* @param icon the path to the icon to associate with this Plasma::Icon.
|
||||
*/
|
||||
Q_INVOKABLE void setIcon(const QString& icon);
|
||||
Q_INVOKABLE void setIcon(const QString &icon);
|
||||
|
||||
/**
|
||||
* @return the size of this Plasma::Icon's graphical icon.
|
||||
@ -146,7 +147,7 @@ public:
|
||||
* allows for a created QAction to be added to the Plasma::Icon.
|
||||
* @param action the QAction to associate with this icon.
|
||||
*/
|
||||
void addIconAction(QAction* action);
|
||||
void addIconAction(QAction *action);
|
||||
|
||||
/**
|
||||
* Associate an action with this Icon
|
||||
@ -159,7 +160,7 @@ public:
|
||||
/**
|
||||
* @return the currently associated action, if any.
|
||||
*/
|
||||
QAction* action() const;
|
||||
QAction *action() const;
|
||||
|
||||
/**
|
||||
* let set the orientation of the icon
|
||||
@ -273,7 +274,7 @@ public:
|
||||
/**
|
||||
* @internal
|
||||
**/
|
||||
void drawActionButtonBase(QPainter* painter, const QSize &size, int element);
|
||||
void drawActionButtonBase(QPainter *painter, const QSize &size, int element);
|
||||
|
||||
private:
|
||||
Q_PRIVATE_SLOT(d, void syncToAction())
|
||||
@ -284,8 +285,9 @@ private:
|
||||
IconPrivate * const d;
|
||||
|
||||
friend class IconPrivate;
|
||||
|
||||
private Q_SLOTS:
|
||||
void actionDestroyed(QObject* obj);
|
||||
void actionDestroyed(QObject *obj);
|
||||
void readColors();
|
||||
void hoverAnimationUpdate(qreal progress);
|
||||
|
||||
@ -293,7 +295,6 @@ private Q_SLOTS:
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
|
||||
/*
|
||||
// Add these to UrlIcon
|
||||
void setUrl(const KUrl& url);
|
||||
|
@ -45,14 +45,14 @@ namespace Plasma
|
||||
class PLASMA_EXPORT IconAction
|
||||
{
|
||||
public:
|
||||
IconAction(Icon* icon, QAction* action);
|
||||
IconAction(Icon *icon, QAction *action);
|
||||
|
||||
void show();
|
||||
void hide();
|
||||
bool isVisible() const;
|
||||
|
||||
int animationId() const;
|
||||
QAction* action() const;
|
||||
QAction *action() const;
|
||||
|
||||
void paint(QPainter *painter) const;
|
||||
bool event(QEvent::Type type, const QPointF &pos);
|
||||
@ -82,7 +82,6 @@ private:
|
||||
int m_animationId;
|
||||
};
|
||||
|
||||
|
||||
struct Margin
|
||||
{
|
||||
qreal left, right, top, bottom;
|
||||
@ -91,10 +90,14 @@ struct Margin
|
||||
class IconPrivate
|
||||
{
|
||||
public:
|
||||
enum MarginType { ItemMargin = 0, TextMargin, IconMargin, NMargins };
|
||||
enum MarginType {
|
||||
ItemMargin = 0,
|
||||
TextMargin,
|
||||
IconMargin,
|
||||
NMargins
|
||||
};
|
||||
|
||||
enum IconState
|
||||
{
|
||||
enum IconState {
|
||||
NoState = 0,
|
||||
HoverState = 1,
|
||||
PressedState = 2,
|
||||
@ -119,22 +122,29 @@ public:
|
||||
QBrush foregroundBrush(const QStyleOptionGraphicsItem *option) const;
|
||||
QBrush backgroundBrush(const QStyleOptionGraphicsItem *option) const;
|
||||
|
||||
QString elidedText(QTextLayout &layout, const QStyleOptionGraphicsItem *option,
|
||||
const QSizeF &maxSize) const;
|
||||
QSizeF layoutText(QTextLayout &layout, const QStyleOptionGraphicsItem *option,
|
||||
const QString &text, const QSizeF &constraints) const;
|
||||
QSizeF layoutText(QTextLayout &layout, const QString &text, qreal maxWidth) const;
|
||||
QRectF labelRectangle(const QStyleOptionGraphicsItem *option, const QPixmap &icon,
|
||||
const QString &string) const;
|
||||
void layoutTextItems(const QStyleOptionGraphicsItem *option, const QPixmap &icon,
|
||||
QTextLayout *labelLayout, QTextLayout *infoLayout, QRectF *textBoundingRect) const;
|
||||
QString elidedText(QTextLayout &layout,
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
const QSizeF &maxSize) const;
|
||||
|
||||
QSizeF layoutText(QTextLayout &layout,
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
const QString &text, const QSizeF &constraints) const;
|
||||
|
||||
inline void setLayoutOptions(QTextLayout &layout, const QStyleOptionGraphicsItem *options) const;
|
||||
QSizeF layoutText(QTextLayout &layout, const QString &text,
|
||||
qreal maxWidth) const;
|
||||
|
||||
QRectF labelRectangle(const QStyleOptionGraphicsItem *option,
|
||||
const QPixmap &icon, const QString &string) const;
|
||||
|
||||
void layoutTextItems(const QStyleOptionGraphicsItem *option,
|
||||
const QPixmap &icon, QTextLayout *labelLayout,
|
||||
QTextLayout *infoLayout, QRectF *textBoundingRect) const;
|
||||
|
||||
inline void setLayoutOptions(QTextLayout &layout,
|
||||
const QStyleOptionGraphicsItem *options) const;
|
||||
|
||||
inline Qt::LayoutDirection iconDirection(const QStyleOptionGraphicsItem *option) const;
|
||||
|
||||
|
||||
enum {
|
||||
Minibutton = 64,
|
||||
MinibuttonHover = 128,
|
||||
@ -149,7 +159,6 @@ public:
|
||||
LastIconPosition
|
||||
};
|
||||
|
||||
|
||||
// Margin functions
|
||||
inline void setActiveMargins();
|
||||
void setVerticalMargin(MarginType type, qreal left, qreal right, qreal top, qreal bottom);
|
||||
@ -203,7 +212,8 @@ public:
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(IconPrivate::IconStates)
|
||||
|
||||
// Inline methods
|
||||
void IconPrivate::setLayoutOptions(QTextLayout &layout, const QStyleOptionGraphicsItem *option) const
|
||||
void IconPrivate::setLayoutOptions(QTextLayout &layout,
|
||||
const QStyleOptionGraphicsItem *option) const
|
||||
{
|
||||
QTextOption textoption;
|
||||
textoption.setTextDirection(option->direction);
|
||||
@ -221,7 +231,7 @@ Qt::LayoutDirection IconPrivate::iconDirection(const QStyleOptionGraphicsItem *o
|
||||
if (invertLayout && orientation == Qt::Horizontal) {
|
||||
if (option->direction == Qt::LeftToRight) {
|
||||
direction = Qt::RightToLeft;
|
||||
}else{
|
||||
} else {
|
||||
direction = Qt::LeftToRight;
|
||||
}
|
||||
} else {
|
||||
@ -237,7 +247,8 @@ void IconPrivate::setActiveMargins()
|
||||
horizontalMargin : verticalMargin);
|
||||
}
|
||||
|
||||
void IconPrivate::setVerticalMargin(MarginType type, qreal left, qreal top, qreal right, qreal bottom)
|
||||
void IconPrivate::setVerticalMargin(MarginType type, qreal left, qreal top,
|
||||
qreal right, qreal bottom)
|
||||
{
|
||||
verticalMargin[type].left = left;
|
||||
verticalMargin[type].right = right;
|
||||
@ -245,7 +256,8 @@ void IconPrivate::setVerticalMargin(MarginType type, qreal left, qreal top, qrea
|
||||
verticalMargin[type].bottom = bottom;
|
||||
}
|
||||
|
||||
void IconPrivate::setHorizontalMargin(MarginType type, qreal left, qreal top, qreal right, qreal bottom)
|
||||
void IconPrivate::setHorizontalMargin(MarginType type, qreal left, qreal top,
|
||||
qreal right, qreal bottom)
|
||||
{
|
||||
horizontalMargin[type].left = left;
|
||||
horizontalMargin[type].right = right;
|
||||
|
@ -86,7 +86,7 @@ Label::Label(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new LabelPrivate(this))
|
||||
{
|
||||
QLabel* native = new QLabel;
|
||||
QLabel *native = new QLabel;
|
||||
connect(native, SIGNAL(linkActivated(QString)), this, SIGNAL(linkActivated(QString)));
|
||||
|
||||
connect(Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(setPalette()));
|
||||
@ -121,7 +121,7 @@ void Label::setImage(const QString &path)
|
||||
d->svg = 0;
|
||||
d->imagePath = path;
|
||||
|
||||
bool absolutePath = !path.isEmpty() &&
|
||||
bool absolutePath = !path.isEmpty() &&
|
||||
#ifdef Q_WS_WIN
|
||||
!QDir::isRelativePath(path)
|
||||
#else
|
||||
@ -154,17 +154,17 @@ QString Label::styleSheet()
|
||||
return widget()->styleSheet();
|
||||
}
|
||||
|
||||
QLabel* Label::nativeWidget() const
|
||||
QLabel *Label::nativeWidget() const
|
||||
{
|
||||
return static_cast<QLabel*>(widget());
|
||||
}
|
||||
|
||||
void Label::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
|
||||
{
|
||||
Q_UNUSED(sourceName)
|
||||
Q_UNUSED(sourceName);
|
||||
|
||||
QStringList texts;
|
||||
foreach (const QVariant& v, data) {
|
||||
foreach (const QVariant &v, data) {
|
||||
if (v.canConvert(QVariant::String)) {
|
||||
texts << v.toString();
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_LABEL_H
|
||||
#define PLASMA_LABEL_H
|
||||
|
||||
@ -42,11 +41,11 @@ class PLASMA_EXPORT Label : public QGraphicsProxyWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QGraphicsWidget* parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QGraphicsWidget *parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(QString image READ image WRITE setImage)
|
||||
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
||||
Q_PROPERTY(QLabel* nativeWidget READ nativeWidget)
|
||||
Q_PROPERTY(QLabel *nativeWidget READ nativeWidget)
|
||||
|
||||
public:
|
||||
explicit Label(QGraphicsWidget *parent = 0);
|
||||
@ -54,7 +53,7 @@ public:
|
||||
|
||||
/**
|
||||
* Sets the display text for this Label
|
||||
*
|
||||
*
|
||||
* @arg text the text to display; should be translated.
|
||||
*/
|
||||
void setText(const QString &text);
|
||||
@ -91,7 +90,7 @@ public:
|
||||
/**
|
||||
* @return the native widget wrapped by this Label
|
||||
*/
|
||||
QLabel* nativeWidget() const;
|
||||
QLabel *nativeWidget() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void linkActivated(const QString &link);
|
||||
|
@ -46,7 +46,7 @@ LineEdit::LineEdit(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new LineEditPrivate)
|
||||
{
|
||||
KLineEdit* native = new KLineEdit;
|
||||
KLineEdit *native = new KLineEdit;
|
||||
connect(native, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
|
||||
connect(native, SIGNAL(returnPressed()), this, SIGNAL(returnPressed()));
|
||||
connect(native, SIGNAL(textEdited(const QString&)), this, SIGNAL(textEdited(const QString&)));
|
||||
@ -79,7 +79,7 @@ QString LineEdit::styleSheet()
|
||||
return widget()->styleSheet();
|
||||
}
|
||||
|
||||
KLineEdit* LineEdit::nativeWidget() const
|
||||
KLineEdit *LineEdit::nativeWidget() const
|
||||
{
|
||||
return static_cast<KLineEdit*>(widget());
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_LINEEDIT_H
|
||||
#define PLASMA_LINEEDIT_H
|
||||
|
||||
@ -41,10 +40,10 @@ class PLASMA_EXPORT LineEdit : public QGraphicsProxyWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QGraphicsWidget* parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QGraphicsWidget *parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
||||
Q_PROPERTY(KLineEdit* nativeWidget READ nativeWidget)
|
||||
Q_PROPERTY(KLineEdit *nativeWidget READ nativeWidget)
|
||||
|
||||
public:
|
||||
explicit LineEdit(QGraphicsWidget *parent = 0);
|
||||
@ -52,7 +51,7 @@ public:
|
||||
|
||||
/**
|
||||
* Sets the display text for this LineEdit
|
||||
*
|
||||
*
|
||||
* @arg text the text to display; should be translated.
|
||||
*/
|
||||
void setText(const QString &text);
|
||||
@ -77,15 +76,15 @@ public:
|
||||
/**
|
||||
* @return the native widget wrapped by this LineEdit
|
||||
*/
|
||||
KLineEdit* nativeWidget() const;
|
||||
KLineEdit *nativeWidget() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void editingFinished();
|
||||
void returnPressed();
|
||||
void textEdited(const QString & text);
|
||||
void textEdited(const QString &text);
|
||||
|
||||
private:
|
||||
LineEditPrivate * const d;
|
||||
LineEditPrivate *const d;
|
||||
};
|
||||
|
||||
} // namespace Plasma
|
||||
|
@ -27,17 +27,17 @@ namespace Plasma {
|
||||
class MeterPrivate
|
||||
{
|
||||
public:
|
||||
MeterPrivate(Meter* m) :
|
||||
minimum(0),
|
||||
maximum(100),
|
||||
value(0),
|
||||
meterType(Meter::AnalogMeter),
|
||||
image(0),
|
||||
minrotate(0),
|
||||
maxrotate(360),
|
||||
meter(m) {};
|
||||
MeterPrivate(Meter *m)
|
||||
: minimum(0),
|
||||
maximum(100),
|
||||
value(0),
|
||||
meterType(Meter::AnalogMeter),
|
||||
image(0),
|
||||
minrotate(0),
|
||||
maxrotate(360),
|
||||
meter(m) {}
|
||||
|
||||
void paint(QPainter *p, const QString& elementID)
|
||||
void paint(QPainter *p, const QString &elementID)
|
||||
{
|
||||
if (image->hasElement(elementID)) {
|
||||
QRectF elementRect = image->elementRect(elementID);
|
||||
@ -129,7 +129,7 @@ public:
|
||||
Plasma::Svg *image;
|
||||
int minrotate;
|
||||
int maxrotate;
|
||||
Meter* meter;
|
||||
Meter *meter;
|
||||
};
|
||||
|
||||
Meter::Meter(QGraphicsItem *parent) :
|
||||
@ -232,9 +232,10 @@ void Meter::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Dat
|
||||
Q_UNUSED(sourceName)
|
||||
|
||||
foreach (const QVariant &v, data) {
|
||||
if (v.type() == QVariant::Int || v.type() == QVariant::UInt
|
||||
|| v.type() == QVariant::LongLong
|
||||
|| v.type() == QVariant::ULongLong) {
|
||||
if (v.type() == QVariant::Int ||
|
||||
v.type() == QVariant::UInt ||
|
||||
v.type() == QVariant::LongLong ||
|
||||
v.type() == QVariant::ULongLong) {
|
||||
setValue(v.toInt());
|
||||
return;
|
||||
}
|
||||
|
@ -93,7 +93,6 @@ public:
|
||||
Svg *svg;
|
||||
};
|
||||
|
||||
|
||||
void PushButtonPrivate::syncActiveRect()
|
||||
{
|
||||
background->setElementPrefix("normal");
|
||||
@ -105,8 +104,9 @@ void PushButtonPrivate::syncActiveRect()
|
||||
qreal activeLeft, activeTop, activeRight, activeBottom;
|
||||
background->getMargins(activeLeft, activeTop, activeRight, activeBottom);
|
||||
|
||||
activeRect = QRectF(QPointF(0,0), q->size());
|
||||
activeRect.adjust(left - activeLeft, top - activeTop, -(right - activeRight), -(bottom - activeBottom));
|
||||
activeRect = QRectF(QPointF(0, 0), q->size());
|
||||
activeRect.adjust(left - activeLeft, top - activeTop,
|
||||
-(right - activeRight), -(bottom - activeBottom));
|
||||
|
||||
background->setElementPrefix("normal");
|
||||
}
|
||||
@ -124,7 +124,6 @@ void PushButtonPrivate::syncBorders()
|
||||
syncActiveRect();
|
||||
}
|
||||
|
||||
|
||||
void PushButtonPrivate::animationUpdate(qreal progress)
|
||||
{
|
||||
if (progress == 1) {
|
||||
@ -138,12 +137,11 @@ void PushButtonPrivate::animationUpdate(qreal progress)
|
||||
q->update();
|
||||
}
|
||||
|
||||
|
||||
PushButton::PushButton(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new PushButtonPrivate(this))
|
||||
{
|
||||
KPushButton* native = new KPushButton;
|
||||
KPushButton *native = new KPushButton;
|
||||
connect(native, SIGNAL(clicked()), this, SIGNAL(clicked()));
|
||||
setWidget(native);
|
||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||
@ -182,7 +180,7 @@ void PushButton::setImage(const QString &path)
|
||||
d->svg = 0;
|
||||
d->imagePath = path;
|
||||
|
||||
bool absolutePath = !path.isEmpty() &&
|
||||
bool absolutePath = !path.isEmpty() &&
|
||||
#ifdef Q_WS_WIN
|
||||
!QDir::isRelativePath(path)
|
||||
#else
|
||||
@ -215,7 +213,7 @@ QString PushButton::styleSheet()
|
||||
return widget()->styleSheet();
|
||||
}
|
||||
|
||||
KPushButton* PushButton::nativeWidget() const
|
||||
KPushButton *PushButton::nativeWidget() const
|
||||
{
|
||||
return static_cast<KPushButton*>(widget());
|
||||
}
|
||||
@ -240,7 +238,7 @@ void PushButton::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
d->background->resizePanel(size());
|
||||
}
|
||||
|
||||
QGraphicsProxyWidget::resizeEvent(event);
|
||||
QGraphicsProxyWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void PushButton::paint(QPainter *painter,
|
||||
@ -272,9 +270,9 @@ void PushButton::paint(QPainter *painter,
|
||||
QPainter buffPainter(&bufferPixmap);
|
||||
d->background->paintPanel(&buffPainter);
|
||||
buffPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||
buffPainter.fillRect(bufferPixmap.rect(), QColor(0,0,0,128));
|
||||
buffPainter.fillRect(bufferPixmap.rect(), QColor(0, 0, 0, 128));
|
||||
|
||||
painter->drawPixmap( 0, 0, bufferPixmap);
|
||||
painter->drawPixmap(0, 0, bufferPixmap);
|
||||
}
|
||||
|
||||
//if is under mouse draw the animated glow overlay
|
||||
@ -282,7 +280,9 @@ void PushButton::paint(QPainter *painter,
|
||||
if (d->animId != -1) {
|
||||
QPixmap normalPix = d->background->panelPixmap();
|
||||
d->background->setElementPrefix("active");
|
||||
painter->drawPixmap(d->activeRect.topLeft(), PaintUtils::transition(d->background->panelPixmap(), normalPix, 1 - d->opacity));
|
||||
painter->drawPixmap(
|
||||
d->activeRect.topLeft(),
|
||||
PaintUtils::transition(d->background->panelPixmap(), normalPix, 1 - d->opacity));
|
||||
} else if (isUnderMouse() || nativeWidget()->isDefault()) {
|
||||
d->background->setElementPrefix("active");
|
||||
d->background->paintPanel(painter, d->activeRect.topLeft());
|
||||
@ -294,10 +294,8 @@ void PushButton::paint(QPainter *painter,
|
||||
d->background->paintPanel(painter);
|
||||
}
|
||||
|
||||
|
||||
painter->setPen(Plasma::Theme::defaultTheme()->color(Theme::ButtonTextColor));
|
||||
|
||||
|
||||
if (nativeWidget()->isDown()) {
|
||||
painter->translate(QPoint(1, 1));
|
||||
}
|
||||
@ -337,11 +335,13 @@ void PushButton::paint(QPainter *painter,
|
||||
if (option->direction == Qt::LeftToRight) {
|
||||
alphaGradient.setColorAt(0, QColor(0, 0, 0, 255));
|
||||
alphaGradient.setColorAt(1, QColor(0, 0, 0, 0));
|
||||
p.drawText(bufferPixmap.rect(), Qt::AlignLeft|Qt::AlignVCenter, nativeWidget()->text() );
|
||||
p.drawText(bufferPixmap.rect(), Qt::AlignLeft|Qt::AlignVCenter,
|
||||
nativeWidget()->text());
|
||||
} else {
|
||||
alphaGradient.setColorAt(0, QColor(0, 0, 0, 0));
|
||||
alphaGradient.setColorAt(1, QColor(0, 0, 0, 255));
|
||||
p.drawText(bufferPixmap.rect(), Qt::AlignRight|Qt::AlignVCenter, nativeWidget()->text() );
|
||||
p.drawText(bufferPixmap.rect(), Qt::AlignRight|Qt::AlignVCenter,
|
||||
nativeWidget()->text());
|
||||
}
|
||||
|
||||
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||
@ -349,7 +349,7 @@ void PushButton::paint(QPainter *painter,
|
||||
|
||||
painter->drawPixmap(rect.topLeft(), bufferPixmap);
|
||||
} else {
|
||||
painter->drawText(rect, Qt::AlignCenter, nativeWidget()->text() );
|
||||
painter->drawText(rect, Qt::AlignCenter, nativeWidget()->text());
|
||||
}
|
||||
}
|
||||
|
||||
@ -360,7 +360,9 @@ void PushButton::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
if (d->animId != -1) {
|
||||
Plasma::Animator::self()->stopCustomAnimation(d->animId);
|
||||
}
|
||||
d->animId = Plasma::Animator::self()->customAnimation(40 / (1000 / FadeInDuration), FadeInDuration,Plasma::Animator::LinearCurve, this, "animationUpdate");
|
||||
d->animId = Plasma::Animator::self()->customAnimation(
|
||||
40 / (1000 / FadeInDuration), FadeInDuration,
|
||||
Plasma::Animator::LinearCurve, this, "animationUpdate");
|
||||
|
||||
d->background->setElementPrefix("active");
|
||||
|
||||
@ -376,7 +378,9 @@ void PushButton::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
}
|
||||
|
||||
d->fadeIn = false;
|
||||
d->animId = Plasma::Animator::self()->customAnimation(40 / (1000 / FadeOutDuration), FadeOutDuration,Plasma::Animator::LinearCurve, this, "animationUpdate");
|
||||
d->animId = Plasma::Animator::self()->customAnimation(
|
||||
40 / (1000 / FadeOutDuration), FadeOutDuration,
|
||||
Plasma::Animator::LinearCurve, this, "animationUpdate");
|
||||
|
||||
d->background->setElementPrefix("active");
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_PUSHBUTTON_H
|
||||
#define PLASMA_PUSHBUTTON_H
|
||||
|
||||
@ -41,11 +40,11 @@ class PLASMA_EXPORT PushButton : public QGraphicsProxyWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QGraphicsWidget* parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QGraphicsWidget *parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(QString image READ image WRITE setImage)
|
||||
Q_PROPERTY(QString stylesheet READ styleSheet WRITE setStyleSheet)
|
||||
Q_PROPERTY(KPushButton* nativeWidget READ nativeWidget)
|
||||
Q_PROPERTY(KPushButton *nativeWidget READ nativeWidget)
|
||||
|
||||
public:
|
||||
explicit PushButton(QGraphicsWidget *parent = 0);
|
||||
@ -53,7 +52,7 @@ public:
|
||||
|
||||
/**
|
||||
* Sets the display text for this PushButton
|
||||
*
|
||||
*
|
||||
* @arg text the text to display; should be translated.
|
||||
*/
|
||||
void setText(const QString &text);
|
||||
@ -90,7 +89,7 @@ public:
|
||||
/**
|
||||
* @return the native widget wrapped by this PushButton
|
||||
*/
|
||||
KPushButton* nativeWidget() const;
|
||||
KPushButton *nativeWidget() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void clicked();
|
||||
@ -104,7 +103,7 @@ protected:
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
|
||||
private:
|
||||
PushButtonPrivate * const d;
|
||||
PushButtonPrivate *const d;
|
||||
|
||||
friend class PushButtonPrivate;
|
||||
Q_PRIVATE_SLOT(d, void syncBorders())
|
||||
|
@ -73,7 +73,7 @@ RadioButton::RadioButton(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new RadioButtonPrivate)
|
||||
{
|
||||
QRadioButton* native = new QRadioButton;
|
||||
QRadioButton *native = new QRadioButton;
|
||||
connect(native, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
|
||||
setWidget(native);
|
||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||
@ -104,7 +104,7 @@ void RadioButton::setImage(const QString &path)
|
||||
d->svg = 0;
|
||||
d->imagePath = path;
|
||||
|
||||
bool absolutePath = !path.isEmpty() &&
|
||||
bool absolutePath = !path.isEmpty() &&
|
||||
#ifdef Q_WS_WIN
|
||||
!QDir::isRelativePath(path)
|
||||
#else
|
||||
@ -137,7 +137,7 @@ QString RadioButton::styleSheet()
|
||||
return widget()->styleSheet();
|
||||
}
|
||||
|
||||
QRadioButton* RadioButton::nativeWidget() const
|
||||
QRadioButton *RadioButton::nativeWidget() const
|
||||
{
|
||||
return static_cast<QRadioButton*>(widget());
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_RADIOBUTTON_H
|
||||
#define PLASMA_RADIOBUTTON_H
|
||||
|
||||
@ -41,11 +40,11 @@ class PLASMA_EXPORT RadioButton : public QGraphicsProxyWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QGraphicsWidget* parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QGraphicsWidget *parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(QString image READ image WRITE setImage)
|
||||
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
||||
Q_PROPERTY(QRadioButton* nativeWidget READ nativeWidget)
|
||||
Q_PROPERTY(QRadioButton *nativeWidget READ nativeWidget)
|
||||
Q_PROPERTY(bool isChecked READ isChecked WRITE setChecked)
|
||||
|
||||
public:
|
||||
@ -54,7 +53,7 @@ public:
|
||||
|
||||
/**
|
||||
* Sets the display text for this RadioButton
|
||||
*
|
||||
*
|
||||
* @arg text the text to display; should be translated.
|
||||
*/
|
||||
void setText(const QString &text);
|
||||
@ -91,7 +90,7 @@ public:
|
||||
/**
|
||||
* @return the native widget wrapped by this RadioButton
|
||||
*/
|
||||
QRadioButton* nativeWidget() const;
|
||||
QRadioButton *nativeWidget() const;
|
||||
|
||||
/**
|
||||
* Sets the checked state.
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright © 2008 Fredrik Höglund <fredrik@kde.org>
|
||||
* Copyright © 2008 Marco Martin <notmart@gmail.com>
|
||||
* Copyright © 2008 Marco Martin <notmart@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
@ -65,37 +65,37 @@ int ScrollBar::pageStep()
|
||||
}
|
||||
|
||||
void ScrollBar::setValue(int val)
|
||||
{
|
||||
{
|
||||
static_cast<QScrollBar*>(widget())->setValue(val);
|
||||
}
|
||||
|
||||
int ScrollBar::value() const
|
||||
{
|
||||
{
|
||||
return static_cast<QScrollBar*>(widget())->value();
|
||||
}
|
||||
|
||||
int ScrollBar::minimum() const
|
||||
{
|
||||
{
|
||||
return static_cast<QScrollBar*>(widget())->minimum();
|
||||
}
|
||||
|
||||
int ScrollBar::maximum() const
|
||||
{
|
||||
{
|
||||
return static_cast<QScrollBar*>(widget())->maximum();
|
||||
}
|
||||
|
||||
void ScrollBar::setStyleSheet(const QString &stylesheet)
|
||||
{
|
||||
widget()->setStyleSheet(stylesheet);
|
||||
widget()->setStyleSheet(stylesheet);
|
||||
}
|
||||
|
||||
QString ScrollBar::styleSheet()
|
||||
{
|
||||
return widget()->styleSheet();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QScrollBar *ScrollBar::nativeWidget() const
|
||||
{
|
||||
{
|
||||
return static_cast<QScrollBar*>(widget());
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright © 2008 Fredrik Höglund <fredrik@kde.org>
|
||||
* Copyright © 2008 Marco Martin <notmart@gmail.com>
|
||||
* Copyright © 2008 Marco Martin <notmart@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
@ -44,7 +44,7 @@ class PLASMA_EXPORT ScrollBar : public QGraphicsProxyWidget
|
||||
Q_PROPERTY(int minimum READ minimum)
|
||||
Q_PROPERTY(int maximum READ maximum)
|
||||
Q_PROPERTY(QString stylesheet READ styleSheet WRITE setStyleSheet)
|
||||
Q_PROPERTY(QScrollBar* nativeWidget READ nativeWidget)
|
||||
Q_PROPERTY(QScrollBar *nativeWidget READ nativeWidget)
|
||||
|
||||
public:
|
||||
explicit ScrollBar(Qt::Orientation orientation, QGraphicsWidget *parent);
|
||||
|
@ -132,7 +132,7 @@ SignalPlotter::SignalPlotter(QGraphicsItem *parent)
|
||||
d->fillPlots = true;
|
||||
|
||||
d->svgBackground = 0;
|
||||
d->backgroundColor = QColor(0,0,0);
|
||||
d->backgroundColor = QColor(0, 0, 0);
|
||||
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
}
|
||||
@ -172,27 +172,34 @@ void SignalPlotter::addSample(const QList<double>& sampleBuf)
|
||||
kDebug(1215) << "Error - d->samples is only " << d->samples << endl;
|
||||
updateDataBuffers();
|
||||
kDebug(1215) << "d->samples is now " << d->samples << endl;
|
||||
if (d->samples < 4)
|
||||
if (d->samples < 4) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
d->plotData.prepend(sampleBuf);
|
||||
Q_ASSERT(sampleBuf.count() == d->plotColors.count());
|
||||
if ((uint)d->plotData.size() > d->samples) {
|
||||
d->plotData.removeLast(); // we have too many. Remove the last item
|
||||
if ((uint)d->plotData.size() > d->samples)
|
||||
d->plotData.removeLast(); // If we still have too many, then we have resized the widget. Remove one more. That way we will slowly resize to the new size
|
||||
if ((uint)d->plotData.size() > d->samples) {
|
||||
// If we still have too many, then we have resized the widget.
|
||||
// Remove one more. That way we will slowly resize to the new size
|
||||
d->plotData.removeLast();
|
||||
}
|
||||
}
|
||||
|
||||
if (d->bezierCurveOffset >= 2) d->bezierCurveOffset = 0;
|
||||
else d->bezierCurveOffset++;
|
||||
if (d->bezierCurveOffset >= 2) {
|
||||
d->bezierCurveOffset = 0;
|
||||
} else {
|
||||
d->bezierCurveOffset++;
|
||||
}
|
||||
|
||||
Q_ASSERT((uint)d->plotData.size() >= d->bezierCurveOffset);
|
||||
|
||||
// If the vertical lines are scrolling, increment the offset
|
||||
// so they move with the data.
|
||||
if (d->verticalLinesScroll) {
|
||||
d->verticalLinesOffset = (d->verticalLinesOffset + d->horizontalScale)
|
||||
% d->verticalLinesDistance;
|
||||
d->verticalLinesOffset =
|
||||
(d->verticalLinesOffset + d->horizontalScale) % d->verticalLinesDistance;
|
||||
}
|
||||
update();
|
||||
}
|
||||
@ -200,12 +207,14 @@ void SignalPlotter::addSample(const QList<double>& sampleBuf)
|
||||
void SignalPlotter::reorderPlots(const QList<uint>& newOrder)
|
||||
{
|
||||
if (newOrder.count() != d->plotColors.count()) {
|
||||
kDebug(1215) << "neworder has " << newOrder.count() << " and plot colors is " << d->plotColors.count() << endl;
|
||||
kDebug(1215) << "neworder has " << newOrder.count()
|
||||
<< " and plot colors is " << d->plotColors.count() << endl;
|
||||
return;
|
||||
}
|
||||
foreach (QList<double> data, d->plotData) {
|
||||
if (newOrder.count() != data.count()) {
|
||||
kDebug(1215) << "Serious problem in move sample. plotdata[i] has " << data.count() << " and neworder has " << newOrder.count() << endl;
|
||||
kDebug(1215) << "Serious problem in move sample. plotdata[i] has "
|
||||
<< data.count() << " and neworder has " << newOrder.count() << endl;
|
||||
} else {
|
||||
QList<double> newPlot;
|
||||
for (int i = 0; i < newOrder.count(); i++) {
|
||||
@ -238,18 +247,23 @@ QList<PlotColor> &SignalPlotter::plotColors()
|
||||
|
||||
void SignalPlotter::removePlot(uint pos)
|
||||
{
|
||||
if (pos >= (uint)d->plotColors.size()) return;
|
||||
if (pos >= (uint)d->plotColors.size()) {
|
||||
return;
|
||||
}
|
||||
d->plotColors.removeAt(pos);
|
||||
|
||||
foreach (QList<double> data, d->plotData) {
|
||||
if ((uint)data.size() >= pos)
|
||||
if ((uint)data.size() >= pos) {
|
||||
data.removeAt(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SignalPlotter::scale(qreal delta)
|
||||
{
|
||||
if (d->scaledBy == delta) return;
|
||||
if (d->scaledBy == delta) {
|
||||
return;
|
||||
}
|
||||
d->scaledBy = delta;
|
||||
d->backgroundPixmap = QPixmap(); // we changed a paint setting, so reset the cache
|
||||
calculateNiceRange();
|
||||
@ -262,7 +276,9 @@ qreal SignalPlotter::scaledBy() const
|
||||
|
||||
void SignalPlotter::setTitle(const QString &title)
|
||||
{
|
||||
if (d->title == title) return;
|
||||
if (d->title == title) {
|
||||
return;
|
||||
}
|
||||
d->title = title;
|
||||
d->backgroundPixmap = QPixmap(); // we changed a paint setting, so reset the cache
|
||||
}
|
||||
@ -296,8 +312,9 @@ double SignalPlotter::verticalMaxValue() const
|
||||
|
||||
void SignalPlotter::setHorizontalScale(uint scale)
|
||||
{
|
||||
if (scale == d->horizontalScale)
|
||||
if (scale == d->horizontalScale) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->horizontalScale = scale;
|
||||
updateDataBuffers();
|
||||
@ -311,7 +328,9 @@ uint SignalPlotter::horizontalScale() const
|
||||
|
||||
void SignalPlotter::setShowVerticalLines(bool value)
|
||||
{
|
||||
if (d->showVerticalLines == value) return;
|
||||
if (d->showVerticalLines == value) {
|
||||
return;
|
||||
}
|
||||
d->showVerticalLines = value;
|
||||
d->backgroundPixmap = QPixmap(); // we changed a paint setting, so reset the cache
|
||||
}
|
||||
@ -323,7 +342,9 @@ bool SignalPlotter::showVerticalLines() const
|
||||
|
||||
void SignalPlotter::setVerticalLinesColor(const QColor &color)
|
||||
{
|
||||
if (d->verticalLinesColor == color) return;
|
||||
if (d->verticalLinesColor == color) {
|
||||
return;
|
||||
}
|
||||
d->verticalLinesColor = color;
|
||||
d->backgroundPixmap = QPixmap(); // we changed a paint setting, so reset the cache
|
||||
}
|
||||
@ -335,7 +356,9 @@ QColor SignalPlotter::verticalLinesColor() const
|
||||
|
||||
void SignalPlotter::setVerticalLinesDistance(uint distance)
|
||||
{
|
||||
if (distance == d->verticalLinesDistance) return;
|
||||
if (distance == d->verticalLinesDistance) {
|
||||
return;
|
||||
}
|
||||
d->verticalLinesDistance = distance;
|
||||
d->backgroundPixmap = QPixmap(); // we changed a paint setting, so reset the cache
|
||||
}
|
||||
@ -347,7 +370,9 @@ uint SignalPlotter::verticalLinesDistance() const
|
||||
|
||||
void SignalPlotter::setVerticalLinesScroll(bool value)
|
||||
{
|
||||
if (value == d->verticalLinesScroll) return;
|
||||
if (value == d->verticalLinesScroll) {
|
||||
return;
|
||||
}
|
||||
d->verticalLinesScroll = value;
|
||||
d->backgroundPixmap = QPixmap(); // we changed a paint setting, so reset the cache
|
||||
}
|
||||
@ -359,7 +384,9 @@ bool SignalPlotter::verticalLinesScroll() const
|
||||
|
||||
void SignalPlotter::setShowHorizontalLines(bool value)
|
||||
{
|
||||
if (value == d->showHorizontalLines) return;
|
||||
if (value == d->showHorizontalLines) {
|
||||
return;
|
||||
}
|
||||
d->showHorizontalLines = value;
|
||||
d->backgroundPixmap = QPixmap(); // we changed a paint setting, so reset the cache
|
||||
}
|
||||
@ -381,7 +408,9 @@ QColor SignalPlotter::fontColor() const
|
||||
|
||||
void SignalPlotter::setHorizontalLinesColor(const QColor &color)
|
||||
{
|
||||
if (color == d->horizontalLinesColor) return;
|
||||
if (color == d->horizontalLinesColor) {
|
||||
return;
|
||||
}
|
||||
d->horizontalLinesColor = color;
|
||||
d->backgroundPixmap = QPixmap(); // we changed a paint setting, so reset the cache
|
||||
}
|
||||
@ -393,7 +422,9 @@ QColor SignalPlotter::horizontalLinesColor() const
|
||||
|
||||
void SignalPlotter::setHorizontalLinesCount(uint count)
|
||||
{
|
||||
if (count == d->horizontalLinesCount) return;
|
||||
if (count == d->horizontalLinesCount) {
|
||||
return;
|
||||
}
|
||||
d->horizontalLinesCount = count;
|
||||
d->backgroundPixmap = QPixmap(); // we changed a paint setting, so reset the cache
|
||||
calculateNiceRange();
|
||||
@ -406,7 +437,9 @@ uint SignalPlotter::horizontalLinesCount() const
|
||||
|
||||
void SignalPlotter::setShowLabels(bool value)
|
||||
{
|
||||
if (value == d->showLabels) return;
|
||||
if (value == d->showLabels) {
|
||||
return;
|
||||
}
|
||||
d->showLabels = value;
|
||||
d->backgroundPixmap = QPixmap(); // we changed a paint setting, so reset the cache
|
||||
}
|
||||
@ -418,7 +451,9 @@ bool SignalPlotter::showLabels() const
|
||||
|
||||
void SignalPlotter::setShowTopBar(bool value)
|
||||
{
|
||||
if (d->showTopBar == value) return;
|
||||
if (d->showTopBar == value) {
|
||||
return;
|
||||
}
|
||||
d->showTopBar = value;
|
||||
d->backgroundPixmap = QPixmap(); // we changed a paint setting, so reset the cache
|
||||
}
|
||||
@ -446,18 +481,21 @@ QString SignalPlotter::svgBackground()
|
||||
|
||||
void SignalPlotter::setSvgBackground(const QString &filename)
|
||||
{
|
||||
if (d->svgFilename == filename) return;
|
||||
if (d->svgFilename == filename) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!filename.isEmpty() && filename[0] == '/') {
|
||||
KStandardDirs* kstd = KGlobal::dirs();
|
||||
KStandardDirs *kstd = KGlobal::dirs();
|
||||
d->svgFilename = kstd->findResource("data", "ksysguard/" + filename);
|
||||
} else {
|
||||
d->svgFilename = filename;
|
||||
}
|
||||
|
||||
if (!d->svgFilename.isEmpty())
|
||||
{
|
||||
if (d->svgBackground) delete d->svgBackground;
|
||||
if (!d->svgFilename.isEmpty()) {
|
||||
if (d->svgBackground) {
|
||||
delete d->svgBackground;
|
||||
}
|
||||
d->svgBackground = new Svg(this);
|
||||
d->svgBackground->setImagePath(d->svgFilename);
|
||||
}
|
||||
@ -466,7 +504,9 @@ void SignalPlotter::setSvgBackground(const QString &filename)
|
||||
|
||||
void SignalPlotter::setBackgroundColor(const QColor &color)
|
||||
{
|
||||
if (color == d->backgroundColor) return;
|
||||
if (color == d->backgroundColor) {
|
||||
return;
|
||||
}
|
||||
d->backgroundColor = color;
|
||||
d->backgroundPixmap = QPixmap(); // we changed a paint setting, so reset the cache
|
||||
}
|
||||
@ -478,7 +518,9 @@ QColor SignalPlotter::backgroundColor() const
|
||||
|
||||
void SignalPlotter::setThinFrame(bool set)
|
||||
{
|
||||
if (d->showThinFrame == set) return;
|
||||
if (d->showThinFrame == set) {
|
||||
return;
|
||||
}
|
||||
d->showThinFrame = set;
|
||||
d->backgroundPixmap = QPixmap(); // we changed a paint setting, so reset the cache
|
||||
}
|
||||
@ -509,7 +551,7 @@ void SignalPlotter::updateDataBuffers()
|
||||
|
||||
QPixmap SignalPlotter::getSnapshotImage(uint w, uint height)
|
||||
{
|
||||
uint horizontalStep = (uint) ((1.0*w/size().width())+0.5); // get the closest integer horizontal step
|
||||
uint horizontalStep = (uint)((1.0 * w / size().width()) + 0.5); // get the closest integer horizontal step
|
||||
uint newWidth = (uint) (horizontalStep * size().width());
|
||||
QPixmap image = QPixmap(newWidth, height);
|
||||
QPainter p(&image);
|
||||
@ -525,7 +567,8 @@ void SignalPlotter::setGeometry(const QRectF &geometry)
|
||||
updateDataBuffers();
|
||||
}
|
||||
|
||||
void SignalPlotter::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
void SignalPlotter::paint(QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
@ -534,8 +577,9 @@ void SignalPlotter::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
|
||||
uint h = (uint) size().height();
|
||||
|
||||
// Do not do repaints when the widget is not yet setup properly.
|
||||
if (w <= 2)
|
||||
if (w <= 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
drawWidget(painter, w, h, d->horizontalScale);
|
||||
}
|
||||
@ -546,8 +590,12 @@ void SignalPlotter::drawWidget(QPainter *p, uint w, uint height, int horizontalS
|
||||
p->setFont(d->font);
|
||||
|
||||
uint fontheight = p->fontMetrics().height();
|
||||
if (d->verticalMin < d->niceVertMin || d->verticalMax > d->niceVertMax || d->verticalMax < (d->niceVertRange*0.75 + d->niceVertMin) || d->niceVertRange == 0)
|
||||
if (d->verticalMin < d->niceVertMin ||
|
||||
d->verticalMax > d->niceVertMax ||
|
||||
d->verticalMax < (d->niceVertRange * 0.75 + d->niceVertMin) ||
|
||||
d->niceVertRange == 0) {
|
||||
calculateNiceRange();
|
||||
}
|
||||
QPen pen;
|
||||
pen.setWidth(1);
|
||||
pen.setCapStyle(Qt::RoundCap);
|
||||
@ -564,7 +612,10 @@ void SignalPlotter::drawWidget(QPainter *p, uint w, uint height, int horizontalS
|
||||
top += fontheight; // The top bar has the same height as fontheight. Thus the top of the graph is at fontheight
|
||||
h -= fontheight;
|
||||
}
|
||||
if (d->backgroundPixmap.isNull() || (uint)d->backgroundPixmap.size().height() != height || (uint)d->backgroundPixmap.size().width() != w) { // recreate on resize etc
|
||||
if (d->backgroundPixmap.isNull() ||
|
||||
(uint)d->backgroundPixmap.size().height() != height ||
|
||||
(uint)d->backgroundPixmap.size().width() != w) {
|
||||
// recreate on resize etc
|
||||
d->backgroundPixmap = QPixmap(w, height);
|
||||
QPainter pCache(&d->backgroundPixmap);
|
||||
pCache.setRenderHint(QPainter::Antialiasing, false);
|
||||
@ -587,11 +638,13 @@ void SignalPlotter::drawWidget(QPainter *p, uint w, uint height, int horizontalS
|
||||
|
||||
// Draw scope-like grid vertical lines if it doesn't move.
|
||||
// If it does move, draw it in the dynamic part of the code.
|
||||
if (!d->verticalLinesScroll && d->showVerticalLines && w > 60)
|
||||
if (!d->verticalLinesScroll && d->showVerticalLines && w > 60) {
|
||||
drawVerticalLines(&pCache, top, w, h);
|
||||
}
|
||||
|
||||
if (d->showHorizontalLines)
|
||||
if (d->showHorizontalLines) {
|
||||
drawHorizontalLines(&pCache, top, w, h);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (d->showThinFrame) {
|
||||
@ -600,7 +653,7 @@ void SignalPlotter::drawWidget(QPainter *p, uint w, uint height, int horizontalS
|
||||
w--;
|
||||
}
|
||||
}
|
||||
p->drawPixmap(0,0, d->backgroundPixmap);
|
||||
p->drawPixmap(0, 0, d->backgroundPixmap);
|
||||
p->setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
if (showTopBar) {
|
||||
@ -611,21 +664,22 @@ void SignalPlotter::drawWidget(QPainter *p, uint w, uint height, int horizontalS
|
||||
|
||||
p->setClipRect(0, top, w, h);
|
||||
// Draw scope-like grid vertical lines
|
||||
if (d->verticalLinesScroll && d->showVerticalLines && w > 60)
|
||||
if (d->verticalLinesScroll && d->showVerticalLines && w > 60) {
|
||||
drawVerticalLines(p, top, w, h);
|
||||
}
|
||||
|
||||
drawPlots(p, top, w, h, horizontalScale);
|
||||
|
||||
if (d->showLabels && w > 60 && h > (fontheight + 1)) // if there's room to draw the labels, then draw them!
|
||||
if (d->showLabels && w > 60 && h > (fontheight + 1)) {
|
||||
// if there's room to draw the labels, then draw them!
|
||||
drawAxisText(p, top, h);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void SignalPlotter::drawBackground(QPainter *p, int w, int h)
|
||||
{
|
||||
p->fillRect(0,0,w, h, d->backgroundColor);
|
||||
if (d->svgBackground)
|
||||
{
|
||||
p->fillRect(0, 0, w, h, d->backgroundColor);
|
||||
if (d->svgBackground) {
|
||||
d->svgBackground->resize(w, h);
|
||||
d->svgBackground->paint(p, 0, 0);
|
||||
}
|
||||
@ -645,37 +699,39 @@ void SignalPlotter::calculateNiceRange()
|
||||
d->niceVertRange = d->verticalMax - d->verticalMin;
|
||||
// If the range is too small we will force it to 1.0 since it
|
||||
// looks a lot nicer.
|
||||
if (d->niceVertRange < 0.000001)
|
||||
if (d->niceVertRange < 0.000001) {
|
||||
d->niceVertRange = 1.0;
|
||||
}
|
||||
|
||||
d->niceVertMin = d->verticalMin;
|
||||
if (d->verticalMin != 0.0) {
|
||||
double dim = pow(10, floor(log10(fabs(d->verticalMin)))) / 2;
|
||||
if (d->verticalMin < 0.0)
|
||||
if (d->verticalMin < 0.0) {
|
||||
d->niceVertMin = dim * floor(d->verticalMin / dim);
|
||||
else
|
||||
} else {
|
||||
d->niceVertMin = dim * ceil(d->verticalMin / dim);
|
||||
}
|
||||
d->niceVertRange = d->verticalMax - d->niceVertMin;
|
||||
if (d->niceVertRange < 0.000001)
|
||||
if (d->niceVertRange < 0.000001) {
|
||||
d->niceVertRange = 1.0;
|
||||
}
|
||||
}
|
||||
// Massage the range so that the grid shows some nice values.
|
||||
double step = d->niceVertRange / (d->scaledBy*(d->horizontalLinesCount+1));
|
||||
double step = d->niceVertRange / (d->scaledBy * (d->horizontalLinesCount + 1));
|
||||
int logdim = (int)floor(log10(step));
|
||||
double dim = pow((double)10.0, logdim) / 2;
|
||||
int a = (int)ceil(step / dim);
|
||||
if (logdim >= 0)
|
||||
if (logdim >= 0) {
|
||||
d->precision = 0;
|
||||
else if (a % 2 == 0){
|
||||
d->precision =-logdim;
|
||||
} else if (a % 2 == 0) {
|
||||
d->precision = -logdim;
|
||||
} else {
|
||||
d->precision = 1-logdim;
|
||||
d->precision = 1 - logdim;
|
||||
}
|
||||
d->niceVertRange = d->scaledBy*dim * a * (d->horizontalLinesCount+1);
|
||||
d->niceVertRange = d->scaledBy * dim * a * (d->horizontalLinesCount + 1);
|
||||
d->niceVertMax = d->niceVertMin + d->niceVertRange;
|
||||
}
|
||||
|
||||
|
||||
void SignalPlotter::drawTopBarFrame(QPainter *p, int separatorX, int height)
|
||||
{
|
||||
// Draw horizontal bar with current sensor values at top of display.
|
||||
@ -685,12 +741,13 @@ void SignalPlotter::drawTopBarFrame(QPainter *p, int separatorX, int height)
|
||||
p->setPen(d->fontColor);
|
||||
p->drawText(0, 1, separatorX, height, Qt::AlignCenter, d->title);
|
||||
p->setPen(d->horizontalLinesColor);
|
||||
p->drawLine(separatorX - 1, 1, separatorX - 1, height-1);
|
||||
p->drawLine(separatorX - 1, 1, separatorX - 1, height - 1);
|
||||
}
|
||||
|
||||
void SignalPlotter::drawTopBarContents(QPainter *p, int x, int width, int height)
|
||||
{
|
||||
// The height is the height of the contents, so this will be one pixel less than the height of the topbar
|
||||
// The height is the height of the contents, so this will be
|
||||
// one pixel less than the height of the topbar
|
||||
double bias = -d->niceVertMin;
|
||||
double scaleFac = width / d->niceVertRange;
|
||||
// The top bar shows the current values of all the plot data.
|
||||
@ -701,8 +758,8 @@ void SignalPlotter::drawTopBarContents(QPainter *p, int x, int width, int height
|
||||
double newest_datapoint = newestData.at(i);
|
||||
int start = x + (int)(bias * scaleFac);
|
||||
int end = x + (int)((bias += newest_datapoint) * scaleFac);
|
||||
int start2 = qMin(start,end);
|
||||
end = qMax(start,end);
|
||||
int start2 = qMin(start, end);
|
||||
end = qMax(start, end);
|
||||
start = start2;
|
||||
|
||||
// If the rect is wider than 2 pixels we draw only the last
|
||||
@ -710,7 +767,7 @@ void SignalPlotter::drawTopBarContents(QPainter *p, int x, int width, int height
|
||||
// a 50% darker color.
|
||||
|
||||
p->setPen(Qt::NoPen);
|
||||
QLinearGradient linearGrad(QPointF(start,1), QPointF(end, 1));
|
||||
QLinearGradient linearGrad(QPointF(start, 1), QPointF(end, 1));
|
||||
linearGrad.setColorAt(0, d->plotColors[i].darkColor);
|
||||
linearGrad.setColorAt(1, d->plotColors[i].color);
|
||||
p->fillRect(start, 1, end - start, height-1, QBrush(linearGrad));
|
||||
@ -721,14 +778,19 @@ void SignalPlotter::drawTopBarContents(QPainter *p, int x, int width, int height
|
||||
void SignalPlotter::drawVerticalLines(QPainter *p, int top, int w, int h)
|
||||
{
|
||||
p->setPen(d->verticalLinesColor);
|
||||
for (int x = d->verticalLinesOffset; x < (w - 2); x += d->verticalLinesDistance)
|
||||
for (int x = d->verticalLinesOffset; x < (w - 2); x += d->verticalLinesDistance) {
|
||||
p->drawLine(w - x, top, w - x, h + top -1);
|
||||
}
|
||||
}
|
||||
|
||||
void SignalPlotter::drawPlots(QPainter *p, int top, int w, int h, int horizontalScale)
|
||||
{
|
||||
Q_ASSERT(d->niceVertRange != 0); if (d->niceVertRange == 0) d->niceVertRange = 1;
|
||||
double scaleFac = (h-1) / d->niceVertRange;
|
||||
Q_ASSERT(d->niceVertRange != 0);
|
||||
|
||||
if (d->niceVertRange == 0) {
|
||||
d->niceVertRange = 1;
|
||||
}
|
||||
double scaleFac = (h - 1) / d->niceVertRange;
|
||||
|
||||
int xPos = 0;
|
||||
QList< QList<double> >::Iterator it = d->plotData.begin();
|
||||
@ -746,35 +808,40 @@ void SignalPlotter::drawPlots(QPainter *p, int top, int w, int h, int horizontal
|
||||
// calculateNiceRange() which massages these values into a nicer
|
||||
// values. Rounding etc. This means it's safe to change these values
|
||||
// without affecting any other drawings.
|
||||
if (d->useAutoRange)
|
||||
if (d->useAutoRange) {
|
||||
d->verticalMin = d->verticalMax = 0.0;
|
||||
}
|
||||
|
||||
// d->bezierCurveOffset is how many points we have at the start.
|
||||
// All the bezier curves are in groups of 3, with the first of the next group being the last point
|
||||
// of the previous group
|
||||
// All the bezier curves are in groups of 3, with the first of the
|
||||
// next group being the last point of the previous group
|
||||
|
||||
// Example, when d->bezierCurveOffset == 0, and we have data, then just plot a normal bezier curve.
|
||||
// (we will have at least 3 points in this case)
|
||||
// When d->bezierCurveOffset == 1, then we want a bezier curve that uses the first data point and
|
||||
// the second data point. Then the next group starts from the second data point.
|
||||
// When d->bezierCurveOffset == 2, then we want a bezier curve that uses the first, second and third data.
|
||||
// Example, when d->bezierCurveOffset == 0, and we have data, then just
|
||||
// plot a normal bezier curve. (we will have at least 3 points in this case)
|
||||
// When d->bezierCurveOffset == 1, then we want a bezier curve that uses
|
||||
// the first data point and the second data point. Then the next group
|
||||
// starts from the second data point.
|
||||
//
|
||||
// When d->bezierCurveOffset == 2, then we want a bezier curve that
|
||||
// uses the first, second and third data.
|
||||
for (uint i = 0; it != d->plotData.end() && i < d->samples; ++i) {
|
||||
QPen pen;
|
||||
pen.setWidth(1);
|
||||
pen.setCapStyle(Qt::FlatCap);
|
||||
|
||||
// We will plot 1 bezier curve for every 3 points, with the 4th point being the end
|
||||
// of one bezier curve and the start of the second. This does means the bezier curves
|
||||
// will not join nicely, but it should be better than nothing.
|
||||
// We will plot 1 bezier curve for every 3 points, with the 4th point
|
||||
// being the end of one bezier curve and the start of the second.
|
||||
// This does means the bezier curves will not join nicely, but it
|
||||
// should be better than nothing.
|
||||
QList<double> datapoints = *it;
|
||||
QList<double> prev_datapoints = datapoints;
|
||||
QList<double> prev_prev_datapoints = datapoints;
|
||||
QList<double> prev_prev_prev_datapoints = datapoints;
|
||||
|
||||
if (i == 0 && d->bezierCurveOffset>0) {
|
||||
// We are plotting an incomplete bezier curve - we don't have all the data we want.
|
||||
// Try to cope.
|
||||
xPos += horizontalScale*d->bezierCurveOffset;
|
||||
if (i == 0 && d->bezierCurveOffset > 0) {
|
||||
// We are plotting an incomplete bezier curve - we don't have
|
||||
// all the data we want. Try to cope.
|
||||
xPos += horizontalScale * d->bezierCurveOffset;
|
||||
if (d->bezierCurveOffset == 1) {
|
||||
prev_datapoints = *it;
|
||||
++it; // Now we are on the first element of the next group, if it exists
|
||||
@ -799,7 +866,7 @@ void SignalPlotter::drawPlots(QPainter *p, int top, int w, int h, int horizontal
|
||||
}
|
||||
} else {
|
||||
// We have a group of 3 points at least. That's 1 start point and 2 control points.
|
||||
xPos += horizontalScale*3;
|
||||
xPos += horizontalScale * 3;
|
||||
it++;
|
||||
if (it != d->plotData.end()) {
|
||||
prev_datapoints = *it;
|
||||
@ -811,7 +878,8 @@ void SignalPlotter::drawPlots(QPainter *p, int top, int w, int h, int horizontal
|
||||
// We have this datapoint, so use it for our finish point
|
||||
prev_prev_prev_datapoints = *it;
|
||||
} else {
|
||||
// We don't have the next set, so use our last control point as our finish point
|
||||
// We don't have the next set, so use our last control
|
||||
// point as our finish point
|
||||
prev_prev_prev_datapoints = prev_prev_datapoints;
|
||||
}
|
||||
} else {
|
||||
@ -822,24 +890,32 @@ void SignalPlotter::drawPlots(QPainter *p, int top, int w, int h, int horizontal
|
||||
}
|
||||
}
|
||||
|
||||
float x0 = w - xPos + 3.0*horizontalScale;
|
||||
float x1 = w - xPos + 2.0*horizontalScale;
|
||||
float x2 = w - xPos + 1.0*horizontalScale;
|
||||
float x0 = w - xPos + 3.0 * horizontalScale;
|
||||
float x1 = w - xPos + 2.0 * horizontalScale;
|
||||
float x2 = w - xPos + 1.0 * horizontalScale;
|
||||
float x3 = w - xPos;
|
||||
float y0 = h -1 + top;
|
||||
float y0 = h - 1 + top;
|
||||
float y1 = y0;
|
||||
float y2 = y0;
|
||||
float y3 = y0;
|
||||
|
||||
int offset = 0; // Our line is 2 pixels thick. This means that when we draw the area, we need to offset
|
||||
double max_y=0;
|
||||
double min_y=0;
|
||||
for (int j = qMin(datapoints.size(), d->plotColors.size())-1; j >=0 ; --j) {
|
||||
double max_y = 0;
|
||||
double min_y = 0;
|
||||
for (int j = qMin(datapoints.size(), d->plotColors.size()) - 1; j >=0; --j) {
|
||||
if (d->useAutoRange) {
|
||||
// If we use autorange, then we need to prepare the min and max values for _next_ time we paint.
|
||||
// If we are stacking the plots, then we need to add the maximums together.
|
||||
double current_maxvalue = qMax(datapoints[j], qMax(prev_datapoints[j], qMax(prev_prev_datapoints[j], prev_prev_prev_datapoints[j])));
|
||||
double current_minvalue = qMin(datapoints[j], qMin(prev_datapoints[j], qMin(prev_prev_datapoints[j], prev_prev_prev_datapoints[j])));
|
||||
double current_maxvalue =
|
||||
qMax(datapoints[j],
|
||||
qMax(prev_datapoints[j],
|
||||
qMax(prev_prev_datapoints[j],
|
||||
prev_prev_prev_datapoints[j])));
|
||||
double current_minvalue =
|
||||
qMin(datapoints[j],
|
||||
qMin(prev_datapoints[j],
|
||||
qMin(prev_prev_datapoints[j],
|
||||
prev_prev_prev_datapoints[j])));
|
||||
d->verticalMax = qMax(d->verticalMax, current_maxvalue);
|
||||
d->verticalMin = qMin(d->verticalMin, current_maxvalue);
|
||||
if (d->stackPlots) {
|
||||
@ -853,35 +929,46 @@ void SignalPlotter::drawPlots(QPainter *p, int top, int w, int h, int horizontal
|
||||
j < prev_prev_datapoints.count() &&
|
||||
j < prev_datapoints.count()) {
|
||||
|
||||
// The height of the whole widget is h+top-> The height of the area we are plotting in is just h.
|
||||
// The y coordinate system starts from the top, so at the bottom the y coordinate is h+top.
|
||||
// The height of the whole widget is h+top-> The height of
|
||||
// the area we are plotting in is just h.
|
||||
// The y coordinate system starts from the top, so at the
|
||||
// bottom the y coordinate is h+top.
|
||||
// So to draw a point at value y', we need to put this at h+top-y'
|
||||
float delta_y0;
|
||||
delta_y0 = (datapoints[j] - d->niceVertMin)*scaleFac;
|
||||
delta_y0 = (datapoints[j] - d->niceVertMin) * scaleFac;
|
||||
|
||||
float delta_y1;
|
||||
delta_y1 = (prev_datapoints[j] - d->niceVertMin)*scaleFac;
|
||||
delta_y1 = (prev_datapoints[j] - d->niceVertMin) * scaleFac;
|
||||
|
||||
float delta_y2;
|
||||
delta_y2 = (prev_prev_datapoints[j] - d->niceVertMin)*scaleFac;
|
||||
delta_y2 = (prev_prev_datapoints[j] - d->niceVertMin) * scaleFac;
|
||||
|
||||
float delta_y3;
|
||||
delta_y3 = (prev_prev_prev_datapoints[j] - d->niceVertMin)*scaleFac;
|
||||
delta_y3 = (prev_prev_prev_datapoints[j] - d->niceVertMin) * scaleFac;
|
||||
|
||||
QPainterPath path;
|
||||
if (d->stackPlots && offset) {
|
||||
// we don't want the lines to overdraw each other. This isn't a great solution though :(
|
||||
if (delta_y0 < 3) delta_y0=3;
|
||||
if (delta_y1 < 3) delta_y1=3;
|
||||
if (delta_y2 < 3) delta_y2=3;
|
||||
if (delta_y3 < 3) delta_y3=3;
|
||||
// we don't want the lines to overdraw each other.
|
||||
// This isn't a great solution though :(
|
||||
if (delta_y0 < 3) {
|
||||
delta_y0=3;
|
||||
}
|
||||
if (delta_y1 < 3) {
|
||||
delta_y1=3;
|
||||
}
|
||||
if (delta_y2 < 3) {
|
||||
delta_y2=3;
|
||||
}
|
||||
if (delta_y3 < 3) {
|
||||
delta_y3=3;
|
||||
}
|
||||
}
|
||||
path.moveTo(x0,y0-delta_y0);
|
||||
path.cubicTo(x1,y1-delta_y1,x2,y2-delta_y2,x3,y3-delta_y3);
|
||||
path.moveTo(x0, y0 - delta_y0);
|
||||
path.cubicTo(x1, y1 - delta_y1, x2, y2 - delta_y2, x3, y3 - delta_y3);
|
||||
|
||||
if (d->fillPlots) {
|
||||
QPainterPath path2(path);
|
||||
QLinearGradient myGradient(0,(h-1+top),0,(h-1+top)/5);
|
||||
QLinearGradient myGradient(0,(h - 1 + top), 0, (h - 1 + top) / 5);
|
||||
Q_ASSERT(d->plotColors.size() >= j);
|
||||
QColor c0(d->plotColors[j].darkColor);
|
||||
QColor c1(d->plotColors[j].color);
|
||||
@ -890,11 +977,14 @@ void SignalPlotter::drawPlots(QPainter *p, int top, int w, int h, int horizontal
|
||||
myGradient.setColorAt(0, c0);
|
||||
myGradient.setColorAt(1, c1);
|
||||
|
||||
path2.lineTo(x3,y3-offset);
|
||||
if (d->stackPlots)
|
||||
path2.cubicTo(x2,y2-offset,x1,y1-offset,x0,y0-offset); // offset is set to 1 after the first plot is drawn, so we don't trample on top of the 2pt thick line
|
||||
else
|
||||
path2.lineTo(x0,y0-1);
|
||||
path2.lineTo(x3, y3 - offset);
|
||||
if (d->stackPlots) {
|
||||
// offset is set to 1 after the first plot is drawn,
|
||||
// so we don't trample on top of the 2pt thick line
|
||||
path2.cubicTo(x2, y2 - offset, x1, y1 - offset, x0, y0 - offset);
|
||||
} else {
|
||||
path2.lineTo(x0, y0 - 1);
|
||||
}
|
||||
p->setBrush(myGradient);
|
||||
p->setPen(Qt::NoPen);
|
||||
p->drawPath(path2);
|
||||
@ -909,10 +999,10 @@ void SignalPlotter::drawPlots(QPainter *p, int top, int w, int h, int horizontal
|
||||
// We can draw the plots stacked on top of each other.
|
||||
// This means that say plot 0 has the value 2 and plot
|
||||
// 1 has the value 3, then we plot plot 0 at 2 and plot 1 at 2+3 = 5.
|
||||
y0-=delta_y0;
|
||||
y1-=delta_y1;
|
||||
y2-=delta_y2;
|
||||
y3-=delta_y3;
|
||||
y0 -= delta_y0;
|
||||
y1 -= delta_y1;
|
||||
y2 -= delta_y2;
|
||||
y3 -= delta_y3;
|
||||
offset = 1; // see the comment further up for int offset;
|
||||
}
|
||||
}
|
||||
@ -935,17 +1025,27 @@ void SignalPlotter::drawAxisText(QPainter *p, int top, int h)
|
||||
// Note we are drawing from 0,0 as the top left corner. So we have to add on top
|
||||
// to get to the top of where we are drawing so top+h is the height of the widget.
|
||||
p->setPen(d->fontColor);
|
||||
double stepsize = d->niceVertRange/(d->scaledBy*(d->horizontalLinesCount+1));
|
||||
int step = (int)ceil((d->horizontalLinesCount+1) * (p->fontMetrics().height() + p->fontMetrics().leading()/2.0) / h);
|
||||
if (step ==0) step = 1;
|
||||
for (int y = d->horizontalLinesCount+1; y >= 1; y-= step) {
|
||||
int y_coord = top + (y * (h-1)) / (d->horizontalLinesCount+1); // Make sure it's y*h first to avoid rounding bugs
|
||||
if (y_coord - p->fontMetrics().ascent() < top) continue; // at most, only allow 4 pixels of the text to be covered up by the top bar. Otherwise just don't bother to draw it
|
||||
double stepsize = d->niceVertRange / (d->scaledBy * (d->horizontalLinesCount + 1));
|
||||
int step =
|
||||
(int)ceil((d->horizontalLinesCount+1) *
|
||||
(p->fontMetrics().height() + p->fontMetrics().leading() / 2.0) / h);
|
||||
if (step == 0) {
|
||||
step = 1;
|
||||
}
|
||||
for (int y = d->horizontalLinesCount + 1; y >= 1; y-= step) {
|
||||
int y_coord =
|
||||
top + (y * (h - 1)) / (d->horizontalLinesCount + 1); // Make sure it's y*h first to avoid rounding bugs
|
||||
if (y_coord - p->fontMetrics().ascent() < top) {
|
||||
// at most, only allow 4 pixels of the text to be covered up
|
||||
// by the top bar. Otherwise just don't bother to draw it
|
||||
continue;
|
||||
}
|
||||
double value;
|
||||
if ((uint)y == d->horizontalLinesCount+1)
|
||||
if ((uint)y == d->horizontalLinesCount + 1) {
|
||||
value = d->niceVertMin; // sometimes using the formulas gives us a value very slightly off
|
||||
else
|
||||
value = d->niceVertMax/d->scaledBy - y * stepsize;
|
||||
} else {
|
||||
value = d->niceVertMax / d->scaledBy - y * stepsize;
|
||||
}
|
||||
|
||||
QString number = KGlobal::locale()->formatNumber(value, d->precision);
|
||||
val = QString("%1 %2").arg(number, d->unit);
|
||||
@ -956,22 +1056,26 @@ void SignalPlotter::drawAxisText(QPainter *p, int top, int h)
|
||||
void SignalPlotter::drawHorizontalLines(QPainter *p, int top, int w, int h)
|
||||
{
|
||||
p->setPen(d->horizontalLinesColor);
|
||||
for (uint y = 0; y <= d->horizontalLinesCount+1; y++) {
|
||||
for (uint y = 0; y <= d->horizontalLinesCount + 1; y++) {
|
||||
// note that the y_coord starts from 0. so we draw from pixel number 0 to h-1. Thus the -1 in the y_coord
|
||||
int y_coord = top + (y * (h-1)) / (d->horizontalLinesCount+1); // Make sure it's y*h first to avoid rounding bugs
|
||||
int y_coord = top + (y * (h - 1)) / (d->horizontalLinesCount + 1); // Make sure it's y*h first to avoid rounding bugs
|
||||
p->drawLine(0, y_coord, w - 2, y_coord);
|
||||
}
|
||||
}
|
||||
|
||||
double SignalPlotter::lastValue(uint i) const
|
||||
{
|
||||
if (d->plotData.isEmpty() || d->plotData.first().size() <= (int) i) return 0;
|
||||
if (d->plotData.isEmpty() || d->plotData.first().size() <= (int)i) {
|
||||
return 0;
|
||||
}
|
||||
return d->plotData.first()[i];
|
||||
}
|
||||
|
||||
QString SignalPlotter::lastValueAsString(uint i) const
|
||||
{
|
||||
if (d->plotData.isEmpty()) return QString();
|
||||
if (d->plotData.isEmpty()) {
|
||||
return QString();
|
||||
}
|
||||
double value = d->plotData.first()[i] / d->scaledBy; // retrieve the newest value for this plot then scale it correct
|
||||
QString number = KGlobal::locale()->formatNumber(value, (value >= 100)?0:2);
|
||||
return QString("%1 %2").arg(number, d->unit);
|
||||
|
@ -45,26 +45,26 @@ struct PlotColor
|
||||
class PLASMA_EXPORT SignalPlotter : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( QString title READ title WRITE setTitle )
|
||||
Q_PROPERTY( QString unit READ unit WRITE setUnit )
|
||||
Q_PROPERTY( qreal scale READ scaledBy WRITE scale ) // Note: The naming of the functions here is poor
|
||||
Q_PROPERTY( bool useAutoRange READ useAutoRange WRITE setUseAutoRange )
|
||||
Q_PROPERTY( uint horizontalScale READ horizontalScale WRITE setHorizontalScale )
|
||||
Q_PROPERTY( bool showVerticalLines READ showVerticalLines WRITE setShowVerticalLines )
|
||||
Q_PROPERTY( QColor verticalLinesColor READ verticalLinesColor WRITE setVerticalLinesColor )
|
||||
Q_PROPERTY( uint verticalLinesDistance READ verticalLinesDistance WRITE setVerticalLinesDistance )
|
||||
Q_PROPERTY( bool verticalLinesScroll READ verticalLinesScroll WRITE setVerticalLinesScroll )
|
||||
Q_PROPERTY( bool showHorizontalLines READ showHorizontalLines WRITE setShowHorizontalLines )
|
||||
Q_PROPERTY( QColor horizontalLinesColor READ horizontalLinesColor WRITE setHorizontalLinesColor )
|
||||
Q_PROPERTY( QColor fontColor READ fontColor WRITE setFontColor )
|
||||
Q_PROPERTY( QFont font READ font WRITE setFont )
|
||||
Q_PROPERTY( uint horizontalLinesCount READ horizontalLinesCount WRITE setHorizontalLinesCount )
|
||||
Q_PROPERTY( bool showLabels READ showLabels WRITE setShowLabels )
|
||||
Q_PROPERTY( bool showTopBar READ showTopBar WRITE setShowTopBar )
|
||||
Q_PROPERTY( QColor backgroundColor READ backgroundColor WRITE setBackgroundColor )
|
||||
Q_PROPERTY( QString svgBackground READ svgBackground WRITE setSvgBackground )
|
||||
Q_PROPERTY( bool thinFrame WRITE setThinFrame )
|
||||
Q_PROPERTY( bool stackPlots READ stackPlots WRITE setStackPlots )
|
||||
Q_PROPERTY(QString title READ title WRITE setTitle)
|
||||
Q_PROPERTY(QString unit READ unit WRITE setUnit)
|
||||
Q_PROPERTY(qreal scale READ scaledBy WRITE scale) // Note: The naming of the functions here is poor
|
||||
Q_PROPERTY(bool useAutoRange READ useAutoRange WRITE setUseAutoRange)
|
||||
Q_PROPERTY(uint horizontalScale READ horizontalScale WRITE setHorizontalScale)
|
||||
Q_PROPERTY(bool showVerticalLines READ showVerticalLines WRITE setShowVerticalLines)
|
||||
Q_PROPERTY(QColor verticalLinesColor READ verticalLinesColor WRITE setVerticalLinesColor)
|
||||
Q_PROPERTY(uint verticalLinesDistance READ verticalLinesDistance WRITE setVerticalLinesDistance)
|
||||
Q_PROPERTY(bool verticalLinesScroll READ verticalLinesScroll WRITE setVerticalLinesScroll)
|
||||
Q_PROPERTY(bool showHorizontalLines READ showHorizontalLines WRITE setShowHorizontalLines)
|
||||
Q_PROPERTY(QColor horizontalLinesColor READ horizontalLinesColor WRITE setHorizontalLinesColor)
|
||||
Q_PROPERTY(QColor fontColor READ fontColor WRITE setFontColor)
|
||||
Q_PROPERTY(QFont font READ font WRITE setFont)
|
||||
Q_PROPERTY(uint horizontalLinesCount READ horizontalLinesCount WRITE setHorizontalLinesCount)
|
||||
Q_PROPERTY(bool showLabels READ showLabels WRITE setShowLabels)
|
||||
Q_PROPERTY(bool showTopBar READ showTopBar WRITE setShowTopBar)
|
||||
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
|
||||
Q_PROPERTY(QString svgBackground READ svgBackground WRITE setSvgBackground)
|
||||
Q_PROPERTY(bool thinFrame WRITE setThinFrame)
|
||||
Q_PROPERTY(bool stackPlots READ stackPlots WRITE setStackPlots)
|
||||
|
||||
public:
|
||||
SignalPlotter(QGraphicsItem *parent = 0);
|
||||
|
@ -46,7 +46,6 @@ public:
|
||||
Plasma::PanelSvg *handle;
|
||||
};
|
||||
|
||||
|
||||
Slider::Slider(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new SliderPrivate)
|
||||
@ -103,21 +102,25 @@ void Slider::paint(QPainter *painter,
|
||||
sliderOpt.sliderValue = slider->value();
|
||||
sliderOpt.singleStep = slider->singleStep();
|
||||
sliderOpt.pageStep = slider->pageStep();
|
||||
if (slider->orientation() == Qt::Horizontal)
|
||||
if (slider->orientation() == Qt::Horizontal) {
|
||||
sliderOpt.state |= QStyle::State_Horizontal;
|
||||
}
|
||||
|
||||
QRect backgroundRect = style->subControlRect(QStyle::CC_Slider, &sliderOpt, QStyle::SC_SliderGroove, slider);
|
||||
QRect backgroundRect =
|
||||
style->subControlRect(QStyle::CC_Slider, &sliderOpt, QStyle::SC_SliderGroove, slider);
|
||||
d->background->resizePanel(backgroundRect.size());
|
||||
d->background->paintPanel(painter, backgroundRect.topLeft());
|
||||
|
||||
//Thickmarks
|
||||
if (sliderOpt.tickPosition != QSlider::NoTicks) {
|
||||
sliderOpt.subControls = QStyle::SC_SliderTickmarks;
|
||||
sliderOpt.palette.setColor(QPalette::WindowText, Plasma::Theme::defaultTheme()->color(Theme::TextColor));
|
||||
sliderOpt.palette.setColor(
|
||||
QPalette::WindowText, Plasma::Theme::defaultTheme()->color(Theme::TextColor));
|
||||
style->drawComplexControl(QStyle::CC_Slider, &sliderOpt, painter, slider);
|
||||
}
|
||||
|
||||
QRect handleRect = style->subControlRect(QStyle::CC_Slider, &sliderOpt, QStyle::SC_SliderHandle, slider);
|
||||
QRect handleRect =
|
||||
style->subControlRect(QStyle::CC_Slider, &sliderOpt, QStyle::SC_SliderHandle, slider);
|
||||
d->handle->resizePanel(handleRect.size());
|
||||
d->handle->paintPanel(painter, handleRect.topLeft());
|
||||
}
|
||||
@ -177,12 +180,11 @@ QString Slider::styleSheet()
|
||||
return widget()->styleSheet();
|
||||
}
|
||||
|
||||
QSlider* Slider::nativeWidget() const
|
||||
QSlider *Slider::nativeWidget() const
|
||||
{
|
||||
return static_cast<QSlider*>(widget());
|
||||
}
|
||||
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
#include <slider.moc>
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_SLIDER_H
|
||||
#define PLASMA_SLIDER_H
|
||||
|
||||
@ -41,13 +40,13 @@ class PLASMA_EXPORT Slider : public QGraphicsProxyWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QGraphicsWidget* parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QGraphicsWidget *parentWidget READ parentWidget)
|
||||
Q_PROPERTY(int maximum READ maximum WRITE setMinimum)
|
||||
Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
|
||||
Q_PROPERTY(int value READ value WRITE setValue)
|
||||
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
|
||||
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
||||
Q_PROPERTY(QSlider* nativeWidget READ nativeWidget)
|
||||
Q_PROPERTY(QSlider *nativeWidget READ nativeWidget)
|
||||
|
||||
public:
|
||||
explicit Slider(QGraphicsWidget *parent = 0);
|
||||
@ -88,7 +87,7 @@ public:
|
||||
/**
|
||||
* @return the native widget wrapped by this Slider
|
||||
*/
|
||||
QSlider* nativeWidget() const;
|
||||
QSlider *nativeWidget() const;
|
||||
|
||||
protected:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
@ -53,10 +53,11 @@ public:
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
//Don't paint the child widgets
|
||||
static_cast<NativeTabBar *>(QGraphicsProxyWidget::widget())->render(painter, QPoint(0,0), QRegion(), 0);
|
||||
static_cast<NativeTabBar *>(QGraphicsProxyWidget::widget())->render(
|
||||
painter, QPoint(0, 0), QRegion(), 0);
|
||||
}
|
||||
|
||||
NativeTabBar *native;
|
||||
@ -99,8 +100,6 @@ public:
|
||||
int newPageAnimId;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void TabBarPrivate::updateTabWidgetMode()
|
||||
{
|
||||
bool tabWidget = false;
|
||||
@ -171,7 +170,6 @@ void TabBarPrivate::shapeChanged(const QTabBar::Shape shape)
|
||||
tabProxy->setPreferredSize(tabProxy->native->sizeHint());
|
||||
}
|
||||
|
||||
|
||||
TabBar::TabBar(QGraphicsWidget *parent)
|
||||
: QGraphicsWidget(parent),
|
||||
d(new TabBarPrivate(this))
|
||||
@ -184,7 +182,6 @@ TabBar::TabBar(QGraphicsWidget *parent)
|
||||
|
||||
d->mainLayout->addItem(d->tabBarLayout);
|
||||
|
||||
|
||||
//tabBar is centered, so a stretch at begin one at the end
|
||||
//FIXME: doesn't seem to be possible to remove stretches from a layout
|
||||
d->leftSpacer = new QGraphicsWidget(this);
|
||||
@ -196,9 +193,12 @@ TabBar::TabBar(QGraphicsWidget *parent)
|
||||
d->tabBarLayout->addItem(d->rightSpacer);
|
||||
//d->tabBarLayout->setStretchFactor(d->tabProxy, 2);
|
||||
|
||||
connect(d->tabProxy->native, SIGNAL(currentChanged(int)), this, SLOT(setCurrentIndex(int)));
|
||||
connect(d->tabProxy->native, SIGNAL(shapeChanged(QTabBar::Shape)), this, SLOT(shapeChanged(QTabBar::Shape)));
|
||||
connect(Plasma::Animator::self(), SIGNAL(movementFinished(QGraphicsItem*)), this, SLOT(slidingCompleted(QGraphicsItem*)));
|
||||
connect(d->tabProxy->native, SIGNAL(currentChanged(int)),
|
||||
this, SLOT(setCurrentIndex(int)));
|
||||
connect(d->tabProxy->native, SIGNAL(shapeChanged(QTabBar::Shape)),
|
||||
this, SLOT(shapeChanged(QTabBar::Shape)));
|
||||
connect(Plasma::Animator::self(), SIGNAL(movementFinished(QGraphicsItem*)),
|
||||
this, SLOT(slidingCompleted(QGraphicsItem*)));
|
||||
}
|
||||
|
||||
TabBar::~TabBar()
|
||||
@ -206,7 +206,8 @@ TabBar::~TabBar()
|
||||
delete d;
|
||||
}
|
||||
|
||||
int TabBar::insertTab(int index, const QIcon &icon, const QString &label, QGraphicsLayoutItem *content)
|
||||
int TabBar::insertTab(int index, const QIcon &icon, const QString &label,
|
||||
QGraphicsLayoutItem *content)
|
||||
{
|
||||
QGraphicsWidget *page = new QGraphicsWidget(this);
|
||||
page->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
@ -304,13 +305,19 @@ void TabBar::setCurrentIndex(int index)
|
||||
QRect beforeCurrentGeom(d->oldPage->geometry().toRect());
|
||||
beforeCurrentGeom.moveTopRight(beforeCurrentGeom.topLeft());
|
||||
|
||||
d->newPageAnimId = Animator::self()->moveItem(d->newPage, Plasma::Animator::SlideOutMovement, d->oldPage->pos().toPoint());
|
||||
d->newPageAnimId = Animator::self()->moveItem(
|
||||
d->newPage, Plasma::Animator::SlideOutMovement,
|
||||
d->oldPage->pos().toPoint());
|
||||
if (index > d->currentIndex) {
|
||||
d->newPage->setPos(d->oldPage->geometry().topRight());
|
||||
d->oldPageAnimId = Animator::self()->moveItem(d->oldPage, Plasma::Animator::SlideOutMovement, beforeCurrentGeom.topLeft());
|
||||
d->oldPageAnimId = Animator::self()->moveItem(
|
||||
d->oldPage, Plasma::Animator::SlideOutMovement,
|
||||
beforeCurrentGeom.topLeft());
|
||||
} else {
|
||||
d->newPage->setPos(beforeCurrentGeom.topLeft());
|
||||
d->oldPageAnimId = Animator::self()->moveItem(d->oldPage, Plasma::Animator::SlideOutMovement, d->oldPage->geometry().topRight().toPoint());
|
||||
d->oldPageAnimId = Animator::self()->moveItem(
|
||||
d->oldPage, Plasma::Animator::SlideOutMovement,
|
||||
d->oldPage->geometry().topRight().toPoint());
|
||||
}
|
||||
#else
|
||||
d->mainLayout->addItem(d->pages[index]);
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_TABWIDGET_H
|
||||
#define PLASMA_TABWIDGET_H
|
||||
|
||||
@ -47,9 +46,9 @@ class PLASMA_EXPORT TabBar : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QTabBar* nativeWidget READ nativeWidget)
|
||||
Q_PROPERTY( int currentIndex READ currentIndex WRITE setCurrentIndex)
|
||||
Q_PROPERTY( int count READ count)
|
||||
Q_PROPERTY(QTabBar *nativeWidget READ nativeWidget)
|
||||
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex)
|
||||
Q_PROPERTY(int count READ count)
|
||||
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
||||
|
||||
public:
|
||||
@ -72,7 +71,8 @@ public:
|
||||
* @arg content the page content that will be shown by this tab
|
||||
* @return the index of the inserted tab
|
||||
*/
|
||||
int insertTab(int index, const QIcon &icon, const QString &label, QGraphicsLayoutItem *content = 0);
|
||||
int insertTab(int index, const QIcon &icon, const QString &label,
|
||||
QGraphicsLayoutItem *content = 0);
|
||||
|
||||
/**
|
||||
* Adds a new tab in the desired position
|
||||
@ -191,7 +191,7 @@ Q_SIGNALS:
|
||||
|
||||
protected:
|
||||
void wheelEvent(QGraphicsSceneWheelEvent *event);
|
||||
|
||||
|
||||
private:
|
||||
TabBarPrivate * const d;
|
||||
|
||||
|
@ -106,7 +106,7 @@ void <Name>::setImage(const QString &path)
|
||||
d->svg = 0;
|
||||
d->imagePath = path;
|
||||
|
||||
bool absolutePath = !path.isEmpty() &&
|
||||
bool absolutePath = !path.isEmpty() &&
|
||||
#ifdef Q_WS_WIN
|
||||
!QDir::isRelativePath(path)
|
||||
#else
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_<NAME>_H
|
||||
#define PLASMA_<NAME>_H
|
||||
|
||||
@ -41,7 +40,7 @@ class PLASMA_EXPORT <Name> : public QGraphicsProxyWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QGraphicsWidget* parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QGraphicsWidget *parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(QString image READ image WRITE setImage)
|
||||
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
||||
@ -53,7 +52,7 @@ public:
|
||||
|
||||
/**
|
||||
* Sets the display text for this <Name>
|
||||
*
|
||||
*
|
||||
* @arg text the text to display; should be translated.
|
||||
*/
|
||||
void setText(const QString &text);
|
||||
|
@ -48,7 +48,7 @@ TextEdit::TextEdit(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new TextEditPrivate)
|
||||
{
|
||||
KTextEdit* native = new KTextEdit;
|
||||
KTextEdit *native = new KTextEdit;
|
||||
connect(native, SIGNAL(textChanged()), this, SIGNAL(textChanged()));
|
||||
setWidget(native);
|
||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||
@ -83,7 +83,7 @@ QString TextEdit::styleSheet()
|
||||
return widget()->styleSheet();
|
||||
}
|
||||
|
||||
KTextEdit* TextEdit::nativeWidget() const
|
||||
KTextEdit *TextEdit::nativeWidget() const
|
||||
{
|
||||
return static_cast<KTextEdit*>(widget());
|
||||
}
|
||||
@ -92,10 +92,10 @@ void TextEdit::dataUpdated(const QString &sourceName, const Plasma::DataEngine::
|
||||
{
|
||||
Q_UNUSED(sourceName)
|
||||
|
||||
KTextEdit * te = nativeWidget();
|
||||
KTextEdit *te = nativeWidget();
|
||||
te->clear();
|
||||
|
||||
foreach (const QVariant& v, data) {
|
||||
foreach (const QVariant &v, data) {
|
||||
if (v.canConvert(QVariant::String)) {
|
||||
te->append(v.toString() + "\n");
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_TEXTEDIT_H
|
||||
#define PLASMA_TEXTEDIT_H
|
||||
|
||||
@ -42,10 +41,10 @@ class PLASMA_EXPORT TextEdit : public QGraphicsProxyWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QGraphicsWidget* parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QGraphicsWidget *parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(QString stylesheet READ styleSheet WRITE setStyleSheet)
|
||||
Q_PROPERTY(KTextEdit* nativeWidget READ nativeWidget)
|
||||
Q_PROPERTY(KTextEdit *nativeWidget READ nativeWidget)
|
||||
|
||||
public:
|
||||
explicit TextEdit(QGraphicsWidget *parent = 0);
|
||||
@ -53,7 +52,7 @@ public:
|
||||
|
||||
/**
|
||||
* Sets the display text for this TextEdit
|
||||
*
|
||||
*
|
||||
* @arg text the text to display; should be translated.
|
||||
*/
|
||||
void setText(const QString &text);
|
||||
@ -78,7 +77,7 @@ public:
|
||||
/**
|
||||
* @return the native widget wrapped by this TextEdit
|
||||
*/
|
||||
KTextEdit* nativeWidget() const;
|
||||
KTextEdit *nativeWidget() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
|
||||
|
@ -46,7 +46,7 @@ TreeView::TreeView(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new TreeViewPrivate)
|
||||
{
|
||||
QTreeView* native = new QTreeView;
|
||||
QTreeView *native = new QTreeView;
|
||||
setWidget(native);
|
||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||
native->setFrameStyle(QFrame::NoFrame);
|
||||
@ -81,7 +81,7 @@ QString TreeView::styleSheet()
|
||||
return widget()->styleSheet();
|
||||
}
|
||||
|
||||
QTreeView* TreeView::nativeWidget() const
|
||||
QTreeView *TreeView::nativeWidget() const
|
||||
{
|
||||
return static_cast<QTreeView*>(widget());
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_TREEVIEW_H
|
||||
#define PLASMA_TREEVIEW_H
|
||||
|
||||
@ -42,10 +41,10 @@ class PLASMA_EXPORT TreeView : public QGraphicsProxyWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QAbstractItemModel* model READ model WRITE setModel)
|
||||
Q_PROPERTY(QGraphicsWidget* parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel)
|
||||
Q_PROPERTY(QGraphicsWidget *parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
||||
Q_PROPERTY(QTreeView* nativeWidget READ nativeWidget)
|
||||
Q_PROPERTY(QTreeView *nativeWidget READ nativeWidget)
|
||||
|
||||
public:
|
||||
explicit TreeView(QGraphicsWidget *parent = 0);
|
||||
@ -78,10 +77,10 @@ public:
|
||||
/**
|
||||
* @return the native widget wrapped by this TreeView
|
||||
*/
|
||||
QTreeView* nativeWidget() const;
|
||||
QTreeView *nativeWidget() const;
|
||||
|
||||
private:
|
||||
TreeViewPrivate * const d;
|
||||
TreeViewPrivate *const d;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
}
|
||||
|
||||
void loadingFinished(bool success);
|
||||
void updateRequested(const QRect& dirtyRect);
|
||||
void updateRequested(const QRect &dirtyRect);
|
||||
void scrollRequested(int dx, int dy, const QRect &scrollRect);
|
||||
|
||||
WebContent *q;
|
||||
@ -111,19 +111,23 @@ void WebContent::setPage(QWebPage *page)
|
||||
d->page = page;
|
||||
|
||||
if (d->page) {
|
||||
connect(d->page, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int)));
|
||||
connect(d->page, SIGNAL(loadFinished(bool)), this, SLOT(loadingFinished(bool)));
|
||||
connect(d->page, SIGNAL(repaintRequested(const QRect&)), this, SLOT(updateRequested(const QRect&)));
|
||||
connect(d->page, SIGNAL(scrollRequested(int, int, const QRect &)), this, SLOT(scrollRequested(int, int, const QRect &)));
|
||||
connect(d->page, SIGNAL(loadProgress(int)),
|
||||
this, SIGNAL(loadProgress(int)));
|
||||
connect(d->page, SIGNAL(loadFinished(bool)),
|
||||
this, SLOT(loadingFinished(bool)));
|
||||
connect(d->page, SIGNAL(repaintRequested(const QRect&)),
|
||||
this, SLOT(updateRequested(const QRect&)));
|
||||
connect(d->page, SIGNAL(scrollRequested(int, int, const QRect &)),
|
||||
this, SLOT(scrollRequested(int, int, const QRect &)));
|
||||
}
|
||||
}
|
||||
|
||||
QWebPage* WebContent::page() const
|
||||
QWebPage *WebContent::page() const
|
||||
{
|
||||
return d->page;
|
||||
}
|
||||
|
||||
QWebFrame* WebContent::mainFrame() const
|
||||
QWebFrame *WebContent::mainFrame() const
|
||||
{
|
||||
return d->page ? d->page->mainFrame() : 0;
|
||||
}
|
||||
@ -356,10 +360,11 @@ void WebContentPrivate::loadingFinished(bool success)
|
||||
q->update();
|
||||
}
|
||||
|
||||
void WebContentPrivate::updateRequested(const QRect& dirtyRect)
|
||||
void WebContentPrivate::updateRequested(const QRect &dirtyRect)
|
||||
{
|
||||
if (loaded && page) {
|
||||
q->update(QRectF(dirtyRect.topLeft().x(), dirtyRect.topLeft().y(), dirtyRect.width(), dirtyRect.height()));
|
||||
q->update(QRectF(dirtyRect.topLeft().x(), dirtyRect.topLeft().y(),
|
||||
dirtyRect.width(), dirtyRect.height()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,17 +93,17 @@ class PLASMA_EXPORT WebContent : public QGraphicsWidget
|
||||
* The QWebPage associated with this item. Useful when more
|
||||
* of the features of the full QWebPage object need to be accessed.
|
||||
*/
|
||||
QWebPage* page() const;
|
||||
QWebPage *page() const;
|
||||
|
||||
/**
|
||||
* The main web frame associated with this item.
|
||||
*/
|
||||
QWebFrame* mainFrame() const;
|
||||
QWebFrame *mainFrame() const;
|
||||
|
||||
/**
|
||||
* Reimplementation
|
||||
*/
|
||||
void setGeometry(const QRectF &geometry);
|
||||
void setGeometry(const QRectF &geometry);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user