coding style fixes.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=870205
This commit is contained in:
parent
a320742114
commit
eae853582b
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_CHECKBOX_H
|
||||
#define PLASMA_CHECKBOX_H
|
||||
|
||||
|
@ -61,7 +61,6 @@ public:
|
||||
QRectF activeRect;
|
||||
};
|
||||
|
||||
|
||||
void ComboBoxPrivate::syncActiveRect()
|
||||
{
|
||||
background->setElementPrefix("normal");
|
||||
@ -74,7 +73,8 @@ void ComboBoxPrivate::syncActiveRect()
|
||||
background->getMargins(activeLeft, activeTop, activeRight, activeBottom);
|
||||
|
||||
activeRect = QRectF(QPointF(0, 0), q->size());
|
||||
activeRect.adjust(left - activeLeft, top - activeTop, -(right - activeRight), -(bottom - activeBottom));
|
||||
activeRect.adjust(left - activeLeft, top - activeTop,
|
||||
-(right - activeRight), -(bottom - activeBottom));
|
||||
|
||||
background->setElementPrefix("normal");
|
||||
}
|
||||
@ -105,8 +105,6 @@ void ComboBoxPrivate::animationUpdate(qreal progress)
|
||||
q->update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
ComboBox::ComboBox(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new ComboBoxPrivate(this))
|
||||
@ -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
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
@ -236,5 +242,4 @@ void FlashPrivate::setupFlash(Flash *flash, int duration)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include "flash.moc"
|
||||
|
@ -49,8 +49,10 @@ class PLASMA_EXPORT Flash : public QGraphicsWidget
|
||||
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();
|
||||
|
@ -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))
|
||||
@ -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
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_GROUPBOX_H
|
||||
#define PLASMA_GROUPBOX_H
|
||||
|
||||
|
106
widgets/icon.cpp
106
widgets/icon.cpp
@ -192,13 +192,15 @@ bool IconAction::event(QEvent::Type type, const QPointF &pos)
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case QEvent::GraphicsSceneMousePress: {
|
||||
case QEvent::GraphicsSceneMousePress:
|
||||
{
|
||||
setSelected(m_rect.contains(pos));
|
||||
return isSelected();
|
||||
}
|
||||
break;
|
||||
|
||||
case QEvent::GraphicsSceneMouseMove: {
|
||||
case QEvent::GraphicsSceneMouseMove:
|
||||
{
|
||||
bool wasSelected = isSelected();
|
||||
bool active = m_rect.contains(pos);
|
||||
setSelected(wasSelected && active);
|
||||
@ -206,7 +208,8 @@ bool IconAction::event(QEvent::Type type, const QPointF &pos)
|
||||
}
|
||||
break;
|
||||
|
||||
case QEvent::GraphicsSceneMouseRelease: {
|
||||
case QEvent::GraphicsSceneMouseRelease:
|
||||
{
|
||||
// kDebug() << "IconAction::event got a QEvent::MouseButtonRelease, " << isSelected();
|
||||
bool wasSelected = isSelected();
|
||||
setSelected(false);
|
||||
@ -396,7 +399,8 @@ 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
|
||||
@ -409,13 +413,13 @@ QSizeF IconPrivate::displaySizeHint(const QStyleOptionGraphicsItem *option, cons
|
||||
// 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
|
||||
@ -515,9 +519,9 @@ 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)
|
||||
@ -551,15 +555,18 @@ void IconPrivate::drawBackground(QPainter *painter, IconState state)
|
||||
|
||||
switch (state) {
|
||||
case IconPrivate::HoverState:
|
||||
shadow.setHsv(shadow.hue(),
|
||||
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.setHsv(
|
||||
shadow.hue(),
|
||||
shadow.saturation(),
|
||||
shadow.value() + (darkShadow?(int)(50*m_hoverAlpha):(int)(-50*m_hoverAlpha)),
|
||||
shadow.value() + (darkShadow ?
|
||||
(int)(50 * m_hoverAlpha) : (int)(-50 * m_hoverAlpha)),
|
||||
204); //80% opacity
|
||||
break;
|
||||
default:
|
||||
@ -574,7 +581,11 @@ void IconPrivate::drawBackground(QPainter *painter, IconState state)
|
||||
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);
|
||||
|
||||
@ -638,10 +653,12 @@ QPointF IconPrivate::iconPosition(const QStyleOptionGraphicsItem *option, const
|
||||
alignment = Qt::Alignment(Qt::AlignHCenter | Qt::AlignTop);
|
||||
//Horizontal
|
||||
} else {
|
||||
alignment = QStyle::visualAlignment(direction, Qt::Alignment(Qt::AlignLeft | Qt::AlignVCenter));
|
||||
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,7 +670,8 @@ QPointF IconPrivate::iconPosition(const QStyleOptionGraphicsItem *option, const
|
||||
return QPointF(pixmapRect.topLeft());
|
||||
}
|
||||
|
||||
QRectF IconPrivate::labelRectangle(const QStyleOptionGraphicsItem *option, const QPixmap &icon,
|
||||
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)
|
||||
break;
|
||||
} 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);
|
||||
@ -965,7 +986,6 @@ void Icon::drawActionButtonBase(QPainter* painter, const QSize &size, int elemen
|
||||
painter->drawEllipse(QRectF(QPointF(.0, .0), size));
|
||||
}
|
||||
|
||||
|
||||
void Icon::setText(const QString &text)
|
||||
{
|
||||
d->text = text;
|
||||
|
@ -60,6 +60,7 @@ class PLASMA_EXPORT Icon : public QGraphicsWidget
|
||||
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.
|
||||
@ -284,6 +285,7 @@ private:
|
||||
IconPrivate * const d;
|
||||
|
||||
friend class IconPrivate;
|
||||
|
||||
private Q_SLOTS:
|
||||
void actionDestroyed(QObject *obj);
|
||||
void readColors();
|
||||
@ -293,7 +295,6 @@ private Q_SLOTS:
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
|
||||
/*
|
||||
// Add these to UrlIcon
|
||||
void setUrl(const KUrl& url);
|
||||
|
@ -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,
|
||||
QString elidedText(QTextLayout &layout,
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
const QSizeF &maxSize) const;
|
||||
QSizeF layoutText(QTextLayout &layout, const QStyleOptionGraphicsItem *option,
|
||||
|
||||
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;
|
||||
|
||||
QSizeF layoutText(QTextLayout &layout, const QString &text,
|
||||
qreal maxWidth) const;
|
||||
|
||||
inline void setLayoutOptions(QTextLayout &layout, const QStyleOptionGraphicsItem *options) 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);
|
||||
@ -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;
|
||||
|
@ -161,7 +161,7 @@ QLabel* Label::nativeWidget() const
|
||||
|
||||
void Label::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
|
||||
{
|
||||
Q_UNUSED(sourceName)
|
||||
Q_UNUSED(sourceName);
|
||||
|
||||
QStringList texts;
|
||||
foreach (const QVariant &v, data) {
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_LABEL_H
|
||||
#define PLASMA_LABEL_H
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_LINEEDIT_H
|
||||
#define PLASMA_LINEEDIT_H
|
||||
|
||||
|
@ -27,15 +27,15 @@ namespace Plasma {
|
||||
class MeterPrivate
|
||||
{
|
||||
public:
|
||||
MeterPrivate(Meter* m) :
|
||||
minimum(0),
|
||||
MeterPrivate(Meter *m)
|
||||
: minimum(0),
|
||||
maximum(100),
|
||||
value(0),
|
||||
meterType(Meter::AnalogMeter),
|
||||
image(0),
|
||||
minrotate(0),
|
||||
maxrotate(360),
|
||||
meter(m) {};
|
||||
meter(m) {}
|
||||
|
||||
void paint(QPainter *p, const QString &elementID)
|
||||
{
|
||||
@ -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");
|
||||
@ -106,7 +105,8 @@ void PushButtonPrivate::syncActiveRect()
|
||||
background->getMargins(activeLeft, activeTop, activeRight, activeBottom);
|
||||
|
||||
activeRect = QRectF(QPointF(0, 0), q->size());
|
||||
activeRect.adjust(left - activeLeft, top - activeTop, -(right - activeRight), -(bottom - activeBottom));
|
||||
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,7 +137,6 @@ void PushButtonPrivate::animationUpdate(qreal progress)
|
||||
q->update();
|
||||
}
|
||||
|
||||
|
||||
PushButton::PushButton(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new PushButtonPrivate(this))
|
||||
@ -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);
|
||||
@ -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
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_RADIOBUTTON_H
|
||||
#define PLASMA_RADIOBUTTON_H
|
||||
|
||||
|
@ -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,7 +481,9 @@ 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();
|
||||
@ -455,9 +492,10 @@ void SignalPlotter::setSvgBackground(const QString &filename)
|
||||
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
|
||||
}
|
||||
@ -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) {
|
||||
@ -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)
|
||||
{
|
||||
if (d->svgBackground) {
|
||||
d->svgBackground->resize(w, h);
|
||||
d->svgBackground->paint(p, 0, 0);
|
||||
}
|
||||
@ -645,28 +699,31 @@ 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));
|
||||
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){
|
||||
} else if (a % 2 == 0) {
|
||||
d->precision = -logdim;
|
||||
} else {
|
||||
d->precision = 1 - logdim;
|
||||
@ -675,7 +732,6 @@ void SignalPlotter::calculateNiceRange()
|
||||
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.
|
||||
@ -690,7 +746,8 @@ void SignalPlotter::drawTopBarFrame(QPainter *p, int separatorX, int height)
|
||||
|
||||
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.
|
||||
@ -721,13 +778,18 @@ 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;
|
||||
Q_ASSERT(d->niceVertRange != 0);
|
||||
|
||||
if (d->niceVertRange == 0) {
|
||||
d->niceVertRange = 1;
|
||||
}
|
||||
double scaleFac = (h - 1) / d->niceVertRange;
|
||||
|
||||
int xPos = 0;
|
||||
@ -746,34 +808,39 @@ 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.
|
||||
// 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;
|
||||
@ -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 {
|
||||
@ -838,8 +906,16 @@ void SignalPlotter::drawPlots(QPainter *p, int top, int w, int h, int horizontal
|
||||
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,8 +929,10 @@ 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;
|
||||
@ -870,11 +948,20 @@ void SignalPlotter::drawPlots(QPainter *p, int top, int w, int h, int horizontal
|
||||
|
||||
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);
|
||||
@ -891,10 +978,13 @@ void SignalPlotter::drawPlots(QPainter *p, int top, int w, int h, int horizontal
|
||||
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
|
||||
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);
|
||||
@ -936,16 +1026,26 @@ void SignalPlotter::drawAxisText(QPainter *p, int top, int h)
|
||||
// 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;
|
||||
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
|
||||
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
|
||||
} else {
|
||||
value = d->niceVertMax / d->scaledBy - y * stepsize;
|
||||
}
|
||||
|
||||
QString number = KGlobal::locale()->formatNumber(value, d->precision);
|
||||
val = QString("%1 %2").arg(number, d->unit);
|
||||
@ -965,13 +1065,17 @@ void SignalPlotter::drawHorizontalLines(QPainter *p, int top, int w, int h)
|
||||
|
||||
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);
|
||||
|
@ -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());
|
||||
}
|
||||
@ -182,7 +185,6 @@ 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
|
||||
|
||||
|
@ -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
|
||||
|
||||
@ -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
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_<NAME>_H
|
||||
#define PLASMA_<NAME>_H
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_TEXTEDIT_H
|
||||
#define PLASMA_TEXTEDIT_H
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_TREEVIEW_H
|
||||
#define PLASMA_TREEVIEW_H
|
||||
|
||||
|
@ -111,10 +111,14 @@ 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 &)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -359,7 +363,8 @@ void WebContentPrivate::loadingFinished(bool success)
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user