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 394 Lines • ▼ Show 20 Line(s) | 374 | { | |||
---|---|---|---|---|---|
395 | 395 | | |||
396 | // for all side view panels, unbold font (design choice) | 396 | // for all side view panels, unbold font (design choice) | ||
397 | if( scrollArea->property( PropertyNames::sidePanelView ).toBool() ) | 397 | if( scrollArea->property( PropertyNames::sidePanelView ).toBool() ) | ||
398 | { | 398 | { | ||
399 | // upbold list font | 399 | // upbold list font | ||
400 | auto font( scrollArea->font() ); | 400 | auto font( scrollArea->font() ); | ||
401 | font.setBold( false ); | 401 | font.setBold( false ); | ||
402 | scrollArea->setFont( font ); | 402 | scrollArea->setFont( font ); | ||
403 | | ||||
404 | // adjust background role | | |||
405 | if( !StyleConfigData::sidePanelDrawFrame() ) | | |||
406 | { | | |||
407 | scrollArea->setBackgroundRole( QPalette::Window ); | | |||
408 | scrollArea->setForegroundRole( QPalette::WindowText ); | | |||
409 | | ||||
410 | if( scrollArea->viewport() ) | | |||
411 | { | | |||
412 | scrollArea->viewport()->setBackgroundRole( QPalette::Window ); | | |||
413 | scrollArea->viewport()->setForegroundRole( QPalette::WindowText ); | | |||
414 | } | | |||
415 | | ||||
416 | // QTreeView animates expanding/collapsing branches. It paints them into a | | |||
417 | // temp pixmap whose background is unconditionally filled with the palette's | | |||
418 | // *base* color which is usually different from the window's color | | |||
419 | // cf. QTreeViewPrivate::renderTreeToPixmapForAnimation() | | |||
420 | if ( auto treeView = qobject_cast<QTreeView *>( scrollArea ) ) { | | |||
421 | if (treeView->isAnimated()) { | | |||
422 | QPalette pal( treeView->palette() ); | | |||
423 | pal.setColor( QPalette::Active, QPalette::Base, treeView->palette().color( treeView->backgroundRole() ) ); | | |||
424 | treeView->setPalette(pal); | | |||
425 | } | | |||
426 | } | | |||
427 | } | | |||
428 | | ||||
429 | } | 403 | } | ||
430 | 404 | | |||
431 | // disable autofill background for flat (== NoFrame) scrollareas, with QPalette::Window as a background | 405 | // disable autofill background for flat (== NoFrame) scrollareas, with QPalette::Window as a background | ||
432 | // this fixes flat scrollareas placed in a tinted widget, such as groupboxes, tabwidgets or framed dock-widgets | 406 | // this fixes flat scrollareas placed in a tinted widget, such as groupboxes, tabwidgets or framed dock-widgets | ||
433 | if( !(scrollArea->frameShape() == QFrame::NoFrame || scrollArea->backgroundRole() == QPalette::Window ) ) | 407 | if( !(scrollArea->frameShape() == QFrame::NoFrame || scrollArea->backgroundRole() == QPalette::Window ) ) | ||
434 | { return; } | 408 | { return; } | ||
435 | 409 | | |||
436 | // get viewport and check background role | 410 | // get viewport and check background role | ||
437 | auto viewport( scrollArea->viewport() ); | 411 | auto viewport( scrollArea->viewport() ); | ||
438 | if( !( viewport && viewport->backgroundRole() == QPalette::Window ) ) return; | 412 | if( !( viewport && viewport->backgroundRole() == QPalette::Window ) ) return; | ||
439 | 413 | | |||
440 | // change viewport autoFill background. | 414 | // change viewport autoFill background. | ||
441 | // do the same for all children if the background role is QPalette::Window | 415 | // do the same for all children if the background role is QPalette::Window | ||
442 | viewport->setAutoFillBackground( false ); | 416 | viewport->setAutoFillBackground( false ); | ||
443 | QList<QWidget*> children( viewport->findChildren<QWidget*>() ); | 417 | QList<QWidget*> children( viewport->findChildren<QWidget*>() ); | ||
444 | foreach( QWidget* child, children ) | 418 | foreach( QWidget* child, children ) | ||
445 | { | 419 | { | ||
446 | if( child->parent() == viewport && child->backgroundRole() == QPalette::Window ) | 420 | if( child->parent() == viewport && child->backgroundRole() == QPalette::Window ) | ||
447 | { child->setAutoFillBackground( false ); } | 421 | { child->setAutoFillBackground( false ); } | ||
448 | } | 422 | } | ||
449 | 423 | | |||
424 | /* | ||||
425 | QTreeView animates expanding/collapsing branches. It paints them into a | ||||
426 | temp pixmap whose background is unconditionally filled with the palette's | ||||
427 | *base* color which is usually different from the window's color | ||||
428 | cf. QTreeViewPrivate::renderTreeToPixmapForAnimation() | ||||
429 | */ | ||||
430 | if( auto treeView = qobject_cast<QTreeView *>( scrollArea ) ) | ||||
431 | { | ||||
432 | if (treeView->isAnimated()) | ||||
433 | { | ||||
434 | QPalette pal( treeView->palette() ); | ||||
435 | pal.setColor( QPalette::Active, QPalette::Base, treeView->palette().color( treeView->backgroundRole() ) ); | ||||
436 | treeView->setPalette(pal); | ||||
437 | } | ||||
438 | } | ||||
439 | | ||||
450 | } | 440 | } | ||
451 | 441 | | |||
452 | //_______________________________________________________________ | 442 | //_______________________________________________________________ | ||
453 | void Style::unpolish( QWidget* widget ) | 443 | void Style::unpolish( QWidget* widget ) | ||
454 | { | 444 | { | ||
455 | 445 | | |||
456 | // register widget to animations | 446 | // register widget to animations | ||
457 | _animations->unregisterWidget( widget ); | 447 | _animations->unregisterWidget( widget ); | ||
▲ Show 20 Lines • Show All 257 Lines • ▼ Show 20 Line(s) | 704 | { | |||
715 | 705 | | |||
716 | case SE_PushButtonContents: return pushButtonContentsRect( option, widget ); | 706 | case SE_PushButtonContents: return pushButtonContentsRect( option, widget ); | ||
717 | case SE_CheckBoxContents: return checkBoxContentsRect( option, widget ); | 707 | case SE_CheckBoxContents: return checkBoxContentsRect( option, widget ); | ||
718 | case SE_RadioButtonContents: return checkBoxContentsRect( option, widget ); | 708 | case SE_RadioButtonContents: return checkBoxContentsRect( option, widget ); | ||
719 | case SE_LineEditContents: return lineEditContentsRect( option, widget ); | 709 | case SE_LineEditContents: return lineEditContentsRect( option, widget ); | ||
720 | case SE_ProgressBarGroove: return progressBarGrooveRect( option, widget ); | 710 | case SE_ProgressBarGroove: return progressBarGrooveRect( option, widget ); | ||
721 | case SE_ProgressBarContents: return progressBarContentsRect( option, widget ); | 711 | case SE_ProgressBarContents: return progressBarContentsRect( option, widget ); | ||
722 | case SE_ProgressBarLabel: return progressBarLabelRect( option, widget ); | 712 | case SE_ProgressBarLabel: return progressBarLabelRect( option, widget ); | ||
713 | case SE_FrameContents: return frameContentsRect( option, widget ); | ||||
723 | case SE_HeaderArrow: return headerArrowRect( option, widget ); | 714 | case SE_HeaderArrow: return headerArrowRect( option, widget ); | ||
724 | case SE_HeaderLabel: return headerLabelRect( option, widget ); | 715 | case SE_HeaderLabel: return headerLabelRect( option, widget ); | ||
725 | case SE_TabBarTabLeftButton: return tabBarTabLeftButtonRect( option, widget ); | 716 | case SE_TabBarTabLeftButton: return tabBarTabLeftButtonRect( option, widget ); | ||
726 | case SE_TabBarTabRightButton: return tabBarTabRightButtonRect( option, widget ); | 717 | case SE_TabBarTabRightButton: return tabBarTabRightButtonRect( option, widget ); | ||
727 | case SE_TabWidgetTabBar: return tabWidgetTabBarRect( option, widget ); | 718 | case SE_TabWidgetTabBar: return tabWidgetTabBarRect( option, widget ); | ||
728 | case SE_TabWidgetTabContents: return tabWidgetTabContentsRect( option, widget ); | 719 | case SE_TabWidgetTabContents: return tabWidgetTabContentsRect( option, widget ); | ||
729 | case SE_TabWidgetTabPane: return tabWidgetTabPaneRect( option, widget ); | 720 | case SE_TabWidgetTabPane: return tabWidgetTabPaneRect( option, widget ); | ||
730 | case SE_TabWidgetLeftCorner: return tabWidgetCornerRect( SE_TabWidgetLeftCorner, option, widget ); | 721 | case SE_TabWidgetLeftCorner: return tabWidgetCornerRect( SE_TabWidgetLeftCorner, option, widget ); | ||
▲ Show 20 Lines • Show All 863 Lines • ▼ Show 20 Line(s) | 1541 | { | |||
1594 | 1585 | | |||
1595 | } else indicatorRect = QRect( rect.x(), inverted ? rect.top() : (rect.bottom() - indicatorSize + 1), rect.width(), indicatorSize ); | 1586 | } else indicatorRect = QRect( rect.x(), inverted ? rect.top() : (rect.bottom() - indicatorSize + 1), rect.width(), indicatorSize ); | ||
1596 | 1587 | | |||
1597 | return indicatorRect; | 1588 | return indicatorRect; | ||
1598 | 1589 | | |||
1599 | } | 1590 | } | ||
1600 | 1591 | | |||
1601 | //___________________________________________________________________________________________________________________ | 1592 | //___________________________________________________________________________________________________________________ | ||
1593 | QRect Style::frameContentsRect( const QStyleOption* option, const QWidget* widget ) const | ||||
1594 | { | ||||
1595 | if( !StyleConfigData::sidePanelDrawFrame() && | ||||
1596 | qobject_cast<const QAbstractScrollArea*>( widget ) && | ||||
1597 | widget->property( PropertyNames::sidePanelView ).toBool() ) | ||||
1598 | { | ||||
1599 | | ||||
1600 | // adjust margins for sidepanel widgets | ||||
1601 | return option->rect.adjusted( 0, 0, -1, 0 ); | ||||
1602 | | ||||
1603 | } else { | ||||
1604 | | ||||
1605 | // base class implementation | ||||
1606 | return ParentStyleClass::subElementRect( SE_FrameContents, option, widget ); | ||||
1607 | | ||||
1608 | } | ||||
1609 | } | ||||
1610 | | ||||
1611 | //___________________________________________________________________________________________________________________ | ||||
1602 | QRect Style::progressBarLabelRect( const QStyleOption* option, const QWidget* ) const | 1612 | QRect Style::progressBarLabelRect( const QStyleOption* option, const QWidget* ) const | ||
1603 | { | 1613 | { | ||
1604 | 1614 | | |||
1605 | // cast option and check | 1615 | // cast option and check | ||
1606 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | 1616 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | ||
1607 | if( !progressBarOption ) return QRect(); | 1617 | if( !progressBarOption ) return QRect(); | ||
1608 | 1618 | | |||
1609 | // get flags and check | 1619 | // get flags and check | ||
▲ Show 20 Lines • Show All 5646 Lines • Show Last 20 Lines |