Changeset View
Changeset View
Standalone View
Standalone View
kstyle/breezestyle.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 331 Lines • ▼ Show 20 Line(s) | 206 | { | |||
---|---|---|---|---|---|
332 | } else if( QComboBox *comboBox = qobject_cast<QComboBox*>( widget ) ) { | 332 | } else if( QComboBox *comboBox = qobject_cast<QComboBox*>( widget ) ) { | ||
333 | 333 | | |||
334 | if( !hasParent( widget, "QWebView" ) ) | 334 | if( !hasParent( widget, "QWebView" ) ) | ||
335 | { | 335 | { | ||
336 | QAbstractItemView *itemView( comboBox->view() ); | 336 | QAbstractItemView *itemView( comboBox->view() ); | ||
337 | if( itemView && itemView->itemDelegate() && itemView->itemDelegate()->inherits( "QComboBoxDelegate" ) ) | 337 | if( itemView && itemView->itemDelegate() && itemView->itemDelegate()->inherits( "QComboBoxDelegate" ) ) | ||
338 | { itemView->setItemDelegate( new BreezePrivate::ComboBoxItemDelegate( itemView ) ); } | 338 | { itemView->setItemDelegate( new BreezePrivate::ComboBoxItemDelegate( itemView ) ); } | ||
339 | } | 339 | } | ||
340 | addEventFilter( widget ); | ||||
340 | 341 | | |||
341 | } else if( widget->inherits( "QComboBoxPrivateContainer" ) ) { | 342 | } else if( widget->inherits( "QComboBoxPrivateContainer" ) ) { | ||
342 | 343 | | |||
343 | addEventFilter( widget ); | 344 | addEventFilter( widget ); | ||
344 | setTranslucentBackground( widget ); | 345 | setTranslucentBackground( widget ); | ||
345 | 346 | | |||
346 | } else if( widget->inherits( "QTipLabel" ) ) { | 347 | } else if( widget->inherits( "QTipLabel" ) ) { | ||
347 | 348 | | |||
348 | setTranslucentBackground( widget ); | 349 | setTranslucentBackground( widget ); | ||
349 | 350 | | |||
351 | } else if( qobject_cast<QCheckBox*>( widget ) || qobject_cast<QRadioButton*>( widget ) || qobject_cast<QTabBar*>( widget ) || qobject_cast<QPushButton*>( widget )) { | ||||
352 | addEventFilter( widget ); | ||||
350 | } | 353 | } | ||
351 | 354 | | |||
352 | // base class polishing | 355 | // base class polishing | ||
353 | ParentStyleClass::polish( widget ); | 356 | ParentStyleClass::polish( widget ); | ||
354 | 357 | | |||
355 | } | 358 | } | ||
356 | 359 | | |||
357 | //______________________________________________________________ | 360 | //______________________________________________________________ | ||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | 431 | { | |||
435 | _windowManager->unregisterWidget( widget ); | 438 | _windowManager->unregisterWidget( widget ); | ||
436 | _splitterFactory->unregisterWidget( widget ); | 439 | _splitterFactory->unregisterWidget( widget ); | ||
437 | 440 | | |||
438 | // remove event filter | 441 | // remove event filter | ||
439 | if( qobject_cast<QAbstractScrollArea*>( widget ) || | 442 | if( qobject_cast<QAbstractScrollArea*>( widget ) || | ||
440 | qobject_cast<QDockWidget*>( widget ) || | 443 | qobject_cast<QDockWidget*>( widget ) || | ||
441 | qobject_cast<QMdiSubWindow*>( widget ) || | 444 | qobject_cast<QMdiSubWindow*>( widget ) || | ||
442 | widget->inherits( "QComboBoxPrivateContainer" ) ) | 445 | widget->inherits( "QComboBoxPrivateContainer" ) ) | ||
443 | { widget->removeEventFilter( this ); } | 446 | { | ||
447 | widget->removeEventFilter( this ); | ||||
448 | } else if( !StyleConfigData::drawFocusIndicatorOnClick() && (!StyleConfigData::drawFocusIndicatorOnClick() && (qobject_cast<QCheckBox*>( widget ) || qobject_cast<QRadioButton*>( widget ) || qobject_cast<QTabBar*>( widget ) || qobject_cast<QTabBar*>( widget ) || qobject_cast<QComboBox*>( widget ) || qobject_cast<QPushButton*>( widget )))) { | ||||
449 | _focusReasonTracker.remove( widget ); | ||||
450 | widget->removeEventFilter( this ); | ||||
451 | } | ||||
444 | 452 | | |||
445 | ParentStyleClass::unpolish( widget ); | 453 | ParentStyleClass::unpolish( widget ); | ||
446 | 454 | | |||
447 | } | 455 | } | ||
448 | 456 | | |||
449 | //______________________________________________________________ | 457 | //______________________________________________________________ | ||
450 | int Style::pixelMetric( PixelMetric metric, const QStyleOption* option, const QWidget* widget ) const | 458 | int Style::pixelMetric( PixelMetric metric, const QStyleOption* option, const QWidget* widget ) const | ||
451 | { | 459 | { | ||
▲ Show 20 Lines • Show All 548 Lines • ▼ Show 20 Line(s) | 1004 | { | |||
1000 | #if QT_VERSION >= 0x050000 | 1008 | #if QT_VERSION >= 0x050000 | ||
1001 | else if( QCommandLinkButton* commandLinkButton = qobject_cast<QCommandLinkButton*>( object ) ) { return eventFilterCommandLinkButton( commandLinkButton, event ); } | 1009 | else if( QCommandLinkButton* commandLinkButton = qobject_cast<QCommandLinkButton*>( object ) ) { return eventFilterCommandLinkButton( commandLinkButton, event ); } | ||
1002 | #endif | 1010 | #endif | ||
1003 | // cast to QWidget | 1011 | // cast to QWidget | ||
1004 | QWidget *widget = static_cast<QWidget*>( object ); | 1012 | QWidget *widget = static_cast<QWidget*>( object ); | ||
1005 | if( widget->inherits( "QAbstractScrollArea" ) || widget->inherits( "KTextEditor::View" ) ) { return eventFilterScrollArea( widget, event ); } | 1013 | if( widget->inherits( "QAbstractScrollArea" ) || widget->inherits( "KTextEditor::View" ) ) { return eventFilterScrollArea( widget, event ); } | ||
1006 | else if( widget->inherits( "QComboBoxPrivateContainer" ) ) { return eventFilterComboBoxContainer( widget, event ); } | 1014 | else if( widget->inherits( "QComboBoxPrivateContainer" ) ) { return eventFilterComboBoxContainer( widget, event ); } | ||
1007 | 1015 | | |||
1016 | if (event->type() == QEvent::FocusIn) { | ||||
1017 | QFocusEvent *fe = static_cast<QFocusEvent *>(event); | ||||
1018 | _focusReasonTracker[widget] = fe->reason(); | ||||
1019 | } | ||||
1020 | | ||||
1008 | // fallback | 1021 | // fallback | ||
1009 | return ParentStyleClass::eventFilter( object, event ); | 1022 | return ParentStyleClass::eventFilter( object, event ); | ||
1010 | 1023 | | |||
1011 | } | 1024 | } | ||
1012 | 1025 | | |||
1013 | //____________________________________________________________________________ | 1026 | //____________________________________________________________________________ | ||
1014 | bool Style::eventFilterScrollArea( QWidget* widget, QEvent* event ) | 1027 | bool Style::eventFilterScrollArea( QWidget* widget, QEvent* event ) | ||
1015 | { | 1028 | { | ||
▲ Show 20 Lines • Show All 2389 Lines • ▼ Show 20 Line(s) | 3410 | { | |||
3405 | 3418 | | |||
3406 | // button state | 3419 | // button state | ||
3407 | const State& state( option->state ); | 3420 | const State& state( option->state ); | ||
3408 | const bool enabled( state & State_Enabled ); | 3421 | const bool enabled( state & State_Enabled ); | ||
3409 | const bool mouseOver( enabled && ( state & State_MouseOver ) ); | 3422 | const bool mouseOver( enabled && ( state & State_MouseOver ) ); | ||
3410 | const bool hasFocus( ( enabled && ( state & State_HasFocus ) ) && !( widget && widget->focusProxy())); | 3423 | const bool hasFocus( ( enabled && ( state & State_HasFocus ) ) && !( widget && widget->focusProxy())); | ||
3411 | const bool sunken( state & ( State_On|State_Sunken ) ); | 3424 | const bool sunken( state & ( State_On|State_Sunken ) ); | ||
3412 | const bool flat( buttonOption->features & QStyleOptionButton::Flat ); | 3425 | const bool flat( buttonOption->features & QStyleOptionButton::Flat ); | ||
3426 | const bool hasFocusFromKeyboard = hasFocus && (StyleConfigData::drawFocusIndicatorOnClick() || (_focusReasonTracker.contains(widget) && | ||||
3427 | (_focusReasonTracker[widget] == Qt::TabFocusReason || _focusReasonTracker[widget] == Qt::BacktabFocusReason))); | ||||
3428 | | ||||
3413 | 3429 | | |||
3414 | // update animation state | 3430 | // update animation state | ||
3415 | // mouse over takes precedence over focus | 3431 | // mouse over takes precedence over focus | ||
3416 | _animations->widgetStateEngine().updateState( widget, AnimationHover, mouseOver ); | 3432 | _animations->widgetStateEngine().updateState( widget, AnimationHover, mouseOver ); | ||
3417 | _animations->widgetStateEngine().updateState( widget, AnimationFocus, hasFocus && !mouseOver ); | 3433 | _animations->widgetStateEngine().updateState( widget, AnimationFocus, hasFocusFromKeyboard && !mouseOver ); | ||
3418 | 3434 | | |||
3419 | const AnimationMode mode( _animations->widgetStateEngine().buttonAnimationMode( widget ) ); | 3435 | const AnimationMode mode( _animations->widgetStateEngine().buttonAnimationMode( widget ) ); | ||
3420 | const qreal opacity( _animations->widgetStateEngine().buttonOpacity( widget ) ); | 3436 | const qreal opacity( _animations->widgetStateEngine().buttonOpacity( widget ) ); | ||
3421 | 3437 | | |||
3422 | if( flat ) | 3438 | if( flat ) | ||
3423 | { | 3439 | { | ||
3424 | 3440 | | |||
3425 | // define colors and render | 3441 | // define colors and render | ||
3426 | const QPalette& palette( option->palette ); | 3442 | const QPalette& palette( option->palette ); | ||
3427 | const QColor color( _helper->toolButtonColor( palette, mouseOver, hasFocus, sunken, opacity, mode ) ); | 3443 | const QColor color( _helper->toolButtonColor( palette, mouseOver, hasFocusFromKeyboard, sunken, opacity, mode ) ); | ||
3428 | _helper->renderToolButtonFrame( painter, rect, color, sunken ); | 3444 | _helper->renderToolButtonFrame( painter, rect, color, sunken ); | ||
3429 | 3445 | | |||
3430 | } else { | 3446 | } else { | ||
3431 | 3447 | | |||
3432 | // update button color from palette in case button is default | 3448 | // update button color from palette in case button is default | ||
3433 | QPalette palette( option->palette ); | 3449 | QPalette palette( option->palette ); | ||
3434 | if( enabled && buttonOption->features & QStyleOptionButton::DefaultButton ) | 3450 | if( enabled && buttonOption->features & QStyleOptionButton::DefaultButton ) | ||
3435 | { | 3451 | { | ||
3436 | const QColor button( palette.color( QPalette::Button ) ); | 3452 | const QColor button( palette.color( QPalette::Button ) ); | ||
3437 | const QColor base( palette.color( QPalette::Base ) ); | 3453 | const QColor base( palette.color( QPalette::Base ) ); | ||
3438 | palette.setColor( QPalette::Button, KColorUtils::mix( button, base, 0.7 ) ); | 3454 | palette.setColor( QPalette::Button, KColorUtils::mix( button, base, 0.7 ) ); | ||
3439 | } | 3455 | } | ||
3440 | 3456 | | |||
3441 | const QColor shadow( _helper->shadowColor( palette ) ); | 3457 | const QColor shadow( _helper->shadowColor( palette ) ); | ||
3442 | const QColor outline( _helper->buttonOutlineColor( palette, mouseOver, hasFocus, opacity, mode ) ); | 3458 | const QColor outline( _helper->buttonOutlineColor( palette, mouseOver, hasFocusFromKeyboard, opacity, mode ) ); | ||
3443 | const QColor background( _helper->buttonBackgroundColor( palette, mouseOver, hasFocus, sunken, opacity, mode ) ); | 3459 | const QColor background( _helper->buttonBackgroundColor( palette, mouseOver, hasFocusFromKeyboard, sunken, opacity, mode ) ); | ||
3444 | 3460 | | |||
3445 | // render | 3461 | // render | ||
3446 | _helper->renderButtonFrame( painter, rect, background, outline, shadow, hasFocus, sunken ); | 3462 | _helper->renderButtonFrame( painter, rect, background, outline, shadow, hasFocusFromKeyboard, sunken ); | ||
3447 | 3463 | | |||
3448 | } | 3464 | } | ||
3449 | 3465 | | |||
3450 | return true; | 3466 | return true; | ||
3451 | 3467 | | |||
3452 | } | 3468 | } | ||
3453 | 3469 | | |||
3454 | //______________________________________________________________ | 3470 | //______________________________________________________________ | ||
▲ Show 20 Lines • Show All 663 Lines • ▼ Show 20 Line(s) | 4125 | { | |||
4118 | 4134 | | |||
4119 | // state | 4135 | // state | ||
4120 | const State& state( option->state ); | 4136 | const State& state( option->state ); | ||
4121 | const bool enabled( state & State_Enabled ); | 4137 | const bool enabled( state & State_Enabled ); | ||
4122 | const bool sunken( state & (State_On | State_Sunken) ); | 4138 | const bool sunken( state & (State_On | State_Sunken) ); | ||
4123 | const bool mouseOver( enabled && (option->state & State_MouseOver) ); | 4139 | const bool mouseOver( enabled && (option->state & State_MouseOver) ); | ||
4124 | const bool hasFocus( enabled && !mouseOver && (option->state & State_HasFocus) ); | 4140 | const bool hasFocus( enabled && !mouseOver && (option->state & State_HasFocus) ); | ||
4125 | const bool flat( buttonOption->features & QStyleOptionButton::Flat ); | 4141 | const bool flat( buttonOption->features & QStyleOptionButton::Flat ); | ||
4142 | const bool hasFocusFromKeyboard = hasFocus && (StyleConfigData::drawFocusIndicatorOnClick() || (_focusReasonTracker.contains(widget) && | ||||
4143 | (_focusReasonTracker[widget] == Qt::TabFocusReason || _focusReasonTracker[widget] == Qt::BacktabFocusReason))); | ||||
4126 | 4144 | | |||
4127 | // content | 4145 | // content | ||
4128 | const bool hasText( !buttonOption->text.isEmpty() ); | 4146 | const bool hasText( !buttonOption->text.isEmpty() ); | ||
4129 | const bool hasIcon( (showIconsOnPushButtons() || flat || !hasText ) && !buttonOption->icon.isNull() ); | 4147 | const bool hasIcon( (showIconsOnPushButtons() || flat || !hasText ) && !buttonOption->icon.isNull() ); | ||
4130 | 4148 | | |||
4131 | // contents | 4149 | // contents | ||
4132 | QRect contentsRect( rect ); | 4150 | QRect contentsRect( rect ); | ||
4133 | if( sunken && !flat ) contentsRect.translate( 1, 1 ); | 4151 | if( sunken && !flat ) contentsRect.translate( 1, 1 ); | ||
4134 | 4152 | | |||
4135 | // color role | 4153 | // color role | ||
4136 | QPalette::ColorRole textRole; | 4154 | QPalette::ColorRole textRole; | ||
4137 | if( flat ) | 4155 | if( flat ) | ||
4138 | { | 4156 | { | ||
4139 | 4157 | | |||
4140 | if( hasFocus && sunken ) textRole = QPalette::HighlightedText; | 4158 | if( hasFocusFromKeyboard && sunken ) textRole = QPalette::HighlightedText; | ||
4141 | else textRole = QPalette::WindowText; | 4159 | else textRole = QPalette::WindowText; | ||
4142 | 4160 | | |||
4143 | } else if( hasFocus ) textRole = QPalette::HighlightedText; | 4161 | } else if( hasFocusFromKeyboard ) textRole = QPalette::HighlightedText; | ||
4144 | else textRole = QPalette::ButtonText; | 4162 | else textRole = QPalette::ButtonText; | ||
4145 | 4163 | | |||
4146 | // menu arrow | 4164 | // menu arrow | ||
4147 | if( buttonOption->features & QStyleOptionButton::HasMenu ) | 4165 | if( buttonOption->features & QStyleOptionButton::HasMenu ) | ||
4148 | { | 4166 | { | ||
4149 | 4167 | | |||
4150 | // define rect | 4168 | // define rect | ||
4151 | QRect arrowRect( contentsRect ); | 4169 | QRect arrowRect( contentsRect ); | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
4202 | 4220 | | |||
4203 | // render icon | 4221 | // render icon | ||
4204 | if( hasIcon && iconRect.isValid() ) { | 4222 | if( hasIcon && iconRect.isValid() ) { | ||
4205 | 4223 | | |||
4206 | // icon state and mode | 4224 | // icon state and mode | ||
4207 | const QIcon::State iconState( sunken ? QIcon::On : QIcon::Off ); | 4225 | const QIcon::State iconState( sunken ? QIcon::On : QIcon::Off ); | ||
4208 | QIcon::Mode iconMode; | 4226 | QIcon::Mode iconMode; | ||
4209 | if( !enabled ) iconMode = QIcon::Disabled; | 4227 | if( !enabled ) iconMode = QIcon::Disabled; | ||
4210 | else if( !flat && hasFocus ) iconMode = QIcon::Selected; | 4228 | else if( !flat && hasFocusFromKeyboard ) iconMode = QIcon::Selected; | ||
4211 | else if( mouseOver && flat ) iconMode = QIcon::Active; | 4229 | else if( mouseOver && flat ) iconMode = QIcon::Active; | ||
4212 | else iconMode = QIcon::Normal; | 4230 | else iconMode = QIcon::Normal; | ||
4213 | 4231 | | |||
4214 | const QPixmap pixmap = buttonOption->icon.pixmap( iconSize, iconMode, iconState ); | 4232 | const QPixmap pixmap = buttonOption->icon.pixmap( iconSize, iconMode, iconState ); | ||
4215 | drawItemPixmap( painter, iconRect, Qt::AlignCenter, pixmap ); | 4233 | drawItemPixmap( painter, iconRect, Qt::AlignCenter, pixmap ); | ||
4216 | 4234 | | |||
4217 | } | 4235 | } | ||
4218 | 4236 | | |||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | 4415 | { | |||
4401 | // check focus state | 4419 | // check focus state | ||
4402 | const bool hasFocus( enabled && ( state & State_HasFocus ) ); | 4420 | const bool hasFocus( enabled && ( state & State_HasFocus ) ); | ||
4403 | 4421 | | |||
4404 | // update animation state | 4422 | // update animation state | ||
4405 | _animations->widgetStateEngine().updateState( widget, AnimationFocus, hasFocus ); | 4423 | _animations->widgetStateEngine().updateState( widget, AnimationFocus, hasFocus ); | ||
4406 | const bool isFocusAnimated( _animations->widgetStateEngine().isAnimated( widget, AnimationFocus ) ); | 4424 | const bool isFocusAnimated( _animations->widgetStateEngine().isAnimated( widget, AnimationFocus ) ); | ||
4407 | const qreal opacity( _animations->widgetStateEngine().opacity( widget, AnimationFocus ) ); | 4425 | const qreal opacity( _animations->widgetStateEngine().opacity( widget, AnimationFocus ) ); | ||
4408 | 4426 | | |||
4427 | // render focus | ||||
4428 | if (StyleConfigData::drawFocusIndicatorOnClick() || (_focusReasonTracker.contains(widget) && | ||||
4429 | (_focusReasonTracker[widget] == Qt::TabFocusReason || _focusReasonTracker[widget] == Qt::BacktabFocusReason))) { | ||||
4409 | // focus color | 4430 | // focus color | ||
4410 | QColor focusColor; | 4431 | QColor focusColor; | ||
4411 | if( isFocusAnimated ) focusColor = _helper->alphaColor( _helper->focusColor( palette ), opacity ); | 4432 | if( isFocusAnimated ) focusColor = _helper->alphaColor( _helper->focusColor( palette ), opacity ); | ||
4412 | else if( hasFocus ) focusColor = _helper->focusColor( palette ); | 4433 | else if( hasFocus ) focusColor = _helper->focusColor( palette ); | ||
4413 | 4434 | | |||
4414 | // render focus | | |||
4415 | _helper->renderFocusLine( painter, textRect, focusColor ); | 4435 | _helper->renderFocusLine( painter, textRect, focusColor ); | ||
4416 | 4436 | } | |||
4417 | } | 4437 | } | ||
4418 | 4438 | | |||
4419 | return true; | 4439 | return true; | ||
4420 | 4440 | | |||
4421 | } | 4441 | } | ||
4422 | 4442 | | |||
4423 | 4443 | | |||
4424 | //___________________________________________________________________________________ | 4444 | //___________________________________________________________________________________ | ||
4425 | bool Style::drawComboBoxLabelControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | 4445 | bool Style::drawComboBoxLabelControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||
4426 | { | 4446 | { | ||
4427 | const QStyleOptionComboBox* comboBoxOption( qstyleoption_cast<const QStyleOptionComboBox*>( option ) ); | 4447 | const QStyleOptionComboBox* comboBoxOption( qstyleoption_cast<const QStyleOptionComboBox*>( option ) ); | ||
4428 | if( !comboBoxOption ) return false; | 4448 | if( !comboBoxOption ) return false; | ||
4429 | if( comboBoxOption->editable ) return false; | 4449 | if( comboBoxOption->editable ) return false; | ||
4430 | 4450 | | |||
4431 | // need to alter palette for focused buttons | 4451 | // need to alter palette for focused buttons | ||
4432 | const State& state( option->state ); | 4452 | const State& state( option->state ); | ||
4433 | const bool enabled( state & State_Enabled ); | 4453 | const bool enabled( state & State_Enabled ); | ||
4434 | const bool sunken( state & (State_On | State_Sunken) ); | 4454 | const bool sunken( state & (State_On | State_Sunken) ); | ||
4435 | const bool mouseOver( enabled && (option->state & State_MouseOver) ); | 4455 | const bool mouseOver( enabled && (option->state & State_MouseOver) ); | ||
4436 | const bool hasFocus( enabled && !mouseOver && (option->state & State_HasFocus) ); | 4456 | const bool hasFocus( enabled && !mouseOver && (option->state & State_HasFocus) ); | ||
4437 | const bool flat( !comboBoxOption->frame ); | 4457 | const bool flat( !comboBoxOption->frame ); | ||
4458 | const bool hasFocusFromKeyboard = hasFocus && (StyleConfigData::drawFocusIndicatorOnClick() || (_focusReasonTracker.contains(widget) && | ||||
4459 | (_focusReasonTracker[widget] == Qt::TabFocusReason || _focusReasonTracker[widget] == Qt::BacktabFocusReason))); | ||||
4438 | 4460 | | |||
4439 | QPalette::ColorRole textRole; | 4461 | QPalette::ColorRole textRole; | ||
4440 | if( flat ) { | 4462 | if( flat ) { | ||
4441 | 4463 | | |||
4442 | if( hasFocus && sunken ) textRole = QPalette::HighlightedText; | 4464 | if( hasFocusFromKeyboard && sunken ) textRole = QPalette::HighlightedText; | ||
4443 | else textRole = QPalette::WindowText; | 4465 | else textRole = QPalette::WindowText; | ||
4444 | 4466 | | |||
4445 | } else if( hasFocus ) textRole = QPalette::HighlightedText; | 4467 | } else if( hasFocusFromKeyboard ) textRole = QPalette::HighlightedText; | ||
4446 | else textRole = QPalette::ButtonText; | 4468 | else textRole = QPalette::ButtonText; | ||
4447 | 4469 | | |||
4448 | // change pen color directly | 4470 | // change pen color directly | ||
4449 | painter->setPen( QPen( option->palette.color( textRole ), 1 ) ); | 4471 | painter->setPen( QPen( option->palette.color( textRole ), 1 ) ); | ||
4450 | 4472 | | |||
4451 | // translate painter for pressed down comboboxes | 4473 | // translate painter for pressed down comboboxes | ||
4452 | if( sunken && !flat ) | 4474 | if( sunken && !flat ) | ||
4453 | { painter->translate( 1, 1 ); } | 4475 | { painter->translate( 1, 1 ); } | ||
▲ Show 20 Lines • Show All 908 Lines • ▼ Show 20 Line(s) | 5362 | { | |||
5362 | transform.rotate(newRot); | 5384 | transform.rotate(newRot); | ||
5363 | painter->setTransform( transform, true ); | 5385 | painter->setTransform( transform, true ); | ||
5364 | 5386 | | |||
5365 | } | 5387 | } | ||
5366 | 5388 | | |||
5367 | // adjust text rect based on font metrics | 5389 | // adjust text rect based on font metrics | ||
5368 | textRect = option->fontMetrics.boundingRect( textRect, textFlags, tabOption->text ); | 5390 | textRect = option->fontMetrics.boundingRect( textRect, textFlags, tabOption->text ); | ||
5369 | 5391 | | |||
5392 | if (StyleConfigData::drawFocusIndicatorOnClick() || (_focusReasonTracker.contains(widget) && | ||||
5393 | (_focusReasonTracker[widget] == Qt::TabFocusReason || _focusReasonTracker[widget] == Qt::BacktabFocusReason))) { | ||||
5370 | // focus color | 5394 | // focus color | ||
5371 | QColor focusColor; | 5395 | QColor focusColor; | ||
5372 | if( animated ) focusColor = _helper->alphaColor( _helper->focusColor( palette ), opacity ); | 5396 | if( animated ) focusColor = _helper->alphaColor( _helper->focusColor( palette ), opacity ); | ||
5373 | else if( hasFocus ) focusColor = _helper->focusColor( palette ); | 5397 | else if( hasFocus ) focusColor = _helper->focusColor( palette ); | ||
5374 | 5398 | | |||
5375 | // render focus line | 5399 | // render focus line | ||
5376 | _helper->renderFocusLine( painter, textRect, focusColor ); | 5400 | _helper->renderFocusLine( painter, textRect, focusColor ); | ||
5401 | } | ||||
5377 | 5402 | | |||
5378 | if( verticalTabs ) painter->restore(); | 5403 | if( verticalTabs ) painter->restore(); | ||
5379 | 5404 | | |||
5380 | return true; | 5405 | return true; | ||
5381 | 5406 | | |||
5382 | } | 5407 | } | ||
5383 | 5408 | | |||
5384 | //___________________________________________________________________________________ | 5409 | //___________________________________________________________________________________ | ||
▲ Show 20 Lines • Show All 566 Lines • ▼ Show 20 Line(s) | 5967 | { | |||
5951 | 5976 | | |||
5952 | // state | 5977 | // state | ||
5953 | const State& state( option->state ); | 5978 | const State& state( option->state ); | ||
5954 | const bool enabled( state & State_Enabled ); | 5979 | const bool enabled( state & State_Enabled ); | ||
5955 | const bool mouseOver( enabled && ( state & State_MouseOver ) ); | 5980 | const bool mouseOver( enabled && ( state & State_MouseOver ) ); | ||
5956 | const bool hasFocus( enabled && ( state & (State_HasFocus | State_Sunken ) ) ); | 5981 | const bool hasFocus( enabled && ( state & (State_HasFocus | State_Sunken ) ) ); | ||
5957 | const bool editable( comboBoxOption->editable ); | 5982 | const bool editable( comboBoxOption->editable ); | ||
5958 | const bool sunken( state & (State_On|State_Sunken) ); | 5983 | const bool sunken( state & (State_On|State_Sunken) ); | ||
5984 | const bool hasFocusFromKeyboard = hasFocus && (StyleConfigData::drawFocusIndicatorOnClick() || (_focusReasonTracker.contains(widget) && | ||||
5985 | (_focusReasonTracker[widget] == Qt::TabFocusReason || _focusReasonTracker[widget] == Qt::BacktabFocusReason))); | ||||
5959 | bool flat( !comboBoxOption->frame ); | 5986 | bool flat( !comboBoxOption->frame ); | ||
5960 | 5987 | | |||
5961 | // frame | 5988 | // frame | ||
5962 | if( option->subControls & SC_ComboBoxFrame ) | 5989 | if( option->subControls & SC_ComboBoxFrame ) | ||
5963 | { | 5990 | { | ||
5964 | 5991 | | |||
5965 | if( editable ) | 5992 | if( editable ) | ||
5966 | { | 5993 | { | ||
Show All 10 Lines | |||||
5977 | 6004 | | |||
5978 | } else { | 6005 | } else { | ||
5979 | 6006 | | |||
5980 | drawPrimitive( PE_FrameLineEdit, option, painter, widget ); | 6007 | drawPrimitive( PE_FrameLineEdit, option, painter, widget ); | ||
5981 | 6008 | | |||
5982 | } | 6009 | } | ||
5983 | 6010 | | |||
5984 | } else { | 6011 | } else { | ||
5985 | | ||||
5986 | // update animation state | 6012 | // update animation state | ||
5987 | // hover takes precedence over focus | 6013 | // hover takes precedence over focus | ||
5988 | _animations->inputWidgetEngine().updateState( widget, AnimationHover, mouseOver ); | 6014 | _animations->inputWidgetEngine().updateState( widget, AnimationHover, mouseOver ); | ||
5989 | _animations->inputWidgetEngine().updateState( widget, AnimationFocus, hasFocus && !mouseOver ); | 6015 | _animations->inputWidgetEngine().updateState( widget, AnimationFocus, hasFocusFromKeyboard && !mouseOver ); | ||
5990 | const AnimationMode mode( _animations->inputWidgetEngine().buttonAnimationMode( widget ) ); | 6016 | const AnimationMode mode( _animations->inputWidgetEngine().buttonAnimationMode( widget ) ); | ||
5991 | const qreal opacity( _animations->inputWidgetEngine().buttonOpacity( widget ) ); | 6017 | const qreal opacity( _animations->inputWidgetEngine().buttonOpacity( widget ) ); | ||
5992 | 6018 | | |||
5993 | if( flat ) { | 6019 | if( flat ) { | ||
5994 | 6020 | | |||
5995 | // define colors and render | 6021 | // define colors and render | ||
5996 | const QColor color( _helper->toolButtonColor( palette, mouseOver, hasFocus, sunken, opacity, mode ) ); | 6022 | const QColor color( _helper->toolButtonColor( palette, mouseOver, hasFocusFromKeyboard, sunken, opacity, mode ) ); | ||
5997 | _helper->renderToolButtonFrame( painter, rect, color, sunken ); | 6023 | _helper->renderToolButtonFrame( painter, rect, color, sunken ); | ||
5998 | 6024 | | |||
5999 | } else { | 6025 | } else { | ||
6000 | 6026 | | |||
6001 | // define colors | 6027 | // define colors | ||
6002 | const QColor shadow( _helper->shadowColor( palette ) ); | 6028 | const QColor shadow( _helper->shadowColor( palette ) ); | ||
6003 | const QColor outline( _helper->buttonOutlineColor( palette, mouseOver, hasFocus, opacity, mode ) ); | 6029 | const QColor outline( _helper->buttonOutlineColor( palette, mouseOver, hasFocusFromKeyboard, opacity, mode ) ); | ||
6004 | const QColor background( _helper->buttonBackgroundColor( palette, mouseOver, hasFocus, false, opacity, mode ) ); | 6030 | const QColor background( _helper->buttonBackgroundColor( palette, mouseOver, hasFocusFromKeyboard, false, opacity, mode ) ); | ||
6005 | 6031 | | |||
6006 | // render | 6032 | // render | ||
6007 | _helper->renderButtonFrame( painter, rect, background, outline, shadow, hasFocus, sunken ); | 6033 | _helper->renderButtonFrame( painter, rect, background, outline, shadow, hasFocusFromKeyboard, sunken ); | ||
6008 | 6034 | | |||
6009 | } | 6035 | } | ||
6010 | 6036 | | |||
6011 | } | 6037 | } | ||
6012 | 6038 | | |||
6013 | } | 6039 | } | ||
6014 | 6040 | | |||
6015 | // arrow | 6041 | // arrow | ||
Show All 37 Lines | 6043 | { | |||
6053 | 6079 | | |||
6054 | } else if( flat ) { | 6080 | } else if( flat ) { | ||
6055 | 6081 | | |||
6056 | if( empty || !enabled ) arrowColor = _helper->arrowColor( palette, QPalette::Disabled, QPalette::WindowText ); | 6082 | if( empty || !enabled ) arrowColor = _helper->arrowColor( palette, QPalette::Disabled, QPalette::WindowText ); | ||
6057 | else if( hasFocus && !mouseOver && sunken ) arrowColor = palette.color( QPalette::HighlightedText ); | 6083 | else if( hasFocus && !mouseOver && sunken ) arrowColor = palette.color( QPalette::HighlightedText ); | ||
6058 | else arrowColor = _helper->arrowColor( palette, QPalette::WindowText ); | 6084 | else arrowColor = _helper->arrowColor( palette, QPalette::WindowText ); | ||
6059 | 6085 | | |||
6060 | } else if( empty || !enabled ) arrowColor = _helper->arrowColor( palette, QPalette::Disabled, QPalette::ButtonText ); | 6086 | } else if( empty || !enabled ) arrowColor = _helper->arrowColor( palette, QPalette::Disabled, QPalette::ButtonText ); | ||
6061 | else if( hasFocus && !mouseOver ) arrowColor = palette.color( QPalette::HighlightedText ); | 6087 | else if( hasFocusFromKeyboard && !mouseOver ) arrowColor = palette.color( QPalette::HighlightedText ); | ||
6062 | else arrowColor = _helper->arrowColor( palette, QPalette::ButtonText ); | 6088 | else arrowColor = _helper->arrowColor( palette, QPalette::ButtonText ); | ||
6063 | 6089 | | |||
6064 | // arrow rect | 6090 | // arrow rect | ||
6065 | QRect arrowRect( subControlRect( CC_ComboBox, option, SC_ComboBoxArrow, widget ) ); | 6091 | QRect arrowRect( subControlRect( CC_ComboBox, option, SC_ComboBoxArrow, widget ) ); | ||
6066 | 6092 | | |||
6067 | // translate for non editable, non flat, sunken comboboxes | 6093 | // translate for non editable, non flat, sunken comboboxes | ||
6068 | if( sunken && !flat && !editable ) arrowRect.translate( 1, 1 ); | 6094 | if( sunken && !flat && !editable ) arrowRect.translate( 1, 1 ); | ||
6069 | 6095 | | |||
▲ Show 20 Lines • Show All 982 Lines • Show Last 20 Lines |