Changeset 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 2743 Lines • ▼ Show 20 Line(s) | 2720 | { | |||
---|---|---|---|---|---|
2744 | // right column | 2744 | // right column | ||
2745 | const int rightColumnWidth = Metrics::MenuButton_IndicatorWidth + Metrics::MenuItem_ItemSpacing; | 2745 | const int rightColumnWidth = Metrics::MenuButton_IndicatorWidth + Metrics::MenuItem_ItemSpacing; | ||
2746 | size.rwidth() += leftColumnWidth + rightColumnWidth; | 2746 | size.rwidth() += leftColumnWidth + rightColumnWidth; | ||
2747 | 2747 | | |||
2748 | // make sure height is large enough for icon and arrow | 2748 | // make sure height is large enough for icon and arrow | ||
2749 | size.setHeight( qMax( size.height(), int(Metrics::MenuButton_IndicatorWidth) ) ); | 2749 | size.setHeight( qMax( size.height(), int(Metrics::MenuButton_IndicatorWidth) ) ); | ||
2750 | size.setHeight( qMax( size.height(), int(Metrics::CheckBox_Size) ) ); | 2750 | size.setHeight( qMax( size.height(), int(Metrics::CheckBox_Size) ) ); | ||
2751 | size.setHeight( qMax( size.height(), iconWidth ) ); | 2751 | size.setHeight( qMax( size.height(), iconWidth ) ); | ||
2752 | return expandSize( size, Metrics::MenuItem_MarginWidth ); | 2752 | return expandSize( size, Metrics::MenuItem_MarginWidth, Metrics::MenuItem_MarginHeight ); | ||
2753 | 2753 | | |||
2754 | } | 2754 | } | ||
2755 | 2755 | | |||
2756 | case QStyleOptionMenuItem::Separator: | 2756 | case QStyleOptionMenuItem::Separator: | ||
2757 | { | 2757 | { | ||
2758 | 2758 | | |||
2759 | if( menuItemOption->text.isEmpty() && menuItemOption->icon.isNull() ) | 2759 | if( menuItemOption->text.isEmpty() && menuItemOption->icon.isNull() ) | ||
2760 | { | 2760 | { | ||
2761 | 2761 | | |||
2762 | return expandSize( QSize(0,1), Metrics::MenuItem_MarginWidth ); | 2762 | return expandSize( QSize(0,1), Metrics::MenuItem_MarginWidth, Metrics::MenuItem_MarginHeight ); | ||
2763 | 2763 | | |||
2764 | } else { | 2764 | } else { | ||
2765 | 2765 | | |||
2766 | // build toolbutton option | 2766 | // build toolbutton option | ||
2767 | const QStyleOptionToolButton toolButtonOption( separatorMenuItemOption( menuItemOption, widget ) ); | 2767 | const QStyleOptionToolButton toolButtonOption( separatorMenuItemOption( menuItemOption, widget ) ); | ||
2768 | 2768 | | |||
2769 | // make sure height is large enough for icon and text | 2769 | // make sure height is large enough for icon and text | ||
2770 | const int iconWidth( menuItemOption->maxIconWidth ); | 2770 | const int iconWidth( menuItemOption->maxIconWidth ); | ||
▲ Show 20 Lines • Show All 1885 Lines • ▼ Show 20 Line(s) | 4651 | } else { | |||
4656 | */ | 4656 | */ | ||
4657 | QStyleOptionToolButton copy( separatorMenuItemOption( menuItemOption, widget ) ); | 4657 | QStyleOptionToolButton copy( separatorMenuItemOption( menuItemOption, widget ) ); | ||
4658 | renderMenuTitle( ©, painter, widget ); | 4658 | renderMenuTitle( ©, painter, widget ); | ||
4659 | 4659 | | |||
4660 | return true; | 4660 | return true; | ||
4661 | 4661 | | |||
4662 | } | 4662 | } | ||
4663 | 4663 | | |||
4664 | } | 4664 | } | ||
hpereiradacosta: this change is unrelated. Please revert. | |||||
4665 | 4665 | | |||
4666 | // store state | 4666 | // store state | ||
4667 | const State& state( option->state ); | 4667 | const State& state( option->state ); | ||
4668 | const bool enabled( state & State_Enabled ); | 4668 | const bool enabled( state & State_Enabled ); | ||
4669 | const bool selected( enabled && (state & State_Selected) ); | 4669 | const bool selected( enabled && (state & State_Selected) ); | ||
4670 | const bool sunken( enabled && (state & (State_On|State_Sunken) ) ); | 4670 | const bool sunken( enabled && (state & (State_On|State_Sunken) ) ); | ||
4671 | const bool reverseLayout( option->direction == Qt::RightToLeft ); | 4671 | const bool reverseLayout( option->direction == Qt::RightToLeft ); | ||
4672 | const bool useStrongFocus( StyleConfigData::menuItemDrawStrongFocus() ); | 4672 | const bool useStrongFocus( StyleConfigData::menuItemDrawStrongFocus() ); | ||
Show All 14 Lines | 4683 | { | |||
4687 | if( rect.right() >= menuItemOption->menuRect.right() ) sides |= SideRight; | 4687 | if( rect.right() >= menuItemOption->menuRect.right() ) sides |= SideRight; | ||
4688 | } | 4688 | } | ||
4689 | 4689 | | |||
4690 | _helper->renderFocusRect( painter, rect, color, outlineColor, sides ); | 4690 | _helper->renderFocusRect( painter, rect, color, outlineColor, sides ); | ||
4691 | 4691 | | |||
4692 | } | 4692 | } | ||
4693 | 4693 | | |||
4694 | // get rect available for contents | 4694 | // get rect available for contents | ||
4695 | auto contentsRect( insideMargin( rect, Metrics::MenuItem_MarginWidth ) ); | 4695 | auto contentsRect( insideMargin( rect, Metrics::MenuItem_MarginWidth, Metrics::MenuItem_MarginHeight ) ); | ||
4696 | 4696 | | |||
4697 | // define relevant rectangles | 4697 | // define relevant rectangles | ||
4698 | // checkbox | 4698 | // checkbox | ||
4699 | QRect checkBoxRect; | 4699 | QRect checkBoxRect; | ||
4700 | checkBoxRect = QRect( contentsRect.left(), contentsRect.top() + (contentsRect.height()-Metrics::CheckBox_Size)/2, Metrics::CheckBox_Size, Metrics::CheckBox_Size ); | 4700 | checkBoxRect = QRect( contentsRect.left(), contentsRect.top() + (contentsRect.height()-Metrics::CheckBox_Size)/2, Metrics::CheckBox_Size, Metrics::CheckBox_Size ); | ||
4701 | contentsRect.setLeft( checkBoxRect.right() + Metrics::MenuItem_ItemSpacing + 1 ); | 4701 | contentsRect.setLeft( checkBoxRect.right() + Metrics::MenuItem_ItemSpacing + 1 ); | ||
4702 | 4702 | | |||
4703 | // render checkbox indicator | 4703 | // render checkbox indicator | ||
4704 | if( menuItemOption->checkType == QStyleOptionMenuItem::NonExclusive ) | 4704 | if( menuItemOption->checkType == QStyleOptionMenuItem::NonExclusive ) | ||
why was this chunk of code moved ? This is unrelated to the change. hpereiradacosta: why was this chunk of code moved ? This is unrelated to the change.
Please try keep the diff to… | |||||
To keep it consistent:
Could you please let it stay here? zzag: To keep it consistent:
1. compute required rectangles
2. align checkbox rect
3. paint text… | |||||
4705 | { | 4705 | { | ||
4706 | 4706 | | |||
4707 | checkBoxRect = visualRect( option, checkBoxRect ); | 4707 | checkBoxRect = visualRect( option, checkBoxRect ); | ||
please dont rename variables just for the safe of it, and keep checkboxrect. hpereiradacosta: please dont rename variables just for the safe of it, and keep checkboxrect. | |||||
4708 | 4708 | | |||
4709 | // checkbox state | 4709 | // checkbox state | ||
4710 | 4710 | | |||
4711 | if( useStrongFocus && ( selected || sunken ) ) | 4711 | if( useStrongFocus && ( selected || sunken ) ) | ||
4712 | { _helper->renderCheckBoxBackground( painter, checkBoxRect, palette.color( QPalette::Window ), sunken ); } | 4712 | { _helper->renderCheckBoxBackground( painter, checkBoxRect, palette.color( QPalette::Window ), sunken ); } | ||
4713 | 4713 | | |||
4714 | CheckBoxState state( menuItemOption->checked ? CheckOn : CheckOff ); | 4714 | CheckBoxState state( menuItemOption->checked ? CheckOn : CheckOff ); | ||
4715 | const bool active( menuItemOption->checked ); | 4715 | const bool active( menuItemOption->checked ); | ||
Show All 17 Lines | |||||
4733 | 4733 | | |||
4734 | // icon | 4734 | // icon | ||
4735 | int iconWidth = 0; | 4735 | int iconWidth = 0; | ||
4736 | const bool showIcon( showIconsInMenuItems() ); | 4736 | const bool showIcon( showIconsInMenuItems() ); | ||
4737 | if( showIcon ) iconWidth = isQtQuickControl( option, widget ) ? qMax( pixelMetric(PM_SmallIconSize, option, widget ), menuItemOption->maxIconWidth ) : menuItemOption->maxIconWidth; | 4737 | if( showIcon ) iconWidth = isQtQuickControl( option, widget ) ? qMax( pixelMetric(PM_SmallIconSize, option, widget ), menuItemOption->maxIconWidth ) : menuItemOption->maxIconWidth; | ||
4738 | 4738 | | |||
4739 | QRect iconRect( contentsRect.left(), contentsRect.top() + (contentsRect.height()-iconWidth)/2, iconWidth, iconWidth ); | 4739 | QRect iconRect( contentsRect.left(), contentsRect.top() + (contentsRect.height()-iconWidth)/2, iconWidth, iconWidth ); | ||
4740 | contentsRect.setLeft( iconRect.right() + Metrics::MenuItem_ItemSpacing + 1 ); | 4740 | contentsRect.setLeft( iconRect.right() + Metrics::MenuItem_ItemSpacing + 1 ); | ||
4741 | 4741 | | |||
If I understand right, this is the double spacing bug fix. hpereiradacosta: If I understand right, this is the double spacing bug fix.
Correct ? Very nice.
In principle… | |||||
Yes. zzag: > This way, if in the future someone wants to revert the margin change, she/he does not revert… | |||||
4742 | if( showIcon && !menuItemOption->icon.isNull() ) | 4742 | if( showIcon && !menuItemOption->icon.isNull() ) | ||
4743 | { | 4743 | { | ||
4744 | 4744 | | |||
4745 | const QSize iconSize( pixelMetric( PM_SmallIconSize, option, widget ), pixelMetric( PM_SmallIconSize, option, widget ) ); | 4745 | const QSize iconSize( pixelMetric( PM_SmallIconSize, option, widget ), pixelMetric( PM_SmallIconSize, option, widget ) ); | ||
4746 | iconRect = centerRect( iconRect, iconSize ); | 4746 | iconRect = centerRect( iconRect, iconSize ); | ||
4747 | iconRect = visualRect( option, iconRect ); | 4747 | iconRect = visualRect( option, iconRect ); | ||
4748 | 4748 | | |||
4749 | // icon mode | 4749 | // icon mode | ||
▲ Show 20 Lines • Show All 1904 Lines • ▼ Show 20 Line(s) | |||||
6654 | 6654 | | |||
6655 | //______________________________________________________________________________ | 6655 | //______________________________________________________________________________ | ||
6656 | void Style::renderMenuTitle( const QStyleOptionToolButton* option, QPainter* painter, const QWidget* ) const | 6656 | void Style::renderMenuTitle( const QStyleOptionToolButton* option, QPainter* painter, const QWidget* ) const | ||
6657 | { | 6657 | { | ||
6658 | 6658 | | |||
6659 | // render a separator at the bottom | 6659 | // render a separator at the bottom | ||
6660 | const auto& palette( option->palette ); | 6660 | const auto& palette( option->palette ); | ||
6661 | const auto color( _helper->separatorColor( palette ) ); | 6661 | const auto color( _helper->separatorColor( palette ) ); | ||
6662 | _helper->renderSeparator( painter, QRect( option->rect.bottomLeft()-QPoint( 0, Metrics::MenuItem_MarginWidth), QSize( option->rect.width(), 1 ) ), color ); | 6662 | _helper->renderSeparator( painter, QRect( option->rect.bottomLeft()-QPoint( 0, Metrics::MenuItem_MarginHeight), QSize( option->rect.width(), 1 ) ), color ); | ||
6663 | 6663 | | |||
6664 | // render text in the center of the rect | 6664 | // render text in the center of the rect | ||
6665 | // icon is discarded on purpose | 6665 | // icon is discarded on purpose | ||
6666 | painter->setFont( option->font ); | 6666 | painter->setFont( option->font ); | ||
6667 | const auto contentsRect = insideMargin( option->rect, Metrics::MenuItem_MarginWidth ); | 6667 | const auto contentsRect = insideMargin( option->rect, Metrics::MenuItem_MarginWidth, Metrics::MenuItem_MarginHeight ); | ||
6668 | drawItemText( painter, contentsRect, Qt::AlignCenter, palette, true, option->text, QPalette::WindowText ); | 6668 | drawItemText( painter, contentsRect, Qt::AlignCenter, palette, true, option->text, QPalette::WindowText ); | ||
6669 | 6669 | | |||
6670 | } | 6670 | } | ||
6671 | 6671 | | |||
6672 | //______________________________________________________________________________ | 6672 | //______________________________________________________________________________ | ||
6673 | qreal Style::dialAngle( const QStyleOptionSlider* sliderOption, int value ) const | 6673 | qreal Style::dialAngle( const QStyleOptionSlider* sliderOption, int value ) const | ||
6674 | { | 6674 | { | ||
6675 | 6675 | | |||
▲ Show 20 Lines • Show All 462 Lines • Show Last 20 Lines |
this change is unrelated. Please revert.