mouseover and mousepressed effects by choosing different svg elements
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=850598
This commit is contained in:
parent
c768094fd1
commit
150bf97172
@ -70,16 +70,22 @@ void Style::drawComplexControl(ComplexControl control,
|
|||||||
painter->save();
|
painter->save();
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
if (option->state & State_MouseOver) {
|
||||||
|
prefix= "mouseover-";
|
||||||
|
}
|
||||||
|
|
||||||
QRect subLine;
|
QRect subLine;
|
||||||
QRect addLine;
|
QRect addLine;
|
||||||
if (scrollOption && scrollOption->orientation == Qt::Horizontal) {
|
if (scrollOption && scrollOption->orientation == Qt::Horizontal) {
|
||||||
subLine = d->scrollbar->elementRect("arrow-left").toRect();
|
subLine = d->scrollbar->elementRect(prefix + "arrow-left").toRect();
|
||||||
addLine = d->scrollbar->elementRect("arrow-right").toRect();
|
addLine = d->scrollbar->elementRect(prefix + "arrow-right").toRect();
|
||||||
} else {
|
} else {
|
||||||
subLine = d->scrollbar->elementRect("arrow-up").toRect();
|
subLine = d->scrollbar->elementRect(prefix + "arrow-up").toRect();
|
||||||
addLine = d->scrollbar->elementRect("arrow-down").toRect();
|
addLine = d->scrollbar->elementRect(prefix + "arrow-down").toRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
subLine.moveCenter(subControlRect(control, option, SC_ScrollBarSubLine, widget).center());
|
subLine.moveCenter(subControlRect(control, option, SC_ScrollBarSubLine, widget).center());
|
||||||
@ -91,16 +97,39 @@ void Style::drawComplexControl(ComplexControl control,
|
|||||||
d->scrollbar->resizePanel(option->rect.size());
|
d->scrollbar->resizePanel(option->rect.size());
|
||||||
d->scrollbar->paintPanel(painter);
|
d->scrollbar->paintPanel(painter);
|
||||||
|
|
||||||
d->scrollbar->setElementPrefix("slider");
|
if (sunken && scrollOption->activeSubControls & SC_ScrollBarSlider) {
|
||||||
|
d->scrollbar->setElementPrefix("sunken-slider");
|
||||||
|
} else {
|
||||||
|
d->scrollbar->setElementPrefix(prefix + "slider");
|
||||||
|
}
|
||||||
|
|
||||||
d->scrollbar->resizePanel(slider.size());
|
d->scrollbar->resizePanel(slider.size());
|
||||||
d->scrollbar->paintPanel(painter, slider.topLeft());
|
d->scrollbar->paintPanel(painter, slider.topLeft());
|
||||||
|
|
||||||
if (scrollOption && scrollOption->orientation == Qt::Horizontal) {
|
if (scrollOption && scrollOption->orientation == Qt::Horizontal) {
|
||||||
d->scrollbar->paint(painter, addLine.topLeft(), "arrow-left");
|
if (sunken && scrollOption->activeSubControls & SC_ScrollBarAddLine) {
|
||||||
d->scrollbar->paint(painter, subLine.topLeft(), "arrow-right");
|
d->scrollbar->paint(painter, addLine.topLeft(), "sunken-arrow-right");
|
||||||
} else {
|
} else {
|
||||||
d->scrollbar->paint(painter, addLine.topLeft(), "arrow-down");
|
d->scrollbar->paint(painter, addLine.topLeft(), prefix + "arrow-right");
|
||||||
d->scrollbar->paint(painter, subLine.topLeft(), "arrow-up");
|
}
|
||||||
|
|
||||||
|
if (sunken && scrollOption->activeSubControls & SC_ScrollBarSubLine) {
|
||||||
|
d->scrollbar->paint(painter, subLine.topLeft(), "sunken-arrow-left");
|
||||||
|
} else {
|
||||||
|
d->scrollbar->paint(painter, subLine.topLeft(), prefix + "arrow-left");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (sunken && scrollOption->activeSubControls & SC_ScrollBarAddLine) {
|
||||||
|
d->scrollbar->paint(painter, addLine.topLeft(), "sunken-arrow-down");
|
||||||
|
} else {
|
||||||
|
d->scrollbar->paint(painter, addLine.topLeft(), prefix + "arrow-down");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sunken && scrollOption->activeSubControls & SC_ScrollBarSubLine) {
|
||||||
|
d->scrollbar->paint(painter, subLine.topLeft(), "sunken-arrow-up");
|
||||||
|
} else {
|
||||||
|
d->scrollbar->paint(painter, subLine.topLeft(), prefix + "arrow-up");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
Loading…
Reference in New Issue
Block a user