style with FrameSvg all the lineedits, spinboxes and comboboxes, use
Plasma::Style to achieve that, since it's a kinda repetitive thing and comboboxes and spinboxes are complex controls the svg used will probably change svn path=/trunk/KDE/kdelibs/; revision=912567
This commit is contained in:
parent
22b6670f00
commit
53658a106e
@ -22,6 +22,9 @@
|
|||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QStyleOptionComplex>
|
#include <QStyleOptionComplex>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
|
|
||||||
@ -32,8 +35,10 @@ namespace Plasma {
|
|||||||
class StylePrivate
|
class StylePrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StylePrivate()
|
StylePrivate(Style *style)
|
||||||
: scrollbar(0)
|
: q(style),
|
||||||
|
scrollbar(0),
|
||||||
|
textBox(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +46,27 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void createScrollbar()
|
||||||
|
{
|
||||||
|
if (!scrollbar) {
|
||||||
|
scrollbar = new Plasma::FrameSvg(q);
|
||||||
|
scrollbar->setImagePath("widgets/scrollbar");
|
||||||
|
scrollbar->setCacheAllRenderedFrames(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void createTextBox()
|
||||||
|
{
|
||||||
|
if (!textBox) {
|
||||||
|
textBox = new Plasma::FrameSvg(q);
|
||||||
|
textBox->setImagePath("widgets/frame");
|
||||||
|
textBox->setElementPrefix("sunken");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Style *q;
|
||||||
Plasma::FrameSvg *scrollbar;
|
Plasma::FrameSvg *scrollbar;
|
||||||
|
Plasma::FrameSvg *textBox;
|
||||||
static Plasma::Style::Ptr s_sharedStyle;
|
static Plasma::Style::Ptr s_sharedStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,11 +90,8 @@ void Style::doneWithSharedStyle()
|
|||||||
|
|
||||||
Style::Style()
|
Style::Style()
|
||||||
: QCommonStyle(),
|
: QCommonStyle(),
|
||||||
d(new StylePrivate)
|
d(new StylePrivate(this))
|
||||||
{
|
{
|
||||||
d->scrollbar = new Plasma::FrameSvg(this);
|
|
||||||
d->scrollbar->setImagePath("widgets/scrollbar");
|
|
||||||
d->scrollbar->setCacheAllRenderedFrames(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Style::~Style()
|
Style::~Style()
|
||||||
@ -82,84 +104,176 @@ void Style::drawComplexControl(ComplexControl control,
|
|||||||
QPainter *painter,
|
QPainter *painter,
|
||||||
const QWidget *widget) const
|
const QWidget *widget) const
|
||||||
{
|
{
|
||||||
if (control != CC_ScrollBar) {
|
switch (control) {
|
||||||
QCommonStyle::drawComplexControl(control, option, painter, widget);
|
case CC_ScrollBar: {
|
||||||
return;
|
d->createScrollbar();
|
||||||
}
|
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
const bool sunken = option->state & State_Sunken;
|
const bool sunken = option->state & State_Sunken;
|
||||||
const QStyleOptionSlider *scrollOption = qstyleoption_cast<const QStyleOptionSlider *>(option);
|
const QStyleOptionSlider *scrollOption = qstyleoption_cast<const QStyleOptionSlider *>(option);
|
||||||
QString prefix;
|
QString prefix;
|
||||||
|
|
||||||
if (option->state & State_MouseOver) {
|
if (option->state & State_MouseOver) {
|
||||||
prefix= "mouseover-";
|
prefix= "mouseover-";
|
||||||
}
|
|
||||||
|
|
||||||
QRect subLine;
|
|
||||||
QRect addLine;
|
|
||||||
if (scrollOption && scrollOption->orientation == Qt::Horizontal) {
|
|
||||||
subLine = d->scrollbar->elementRect(prefix + "arrow-left").toRect();
|
|
||||||
addLine = d->scrollbar->elementRect(prefix + "arrow-right").toRect();
|
|
||||||
} else {
|
|
||||||
subLine = d->scrollbar->elementRect(prefix + "arrow-up").toRect();
|
|
||||||
addLine = d->scrollbar->elementRect(prefix + "arrow-down").toRect();
|
|
||||||
}
|
|
||||||
|
|
||||||
subLine.moveCenter(subControlRect(control, option, SC_ScrollBarSubLine, widget).center());
|
|
||||||
addLine.moveCenter(subControlRect(control, option, SC_ScrollBarAddLine, widget).center());
|
|
||||||
|
|
||||||
const QRect slider =
|
|
||||||
subControlRect(control, option, SC_ScrollBarSlider, widget).adjusted(1, 0, -1, 0);
|
|
||||||
|
|
||||||
d->scrollbar->setElementPrefix("background");
|
|
||||||
d->scrollbar->resizeFrame(option->rect.size());
|
|
||||||
d->scrollbar->paintFrame(painter);
|
|
||||||
|
|
||||||
if (sunken && scrollOption && scrollOption->activeSubControls & SC_ScrollBarSlider) {
|
|
||||||
d->scrollbar->setElementPrefix("sunken-slider");
|
|
||||||
} else {
|
|
||||||
d->scrollbar->setElementPrefix(prefix + "slider");
|
|
||||||
}
|
|
||||||
|
|
||||||
d->scrollbar->resizeFrame(slider.size());
|
|
||||||
d->scrollbar->paintFrame(painter, slider.topLeft());
|
|
||||||
|
|
||||||
if (scrollOption && scrollOption->orientation == Qt::Horizontal) {
|
|
||||||
if (sunken && scrollOption->activeSubControls & SC_ScrollBarAddLine) {
|
|
||||||
d->scrollbar->paint(painter, addLine, "sunken-arrow-right");
|
|
||||||
} else {
|
|
||||||
d->scrollbar->paint(painter, addLine, prefix + "arrow-right");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sunken && scrollOption->activeSubControls & SC_ScrollBarSubLine) {
|
QRect subLine;
|
||||||
d->scrollbar->paint(painter, subLine, "sunken-arrow-left");
|
QRect addLine;
|
||||||
|
if (scrollOption && scrollOption->orientation == Qt::Horizontal) {
|
||||||
|
subLine = d->scrollbar->elementRect(prefix + "arrow-left").toRect();
|
||||||
|
addLine = d->scrollbar->elementRect(prefix + "arrow-right").toRect();
|
||||||
} else {
|
} else {
|
||||||
d->scrollbar->paint(painter, subLine, prefix + "arrow-left");
|
subLine = d->scrollbar->elementRect(prefix + "arrow-up").toRect();
|
||||||
}
|
addLine = d->scrollbar->elementRect(prefix + "arrow-down").toRect();
|
||||||
} else {
|
|
||||||
if (sunken && scrollOption && scrollOption->activeSubControls & SC_ScrollBarAddLine) {
|
|
||||||
d->scrollbar->paint(painter, addLine, "sunken-arrow-down");
|
|
||||||
} else {
|
|
||||||
d->scrollbar->paint(painter, addLine, prefix + "arrow-down");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sunken && scrollOption && scrollOption->activeSubControls & SC_ScrollBarSubLine) {
|
subLine.moveCenter(subControlRect(control, option, SC_ScrollBarSubLine, widget).center());
|
||||||
d->scrollbar->paint(painter, subLine, "sunken-arrow-up");
|
addLine.moveCenter(subControlRect(control, option, SC_ScrollBarAddLine, widget).center());
|
||||||
|
|
||||||
|
const QRect slider =
|
||||||
|
subControlRect(control, option, SC_ScrollBarSlider, widget).adjusted(1, 0, -1, 0);
|
||||||
|
|
||||||
|
d->scrollbar->setElementPrefix("background");
|
||||||
|
d->scrollbar->resizeFrame(option->rect.size());
|
||||||
|
d->scrollbar->paintFrame(painter);
|
||||||
|
|
||||||
|
if (sunken && scrollOption && scrollOption->activeSubControls & SC_ScrollBarSlider) {
|
||||||
|
d->scrollbar->setElementPrefix("sunken-slider");
|
||||||
} else {
|
} else {
|
||||||
d->scrollbar->paint(painter, subLine, prefix + "arrow-up");
|
d->scrollbar->setElementPrefix(prefix + "slider");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d->scrollbar->resizeFrame(slider.size());
|
||||||
|
d->scrollbar->paintFrame(painter, slider.topLeft());
|
||||||
|
|
||||||
|
if (scrollOption && scrollOption->orientation == Qt::Horizontal) {
|
||||||
|
if (sunken && scrollOption->activeSubControls & SC_ScrollBarAddLine) {
|
||||||
|
d->scrollbar->paint(painter, addLine, "sunken-arrow-right");
|
||||||
|
} else {
|
||||||
|
d->scrollbar->paint(painter, addLine, prefix + "arrow-right");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sunken && scrollOption->activeSubControls & SC_ScrollBarSubLine) {
|
||||||
|
d->scrollbar->paint(painter, subLine, "sunken-arrow-left");
|
||||||
|
} else {
|
||||||
|
d->scrollbar->paint(painter, subLine, prefix + "arrow-left");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (sunken && scrollOption && scrollOption->activeSubControls & SC_ScrollBarAddLine) {
|
||||||
|
d->scrollbar->paint(painter, addLine, "sunken-arrow-down");
|
||||||
|
} else {
|
||||||
|
d->scrollbar->paint(painter, addLine, prefix + "arrow-down");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sunken && scrollOption && scrollOption->activeSubControls & SC_ScrollBarSubLine) {
|
||||||
|
d->scrollbar->paint(painter, subLine, "sunken-arrow-up");
|
||||||
|
} else {
|
||||||
|
d->scrollbar->paint(painter, subLine, prefix + "arrow-up");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
case CC_SpinBox: {
|
||||||
|
d->createTextBox();
|
||||||
|
|
||||||
painter->restore();
|
d->textBox->resizeFrame(option->rect.size());
|
||||||
|
d->textBox->paintFrame(painter);
|
||||||
|
|
||||||
|
const QStyleOptionSpinBox *spinOpt = qstyleoption_cast<const QStyleOptionSpinBox *>(option);
|
||||||
|
bool upSunken = (spinOpt->activeSubControls & SC_SpinBoxUp) &&
|
||||||
|
(spinOpt->state & (State_Sunken | State_On));
|
||||||
|
bool downSunken = (spinOpt->activeSubControls & SC_SpinBoxDown) &&
|
||||||
|
(spinOpt->state & (State_Sunken | State_On));
|
||||||
|
|
||||||
|
const QSpinBox *spin = qobject_cast<const QSpinBox *>(widget);
|
||||||
|
PrimitiveElement pe;
|
||||||
|
if (spin->buttonSymbols() == QSpinBox::PlusMinus) {
|
||||||
|
pe = PE_IndicatorSpinPlus;
|
||||||
|
} else {
|
||||||
|
pe = PE_IndicatorArrowUp;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStyleOption upOpt;
|
||||||
|
upOpt = *option;
|
||||||
|
upOpt.rect = subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);
|
||||||
|
|
||||||
|
if (upSunken) {
|
||||||
|
upOpt.state = State_Sunken|State_Enabled;
|
||||||
|
} else {
|
||||||
|
upOpt.state = State_Enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
qApp->style()->drawPrimitive(pe, &upOpt, painter, widget);
|
||||||
|
|
||||||
|
if (spin->buttonSymbols() == QSpinBox::PlusMinus) {
|
||||||
|
pe = PE_IndicatorSpinMinus;
|
||||||
|
} else {
|
||||||
|
pe = PE_IndicatorArrowDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStyleOption downOpt;
|
||||||
|
downOpt= *option;
|
||||||
|
downOpt.rect = subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
|
||||||
|
|
||||||
|
if (downSunken) {
|
||||||
|
downOpt.state = State_Sunken|State_Enabled;
|
||||||
|
} else {
|
||||||
|
downOpt.state = State_Enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
qApp->style()->drawPrimitive(pe, &downOpt, painter, widget);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CC_ComboBox: {
|
||||||
|
const QComboBox *combo = qobject_cast<const QComboBox *>(widget);
|
||||||
|
if (!combo->isEditable()) {
|
||||||
|
qApp->style()->drawComplexControl(control, option, painter, widget);
|
||||||
|
} else {
|
||||||
|
d->createTextBox();
|
||||||
|
d->textBox->resizeFrame(option->rect.size());
|
||||||
|
d->textBox->paintFrame(painter);
|
||||||
|
|
||||||
|
QStyleOption arrowOpt;
|
||||||
|
arrowOpt = *option;
|
||||||
|
arrowOpt.rect = subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget);
|
||||||
|
qApp->style()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
qApp->style()->drawComplexControl(control, option, painter, widget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Style::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(widget)
|
||||||
|
|
||||||
|
switch (element) {
|
||||||
|
case PE_PanelLineEdit:
|
||||||
|
//comboboxes draws their own frame
|
||||||
|
if (qobject_cast<QComboBox *>(widget->parent())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
d->createTextBox();
|
||||||
|
|
||||||
|
d->textBox->resizeFrame(option->rect.size());
|
||||||
|
d->textBox->paintFrame(painter);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qApp->style()->drawPrimitive(element, option, painter, widget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
|
int Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
|
||||||
{
|
{
|
||||||
switch (metric) {
|
switch (metric) {
|
||||||
case PM_ScrollBarExtent: {
|
case PM_ScrollBarExtent: {
|
||||||
|
d->createScrollbar();
|
||||||
const QStyleOptionSlider *scrollOption = qstyleoption_cast<const QStyleOptionSlider *>(option);
|
const QStyleOptionSlider *scrollOption = qstyleoption_cast<const QStyleOptionSlider *>(option);
|
||||||
if (scrollOption && scrollOption->orientation == Qt::Vertical) {
|
if (scrollOption && scrollOption->orientation == Qt::Vertical) {
|
||||||
return d->scrollbar->elementSize("arrow-down").width() + 2;
|
return d->scrollbar->elementSize("arrow-down").width() + 2;
|
||||||
|
@ -44,6 +44,8 @@ public:
|
|||||||
explicit Style();
|
explicit Style();
|
||||||
~Style();
|
~Style();
|
||||||
|
|
||||||
|
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void drawComplexControl(ComplexControl control,
|
void drawComplexControl(ComplexControl control,
|
||||||
const QStyleOptionComplex *option,
|
const QStyleOptionComplex *option,
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <kiconeffect.h>
|
#include <kiconeffect.h>
|
||||||
#include <kiconloader.h>
|
#include <kiconloader.h>
|
||||||
|
|
||||||
|
#include <plasma/private/style_p.h>
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "framesvg.h"
|
#include "framesvg.h"
|
||||||
#include "animator.h"
|
#include "animator.h"
|
||||||
@ -59,6 +60,7 @@ public:
|
|||||||
bool fadeIn;
|
bool fadeIn;
|
||||||
qreal opacity;
|
qreal opacity;
|
||||||
QRectF activeRect;
|
QRectF activeRect;
|
||||||
|
Plasma::Style::Ptr style;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ComboBoxPrivate::syncActiveRect()
|
void ComboBoxPrivate::syncActiveRect()
|
||||||
@ -90,6 +92,15 @@ void ComboBoxPrivate::syncBorders()
|
|||||||
|
|
||||||
//calc the rect for the over effect
|
//calc the rect for the over effect
|
||||||
syncActiveRect();
|
syncActiveRect();
|
||||||
|
|
||||||
|
KComboBox *native = q->nativeWidget();
|
||||||
|
QColor color = Theme::defaultTheme()->color(Theme::TextColor);
|
||||||
|
QPalette p = native->palette();
|
||||||
|
|
||||||
|
p.setColor(QPalette::Normal, QPalette::Text, color);
|
||||||
|
p.setColor(QPalette::Inactive, QPalette::Text, color);
|
||||||
|
native->setPalette(p);
|
||||||
|
native->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComboBoxPrivate::animationUpdate(qreal progress)
|
void ComboBoxPrivate::animationUpdate(qreal progress)
|
||||||
@ -122,11 +133,14 @@ ComboBox::ComboBox(QGraphicsWidget *parent)
|
|||||||
d->syncBorders();
|
d->syncBorders();
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(syncBorders()));
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(syncBorders()));
|
||||||
|
d->style = Plasma::Style::sharedStyle();
|
||||||
|
native->setStyle(d->style.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
ComboBox::~ComboBox()
|
ComboBox::~ComboBox()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
|
Plasma::Style::doneWithSharedStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ComboBox::text() const
|
QString ComboBox::text() const
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include <klineedit.h>
|
#include <klineedit.h>
|
||||||
#include <kmimetype.h>
|
#include <kmimetype.h>
|
||||||
|
|
||||||
|
#include <plasma/private/style_p.h>
|
||||||
|
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
|
|
||||||
@ -33,18 +35,34 @@ namespace Plasma
|
|||||||
class LineEditPrivate
|
class LineEditPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LineEditPrivate()
|
LineEditPrivate(LineEdit *lineEdit)
|
||||||
|
:q(lineEdit)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~LineEditPrivate()
|
~LineEditPrivate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPalette()
|
||||||
|
{
|
||||||
|
KLineEdit *native = q->nativeWidget();
|
||||||
|
QColor color = Theme::defaultTheme()->color(Theme::TextColor);
|
||||||
|
QPalette p = native->palette();
|
||||||
|
|
||||||
|
p.setColor(QPalette::Normal, QPalette::Text, color);
|
||||||
|
p.setColor(QPalette::Inactive, QPalette::Text, color);
|
||||||
|
native->setPalette(p);
|
||||||
|
native->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
|
||||||
|
}
|
||||||
|
|
||||||
|
LineEdit *q;
|
||||||
|
Plasma::Style::Ptr style;
|
||||||
};
|
};
|
||||||
|
|
||||||
LineEdit::LineEdit(QGraphicsWidget *parent)
|
LineEdit::LineEdit(QGraphicsWidget *parent)
|
||||||
: QGraphicsProxyWidget(parent),
|
: QGraphicsProxyWidget(parent),
|
||||||
d(new LineEditPrivate)
|
d(new LineEditPrivate(this))
|
||||||
{
|
{
|
||||||
KLineEdit *native = new KLineEdit;
|
KLineEdit *native = new KLineEdit;
|
||||||
connect(native, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
|
connect(native, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
|
||||||
@ -52,11 +70,17 @@ LineEdit::LineEdit(QGraphicsWidget *parent)
|
|||||||
connect(native, SIGNAL(textEdited(const QString&)), this, SIGNAL(textEdited(const QString&)));
|
connect(native, SIGNAL(textEdited(const QString&)), this, SIGNAL(textEdited(const QString&)));
|
||||||
setWidget(native);
|
setWidget(native);
|
||||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||||
|
d->style = Plasma::Style::sharedStyle();
|
||||||
|
native->setStyle(d->style.data());
|
||||||
|
|
||||||
|
d->setPalette();
|
||||||
|
connect(Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(setPalette()));
|
||||||
}
|
}
|
||||||
|
|
||||||
LineEdit::~LineEdit()
|
LineEdit::~LineEdit()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
|
Plasma::Style::doneWithSharedStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEdit::setText(const QString &text)
|
void LineEdit::setText(const QString &text)
|
||||||
|
@ -84,6 +84,8 @@ Q_SIGNALS:
|
|||||||
void textEdited(const QString &text);
|
void textEdited(const QString &text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Q_PRIVATE_SLOT(d, void setPalette())
|
||||||
|
|
||||||
LineEditPrivate *const d;
|
LineEditPrivate *const d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,24 +25,47 @@
|
|||||||
#include <knuminput.h>
|
#include <knuminput.h>
|
||||||
#include <kmimetype.h>
|
#include <kmimetype.h>
|
||||||
|
|
||||||
|
#include <plasma/theme.h>
|
||||||
|
#include <plasma/private/style_p.h>
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class SpinBoxPrivate
|
class SpinBoxPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SpinBoxPrivate()
|
SpinBoxPrivate(SpinBox *spinBox)
|
||||||
|
: q(spinBox)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~SpinBoxPrivate()
|
~SpinBoxPrivate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPalette()
|
||||||
|
{
|
||||||
|
QSpinBox *native = q->nativeWidget();
|
||||||
|
QColor color = Theme::defaultTheme()->color(Theme::TextColor);
|
||||||
|
QPalette p = native->palette();
|
||||||
|
|
||||||
|
p.setColor(QPalette::Normal, QPalette::Text, color);
|
||||||
|
p.setColor(QPalette::Inactive, QPalette::Text, color);
|
||||||
|
p.setColor(QPalette::Normal, QPalette::ButtonText, color);
|
||||||
|
p.setColor(QPalette::Inactive, QPalette::ButtonText, color);
|
||||||
|
p.setColor(QPalette::Normal, QPalette::Base, QColor(0,0,0,0));
|
||||||
|
p.setColor(QPalette::Inactive, QPalette::Base, QColor(0,0,0,0));
|
||||||
|
native->setPalette(p);
|
||||||
|
native->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
|
||||||
|
}
|
||||||
|
|
||||||
|
SpinBox *q;
|
||||||
|
Plasma::Style::Ptr style;
|
||||||
};
|
};
|
||||||
|
|
||||||
SpinBox::SpinBox(QGraphicsWidget *parent)
|
SpinBox::SpinBox(QGraphicsWidget *parent)
|
||||||
: QGraphicsProxyWidget(parent),
|
: QGraphicsProxyWidget(parent),
|
||||||
d(new SpinBoxPrivate)
|
d(new SpinBoxPrivate(this))
|
||||||
{
|
{
|
||||||
KIntSpinBox *native = new KIntSpinBox;
|
KIntSpinBox *native = new KIntSpinBox;
|
||||||
|
|
||||||
@ -51,11 +74,18 @@ SpinBox::SpinBox(QGraphicsWidget *parent)
|
|||||||
|
|
||||||
setWidget(native);
|
setWidget(native);
|
||||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||||
|
native->setAutoFillBackground(false);
|
||||||
|
|
||||||
|
d->style = Plasma::Style::sharedStyle();
|
||||||
|
native->setStyle(d->style.data());
|
||||||
|
d->setPalette();
|
||||||
|
connect(Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(setPalette()));
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinBox::~SpinBox()
|
SpinBox::~SpinBox()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
|
Plasma::Style::doneWithSharedStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpinBox::setMaximum(int max)
|
void SpinBox::setMaximum(int max)
|
||||||
|
@ -131,6 +131,8 @@ Q_SIGNALS:
|
|||||||
void editingFinished();
|
void editingFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Q_PRIVATE_SLOT(d, void setPalette())
|
||||||
|
|
||||||
SpinBoxPrivate * const d;
|
SpinBoxPrivate * const d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user