Changeset View
Standalone View
kstyle/breezestyle.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show All 25 Lines | |||||
26 | #include "breezemnemonics.h" | 26 | #include "breezemnemonics.h" | ||
27 | #include "breezepropertynames.h" | 27 | #include "breezepropertynames.h" | ||
28 | #include "breezeshadowhelper.h" | 28 | #include "breezeshadowhelper.h" | ||
29 | #include "breezesplitterproxy.h" | 29 | #include "breezesplitterproxy.h" | ||
30 | #include "breezestyleconfigdata.h" | 30 | #include "breezestyleconfigdata.h" | ||
31 | #include "breezewidgetexplorer.h" | 31 | #include "breezewidgetexplorer.h" | ||
32 | #include "breezewindowmanager.h" | 32 | #include "breezewindowmanager.h" | ||
33 | #include "breezeblurhelper.h" | 33 | #include "breezeblurhelper.h" | ||
34 | #include "breezetoolsareamanager.h" | ||||
34 | 35 | | |||
35 | #include <KColorUtils> | 36 | #include <KColorUtils> | ||
36 | 37 | | |||
37 | #include <QApplication> | 38 | #include <QApplication> | ||
38 | #include <QCheckBox> | 39 | #include <QCheckBox> | ||
39 | #include <QComboBox> | 40 | #include <QComboBox> | ||
40 | #include <QDial> | 41 | #include <QDial> | ||
41 | #include <QDBusConnection> | 42 | #include <QDBusConnection> | ||
42 | #include <QDockWidget> | 43 | #include <QDockWidget> | ||
43 | #include <QFormLayout> | 44 | #include <QFormLayout> | ||
44 | #include <QGraphicsView> | 45 | #include <QGraphicsView> | ||
45 | #include <QGroupBox> | 46 | #include <QGroupBox> | ||
46 | #include <QLineEdit> | 47 | #include <QLineEdit> | ||
47 | #include <QMainWindow> | 48 | #include <QMainWindow> | ||
48 | #include <QMdiSubWindow> | 49 | #include <QMdiSubWindow> | ||
49 | #include <QMenu> | 50 | #include <QMenu> | ||
50 | #include <QPainter> | 51 | #include <QPainter> | ||
51 | #include <QPushButton> | 52 | #include <QPushButton> | ||
52 | #include <QRadioButton> | 53 | #include <QRadioButton> | ||
53 | #include <QScrollBar> | 54 | #include <QScrollBar> | ||
54 | #include <QItemDelegate> | 55 | #include <QItemDelegate> | ||
56 | #include <QScreen> | ||||
hpereiradacosta: Not needed | |||||
55 | #include <QSplitterHandle> | 57 | #include <QSplitterHandle> | ||
56 | #include <QTextEdit> | 58 | #include <QTextEdit> | ||
57 | #include <QToolBar> | 59 | #include <QToolBar> | ||
58 | #include <QToolBox> | 60 | #include <QToolBox> | ||
59 | #include <QToolButton> | 61 | #include <QToolButton> | ||
60 | #include <QTreeView> | 62 | #include <QTreeView> | ||
61 | #include <QWidgetAction> | 63 | #include <QWidgetAction> | ||
62 | 64 | | |||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 158 | Style::Style(): | |||
161 | , _mnemonics( new Mnemonics( this ) ) | 163 | , _mnemonics( new Mnemonics( this ) ) | ||
162 | , _blurHelper( new BlurHelper( this ) ) | 164 | , _blurHelper( new BlurHelper( this ) ) | ||
163 | , _windowManager( new WindowManager( this ) ) | 165 | , _windowManager( new WindowManager( this ) ) | ||
164 | , _frameShadowFactory( new FrameShadowFactory( this ) ) | 166 | , _frameShadowFactory( new FrameShadowFactory( this ) ) | ||
165 | , _mdiWindowShadowFactory( new MdiWindowShadowFactory( this ) ) | 167 | , _mdiWindowShadowFactory( new MdiWindowShadowFactory( this ) ) | ||
166 | , _splitterFactory( new SplitterFactory( this ) ) | 168 | , _splitterFactory( new SplitterFactory( this ) ) | ||
167 | , _widgetExplorer( new WidgetExplorer( this ) ) | 169 | , _widgetExplorer( new WidgetExplorer( this ) ) | ||
168 | , _tabBarData( new BreezePrivate::TabBarData( this ) ) | 170 | , _tabBarData( new BreezePrivate::TabBarData( this ) ) | ||
171 | , _toolsAreaManager ( new ToolsAreaManager(this) ) | ||||
Compiler complains about variable being initialized in incorrect order. Member initialization must be in the same order as the declaration. (here toolsarea befor tabbardata) hpereiradacosta: Compiler complains about variable being initialized in incorrect order. Member initialization… | |||||
169 | #if BREEZE_HAVE_KSTYLE | 172 | #if BREEZE_HAVE_KSTYLE | ||
170 | , SH_ArgbDndWindow( newStyleHint( QStringLiteral( "SH_ArgbDndWindow" ) ) ) | 173 | , SH_ArgbDndWindow( newStyleHint( QStringLiteral( "SH_ArgbDndWindow" ) ) ) | ||
171 | , CE_CapacityBar( newControlElement( QStringLiteral( "CE_CapacityBar" ) ) ) | 174 | , CE_CapacityBar( newControlElement( QStringLiteral( "CE_CapacityBar" ) ) ) | ||
172 | #endif | 175 | #endif | ||
173 | { | 176 | { | ||
174 | 177 | | |||
175 | // use DBus connection to update on breeze configuration change | 178 | // use DBus connection to update on breeze configuration change | ||
176 | auto dbus = QDBusConnection::sessionBus(); | 179 | auto dbus = QDBusConnection::sessionBus(); | ||
Show All 31 Lines | 209 | { | |||
208 | 211 | | |||
209 | // register widget to animations | 212 | // register widget to animations | ||
210 | _animations->registerWidget( widget ); | 213 | _animations->registerWidget( widget ); | ||
211 | _windowManager->registerWidget( widget ); | 214 | _windowManager->registerWidget( widget ); | ||
212 | _frameShadowFactory->registerWidget( widget, *_helper ); | 215 | _frameShadowFactory->registerWidget( widget, *_helper ); | ||
213 | _mdiWindowShadowFactory->registerWidget( widget ); | 216 | _mdiWindowShadowFactory->registerWidget( widget ); | ||
214 | _shadowHelper->registerWidget( widget ); | 217 | _shadowHelper->registerWidget( widget ); | ||
215 | _splitterFactory->registerWidget( widget ); | 218 | _splitterFactory->registerWidget( widget ); | ||
219 | _toolsAreaManager->registerWidget ( widget ); | ||||
216 | 220 | | |||
217 | // enable mouse over effects for all necessary widgets | 221 | // enable mouse over effects for all necessary widgets | ||
218 | if( | 222 | if( | ||
219 | qobject_cast<QAbstractItemView*>( widget ) | 223 | qobject_cast<QAbstractItemView*>( widget ) | ||
220 | || qobject_cast<QAbstractSpinBox*>( widget ) | 224 | || qobject_cast<QAbstractSpinBox*>( widget ) | ||
221 | || qobject_cast<QCheckBox*>( widget ) | 225 | || qobject_cast<QCheckBox*>( widget ) | ||
222 | || qobject_cast<QComboBox*>( widget ) | 226 | || qobject_cast<QComboBox*>( widget ) | ||
223 | || qobject_cast<QDial*>( widget ) | 227 | || qobject_cast<QDial*>( widget ) | ||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Line(s) | 348 | } else if( widget->inherits( "QComboBoxPrivateContainer" ) ) { | |||
346 | addEventFilter( widget ); | 350 | addEventFilter( widget ); | ||
347 | setTranslucentBackground( widget ); | 351 | setTranslucentBackground( widget ); | ||
348 | 352 | | |||
349 | } else if( widget->inherits( "QTipLabel" ) ) { | 353 | } else if( widget->inherits( "QTipLabel" ) ) { | ||
350 | 354 | | |||
351 | setTranslucentBackground( widget ); | 355 | setTranslucentBackground( widget ); | ||
352 | 356 | | |||
353 | } | 357 | } | ||
354 | 358 | | |||
Just for my understanding: why is it necessary ? hpereiradacosta: Just for my understanding: why is it necessary ?
Here at least, nothing changes if I take this… | |||||
This causes Qt to request a background be drawn on these widgets, which is used for painting the border when there would normally be no widgets to paint on. Check systemsettings5 and spectacle. cblack: This causes Qt to request a background be drawn on these widgets, which is used for painting… | |||||
355 | // base class polishing | 359 | // base class polishing | ||
356 | ParentStyleClass::polish( widget ); | 360 | ParentStyleClass::polish( widget ); | ||
357 | 361 | | |||
358 | } | 362 | } | ||
359 | 363 | | |||
360 | //______________________________________________________________ | 364 | //______________________________________________________________ | ||
361 | void Style::polishScrollArea( QAbstractScrollArea* scrollArea ) | 365 | void Style::polishScrollArea( QAbstractScrollArea* scrollArea ) | ||
362 | { | 366 | { | ||
▲ Show 20 Lines • Show All 492 Lines • ▼ Show 20 Line(s) | 817 | { | |||
855 | // call function if implemented | 859 | // call function if implemented | ||
856 | if( !( fcn && fcn( *this, option, painter, widget ) ) ) | 860 | if( !( fcn && fcn( *this, option, painter, widget ) ) ) | ||
857 | { ParentStyleClass::drawPrimitive( element, option, painter, widget ); } | 861 | { ParentStyleClass::drawPrimitive( element, option, painter, widget ); } | ||
858 | 862 | | |||
859 | painter->restore(); | 863 | painter->restore(); | ||
860 | 864 | | |||
861 | } | 865 | } | ||
862 | 866 | | |||
863 | //______________________________________________________________ | 867 | //______________________________________________________________ | ||
"option" is unused (and compiler complains about it) hpereiradacosta: "option" is unused (and compiler complains about it)
Either add Q_UNUSED(option) just put… | |||||
864 | void Style::drawControl( ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | 868 | void Style::drawControl( ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||
865 | { | 869 | { | ||
866 | 870 | | |||
Just "setPen( _helper-> ...) hpereiradacosta: Just "setPen( _helper-> ...)
you don't need the temporary QPen if it has a width 1. | |||||
867 | StyleControl fcn; | 871 | StyleControl fcn; | ||
868 | 872 | | |||
hpereiradacosta: Same remark | |||||
869 | #if BREEZE_HAVE_KSTYLE | 873 | #if BREEZE_HAVE_KSTYLE | ||
870 | if( element == CE_CapacityBar ) | 874 | if( element == CE_CapacityBar ) | ||
871 | { | 875 | { | ||
872 | fcn = &Style::drawProgressBarControl; | 876 | fcn = &Style::drawProgressBarControl; | ||
What are these + and -100 numbers ? They sound arbitrary. At the minimum there should be a comment, and an enum to define what this number is. hpereiradacosta: What are these + and -100 numbers ? They sound arbitrary. At the minimum there should be a… | |||||
873 | 877 | | |||
874 | } else | 878 | } else | ||
875 | #endif | 879 | #endif | ||
876 | 880 | | |||
877 | switch( element ) { | 881 | switch( element ) { | ||
878 | 882 | | |||
879 | case CE_PushButtonBevel: fcn = &Style::drawPanelButtonCommandPrimitive; break; | 883 | case CE_PushButtonBevel: fcn = &Style::drawPanelButtonCommandPrimitive; break; | ||
880 | case CE_PushButtonLabel: fcn = &Style::drawPushButtonLabelControl; break; | 884 | case CE_PushButtonLabel: fcn = &Style::drawPushButtonLabelControl; break; | ||
881 | case CE_CheckBoxLabel: fcn = &Style::drawCheckBoxLabelControl; break; | 885 | case CE_CheckBoxLabel: fcn = &Style::drawCheckBoxLabelControl; break; | ||
882 | case CE_RadioButtonLabel: fcn = &Style::drawCheckBoxLabelControl; break; | 886 | case CE_RadioButtonLabel: fcn = &Style::drawCheckBoxLabelControl; break; | ||
883 | case CE_ToolButtonLabel: fcn = &Style::drawToolButtonLabelControl; break; | 887 | case CE_ToolButtonLabel: fcn = &Style::drawToolButtonLabelControl; break; | ||
884 | case CE_ComboBoxLabel: fcn = &Style::drawComboBoxLabelControl; break; | 888 | case CE_ComboBoxLabel: fcn = &Style::drawComboBoxLabelControl; break; | ||
885 | case CE_MenuBarEmptyArea: fcn = &Style::emptyControl; break; | 889 | case CE_MenuBarEmptyArea: fcn = &Style::drawMenuBarEmptyAreaControl; break; | ||
886 | case CE_MenuBarItem: fcn = &Style::drawMenuBarItemControl; break; | 890 | case CE_MenuBarItem: fcn = &Style::drawMenuBarItemControl; break; | ||
davidre: Stray qdebug | |||||
887 | case CE_MenuItem: fcn = &Style::drawMenuItemControl; break; | 891 | case CE_MenuItem: fcn = &Style::drawMenuItemControl; break; | ||
888 | case CE_ToolBar: fcn = &Style::emptyControl; break; | 892 | case CE_ToolBar: fcn = &Style::drawToolBarControl; break; | ||
889 | case CE_ProgressBar: fcn = &Style::drawProgressBarControl; break; | 893 | case CE_ProgressBar: fcn = &Style::drawProgressBarControl; break; | ||
890 | case CE_ProgressBarContents: fcn = &Style::drawProgressBarContentsControl; break; | 894 | case CE_ProgressBarContents: fcn = &Style::drawProgressBarContentsControl; break; | ||
891 | case CE_ProgressBarGroove: fcn = &Style::drawProgressBarGrooveControl; break; | 895 | case CE_ProgressBarGroove: fcn = &Style::drawProgressBarGrooveControl; break; | ||
892 | case CE_ProgressBarLabel: fcn = &Style::drawProgressBarLabelControl; break; | 896 | case CE_ProgressBarLabel: fcn = &Style::drawProgressBarLabelControl; break; | ||
893 | case CE_ScrollBarSlider: fcn = &Style::drawScrollBarSliderControl; break; | 897 | case CE_ScrollBarSlider: fcn = &Style::drawScrollBarSliderControl; break; | ||
894 | case CE_ScrollBarAddLine: fcn = &Style::drawScrollBarAddLineControl; break; | 898 | case CE_ScrollBarAddLine: fcn = &Style::drawScrollBarAddLineControl; break; | ||
895 | case CE_ScrollBarSubLine: fcn = &Style::drawScrollBarSubLineControl; break; | 899 | case CE_ScrollBarSubLine: fcn = &Style::drawScrollBarSubLineControl; break; | ||
896 | case CE_ScrollBarAddPage: fcn = &Style::emptyControl; break; | 900 | case CE_ScrollBarAddPage: fcn = &Style::emptyControl; break; | ||
▲ Show 20 Lines • Show All 3323 Lines • ▼ Show 20 Line(s) | |||||
4220 | bool Style::drawToolButtonLabelControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | 4224 | bool Style::drawToolButtonLabelControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||
4221 | { | 4225 | { | ||
4222 | 4226 | | |||
4223 | // cast option and check | 4227 | // cast option and check | ||
4224 | const auto toolButtonOption( qstyleoption_cast<const QStyleOptionToolButton*>(option) ); | 4228 | const auto toolButtonOption( qstyleoption_cast<const QStyleOptionToolButton*>(option) ); | ||
4225 | 4229 | | |||
4226 | // copy rect and palette | 4230 | // copy rect and palette | ||
4227 | const auto& rect = option->rect; | 4231 | const auto& rect = option->rect; | ||
4228 | const auto& palette = option->palette; | 4232 | auto palette = option->palette; | ||
4233 | | ||||
4234 | if (_helper->isInToolsArea(widget)) { | ||||
4235 | palette.setColor(QPalette::ButtonText, _helper->titleBarTextColor(widget->isActiveWindow())); | ||||
4236 | palette.setColor(QPalette::WindowText, _helper->titleBarTextColor(widget->isActiveWindow())); | ||||
4237 | } | ||||
as far as I can tell, this palette is used only later, in "drawItemText" and only if text is shown. I would move this all block there (line 4395 or so) hpereiradacosta: as far as I can tell, this palette is used only later, in "drawItemText" and only if text is… | |||||
4229 | 4238 | | |||
4230 | // state | 4239 | // state | ||
4231 | const State& state( option->state ); | 4240 | const State& state( option->state ); | ||
4232 | const bool enabled( state & State_Enabled ); | 4241 | const bool enabled( state & State_Enabled ); | ||
4233 | const bool sunken( state & (State_On | State_Sunken) ); | 4242 | const bool sunken( state & (State_On | State_Sunken) ); | ||
4234 | const bool mouseOver( enabled && (option->state & State_MouseOver) ); | 4243 | const bool mouseOver( enabled && (option->state & State_MouseOver) ); | ||
4235 | const bool flat( state & State_AutoRaise ); | 4244 | const bool flat( state & State_AutoRaise ); | ||
4236 | 4245 | | |||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 4289 | } else { | |||
4299 | 4308 | | |||
4300 | textFlags |= Qt::AlignLeft | Qt::AlignVCenter; | 4309 | textFlags |= Qt::AlignLeft | Qt::AlignVCenter; | ||
4301 | 4310 | | |||
4302 | } | 4311 | } | ||
4303 | 4312 | | |||
4304 | // make sure there is enough room for icon | 4313 | // make sure there is enough room for icon | ||
4305 | if( iconRect.isValid() ) iconRect = centerRect( iconRect, iconSize ); | 4314 | if( iconRect.isValid() ) iconRect = centerRect( iconRect, iconSize ); | ||
4306 | 4315 | | |||
4307 | // render arrow or icon | 4316 | // render arrow or icon | ||
Why has this code moved ? As far as I can tell it is used only line 4396, and so the initialization should remain in the corresponding if block. hpereiradacosta: Why has this code moved ? As far as I can tell it is used only line 4396, and so the… | |||||
4308 | if( hasArrow && iconRect.isValid() ) | 4317 | if( hasArrow && iconRect.isValid() ) | ||
4309 | { | 4318 | { | ||
4310 | 4319 | | |||
4311 | QStyleOptionToolButton copy( *toolButtonOption ); | 4320 | QStyleOptionToolButton copy( *toolButtonOption ); | ||
4312 | copy.rect = iconRect; | 4321 | copy.rect = iconRect; | ||
4313 | switch( toolButtonOption->arrowType ) | 4322 | switch( toolButtonOption->arrowType ) | ||
4314 | { | 4323 | { | ||
4315 | case Qt::LeftArrow: drawPrimitive( PE_IndicatorArrowLeft, ©, painter, widget ); break; | 4324 | case Qt::LeftArrow: drawPrimitive( PE_IndicatorArrowLeft, ©, painter, widget ); break; | ||
Show All 9 Lines | 4331 | } else if( hasIcon && iconRect.isValid() ) { | |||
4325 | const QIcon::State iconState( sunken ? QIcon::On : QIcon::Off ); | 4334 | const QIcon::State iconState( sunken ? QIcon::On : QIcon::Off ); | ||
4326 | QIcon::Mode iconMode; | 4335 | QIcon::Mode iconMode; | ||
4327 | if( !enabled ) iconMode = QIcon::Disabled; | 4336 | if( !enabled ) iconMode = QIcon::Disabled; | ||
4328 | else if( (!flat && hasFocus) || (flat && (state & State_Sunken) && !mouseOver) ) iconMode = QIcon::Selected; | 4337 | else if( (!flat && hasFocus) || (flat && (state & State_Sunken) && !mouseOver) ) iconMode = QIcon::Selected; | ||
4329 | else if( mouseOver && flat ) iconMode = QIcon::Active; | 4338 | else if( mouseOver && flat ) iconMode = QIcon::Active; | ||
4330 | else iconMode = QIcon::Normal; | 4339 | else iconMode = QIcon::Normal; | ||
4331 | 4340 | | |||
4332 | const QPixmap pixmap = toolButtonOption->icon.pixmap( iconSize, iconMode, iconState ); | 4341 | const QPixmap pixmap = toolButtonOption->icon.pixmap( iconSize, iconMode, iconState ); | ||
4333 | drawItemPixmap( painter, iconRect, Qt::AlignCenter, pixmap ); | 4342 | drawItemPixmap( painter, iconRect, Qt::AlignCenter, pixmap ); | ||
updating the palette in every paint event (and calling resetPalette()) will be very innefficient. You need to track whether the palette actually needs change before calling these. hpereiradacosta: updating the palette in every paint event (and calling resetPalette()) will be very… | |||||
If the tools area is enabled and a widget is in the tools area, then the palette needs changing. It is ugly, but that's what the best you can get when KIconLoader ignores widget palettes. cblack: If the tools area is enabled and a widget is in the tools area, then the palette needs changing. | |||||
Not at every paint event. You should check if kiconloader already have a customPalette, if it matches the one you want, and update (or reset) only when necessary. hpereiradacosta: Not at every paint event. You should check if kiconloader already have a customPalette, if it… | |||||
The issue is that the QStyle only has the global icon palette to mutate for the tools area. If the custom palette were to be left intact, that would affect widgets it's not supposed to. There is no other code flow that won't result in KIconLoader using a custom palette when it shouldn't. The reason this is necessary in the first place is that KIconLoader doesn't honor the widget palettes set elsewhere in the QStyle. This code is simply working with what it's being given, and the issues that lead to this solution are deep-rooted in Qt. You simply cannot do anything else without likely breaking Qt's current APIs that are in control of this. cblack: The issue is that the QStyle only has the global icon palette to mutate for the tools area. If… | |||||
I am sorry to say this is a serious show stopper. If there is no way to make this more efficient, then as far as I am concerned this is a no-go. Maybe one could try to cache the icons ourselves ? (and trigger cache clear when appropriate ?) hpereiradacosta: I am sorry to say this is a serious show stopper.
One cannot reset/update the kiconloader… | |||||
I'll dig in KIconLoader code a bit over the week-end to see what really happens when calling setCustomPalette and resetPalette, to get a sense of how resource consuming this is ... hpereiradacosta: I'll dig in KIconLoader code a bit over the week-end to see what really happens when calling… | |||||
So, hpereiradacosta: So,
Digging into the code it seems that this might not be as big of a problem as anticipated. | |||||
4334 | 4343 | | |||
4335 | } | 4344 | } | ||
4336 | 4345 | | |||
4337 | // render text | 4346 | // render text | ||
4338 | if( hasText && textRect.isValid() ) | 4347 | if( hasText && textRect.isValid() ) | ||
4339 | { | 4348 | { | ||
4340 | 4349 | | |||
4341 | QPalette::ColorRole textRole( QPalette::ButtonText ); | 4350 | QPalette::ColorRole textRole( QPalette::ButtonText ); | ||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Line(s) | 4481 | #endif | |||
4504 | { | 4513 | { | ||
4505 | 4514 | | |||
4506 | // cast option and check | 4515 | // cast option and check | ||
4507 | const auto menuItemOption = qstyleoption_cast<const QStyleOptionMenuItem*>( option ); | 4516 | const auto menuItemOption = qstyleoption_cast<const QStyleOptionMenuItem*>( option ); | ||
4508 | if( !menuItemOption ) return true; | 4517 | if( !menuItemOption ) return true; | ||
4509 | 4518 | | |||
4510 | // copy rect and palette | 4519 | // copy rect and palette | ||
4511 | const auto& rect( option->rect ); | 4520 | const auto& rect( option->rect ); | ||
4512 | const auto& palette( option->palette ); | 4521 | auto palette( option->palette ); | ||
4522 | | ||||
4523 | palette.setColor(QPalette::WindowText, _helper->titleBarTextColor(widget->isActiveWindow())); | ||||
4513 | 4524 | | |||
4514 | // store state | 4525 | // store state | ||
4515 | const State& state( option->state ); | 4526 | const State& state( option->state ); | ||
4516 | const bool enabled( state & State_Enabled ); | 4527 | const bool enabled( state & State_Enabled ); | ||
4517 | const bool selected( enabled && (state & State_Selected) ); | 4528 | const bool selected( enabled && (state & State_Selected) ); | ||
4518 | const bool sunken( enabled && (state & State_Sunken) ); | 4529 | const bool sunken( enabled && (state & State_Sunken) ); | ||
4519 | const bool useStrongFocus( StyleConfigData::menuItemDrawStrongFocus() ); | 4530 | const bool useStrongFocus( StyleConfigData::menuItemDrawStrongFocus() ); | ||
4520 | 4531 | | |||
4532 | painter->save(); | ||||
4533 | painter->setRenderHints( QPainter::Antialiasing ); | ||||
4534 | | ||||
4535 | painter->setPen(_helper->titleBarColor(widget->isActiveWindow())); | ||||
4536 | painter->setBrush(_helper->titleBarColor(widget->isActiveWindow())); | ||||
4537 | | ||||
4538 | QRectF copy(widget->geometry()); | ||||
Are you sure about the logic here ? geometry is relative to the parent corrdinate system while childrenRect is relative to current widget. hpereiradacosta: Are you sure about the logic here ? geometry is relative to the parent corrdinate system while… | |||||
Here at least, using opt->rect directly (no need for the copy), fixes the multiple toolbar issue, with no regression elsewhere. hpereiradacosta: Here at least, using opt->rect directly (no need for the copy), fixes the multiple toolbar… | |||||
4539 | copy.setTop(widget->childrenRect().top()); | ||||
4540 | | ||||
4541 | painter->drawRect(copy); | ||||
4542 | | ||||
4521 | // render hover and focus | 4543 | // render hover and focus | ||
4522 | if( useStrongFocus && ( selected || sunken ) ) | 4544 | if( useStrongFocus && ( selected || sunken ) ) | ||
4523 | { | 4545 | { | ||
4524 | 4546 | | |||
4525 | QColor outlineColor; | 4547 | QColor outlineColor; | ||
4526 | if( sunken ) outlineColor = _helper->focusColor( palette ); | 4548 | if( sunken ) outlineColor = _helper->focusColor( palette ); | ||
4527 | else if( selected ) outlineColor = _helper->hoverColor( palette ); | 4549 | else if( selected ) outlineColor = _helper->hoverColor( palette ); | ||
4528 | _helper->renderFocusRect( painter, rect, outlineColor ); | 4550 | _helper->renderFocusRect( painter, rect, outlineColor ); | ||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 4609 | { | |||
4591 | else if( selected ) outlineColor = _helper->hoverColor( palette ); | 4613 | else if( selected ) outlineColor = _helper->hoverColor( palette ); | ||
4592 | 4614 | | |||
4593 | _helper->renderFocusLine( painter, textRect, outlineColor ); | 4615 | _helper->renderFocusLine( painter, textRect, outlineColor ); | ||
4594 | 4616 | | |||
4595 | } | 4617 | } | ||
4596 | 4618 | | |||
4597 | } | 4619 | } | ||
4598 | 4620 | | |||
4599 | return true; | 4621 | if (!_helper->toolsAreaHasToolBar(widget)) { | ||
4622 | _helper->renderToolsAreaBorder(painter, widget); | ||||
4623 | } | ||||
4624 | | ||||
4625 | painter->restore(); | ||||
4600 | 4626 | | |||
4627 | return true; | ||||
4601 | } | 4628 | } | ||
4602 | 4629 | | |||
4603 | 4630 | | |||
4604 | //___________________________________________________________________________________ | 4631 | //___________________________________________________________________________________ | ||
4605 | bool Style::drawMenuItemControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | 4632 | bool Style::drawMenuItemControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||
4606 | { | 4633 | { | ||
4607 | 4634 | | |||
4608 | // cast option and check | 4635 | // cast option and check | ||
▲ Show 20 Lines • Show All 203 Lines • ▼ Show 20 Line(s) | 4800 | { | |||
4812 | 4839 | | |||
4813 | } | 4840 | } | ||
4814 | 4841 | | |||
4815 | } | 4842 | } | ||
4816 | 4843 | | |||
4817 | return true; | 4844 | return true; | ||
4818 | } | 4845 | } | ||
4819 | 4846 | | |||
4847 | bool Style::drawToolBarControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||||
4848 | { | ||||
4849 | if (!_helper->isInToolsArea(widget)) { | ||||
as far as I can tell you dont need the cast to QToolbar. Just use the widget. hpereiradacosta: as far as I can tell you dont need the cast to QToolbar. Just use the widget.
(and in any case… | |||||
4850 | return true; | ||||
4851 | } | ||||
4852 | | ||||
4853 | painter->save(); | ||||
Same remark. This is very innefficient. hpereiradacosta: Same remark. This is very innefficient.
You need to track whether the palette actually need… | |||||
4854 | painter->setRenderHints( QPainter::Antialiasing ); | ||||
4855 | | ||||
4856 | painter->setPen(_helper->titleBarColor(widget->isActiveWindow())); | ||||
4857 | painter->setBrush(_helper->titleBarColor(widget->isActiveWindow())); | ||||
4858 | | ||||
4859 | QRectF copy(widget->geometry()); | ||||
This should move in the if condition below. Creating a new palette (even by copy) is expensive. hpereiradacosta: This should move in the if condition below. Creating a new palette (even by copy) is expensive. | |||||
4860 | copy.setTop(widget->childrenRect().top() - 10); | ||||
4861 | | ||||
hpereiradacosta: same remark | |||||
4862 | painter->drawRect(copy); | ||||
4863 | | ||||
4864 | _helper->renderToolsAreaBorder(painter, widget); | ||||
4865 | | ||||
4866 | painter->restore(); | ||||
4867 | return true; | ||||
4868 | } | ||||
hpereiradacosta: same remark about option being unused | |||||
4869 | | ||||
hpereiradacosta: Same remark as above. | |||||
4870 | bool Style::drawMenuBarEmptyAreaControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||||
4871 | { | ||||
4872 | if (!_helper->isInToolsArea(widget)) { | ||||
4873 | return true; | ||||
4874 | } | ||||
4875 | | ||||
4876 | painter->save(); | ||||
4877 | painter->setRenderHints( QPainter::Antialiasing ); | ||||
4878 | | ||||
4879 | painter->setPen(_helper->titleBarColor(widget->isActiveWindow())); | ||||
4880 | painter->setBrush(_helper->titleBarColor(widget->isActiveWindow())); | ||||
4881 | | ||||
4882 | QRectF copy(widget->geometry()); | ||||
4883 | copy.setTop(widget->childrenRect().top()); | ||||
4884 | | ||||
4885 | painter->drawRect(copy); | ||||
4886 | | ||||
4887 | if (!_helper->toolsAreaHasToolBar(widget)) { | ||||
4888 | _helper->renderToolsAreaBorder(painter, widget); | ||||
4889 | } | ||||
4890 | | ||||
4891 | painter->restore(); | ||||
4892 | return true; | ||||
4893 | } | ||||
4894 | | ||||
4820 | //___________________________________________________________________________________ | 4895 | //___________________________________________________________________________________ | ||
another case where it is probably more correct to use option->rect directly. hpereiradacosta: another case where it is probably more correct to use option->rect directly. | |||||
4821 | bool Style::drawProgressBarControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | 4896 | bool Style::drawProgressBarControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||
4822 | { | 4897 | { | ||
4823 | 4898 | | |||
4824 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | 4899 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | ||
4825 | if( !progressBarOption ) return true; | 4900 | if( !progressBarOption ) return true; | ||
4826 | 4901 | | |||
4827 | // render groove | 4902 | // render groove | ||
4828 | QStyleOptionProgressBar progressBarOption2 = *progressBarOption; | 4903 | QStyleOptionProgressBar progressBarOption2 = *progressBarOption; | ||
▲ Show 20 Lines • Show All 2313 Lines • Show Last 20 Lines |
Not needed