From 0a5a98a9684e038727bf7c1d232db997ceca7897 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Thu, 10 Jul 2008 19:48:55 +0000 Subject: [PATCH] use a gradient on larger handles, from the colour to transparent and back again. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=830580 --- applethandle.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/applethandle.cpp b/applethandle.cpp index 8efd1b5b9..2f6471b6a 100644 --- a/applethandle.cpp +++ b/applethandle.cpp @@ -206,7 +206,25 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti QPainterPath path = handleRect(m_rect, 10, m_buttonsOnRight); painter->strokePath(path, m_gradientColor); - painter->fillPath(path, m_gradientColor.lighter()); + + int minHeight = minimumHeight(); + qreal h = m_rect.height(); + if (h > minHeight * 1.25) { + QLinearGradient g(m_rect.topLeft(), m_rect.bottomLeft()); + // where the top icons stop + qreal firstStop = (ICON_SIZE + ICON_MARGIN) * 3 + ICON_MARGIN * 2; + // now between that and where the close icon is + firstStop = firstStop + (((h - (ICON_SIZE + ICON_MARGIN * 2)) - firstStop) * 0.7); + // now the ratio of the height + firstStop /= h; + + g.setColorAt(0.0, m_gradientColor.lighter()); + g.setColorAt(firstStop, Qt::transparent); + g.setColorAt(1.0, m_gradientColor.lighter()); + painter->fillPath(path, g); + } else { + painter->fillPath(path, m_gradientColor.lighter()); + } painter->restore(); //XXX this code is duplicated in the next function @@ -825,16 +843,22 @@ void AppletHandle::forceDisappear() startFading(FadeOut, m_entryPos); } -void AppletHandle::calculateSize() +int AppletHandle::minimumHeight() { int requiredHeight = ICON_MARGIN + //first margin (ICON_SIZE + ICON_MARGIN) * 4 + //XXX remember to update this if the number of buttons changes ICON_MARGIN; //blank space before the close button - if (m_applet->hasConfigurationInterface()) { + if (m_applet && m_applet->hasConfigurationInterface()) { requiredHeight += (ICON_SIZE + ICON_MARGIN); } + return requiredHeight; +} + +void AppletHandle::calculateSize() +{ + int requiredHeight = minimumHeight(); int top = m_applet->contentsRect().top(); if (requiredHeight > m_applet->contentsRect().height()) {