summaryrefslogtreecommitdiff
path: root/noncore/styles/liquid/liquid.cpp
Side-by-side diff
Diffstat (limited to 'noncore/styles/liquid/liquid.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquid.cpp7
1 files changed, 0 insertions, 7 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index daac22c..e6d8310 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -1011,340 +1011,333 @@ public:
p.restore();
}
if ( event->rect().intersects( contentsRect() )) {
p.setClipRegion( event->region().intersect( contentsRect() ) );
int x, y, w, h;
contentsRect ( ). rect ( &x, &y, &w, &h );
int prog = progress ( );
int total = totalSteps ( );
if ( prog < 0 )
prog = 0;
if ( total <= 0 )
total = 1;
int bw = w * prog / total;
if ( bw > w )
bw = w;
p.setPen(g.button().dark(130));
p.drawRect(x, y, bw, h);
p.setPen(g.button().light(120));
p.drawRect(x+1, y+1, bw-2, h-2);
if(bw >= 4 && h >= 4 && pix)
p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix);
if ( progress ( )>= 0 && totalSteps ( ) > 0 ) {
QString pstr;
pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ());
p. setPen ( g.text());//g.highlightedText ( ));
p. drawText (x,y,w-1,h-1,AlignCenter,pstr);
}
}
}
};
/*
* The same for QToolButton:
* TT hardcoded the drawing of the focus rect ...
*
* - sandman
*/
class HackToolButton : public QToolButton {
public:
HackToolButton ( );
void paint ( QPaintEvent *ev )
{
erase ( ev-> region ( ));
QPainter p ( this );
style ( ). drawToolButton ( this, &p );
drawButtonLabel ( &p );
}
};
/*
* This is a fun method ;-) Here's an overview. KToolBar grabs resize to
* force everything to erase and repaint on resize. This is going away, I'm
* trying to get shaped widgets to work right without masking. QPushButton,
* QComboBox, and Panel applet handles capture mouse enter and leaves in order
* to set the highlightwidget and repaint for mouse hovers. CheckBoxes and
* RadioButtons need to do this differently. Qt buffers these in pixmaps and
* caches them in QPixmapCache, which is bad for doing things like hover
* because the style methods aren't called in paintEvents if everything
* is cached. We use our own Paint event handler instead. Taskbuttons and
* pager buttons draw into a pixmap buffer, so we handle those with palette
* modifications. For QHeader, different header items are actually one widget
* that draws multiple items, so we need to check which ID is hightlighted
* and draw it. Finally, we also check enter and leave events for QLineEdit,
* since if it's inside a combobox we want to highlight the combobox during
* hovering in the edit.
*/
bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
{
if(obj->inherits("QToolBar")){
if(ev->type() == QEvent::Resize){
const QObjectList *tbChildList = obj->children();
QObjectListIt it(*tbChildList);
QObject *child;
while((child = it.current()) != NULL){
++it;
if(child->isWidgetType())
((QWidget *)child)->repaint(true);
}
}
}
else if(obj->inherits("QToolButton")){
QToolButton *btn = (QToolButton *)obj;
if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise ()
if(btn->isEnabled()){
highlightWidget = btn;
btn->repaint(false);
-
- qDebug ( "TB FOCUS IN [%p]", btn );
}
}
else if(ev->type() == QEvent::FocusOut ){
if(btn == highlightWidget){
highlightWidget = NULL;
btn->repaint(false);
-
- qDebug ( "TB FOCUS OUT [%p]", btn );
}
}
else if(ev->type() == QEvent::Paint) {
(( HackToolButton *) btn )-> paint ((QPaintEvent *) ev );
return true;
}
}
else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){
QButton *btn = (QButton *)obj;
bool isRadio = obj->inherits("QRadioButton");
if(ev->type() == QEvent::Paint){
//if(btn->autoMask())
btn->erase();
QPainter p;
p.begin(btn);
QFontMetrics fm = btn->fontMetrics();
QSize lsz = fm.size(ShowPrefix, btn->text());
QSize sz = isRadio ? exclusiveIndicatorSize()
: indicatorSize();
/*
if(btn->hasFocus()){
QRect r = QRect(0, 0, btn->width(), btn->height());
p.setPen(btn->colorGroup().button().dark(140));
p.drawLine(r.x()+1, r.y(), r.right()-1, r.y());
p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1);
p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1);
p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom());
}
*/
int x = 0;
int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2;
if(isRadio)
drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(),
btn->colorGroup(), btn->isOn(),
btn->isDown(), btn->isEnabled());
else
drawIndicator(&p, x, y, sz.width(), sz.height(),
btn->colorGroup(), btn->state(), btn->isDown(),
btn->isEnabled());
x = sz.width() + 6;
y = 0;
drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1),
btn->height(), AlignLeft|AlignVCenter|ShowPrefix,
btn->colorGroup(), btn->isEnabled(),
btn->pixmap(), btn->text());
p.end();
return(true);
}
}
else if(obj->inherits("QHeader")){
QHeader *hw = (QHeader *)obj;
if(ev->type() == QEvent::Enter){
currentHeader = hw;
headerHoverID = -1;
}
else if(ev->type() == QEvent::Leave){
currentHeader = NULL;
if(headerHoverID != -1){
hw->repaint(hw->sectionPos(headerHoverID), 0,
hw->sectionSize(headerHoverID), hw->height());
}
headerHoverID = -1;
}
else if(ev->type() == QEvent::MouseMove){
QMouseEvent *me = (QMouseEvent *)ev;
int oldHeader = headerHoverID;
headerHoverID = hw->sectionAt(me->x());
if(oldHeader != headerHoverID){
// reset old header
if(oldHeader != -1){
hw->repaint(hw->sectionPos(oldHeader), 0,
hw->sectionSize(oldHeader), hw->height());
}
if(headerHoverID != -1){
hw->repaint(hw->sectionPos(headerHoverID), 0,
hw->sectionSize(headerHoverID), hw->height());
}
}
}
}
else if (obj-> inherits( "QProgressBar" )) {
if ( ev->type() == QEvent::Paint ) {
HackProgressBar *p = (HackProgressBar *) obj;
const QColorGroup &g = p-> colorGroup ( );
QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb());
if(!pix){
int h, s, v;
g.button().dark(120).hsv(&h, &s, &v);
pix = new QPixmap(*bevelFillPix);
adjustHSV(*pix, h, s, v);
bevelFillDict.insert(g.button().dark(120).rgb(), pix);
}
p-> paint ((QPaintEvent *) ev, g, pix );
return true;
}
}
return false ;
}
void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
const QBrush *)
{
drawRoundButton(p, sunken ? g.background() : g.button(), g.background(),
x, y, w, h);
}
void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
const QBrush *)
{
if(p->device()->devType() != QInternal::Widget){
// drawing into a temp pixmap, don't use mask
QColor c = sunken ? g.button() : g.background();
p->setPen(c.dark(130));
p->drawRect(x, y, w, h);
p->setPen(c.light(105));
p->drawRect(x+1, y+1, w-2, h-2);
// fill
QPixmap *pix = bevelFillDict.find(c.rgb());
if(!pix){
int h, s, v;
c.hsv(&h, &s, &v);
pix = new QPixmap(*bevelFillPix);
adjustHSV(*pix, h, s, v);
bevelFillDict.insert(c.rgb(), pix);
}
p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix);
- qDebug ( "DRAW TOOLBUTTON IN PIXMAP" );
}
else{
- qDebug ( "DRAW TOOLBUTTON sunken=%d/high=%p/device=%p", sunken, highlightWidget,p->device() );
-
drawClearBevel(p, x, y, w, h, sunken ? g.button() :
highlightWidget == p->device() ? g.button().light(110) :
g.background(), g.background());
}
}
void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p)
{
QRect r = btn->rect();
bool sunken = btn->isOn() || btn->isDown();
QColorGroup g = btn->colorGroup();
//int dw = buttonDefaultIndicatorWidth();
if(btn->hasFocus() || btn->isDefault()){
QColor c = btn->hasFocus() ? g.button().light(110) : g.background();
QPixmap *pix = bevelFillDict.find(c.rgb());
if(!pix){
int h, s, v;
c.hsv(&h, &s, &v);
pix = new QPixmap(*bevelFillPix);
adjustHSV(*pix, h, s, v);
bevelFillDict.insert(c.rgb(), pix);
}
p->setPen(c.dark(150));
p->drawLine(r.x()+1, r.y(), r.right()-1, r.y());
p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1);
p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1);
p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom());
p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix);
}
QColor newColor = btn == highlightWidget || sunken ?
g.button().light(120) : g.button();
drawRoundButton(p, newColor, g.background(),
r.x(), r.y(), r.width(), r.height(), !btn->autoMask(),
sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(),
btn->autoMask());
}
void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p)
{
int x1, y1, x2, y2, w, h;
btn->rect().coords(&x1, &y1, &x2, &y2);
w = btn->width();
h = btn->height();
bool act = btn->isOn() || btn->isDown();
if(act){
++x1, ++y1;
}
// Draw iconset first, if any
if ( btn->iconSet() && !btn->iconSet()->isNull() )
{
QIconSet::Mode mode = btn->isEnabled()
? QIconSet::Normal : QIconSet::Disabled;
if ( mode == QIconSet::Normal && btn->hasFocus() )
mode = QIconSet::Active;
QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode );
int pixw = pixmap.width();
int pixh = pixmap.height();
p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap );
x1 += pixw + 8;
w -= pixw + 8;
}
if(act){
QFont font = btn->font();
font.setBold(true);
p->setFont(font);
QColor shadow(btn->colorGroup().button().dark(130));
drawItem( p, x1+1, y1+1, w, h,
AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
btn->pixmap(), btn->text(), -1,
&shadow);
drawItem( p, x1, y1, w, h,
AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
btn->pixmap(), btn->text(), -1, &btn->colorGroup().light());
}
else{
/* Too blurry
drawItem( p, x1+1, y1+1, w, h,
AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
btn->pixmap(), btn->text(), -1,
&btn->colorGroup().button().dark(115));
*/
drawItem( p, x1, y1, w, h,
AlignCenter | ShowPrefix,
btn->colorGroup(), btn->isEnabled(),
btn->pixmap(), btn->text(), -1,
&btn->colorGroup().buttonText());
}