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

List:       kde-commits
Subject:    KDE/kdebase/apps/plasma/applets/folderview
From:       Fredrik Höglund <fredrik () kde ! org>
Date:       2008-06-30 21:32:14
Message-ID: 1214861534.011337.19541.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 826521 by fredrik:

Fix some issues with text shadows:
* Don't abuse the background color for shadows - if the background is opaque
  it will make the shadows invisible. Use black shadows with bright text and
  white shadows with dark text instead.
* Center white shadows to create a halo effect.
* Make the shadow color for selected items depend on the text highlight color.
* Change the shadow offset in RTL mode, so the light appears to be coming
  from the upper right corner of the screen.


 M  +29 -1     folderview.cpp  
 M  +1 -0      folderview.h  


--- trunk/KDE/kdebase/apps/plasma/applets/folderview/folderview.cpp #826520:826521
@@ -522,6 +522,30 @@
     return mapToViewport(dirty.translated(contentsRect().topLeft().toPoint())).toAlignedRect();
  }
 
+void FolderView::updateTextShadows(const QColor &textColor)
+{
+    QColor shadowColor;
+
+    // Use black shadows with bright text, and white shadows with dark text.
+    if (qGray(textColor.rgb()) > 192) {
+        shadowColor = Qt::black;
+    } else {
+        shadowColor = Qt::white;
+    }
+
+    if (m_delegate->shadowColor() != shadowColor)
+    {
+        m_delegate->setShadowColor(shadowColor);
+
+        // Center white shadows to create a halo effect, and offset dark shadows \
slightly. +        if (shadowColor == Qt::white) {
+            m_delegate->setShadowOffset(QPoint(0, 0));
+        } else {
+            m_delegate->setShadowOffset(QPoint(layoutDirection() == Qt::RightToLeft \
? -1 : 1, 1)); +        }
+    }
+}
+
 void FolderView::paintInterface(QPainter *painter, const QStyleOptionGraphicsItem \
*option, const QRect &contentRect)  {
     if (m_pixmap.isNull()) {
@@ -537,7 +561,6 @@
 
     QStyleOptionViewItemV4 opt = viewOptions();
     opt.palette.setColor(QPalette::All, QPalette::Text, \
                Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor));
-    m_delegate->setShadowColor(Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor));
  
     // Paint the folder text
     QPen currentPen = painter->pen();
@@ -611,7 +634,10 @@
                 if (m_dragInProgress) {
                     continue;
                 }
+                updateTextShadows(palette().color(QPalette::HighlightedText));
                 opt.state |= QStyle::State_Selected;
+            } else {
+                updateTextShadows(palette().color(QPalette::Text));
             }
 
             if (hasFocus() && index == m_selectionModel->currentIndex()) {
@@ -1370,6 +1396,8 @@
     QStyleOptionViewItemV4 option = viewOptions(); 
     option.state |= QStyle::State_Selected;
 
+    updateTextShadows(palette().color(QPalette::HighlightedText));
+
     QPainter p(&pixmap);
     foreach (const QModelIndex &index, indexes)
     {
--- trunk/KDE/kdebase/apps/plasma/applets/folderview/folderview.h #826520:826521
@@ -102,6 +102,7 @@
     void markAreaDirty(const QRect &rect);
     void markAreaDirty(const QRectF &rect) { markAreaDirty(rect.toAlignedRect()); }
     void markEverythingDirty();
+    void updateTextShadows(const QColor &textColor);
     QModelIndex indexAt(const QPointF &point);
     QRectF visualRect(const QModelIndex &index);
     QSize iconSize() const;


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

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