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 1656 Lines • ▼ Show 20 Line(s) | 145 | { | |||
---|---|---|---|---|---|
1657 | 1657 | | |||
1658 | } | 1658 | } | ||
1659 | 1659 | | |||
1660 | //____________________________________________________________________ | 1660 | //____________________________________________________________________ | ||
1661 | QRect Style::tabBarTabLeftButtonRect( const QStyleOption* option, const QWidget* ) const | 1661 | QRect Style::tabBarTabLeftButtonRect( const QStyleOption* option, const QWidget* ) const | ||
1662 | { | 1662 | { | ||
1663 | 1663 | | |||
1664 | // cast option and check | 1664 | // cast option and check | ||
1665 | const auto tabOptionV3( qstyleoption_cast<const QStyleOptionTabV3*>( option ) ); | 1665 | #if BREEZE_USE_KDE4 | ||
1666 | if( !tabOptionV3 || tabOptionV3->leftButtonSize.isEmpty() ) return QRect(); | 1666 | const auto tabOption( qstyleoption_cast<const QStyleOptionTabV3*>( option ) ); | ||
1667 | #else | ||||
1668 | const auto tabOption( qstyleoption_cast<const QStyleOptionTab*>( option ) ); | ||||
1669 | #endif | ||||
1670 | if( !tabOption || tabOption->leftButtonSize.isEmpty() ) return QRect(); | ||||
1667 | 1671 | | |||
1668 | const auto rect( option->rect ); | 1672 | const auto rect( option->rect ); | ||
1669 | const QSize size( tabOptionV3->leftButtonSize ); | 1673 | const QSize size( tabOption->leftButtonSize ); | ||
1670 | QRect buttonRect( QPoint(0,0), size ); | 1674 | QRect buttonRect( QPoint(0,0), size ); | ||
1671 | 1675 | | |||
1672 | // vertical positioning | 1676 | // vertical positioning | ||
1673 | switch( tabOptionV3->shape ) | 1677 | switch( tabOption->shape ) | ||
1674 | { | 1678 | { | ||
1675 | case QTabBar::RoundedNorth: | 1679 | case QTabBar::RoundedNorth: | ||
1676 | case QTabBar::TriangularNorth: | 1680 | case QTabBar::TriangularNorth: | ||
1677 | 1681 | | |||
1678 | case QTabBar::RoundedSouth: | 1682 | case QTabBar::RoundedSouth: | ||
1679 | case QTabBar::TriangularSouth: | 1683 | case QTabBar::TriangularSouth: | ||
1680 | buttonRect.moveLeft( rect.left() + Metrics::TabBar_TabMarginWidth ); | 1684 | buttonRect.moveLeft( rect.left() + Metrics::TabBar_TabMarginWidth ); | ||
1681 | buttonRect.moveTop( ( rect.height() - buttonRect.height() )/2 ); | 1685 | buttonRect.moveTop( ( rect.height() - buttonRect.height() )/2 ); | ||
Show All 19 Lines | |||||
1701 | 1705 | | |||
1702 | } | 1706 | } | ||
1703 | 1707 | | |||
1704 | //____________________________________________________________________ | 1708 | //____________________________________________________________________ | ||
1705 | QRect Style::tabBarTabRightButtonRect( const QStyleOption* option, const QWidget* ) const | 1709 | QRect Style::tabBarTabRightButtonRect( const QStyleOption* option, const QWidget* ) const | ||
1706 | { | 1710 | { | ||
1707 | 1711 | | |||
1708 | // cast option and check | 1712 | // cast option and check | ||
1709 | const auto tabOptionV3( qstyleoption_cast<const QStyleOptionTabV3*>( option ) ); | 1713 | #if BREEZE_USE_KDE4 | ||
1710 | if( !tabOptionV3 || tabOptionV3->rightButtonSize.isEmpty() ) return QRect(); | 1714 | const auto tabOption( qstyleoption_cast<const QStyleOptionTabV3*>( option ) ); | ||
1715 | #else | ||||
1716 | const auto tabOption( qstyleoption_cast<const QStyleOptionTab*>( option ) ); | ||||
1717 | #endif | ||||
1718 | if( !tabOption || tabOption->rightButtonSize.isEmpty() ) return QRect(); | ||||
1711 | 1719 | | |||
1712 | const auto rect( option->rect ); | 1720 | const auto rect( option->rect ); | ||
1713 | const auto size( tabOptionV3->rightButtonSize ); | 1721 | const auto size( tabOption->rightButtonSize ); | ||
1714 | QRect buttonRect( QPoint(0,0), size ); | 1722 | QRect buttonRect( QPoint(0,0), size ); | ||
1715 | 1723 | | |||
1716 | // vertical positioning | 1724 | // vertical positioning | ||
1717 | switch( tabOptionV3->shape ) | 1725 | switch( tabOption->shape ) | ||
1718 | { | 1726 | { | ||
1719 | case QTabBar::RoundedNorth: | 1727 | case QTabBar::RoundedNorth: | ||
1720 | case QTabBar::TriangularNorth: | 1728 | case QTabBar::TriangularNorth: | ||
1721 | 1729 | | |||
1722 | case QTabBar::RoundedSouth: | 1730 | case QTabBar::RoundedSouth: | ||
1723 | case QTabBar::TriangularSouth: | 1731 | case QTabBar::TriangularSouth: | ||
1724 | buttonRect.moveRight( rect.right() - Metrics::TabBar_TabMarginWidth ); | 1732 | buttonRect.moveRight( rect.right() - Metrics::TabBar_TabMarginWidth ); | ||
1725 | buttonRect.moveTop( ( rect.height() - buttonRect.height() )/2 ); | 1733 | buttonRect.moveTop( ( rect.height() - buttonRect.height() )/2 ); | ||
▲ Show 20 Lines • Show All 1176 Lines • ▼ Show 20 Line(s) | 2874 | { | |||
2902 | } | 2910 | } | ||
2903 | 2911 | | |||
2904 | } | 2912 | } | ||
2905 | 2913 | | |||
2906 | //______________________________________________________________ | 2914 | //______________________________________________________________ | ||
2907 | QSize Style::tabBarTabSizeFromContents( const QStyleOption* option, const QSize& contentsSize, const QWidget* ) const | 2915 | QSize Style::tabBarTabSizeFromContents( const QStyleOption* option, const QSize& contentsSize, const QWidget* ) const | ||
2908 | { | 2916 | { | ||
2909 | const auto tabOption( qstyleoption_cast<const QStyleOptionTab*>( option ) ); | 2917 | const auto tabOption( qstyleoption_cast<const QStyleOptionTab*>( option ) ); | ||
2910 | const auto tabOptionV3( qstyleoption_cast<const QStyleOptionTabV3*>( option ) ); | | |||
2911 | const bool hasText( tabOption && !tabOption->text.isEmpty() ); | 2918 | const bool hasText( tabOption && !tabOption->text.isEmpty() ); | ||
2912 | const bool hasIcon( tabOption && !tabOption->icon.isNull() ); | 2919 | const bool hasIcon( tabOption && !tabOption->icon.isNull() ); | ||
2920 | #if BREEZE_USE_KDE4 | ||||
2921 | const auto tabOptionV3( qstyleoption_cast<const QStyleOptionTabV3*>( option ) ); | ||||
2913 | const bool hasLeftButton( tabOptionV3 && !tabOptionV3->leftButtonSize.isEmpty() ); | 2922 | const bool hasLeftButton( tabOptionV3 && !tabOptionV3->leftButtonSize.isEmpty() ); | ||
2914 | const bool hasRightButton( tabOptionV3 && !tabOptionV3->leftButtonSize.isEmpty() ); | 2923 | const bool hasRightButton( tabOptionV3 && !tabOptionV3->leftButtonSize.isEmpty() ); | ||
2924 | #else | ||||
2925 | const bool hasLeftButton( tabOption && !tabOption->leftButtonSize.isEmpty() ); | ||||
2926 | const bool hasRightButton( tabOption && !tabOption->leftButtonSize.isEmpty() ); | ||||
2927 | #endif | ||||
2915 | 2928 | | |||
2916 | // calculate width increment for horizontal tabs | 2929 | // calculate width increment for horizontal tabs | ||
2917 | int widthIncrement = 0; | 2930 | int widthIncrement = 0; | ||
2918 | if( hasIcon && !( hasText || hasLeftButton || hasRightButton ) ) widthIncrement -= 4; | 2931 | if( hasIcon && !( hasText || hasLeftButton || hasRightButton ) ) widthIncrement -= 4; | ||
2919 | if( hasText && hasIcon ) widthIncrement += Metrics::TabBar_TabItemSpacing; | 2932 | if( hasText && hasIcon ) widthIncrement += Metrics::TabBar_TabItemSpacing; | ||
2920 | if( hasLeftButton && ( hasText || hasIcon ) ) widthIncrement += Metrics::TabBar_TabItemSpacing; | 2933 | if( hasLeftButton && ( hasText || hasIcon ) ) widthIncrement += Metrics::TabBar_TabItemSpacing; | ||
2921 | if( hasRightButton && ( hasText || hasIcon || hasLeftButton ) ) widthIncrement += Metrics::TabBar_TabItemSpacing; | 2934 | if( hasRightButton && ( hasText || hasIcon || hasLeftButton ) ) widthIncrement += Metrics::TabBar_TabItemSpacing; | ||
2922 | 2935 | | |||
▲ Show 20 Lines • Show All 4287 Lines • Show Last 20 Lines |