Changeset View
Changeset View
Standalone View
Standalone View
kstyle/breezehelper.cpp
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 38 | { | |||
---|---|---|---|---|---|
47 | 47 | | |||
48 | //____________________________________________________________________ | 48 | //____________________________________________________________________ | ||
49 | KSharedConfig::Ptr Helper::config() const | 49 | KSharedConfig::Ptr Helper::config() const | ||
50 | { return _config; } | 50 | { return _config; } | ||
51 | 51 | | |||
52 | //____________________________________________________________________ | 52 | //____________________________________________________________________ | ||
53 | void Helper::loadConfig() | 53 | void Helper::loadConfig() | ||
54 | { | 54 | { | ||
55 | _viewFocusBrush = KStatefulBrush( KColorScheme::View, KColorScheme::FocusColor ); | | |||
56 | _viewHoverBrush = KStatefulBrush( KColorScheme::View, KColorScheme::HoverColor ); | | |||
57 | _viewNegativeTextBrush = KStatefulBrush( KColorScheme::View, KColorScheme::NegativeText ); | 55 | _viewNegativeTextBrush = KStatefulBrush( KColorScheme::View, KColorScheme::NegativeText ); | ||
56 | _buttonAltBackgroundBrush = KStatefulBrush( KColorScheme::Button, KColorScheme::AlternateBackground ); | ||||
58 | 57 | | |||
59 | const QPalette palette( QApplication::palette() ); | 58 | const QPalette palette( QApplication::palette() ); | ||
60 | const KConfigGroup group( _config->group( "WM" ) ); | 59 | const KConfigGroup group( _config->group( "WM" ) ); | ||
61 | _activeTitleBarColor = group.readEntry( "activeBackground", palette.color( QPalette::Active, QPalette::Highlight ) ); | 60 | _activeTitleBarColor = group.readEntry( "activeBackground", palette.color( QPalette::Active, QPalette::Highlight ) ); | ||
62 | _activeTitleBarTextColor = group.readEntry( "activeForeground", palette.color( QPalette::Active, QPalette::HighlightedText ) ); | 61 | _activeTitleBarTextColor = group.readEntry( "activeForeground", palette.color( QPalette::Active, QPalette::HighlightedText ) ); | ||
63 | _inactiveTitleBarColor = group.readEntry( "inactiveBackground", palette.color( QPalette::Disabled, QPalette::Highlight ) ); | 62 | _inactiveTitleBarColor = group.readEntry( "inactiveBackground", palette.color( QPalette::Disabled, QPalette::Highlight ) ); | ||
64 | _inactiveTitleBarTextColor = group.readEntry( "inactiveForeground", palette.color( QPalette::Disabled, QPalette::HighlightedText ) ); | 63 | _inactiveTitleBarTextColor = group.readEntry( "inactiveForeground", palette.color( QPalette::Disabled, QPalette::HighlightedText ) ); | ||
65 | } | 64 | } | ||
Show All 37 Lines | |||||
103 | QColor Helper::focusOutlineColor( const QPalette& palette ) const | 102 | QColor Helper::focusOutlineColor( const QPalette& palette ) const | ||
104 | { return KColorUtils::mix( focusColor( palette ), palette.color( QPalette::WindowText ), 0.15 ); } | 103 | { return KColorUtils::mix( focusColor( palette ), palette.color( QPalette::WindowText ), 0.15 ); } | ||
105 | 104 | | |||
106 | //____________________________________________________________________ | 105 | //____________________________________________________________________ | ||
107 | QColor Helper::hoverOutlineColor( const QPalette& palette ) const | 106 | QColor Helper::hoverOutlineColor( const QPalette& palette ) const | ||
108 | { return KColorUtils::mix( hoverColor( palette ), palette.color( QPalette::WindowText ), 0.15 ); } | 107 | { return KColorUtils::mix( hoverColor( palette ), palette.color( QPalette::WindowText ), 0.15 ); } | ||
109 | 108 | | |||
110 | //____________________________________________________________________ | 109 | //____________________________________________________________________ | ||
111 | QColor Helper::buttonFocusOutlineColor( const QPalette& palette ) const | | |||
112 | { return KColorUtils::mix( focusColor( palette ), palette.color( QPalette::ButtonText ), 0.15 ); } | | |||
113 | | ||||
114 | //____________________________________________________________________ | | |||
115 | QColor Helper::buttonHoverOutlineColor( const QPalette& palette ) const | | |||
116 | { return KColorUtils::mix( hoverColor( palette ), palette.color( QPalette::ButtonText ), 0.15 ); } | | |||
117 | | ||||
118 | //____________________________________________________________________ | | |||
119 | QColor Helper::sidePanelOutlineColor( const QPalette& palette, bool hasFocus, qreal opacity, AnimationMode mode ) const | 110 | QColor Helper::sidePanelOutlineColor( const QPalette& palette, bool hasFocus, qreal opacity, AnimationMode mode ) const | ||
120 | { | 111 | { | ||
121 | 112 | | |||
122 | QColor outline( palette.color( QPalette::Inactive, QPalette::Highlight ) ); | 113 | QColor outline( palette.color( QPalette::Inactive, QPalette::Highlight ) ); | ||
123 | const QColor &focus = palette.color( QPalette::Active, QPalette::Highlight ); | 114 | const QColor &focus = palette.color( QPalette::Active, QPalette::Highlight ); | ||
124 | 115 | | |||
125 | if( mode == AnimationFocus ) | 116 | if( mode == AnimationFocus ) | ||
126 | { | 117 | { | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | |||||
186 | 177 | | |||
187 | } | 178 | } | ||
188 | 179 | | |||
189 | //____________________________________________________________________ | 180 | //____________________________________________________________________ | ||
190 | QColor Helper::buttonOutlineColor( const QPalette& palette, bool mouseOver, bool hasFocus, qreal opacity, AnimationMode mode ) const | 181 | QColor Helper::buttonOutlineColor( const QPalette& palette, bool mouseOver, bool hasFocus, qreal opacity, AnimationMode mode ) const | ||
191 | { | 182 | { | ||
192 | 183 | | |||
193 | QColor outline( KColorUtils::mix( palette.color( QPalette::Button ), palette.color( QPalette::ButtonText ), 0.3 ) ); | 184 | QColor outline( KColorUtils::mix( palette.color( QPalette::Button ), palette.color( QPalette::ButtonText ), 0.3 ) ); | ||
194 | if( mode == AnimationHover ) | 185 | const QColor focus = focusColor( palette ); | ||
195 | { | 186 | const QColor hover = hoverColor( palette ); | ||
196 | | ||||
197 | if( hasFocus ) | | |||
198 | { | | |||
199 | const QColor focus( buttonFocusOutlineColor( palette ) ); | | |||
200 | const QColor hover( buttonHoverOutlineColor( palette ) ); | | |||
201 | outline = KColorUtils::mix( focus, hover, opacity ); | | |||
202 | | ||||
203 | } else { | | |||
204 | 187 | | |||
205 | const QColor hover( hoverColor( palette ) ); | 188 | // Focus has precedence over hover | ||
206 | outline = KColorUtils::mix( outline, hover, opacity ); | 189 | if( mode == AnimationFocus ) { | ||
207 | 190 | | |||
208 | } | 191 | outline = KColorUtils::mix( outline, focus, opacity ); | ||
209 | 192 | | |||
210 | } else if( mouseOver ) { | 193 | } else if( hasFocus ) { | ||
211 | 194 | | |||
212 | if( hasFocus ) outline = buttonHoverOutlineColor( palette ); | 195 | outline = focus; | ||
213 | else outline = hoverColor( palette ); | | |||
214 | 196 | | |||
215 | } else if( mode == AnimationFocus ) { | 197 | } else if( mode == AnimationHover ) { | ||
216 | 198 | | |||
217 | const QColor focus( buttonFocusOutlineColor( palette ) ); | 199 | outline = KColorUtils::mix( outline, hover, opacity ); | ||
218 | outline = KColorUtils::mix( outline, focus, opacity ); | | |||
219 | 200 | | |||
220 | } else if( hasFocus ) { | 201 | } else if( mouseOver ) { | ||
221 | 202 | | |||
222 | outline = buttonFocusOutlineColor( palette ); | 203 | outline = hover; | ||
223 | 204 | | |||
224 | } | 205 | } | ||
225 | 206 | | |||
226 | return outline; | 207 | return outline; | ||
227 | 208 | | |||
228 | } | 209 | } | ||
229 | 210 | | |||
230 | //____________________________________________________________________ | 211 | //____________________________________________________________________ | ||
231 | QColor Helper::buttonBackgroundColor( const QPalette& palette, bool mouseOver, bool hasFocus, bool sunken, qreal opacity, AnimationMode mode ) const | 212 | QColor Helper::buttonBackgroundColor( const QPalette& palette, bool mouseOver, bool hasFocus, bool sunken, qreal opacity, AnimationMode mode ) const | ||
232 | { | 213 | { | ||
233 | 214 | | |||
234 | QColor background( sunken ? | 215 | QColor background = palette.color( QPalette::Button ); | ||
235 | KColorUtils::mix( palette.color( QPalette::Button ), palette.color( QPalette::ButtonText ), 0.2 ): | 216 | const QColor hover = hoverBackgroundColor( palette ); | ||
236 | palette.color( QPalette::Button ) ); | 217 | const QColor focus = focusBackgroundColor( palette ); | ||
218 | const QColor hoverFocus = hoverBackgroundColor( palette, focus ); | ||||
237 | 219 | | |||
238 | if( mode == AnimationHover ) | 220 | //FIXME: For some reason, the background color still changes on focus when all the logic for changing the background on focus is removed | ||
239 | { | 221 | if( mode == AnimationPressed ) { | ||
240 | 222 | | |||
241 | const QColor focus( focusColor( palette ) ); | 223 | background = KColorUtils::mix( background, buttonAltBackgroundColor( palette ), opacity ); | ||
242 | const QColor hover( hoverColor( palette ) ); | 224 | | ||
243 | if( hasFocus ) background = KColorUtils::mix( focus, hover, opacity ); | 225 | } else if ( sunken ) { | ||
226 | | ||||
227 | background = buttonAltBackgroundColor( palette ); | ||||
244 | 228 | | |||
245 | } else if( mouseOver && hasFocus ) { | 229 | } else if( mode == AnimationHover ) { | ||
230 | | ||||
231 | if( hasFocus && !sunken) background = KColorUtils::mix( focus, hoverFocus, opacity ); | ||||
232 | else background = KColorUtils::mix( background, hover, opacity ); | ||||
246 | 233 | | |||
247 | background = hoverColor( palette ); | 234 | } else if( mouseOver ) { | ||
235 | | ||||
236 | if( hasFocus ) background = hoverFocus; | ||||
237 | else background = hover; | ||||
248 | 238 | | |||
249 | } else if( mode == AnimationFocus ) { | 239 | } else if( mode == AnimationFocus ) { | ||
250 | 240 | | |||
251 | const QColor focus( focusColor( palette ) ); | | |||
252 | background = KColorUtils::mix( background, focus, opacity ); | 241 | background = KColorUtils::mix( background, focus, opacity ); | ||
253 | 242 | | |||
254 | } else if( hasFocus ) { | 243 | } else if( hasFocus ) { | ||
255 | 244 | | |||
256 | background = focusColor( palette ); | 245 | background = focus; | ||
257 | 246 | | |||
258 | } | 247 | } | ||
259 | 248 | | |||
260 | return background; | 249 | return background; | ||
261 | 250 | | |||
262 | } | 251 | } | ||
263 | 252 | | |||
264 | //____________________________________________________________________ | 253 | //____________________________________________________________________ | ||
▲ Show 20 Lines • Show All 357 Lines • ▼ Show 20 Line(s) | 608 | { | |||
622 | painter->setRenderHint( QPainter::Antialiasing, true ); | 611 | painter->setRenderHint( QPainter::Antialiasing, true ); | ||
623 | 612 | | |||
624 | // copy rect | 613 | // copy rect | ||
625 | QRectF frameRect( rect ); | 614 | QRectF frameRect( rect ); | ||
626 | frameRect.adjust( 1, 1, -1, -1 ); | 615 | frameRect.adjust( 1, 1, -1, -1 ); | ||
627 | qreal radius( frameRadius( PenWidth::NoPen, -1 ) ); | 616 | qreal radius( frameRadius( PenWidth::NoPen, -1 ) ); | ||
628 | 617 | | |||
629 | // shadow | 618 | // shadow | ||
630 | if( sunken ) { | 619 | if( !sunken ) { | ||
631 | | ||||
632 | frameRect.translate( 1, 1 ); | | |||
633 | | ||||
634 | } else { | | |||
635 | 620 | | |||
636 | renderRoundedRectShadow( painter, frameRect, shadow, radius ); | 621 | renderRoundedRectShadow( painter, frameRect, shadow, radius ); | ||
637 | 622 | | |||
638 | } | 623 | } | ||
639 | 624 | | |||
640 | if( outline.isValid() ) | 625 | if( outline.isValid() ) | ||
641 | { | 626 | { | ||
642 | 627 | | |||
643 | QLinearGradient gradient( frameRect.topLeft(), frameRect.bottomLeft() ); | 628 | painter->setPen( QPen( outline, PenWidth::Frame ) ); | ||
644 | gradient.setColorAt( 0, outline.lighter( hasFocus ? 103:101 ) ); | | |||
645 | gradient.setColorAt( 1, outline.darker( hasFocus ? 110:103 ) ); | | |||
646 | painter->setPen( QPen( QBrush( gradient ), 1.0 ) ); | | |||
647 | 629 | | |||
648 | frameRect = strokedRect( frameRect ); | 630 | frameRect = strokedRect( frameRect ); | ||
649 | radius = frameRadiusForNewPenWidth( radius, PenWidth::Frame ); | 631 | radius = frameRadiusForNewPenWidth( radius, PenWidth::Frame ); | ||
650 | 632 | | |||
651 | } else painter->setPen( Qt::NoPen ); | 633 | } else painter->setPen( Qt::NoPen ); | ||
652 | 634 | | |||
653 | // content | 635 | // content | ||
654 | if( color.isValid() ) | 636 | if( color.isValid() ) | ||
655 | { | 637 | { | ||
656 | 638 | | |||
657 | QLinearGradient gradient( frameRect.topLeft(), frameRect.bottomLeft() ); | 639 | painter->setBrush( color ); | ||
658 | gradient.setColorAt( 0, color.lighter( hasFocus ? 103:101 ) ); | | |||
659 | gradient.setColorAt( 1, color.darker( hasFocus ? 110:103 ) ); | | |||
660 | painter->setBrush( gradient ); | | |||
661 | 640 | | |||
662 | } else painter->setBrush( Qt::NoBrush ); | 641 | } else painter->setBrush( Qt::NoBrush ); | ||
663 | 642 | | |||
664 | // render | 643 | // render | ||
665 | painter->drawRoundedRect( frameRect, radius, radius ); | 644 | painter->drawRoundedRect( frameRect, radius, radius ); | ||
666 | 645 | | |||
667 | } | 646 | } | ||
668 | 647 | | |||
▲ Show 20 Lines • Show All 939 Lines • Show Last 20 Lines |