Port sidebar delegate to KColorScheme.

Certain KDE color schemes have Window Background and View Text
not contrasting, which causes invisible icon labels when using
QPalette::Text on QPalette::Base. An example is the default
color scheme in openSUSE 12.3.

Thanks to Will Stephenson for noticing.
CCMAIL:wstephenson@kde.org

It turns out that the Places sidebar in Dolphin suffers from
the same bug, so a similar change should be done there. Frank?
CCMAIL:frank78ac@googlemail.com
remotes/origin/epub-qtextdoc
Eike Hein 13 years ago
parent a034e086e5
commit a3b3545cab
  1. 22
      ui/sidebar.cpp

@ -29,6 +29,7 @@
#include <kiconloader.h> #include <kiconloader.h>
#include <klocale.h> #include <klocale.h>
#include <kmenu.h> #include <kmenu.h>
#include <kcolorscheme.h>
#include "settings.h" #include "settings.h"
@ -107,27 +108,32 @@ void SidebarDelegate::paint( QPainter *painter, const QStyleOptionViewItem &opti
QColor foreColor; QColor foreColor;
bool disabled = false; bool disabled = false;
bool hover = false; bool hover = false;
if ( !( option.state & QStyle::State_Enabled ) ) if ( !( option.state & QStyle::State_Enabled ) )
{ {
backBrush = option.palette.brush( QPalette::Disabled, QPalette::Base ); KColorScheme colorScheme( QPalette::Disabled, KColorScheme::Window );
foreColor = option.palette.color( QPalette::Disabled, QPalette::Text ); backBrush = colorScheme.background();
foreColor = colorScheme.foreground().color();
disabled = true; disabled = true;
} }
else if ( option.state & ( QStyle::State_HasFocus | QStyle::State_Selected ) ) else if ( option.state & ( QStyle::State_HasFocus | QStyle::State_Selected ) )
{ {
backBrush = option.palette.brush( QPalette::Highlight ); KColorScheme colorScheme( option.palette.currentColorGroup(), KColorScheme::Selection );
foreColor = option.palette.color( QPalette::HighlightedText ); backBrush = colorScheme.background();
foreColor = colorScheme.foreground().color();
} }
else if ( option.state & QStyle::State_MouseOver ) else if ( option.state & QStyle::State_MouseOver )
{ {
backBrush = option.palette.color( QPalette::Highlight ).light( 115 ); KColorScheme colorScheme( option.palette.currentColorGroup(), KColorScheme::Selection );
foreColor = option.palette.color( QPalette::HighlightedText ); backBrush = colorScheme.background().color().light( 115 );
foreColor = colorScheme.foreground().color();
hover = true; hover = true;
} }
else /*if ( option.state & QStyle::State_Enabled )*/ else /*if ( option.state & QStyle::State_Enabled )*/
{ {
backBrush = option.palette.brush( QPalette::Base ); KColorScheme colorScheme( option.palette.currentColorGroup(), KColorScheme::Window );
foreColor = option.palette.color( QPalette::Text ); backBrush = colorScheme.background();
foreColor = colorScheme.foreground().color();
} }
QStyle *style = QApplication::style(); QStyle *style = QApplication::style();
QStyleOptionViewItemV4 opt( option ); QStyleOptionViewItemV4 opt( option );

Loading…
Cancel
Save