[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    Re: [Panel-devel] Kickoff menu items
From:       Aurélien Gâteau <aurelien.gateau () free ! fr>
Date:       2007-12-01 13:46:17
Message-ID: firoj9$dhm$1 () ger ! gmane ! org
[Download RAW message or body]

I played a bit more with Kickoff items yesterday night. New version:
- Keeps subtitles where they are but show them in a light color when not
selected.
- Apply gradient effect to the icon as well (a bit too flashy IMO).
- Try to really use as much width as possible: it's not rounded anymore
(still hackish).

Meanwhile, I had a look at the KDE3 version of Kickoff, and realized my work
was making it look more and more like the KDE3 version. I consider this a
good thing but I guess others don't, otherwise the rendering wouldn't have
been changed so much.

Anyway, here is the (still hackish) patch, as well as two shots.

http://img260.imageshack.us/img260/6554/folderfj0.png

http://img101.imageshack.us/img101/5225/itemdk0.png

Aurélien

["kickoff_selected_items2.diff" (text/x-diff)]

Index: ui/flipscrollview.cpp
===================================================================
--- ui/flipscrollview.cpp	(révision 743289)
+++ ui/flipscrollview.cpp	(copie de travail)
@@ -280,7 +280,7 @@
 QRect FlipScrollView::visualRect(const QModelIndex& index) const
 {
     int topOffset = d->headerRect(index.parent()).height();
-    int leftOffset = d->backArrowRect().width() + ItemDelegate::BACK_ARROW_SPACING;
+    int leftOffset = d->backArrowRect().width(); // + \
ItemDelegate::BACK_ARROW_SPACING;  
     if (index.parent() != d->currentRoot() && index.parent() != d->previousRoot()) {
         return QRect();
@@ -306,7 +306,7 @@
     int scrollBarWidth = verticalScrollBar()->isVisible() ? 
                                     verticalScrollBar()->width() : 0;
     QRect itemRect(leftOffset, topOffset + index.row() * d->itemHeight,
-                   width() - leftOffset - scrollBarWidth - \
ItemDelegate::BACK_ARROW_SPACING, +                   width() - leftOffset - \
scrollBarWidth /*- ItemDelegate::BACK_ARROW_SPACING*/,  d->itemHeight);
 
     const qreal timeValue = d->flipAnimTimeLine->currentValue();
@@ -533,7 +533,7 @@
             QRect triRect = option.rect;
             QPainterPath tPath = d->trianglePath();
             triRect.setLeft(triRect.right() - ItemDelegate::ITEM_RIGHT_MARGIN);
-            painter.translate(triRect.center().x(), triRect.y() + \
(tPath.boundingRect().height() / 2)  + 3); +            \
painter.translate(triRect.center().x(), triRect.y() + (triRect.height() - \
tPath.boundingRect().height()) / 2 + 5);  painter.rotate(180);
             painter.drawPath(tPath);
             painter.resetTransform();
Index: ui/itemdelegate.cpp
===================================================================
--- ui/itemdelegate.cpp	(révision 743289)
+++ ui/itemdelegate.cpp	(copie de travail)
@@ -47,7 +47,8 @@
 {
     const bool hover = option.state & \
(QStyle::State_Selected|QStyle::State_MouseOver|QStyle::State_HasFocus);  QRect \
                contentRect = option.rect;
-    contentRect.setBottom(contentRect.bottom() - 1);
+    contentRect.adjust(3, 0, 0, -1);
+    //contentRect.setBottom(contentRect.bottom() - 1);
     QRect decorationRect = QStyle::alignedRect(option.direction,
                                                option.decorationPosition == \
QStyleOptionViewItem::Left ? Qt::AlignLeft : Qt::AlignRight,  option.decorationSize,
@@ -75,9 +76,9 @@
 
     if (subTitleText.isEmpty()) {
         subTitleText = " ";
+    } else {
+        titleRect.setHeight(titleRect.height() / 2);
     }
-
-    titleRect.setHeight(titleRect.height() / 2);
     QRect subTitleRect = titleRect;
     subTitleRect.translate(0, subTitleRect.height());
     QFont subTitleFont = fontForSubTitle(option.font);
@@ -93,39 +94,70 @@
         QRect textAreaRect = contentRect;
         qreal actualTextWidth = qMax(titleMetrics.width(titleText), \
                subTitleMetrics.width(subTitleText));
         textAreaRect.adjust(decorationRect.width() + ICON_TEXT_MARGIN - 3, 0, \
-(titleRect.width() - actualTextWidth) + 3, 1); +        #if 0
         // use a slightly translucent version of the palette's highlight color
         // for the background
         backgroundColor.setAlphaF(0.5);
         painter->setBrush(QBrush(backgroundColor));
         painter->drawPath(roundedRectangle(textAreaRect, 5));
+        #endif
+        painter->setOpacity(0.5);
+        painter->fillRect(option.rect, backgroundColor);
         painter->restore();
     }
 
     // draw icon
     QIcon decorationIcon = index.data(Qt::DecorationRole).value<QIcon>();
 
-    if (!hover) {
+    /*if (!hover) {
         painter->save();
         painter->setOpacity(0.7);
-    }
+    }*/
 
     decorationIcon.paint(painter, decorationRect, option.decorationAlignment);
 
-    if (!hover) {
+    if (hover) {
+        #define BLING
+        #ifdef BLING
+        painter->save();
+        painter->setPen(Qt::NoPen);
+        QLinearGradient gradient;
+        gradient.setStart(option.rect.topLeft());
+        gradient.setFinalStop(option.rect.bottomLeft());
+        gradient.setColorAt(0, QColor::fromRgbF(1, 1, 1, 0.8));
+        gradient.setColorAt(0.399, QColor::fromRgbF(1, 1, 1, 0.3));
+        gradient.setColorAt(0.4, QColor::fromRgbF(1, 1, 1, 0));
+        gradient.setColorAt(1, QColor::fromRgbF(1, 1, 1, 0.3));
+        painter->fillRect(option.rect.adjusted(1, 1, -1, -1), QBrush(gradient));
         painter->restore();
+        #endif
     }
 
+    /*if (!hover) {
+        painter->restore();
+    }*/
+
     painter->save();
 
     // draw title
     painter->setFont(titleFont);
     painter->drawText(titleRect, Qt::AlignLeft|Qt::AlignVCenter, titleText);
 
+    // draw sub-title
+    painter->save();
+    if (!hover) {
+        painter->setOpacity(0.5);
+    }
+    painter->setFont(subTitleFont);
+    painter->drawText(subTitleRect, Qt::AlignLeft|Qt::AlignVCenter, subTitleText);
+    painter->restore();
+#if 0
     if (hover) {
         // draw sub-title
         painter->setFont(subTitleFont);
         painter->drawText(subTitleRect, Qt::AlignLeft|Qt::AlignVCenter, \
subTitleText);  }
+#endif
 
     painter->restore();
 



_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic