Hi, while I caught the flu, I bothered with Qt4 a bit for the first time (being addicted to _Py_Qt3 since ages).
Building an rpm for SuSE 9.3 went pretty smooth, and playing around with qtdemo in the build dir was very appealing, up to the point where I recognized the appearance of buttons/combos and the like on mouse over for the first time.. Well, I may use a palette, where this is especially disturbing, but repainting the buttons top and bottom lines with the highlight color just looks butt ugly here. Since I still had some spare time, I looked into the source, quickly found the offending part, and started to play. The result is attached. Let me know your opinions, and let's hope, that Trolltech adds something similar to the next version.. BTW, compared with the rest of my KDE 3.5.5 desktop in plastik style, I also noted, that all but the button color wasn't imported correctly from my environment.. BTW2: the appearance of QProgressBars is also unfortunate, if the highlight color doesn't contrast strongly with the background. Here's my palette: Palette\active=#000000, #f8d991, #ffffff, #fbecc8, #7c6c48, #a59161, #000000, #ffffff, #000000, #ffffff, #ffe8ae, #000000, #ffdd76, #000000, #0000ff, #ff00ff, #e8e8e8 [just replace in .config/Trolltech.conf] Kind regards, Pete
--- src/gui/styles/qplastiquestyle.cpp.orig 2006-10-20 12:23:41.000000000 +0200
+++ src/gui/styles/qplastiquestyle.cpp 2006-11-11 12:59:33.578162970 +0100
@@ -402,6 +402,25 @@ static const char * const qt_titlebar_co
" ",
" "};
+// shamelessly stolen from kdelibs/kstyles/plastik/misc.cpp
+QColor alphaBlendColors(const QColor &bgColor, const QColor &fgColor, const int a)
+{
+ // normal button...
+ QRgb rgb = bgColor.rgb();
+ QRgb rgb_b = fgColor.rgb();
+ int alpha = a;
+ if(alpha>255) alpha = 255;
+ if(alpha<0) alpha = 0;
+ int inv_alpha = 255 - alpha;
+
+ QColor result = QColor( qRgb(qRed(rgb_b)*inv_alpha/255 + qRed(rgb)*alpha/255,
+ qGreen(rgb_b)*inv_alpha/255 + qGreen(rgb)*alpha/255,
+ qBlue(rgb_b)*inv_alpha/255 + qBlue(rgb)*alpha/255) );
+
+ return result;
+}
+
+
#define BEGIN_PLASTIQUE_PIXMAPCACHE(a) \
QRect rect = button->rect; \
QPixmap cache; \
@@ -1518,9 +1537,18 @@ void QPlastiqueStyle::drawPrimitive(Prim
}
// Main fill
- p->fillRect(fillRect,
- qMapBrushToRect(sunken ? sunkenButtonGradientBrush
- : buttonGradientBrush, rect));
+ if (hover && !sunken) {
+ QColor hoverColor = alphaBlendColors(option->palette.button(),
+ option->palette.highlight(), 230);
+ QBrush buttonHoverBrush = qMapBrushToRect(hoverColor, rect);
+ QLinearGradient buttonHoverGradient(rect.topLeft(), rect.bottomLeft());
+ buttonHoverGradient.setColorAt(0.0, buttonHoverBrush.color().light(104));
+ buttonHoverGradient.setColorAt(1.0, buttonHoverBrush.color().dark(110));
+ buttonGradientBrush = QBrush(buttonHoverGradient);
+ p->fillRect(fillRect, qMapBrushToRect(buttonGradientBrush, rect));
+ } else p->fillRect(fillRect,
+ qMapBrushToRect(sunken ? sunkenButtonGradientBrush
+ : buttonGradientBrush, rect));
// Top line
p->setPen(QPen(qBrushLight(qMapBrushToRect(sunken ? sunkenButtonGradientBrush
@@ -1549,28 +1577,31 @@ void QPlastiqueStyle::drawPrimitive(Prim
// Hovering
if (hover && !sunken) {
QBrush hover = qMapBrushToRect(option->palette.highlight(), rect);
- QBrush hoverOuter = hover;
- qBrushSetAlphaF(&hoverOuter, 0.7);
-
+ qBrushSetAlphaF(&hover, 0.7);
p->setPen(QPen(hover, 0));
- p->drawLine(rect.left() + 2, rect.top(), rect.right() - 2, rect.top());
- p->drawLine(rect.left() + 2, rect.bottom(), rect.right() - 2, rect.bottom());
+ p->drawLine(rect.left() + 2, rect.top() + 1, rect.right() - 2, rect.top() + 1);
+ p->drawLine(rect.left() + 2, rect.bottom() - 1, rect.right() - 2, rect.bottom() - 1);
- p->setPen(QPen(hoverOuter, 0));
- p->drawLine(rect.left() + 1, rect.top() + 1, rect.right() - 1, rect.top() + 1);
- p->drawLine(rect.left() + 1, rect.bottom() - 1, rect.right() - 1, rect.bottom() - 1);
+ p->drawLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2);
+ p->drawLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2);
QBrush hoverInner = hover;
- qBrushSetAlphaF(&hoverInner, 0.45);
+ qBrushSetAlphaF(&hoverInner, 0.5);
p->setPen(QPen(hoverInner, 0));
- p->drawLine(rect.left() + 1, rect.top() + 2, rect.right() - 1, rect.top() + 2);
- p->drawLine(rect.left() + 1, rect.bottom() - 2, rect.right() - 1, rect.bottom() - 2);
+ p->drawLine(rect.left() + 2, rect.top() + 2, rect.right() - 2, rect.top() + 2);
+ p->drawLine(rect.left() + 2, rect.bottom() - 2, rect.right() - 2, rect.bottom() - 2);
- QBrush hoverSide = hover;
- qBrushSetAlphaF(&hoverSide, 0.075);
- p->setPen(QPen(hoverSide, 0));
- p->drawLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2);
- p->drawLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2);
+ p->drawLine(rect.left() + 2, rect.top() + 2, rect.left() + 2, rect.bottom() - 2);
+ p->drawLine(rect.right() - 2, rect.top() + 2, rect.right() - 2, rect.bottom() - 2);
+
+ QBrush hoverInnerst = hover;
+ qBrushSetAlphaF(&hoverInnerst, 0.35);
+ p->setPen(QPen(hoverInnerst, 0));
+ p->drawLine(rect.left() + 3, rect.top() + 3, rect.right() - 3, rect.top() + 3);
+ p->drawLine(rect.left() + 3, rect.bottom() - 3, rect.right() - 3, rect.bottom() - 3);
+
+ p->drawLine(rect.left() + 3, rect.top() + 3, rect.left() + 3, rect.bottom() - 3);
+ p->drawLine(rect.right() - 3, rect.top() + 3, rect.right() - 3, rect.bottom() - 3);
}
p->setPen(oldPen);
qprogress.png
Description: PNG image
_______________________________________________ PyKDE mailing list [email protected] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
