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 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> | ||
37 | #include <KIconLoader> | ||||
36 | 38 | | |||
37 | #include <QApplication> | 39 | #include <QApplication> | ||
40 | #include <QBitmap> | ||||
38 | #include <QCheckBox> | 41 | #include <QCheckBox> | ||
39 | #include <QComboBox> | 42 | #include <QComboBox> | ||
40 | #include <QDial> | 43 | #include <QDial> | ||
44 | #include <QDialog> | ||||
41 | #include <QDBusConnection> | 45 | #include <QDBusConnection> | ||
42 | #include <QDockWidget> | 46 | #include <QDockWidget> | ||
43 | #include <QFormLayout> | 47 | #include <QFormLayout> | ||
44 | #include <QGraphicsView> | 48 | #include <QGraphicsView> | ||
45 | #include <QGroupBox> | 49 | #include <QGroupBox> | ||
46 | #include <QLineEdit> | 50 | #include <QLineEdit> | ||
47 | #include <QMainWindow> | 51 | #include <QMainWindow> | ||
48 | #include <QMdiSubWindow> | 52 | #include <QMdiSubWindow> | ||
49 | #include <QMenu> | 53 | #include <QMenu> | ||
50 | #include <QPainter> | 54 | #include <QPainter> | ||
51 | #include <QPushButton> | 55 | #include <QPushButton> | ||
52 | #include <QRadioButton> | 56 | #include <QRadioButton> | ||
53 | #include <QScrollBar> | 57 | #include <QScrollBar> | ||
54 | #include <QItemDelegate> | 58 | #include <QItemDelegate> | ||
55 | #include <QSplitterHandle> | 59 | #include <QSplitterHandle> | ||
56 | #include <QTextEdit> | 60 | #include <QTextEdit> | ||
57 | #include <QToolBar> | 61 | #include <QToolBar> | ||
58 | #include <QToolBox> | 62 | #include <QToolBox> | ||
59 | #include <QToolButton> | 63 | #include <QToolButton> | ||
60 | #include <QTreeView> | 64 | #include <QTreeView> | ||
61 | #include <QWidgetAction> | 65 | #include <QWidgetAction> | ||
66 | #include <QMdiArea> | ||||
62 | 67 | | |||
63 | #if BREEZE_HAVE_QTQUICK | 68 | #if BREEZE_HAVE_QTQUICK | ||
64 | #include <QQuickWindow> | 69 | #include <QQuickWindow> | ||
65 | #endif | 70 | #endif | ||
66 | 71 | | |||
67 | namespace BreezePrivate | 72 | namespace BreezePrivate | ||
68 | { | 73 | { | ||
69 | 74 | | |||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 161 | Style::Style(): | |||
159 | , _shadowHelper( new ShadowHelper( this, *_helper ) ) | 164 | , _shadowHelper( new ShadowHelper( this, *_helper ) ) | ||
160 | , _animations( new Animations( this ) ) | 165 | , _animations( new Animations( this ) ) | ||
161 | , _mnemonics( new Mnemonics( this ) ) | 166 | , _mnemonics( new Mnemonics( this ) ) | ||
162 | , _blurHelper( new BlurHelper( this ) ) | 167 | , _blurHelper( new BlurHelper( this ) ) | ||
163 | , _windowManager( new WindowManager( this ) ) | 168 | , _windowManager( new WindowManager( this ) ) | ||
164 | , _frameShadowFactory( new FrameShadowFactory( this ) ) | 169 | , _frameShadowFactory( new FrameShadowFactory( this ) ) | ||
165 | , _mdiWindowShadowFactory( new MdiWindowShadowFactory( this ) ) | 170 | , _mdiWindowShadowFactory( new MdiWindowShadowFactory( this ) ) | ||
166 | , _splitterFactory( new SplitterFactory( this ) ) | 171 | , _splitterFactory( new SplitterFactory( this ) ) | ||
172 | , _toolsAreaManager ( new ToolsAreaManager( _helper, this ) ) | ||||
167 | , _widgetExplorer( new WidgetExplorer( this ) ) | 173 | , _widgetExplorer( new WidgetExplorer( this ) ) | ||
168 | , _tabBarData( new BreezePrivate::TabBarData( this ) ) | 174 | , _tabBarData( new BreezePrivate::TabBarData( this ) ) | ||
169 | #if BREEZE_HAVE_KSTYLE | 175 | #if BREEZE_HAVE_KSTYLE | ||
170 | , SH_ArgbDndWindow( newStyleHint( QStringLiteral( "SH_ArgbDndWindow" ) ) ) | 176 | , SH_ArgbDndWindow( newStyleHint( QStringLiteral( "SH_ArgbDndWindow" ) ) ) | ||
171 | , CE_CapacityBar( newControlElement( QStringLiteral( "CE_CapacityBar" ) ) ) | 177 | , CE_CapacityBar( newControlElement( QStringLiteral( "CE_CapacityBar" ) ) ) | ||
172 | #endif | 178 | #endif | ||
173 | { | 179 | { | ||
174 | 180 | | |||
175 | // use DBus connection to update on breeze configuration change | 181 | // use DBus connection to update on breeze configuration change | ||
176 | auto dbus = QDBusConnection::sessionBus(); | 182 | auto dbus = QDBusConnection::sessionBus(); | ||
177 | dbus.connect( QString(), | 183 | dbus.connect( QString(), | ||
178 | QStringLiteral( "/BreezeStyle" ), | 184 | QStringLiteral( "/BreezeStyle" ), | ||
179 | QStringLiteral( "org.kde.Breeze.Style" ), | 185 | QStringLiteral( "org.kde.Breeze.Style" ), | ||
180 | QStringLiteral( "reparseConfiguration" ), this, SLOT(configurationChanged()) ); | 186 | QStringLiteral( "reparseConfiguration" ), this, SLOT(configurationChanged()) ); | ||
181 | 187 | | |||
182 | dbus.connect( QString(), | 188 | dbus.connect( QString(), | ||
183 | QStringLiteral( "/BreezeDecoration" ), | 189 | QStringLiteral( "/BreezeDecoration" ), | ||
184 | QStringLiteral( "org.kde.Breeze.Style" ), | 190 | QStringLiteral( "org.kde.Breeze.Style" ), | ||
185 | QStringLiteral( "reparseConfiguration" ), this, SLOT(configurationChanged()) ); | 191 | QStringLiteral( "reparseConfiguration" ), this, SLOT(configurationChanged()) ); | ||
192 | | ||||
193 | dbus.connect( QString(), | ||||
194 | QStringLiteral( "/KGlobalSettings" ), | ||||
195 | QStringLiteral( "org.kde.KGlobalSettings" ), | ||||
196 | QStringLiteral( "notifyChange" ), this, SLOT(configurationChanged()) ); | ||||
197 | | ||||
198 | dbus.connect( QString(), | ||||
199 | QStringLiteral( "/KWin" ), | ||||
200 | QStringLiteral( "org.kde.KWin" ), | ||||
201 | QStringLiteral( "reloadConfig" ), this, SLOT(configurationChanged())); | ||||
202 | | ||||
186 | #if QT_VERSION < 0x050D00 // Check if Qt version < 5.13 | 203 | #if QT_VERSION < 0x050D00 // Check if Qt version < 5.13 | ||
187 | this->addEventFilter(qApp); | 204 | this->addEventFilter(qApp); | ||
188 | #else | 205 | #else | ||
189 | connect(qApp, &QApplication::paletteChanged, this, &Style::configurationChanged); | 206 | connect(qApp, &QApplication::paletteChanged, this, &Style::configurationChanged); | ||
190 | #endif | 207 | #endif | ||
191 | // call the slot directly; this initial call will set up things that also | 208 | // call the slot directly; this initial call will set up things that also | ||
192 | // need to be reset when the system palette changes | 209 | // need to be reset when the system palette changes | ||
193 | loadConfiguration(); | 210 | loadConfiguration(); | ||
Show All 14 Lines | 223 | { | |||
208 | 225 | | |||
209 | // register widget to animations | 226 | // register widget to animations | ||
210 | _animations->registerWidget( widget ); | 227 | _animations->registerWidget( widget ); | ||
211 | _windowManager->registerWidget( widget ); | 228 | _windowManager->registerWidget( widget ); | ||
212 | _frameShadowFactory->registerWidget( widget, *_helper ); | 229 | _frameShadowFactory->registerWidget( widget, *_helper ); | ||
213 | _mdiWindowShadowFactory->registerWidget( widget ); | 230 | _mdiWindowShadowFactory->registerWidget( widget ); | ||
214 | _shadowHelper->registerWidget( widget ); | 231 | _shadowHelper->registerWidget( widget ); | ||
215 | _splitterFactory->registerWidget( widget ); | 232 | _splitterFactory->registerWidget( widget ); | ||
233 | _toolsAreaManager->registerWidget ( widget ); | ||||
216 | 234 | | |||
217 | // enable mouse over effects for all necessary widgets | 235 | // enable mouse over effects for all necessary widgets | ||
218 | if( | 236 | if( | ||
219 | qobject_cast<QAbstractItemView*>( widget ) | 237 | qobject_cast<QAbstractItemView*>( widget ) | ||
220 | || qobject_cast<QAbstractSpinBox*>( widget ) | 238 | || qobject_cast<QAbstractSpinBox*>( widget ) | ||
221 | || qobject_cast<QCheckBox*>( widget ) | 239 | || qobject_cast<QCheckBox*>( widget ) | ||
222 | || qobject_cast<QComboBox*>( widget ) | 240 | || qobject_cast<QComboBox*>( widget ) | ||
223 | || qobject_cast<QDial*>( widget ) | 241 | || qobject_cast<QDial*>( widget ) | ||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Line(s) | 362 | } else if( widget->inherits( "QComboBoxPrivateContainer" ) ) { | |||
345 | 363 | | |||
346 | addEventFilter( widget ); | 364 | addEventFilter( widget ); | ||
347 | setTranslucentBackground( widget ); | 365 | setTranslucentBackground( widget ); | ||
348 | 366 | | |||
349 | } else if( widget->inherits( "QTipLabel" ) ) { | 367 | } else if( widget->inherits( "QTipLabel" ) ) { | ||
350 | 368 | | |||
351 | setTranslucentBackground( widget ); | 369 | setTranslucentBackground( widget ); | ||
352 | 370 | | |||
371 | } else if ( qobject_cast<QMainWindow*> (widget) || qobject_cast<QDialog*> (widget) ) { | ||||
372 | widget->setAttribute(Qt::WA_StyledBackground); | ||||
353 | } | 373 | } | ||
354 | | ||||
355 | // base class polishing | 374 | // base class polishing | ||
356 | ParentStyleClass::polish( widget ); | 375 | ParentStyleClass::polish( widget ); | ||
357 | 376 | | |||
358 | } | 377 | } | ||
359 | 378 | | |||
360 | //______________________________________________________________ | 379 | //______________________________________________________________ | ||
361 | void Style::polishScrollArea( QAbstractScrollArea* scrollArea ) | 380 | void Style::polishScrollArea( QAbstractScrollArea* scrollArea ) | ||
362 | { | 381 | { | ||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 451 | { | |||
434 | // register widget to animations | 453 | // register widget to animations | ||
435 | _animations->unregisterWidget( widget ); | 454 | _animations->unregisterWidget( widget ); | ||
436 | _frameShadowFactory->unregisterWidget( widget ); | 455 | _frameShadowFactory->unregisterWidget( widget ); | ||
437 | _mdiWindowShadowFactory->unregisterWidget( widget ); | 456 | _mdiWindowShadowFactory->unregisterWidget( widget ); | ||
438 | _shadowHelper->unregisterWidget( widget ); | 457 | _shadowHelper->unregisterWidget( widget ); | ||
439 | _windowManager->unregisterWidget( widget ); | 458 | _windowManager->unregisterWidget( widget ); | ||
440 | _splitterFactory->unregisterWidget( widget ); | 459 | _splitterFactory->unregisterWidget( widget ); | ||
441 | _blurHelper->unregisterWidget( widget ); | 460 | _blurHelper->unregisterWidget( widget ); | ||
461 | _toolsAreaManager->unregisterWidget ( widget ); | ||||
442 | 462 | | |||
443 | // remove event filter | 463 | // remove event filter | ||
444 | if( qobject_cast<QAbstractScrollArea*>( widget ) || | 464 | if( qobject_cast<QAbstractScrollArea*>( widget ) || | ||
445 | qobject_cast<QDockWidget*>( widget ) || | 465 | qobject_cast<QDockWidget*>( widget ) || | ||
446 | qobject_cast<QMdiSubWindow*>( widget ) || | 466 | qobject_cast<QMdiSubWindow*>( widget ) || | ||
447 | widget->inherits( "QComboBoxPrivateContainer" ) ) | 467 | widget->inherits( "QComboBoxPrivateContainer" ) ) | ||
448 | { widget->removeEventFilter( this ); } | 468 | { widget->removeEventFilter( this ); } | ||
449 | 469 | | |||
▲ Show 20 Lines • Show All 389 Lines • ▼ Show 20 Line(s) | 837 | { | |||
839 | case PE_Frame: fcn = &Style::drawFramePrimitive; break; | 859 | case PE_Frame: fcn = &Style::drawFramePrimitive; break; | ||
840 | case PE_FrameLineEdit: fcn = &Style::drawFrameLineEditPrimitive; break; | 860 | case PE_FrameLineEdit: fcn = &Style::drawFrameLineEditPrimitive; break; | ||
841 | case PE_FrameMenu: fcn = &Style::drawFrameMenuPrimitive; break; | 861 | case PE_FrameMenu: fcn = &Style::drawFrameMenuPrimitive; break; | ||
842 | case PE_FrameGroupBox: fcn = &Style::drawFrameGroupBoxPrimitive; break; | 862 | case PE_FrameGroupBox: fcn = &Style::drawFrameGroupBoxPrimitive; break; | ||
843 | case PE_FrameTabWidget: fcn = &Style::drawFrameTabWidgetPrimitive; break; | 863 | case PE_FrameTabWidget: fcn = &Style::drawFrameTabWidgetPrimitive; break; | ||
844 | case PE_FrameTabBarBase: fcn = &Style::drawFrameTabBarBasePrimitive; break; | 864 | case PE_FrameTabBarBase: fcn = &Style::drawFrameTabBarBasePrimitive; break; | ||
845 | case PE_FrameWindow: fcn = &Style::drawFrameWindowPrimitive; break; | 865 | case PE_FrameWindow: fcn = &Style::drawFrameWindowPrimitive; break; | ||
846 | case PE_FrameFocusRect: fcn = _frameFocusPrimitive; break; | 866 | case PE_FrameFocusRect: fcn = _frameFocusPrimitive; break; | ||
867 | case PE_Widget: fcn = &Style::drawWidgetPrimitive; break; | ||||
847 | 868 | | |||
848 | // fallback | 869 | // fallback | ||
849 | default: break; | 870 | default: break; | ||
850 | 871 | | |||
851 | } | 872 | } | ||
852 | 873 | | |||
853 | painter->save(); | 874 | painter->save(); | ||
854 | 875 | | |||
855 | // call function if implemented | 876 | // call function if implemented | ||
856 | if( !( fcn && fcn( *this, option, painter, widget ) ) ) | 877 | if( !( fcn && fcn( *this, option, painter, widget ) ) ) | ||
857 | { ParentStyleClass::drawPrimitive( element, option, painter, widget ); } | 878 | { ParentStyleClass::drawPrimitive( element, option, painter, widget ); } | ||
858 | 879 | | |||
859 | painter->restore(); | 880 | painter->restore(); | ||
860 | 881 | | |||
861 | } | 882 | } | ||
862 | 883 | | |||
884 | bool Style::drawWidgetPrimitive( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const { | ||||
885 | Q_UNUSED(option) | ||||
886 | auto parent = widget; | ||||
887 | while (parent != nullptr) { | ||||
888 | if (qobject_cast<const QDockWidget*>(parent) || qobject_cast<const QMdiArea*>(parent)) return true; | ||||
889 | parent = parent->parentWidget(); | ||||
890 | } | ||||
891 | if (qobject_cast<const QMainWindow*>(widget) || qobject_cast<const QDialog*> (widget)) { | ||||
892 | if (!_helper->toolsAreaHasContents(widget) && _helper->shouldDrawToolsArea(widget)) { | ||||
893 | painter->save(); | ||||
894 | painter->setPen(_helper->toolsAreaBorderColor(widget)); | ||||
895 | painter->setRenderHints(QPainter::Antialiasing, false); | ||||
896 | painter->setBrush(Qt::NoBrush); | ||||
897 | | ||||
898 | painter->drawLine( | ||||
899 | widget->rect().left()*2, | ||||
900 | widget->rect().top(), | ||||
901 | widget->rect().right()*2, | ||||
902 | widget->rect().top() | ||||
903 | ); | ||||
904 | painter->restore(); | ||||
905 | } else if (_helper->shouldDrawToolsArea(widget)) { | ||||
906 | auto rect = _helper->toolsAreaToolbarsRect(widget); | ||||
907 | | ||||
908 | painter->save(); | ||||
909 | { | ||||
910 | painter->setBrush(_helper->titleBarColor(widget->isActiveWindow())); | ||||
911 | painter->setPen(Qt::NoPen); | ||||
912 | | ||||
913 | painter->drawRect(rect); | ||||
914 | } | ||||
915 | painter->restore(); | ||||
916 | | ||||
917 | painter->save(); | ||||
918 | { | ||||
919 | painter->setPen(_helper->toolsAreaBorderColor(widget)); | ||||
920 | painter->setBrush(Qt::NoBrush); | ||||
921 | painter->setRenderHints(QPainter::Antialiasing, false); | ||||
922 | | ||||
923 | painter->drawLine( | ||||
924 | rect.left()*2, | ||||
925 | rect.bottom(), | ||||
926 | rect.right()*2, | ||||
927 | rect.bottom() | ||||
928 | ); | ||||
929 | } | ||||
930 | painter->restore(); | ||||
931 | } | ||||
932 | } | ||||
933 | return true; | ||||
934 | } | ||||
935 | | ||||
863 | //______________________________________________________________ | 936 | //______________________________________________________________ | ||
864 | void Style::drawControl( ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | 937 | void Style::drawControl( ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||
865 | { | 938 | { | ||
866 | 939 | | |||
867 | StyleControl fcn; | 940 | StyleControl fcn; | ||
868 | 941 | | |||
869 | #if BREEZE_HAVE_KSTYLE | 942 | #if BREEZE_HAVE_KSTYLE | ||
870 | if( element == CE_CapacityBar ) | 943 | if( element == CE_CapacityBar ) | ||
871 | { | 944 | { | ||
872 | fcn = &Style::drawProgressBarControl; | 945 | fcn = &Style::drawProgressBarControl; | ||
873 | 946 | | |||
874 | } else | 947 | } else | ||
875 | #endif | 948 | #endif | ||
876 | 949 | | |||
877 | switch( element ) { | 950 | switch( element ) { | ||
878 | 951 | | |||
879 | case CE_PushButtonBevel: fcn = &Style::drawPanelButtonCommandPrimitive; break; | 952 | case CE_PushButtonBevel: fcn = &Style::drawPanelButtonCommandPrimitive; break; | ||
880 | case CE_PushButtonLabel: fcn = &Style::drawPushButtonLabelControl; break; | 953 | case CE_PushButtonLabel: fcn = &Style::drawPushButtonLabelControl; break; | ||
881 | case CE_CheckBoxLabel: fcn = &Style::drawCheckBoxLabelControl; break; | 954 | case CE_CheckBoxLabel: fcn = &Style::drawCheckBoxLabelControl; break; | ||
882 | case CE_RadioButtonLabel: fcn = &Style::drawCheckBoxLabelControl; break; | 955 | case CE_RadioButtonLabel: fcn = &Style::drawCheckBoxLabelControl; break; | ||
883 | case CE_ToolButtonLabel: fcn = &Style::drawToolButtonLabelControl; break; | 956 | case CE_ToolButtonLabel: fcn = &Style::drawToolButtonLabelControl; break; | ||
884 | case CE_ComboBoxLabel: fcn = &Style::drawComboBoxLabelControl; break; | 957 | case CE_ComboBoxLabel: fcn = &Style::drawComboBoxLabelControl; break; | ||
885 | case CE_MenuBarEmptyArea: fcn = &Style::emptyControl; break; | 958 | case CE_MenuBarEmptyArea: fcn = &Style::drawMenuBarEmptyAreaControl; break; | ||
886 | case CE_MenuBarItem: fcn = &Style::drawMenuBarItemControl; break; | 959 | case CE_MenuBarItem: fcn = &Style::drawMenuBarItemControl; break; | ||
887 | case CE_MenuItem: fcn = &Style::drawMenuItemControl; break; | 960 | case CE_MenuItem: fcn = &Style::drawMenuItemControl; break; | ||
888 | case CE_ToolBar: fcn = &Style::emptyControl; break; | 961 | case CE_ToolBar: fcn = &Style::drawToolBarControl; break; | ||
889 | case CE_ProgressBar: fcn = &Style::drawProgressBarControl; break; | 962 | case CE_ProgressBar: fcn = &Style::drawProgressBarControl; break; | ||
890 | case CE_ProgressBarContents: fcn = &Style::drawProgressBarContentsControl; break; | 963 | case CE_ProgressBarContents: fcn = &Style::drawProgressBarContentsControl; break; | ||
891 | case CE_ProgressBarGroove: fcn = &Style::drawProgressBarGrooveControl; break; | 964 | case CE_ProgressBarGroove: fcn = &Style::drawProgressBarGrooveControl; break; | ||
892 | case CE_ProgressBarLabel: fcn = &Style::drawProgressBarLabelControl; break; | 965 | case CE_ProgressBarLabel: fcn = &Style::drawProgressBarLabelControl; break; | ||
893 | case CE_ScrollBarSlider: fcn = &Style::drawScrollBarSliderControl; break; | 966 | case CE_ScrollBarSlider: fcn = &Style::drawScrollBarSliderControl; break; | ||
894 | case CE_ScrollBarAddLine: fcn = &Style::drawScrollBarAddLineControl; break; | 967 | case CE_ScrollBarAddLine: fcn = &Style::drawScrollBarAddLineControl; break; | ||
895 | case CE_ScrollBarSubLine: fcn = &Style::drawScrollBarSubLineControl; break; | 968 | case CE_ScrollBarSubLine: fcn = &Style::drawScrollBarSubLineControl; break; | ||
896 | case CE_ScrollBarAddPage: fcn = &Style::emptyControl; break; | 969 | case CE_ScrollBarAddPage: fcn = &Style::emptyControl; break; | ||
▲ Show 20 Lines • Show All 429 Lines • ▼ Show 20 Line(s) | |||||
1326 | { | 1399 | { | ||
1327 | 1400 | | |||
1328 | // reload | 1401 | // reload | ||
1329 | StyleConfigData::self()->load(); | 1402 | StyleConfigData::self()->load(); | ||
1330 | 1403 | | |||
1331 | // reload configuration | 1404 | // reload configuration | ||
1332 | loadConfiguration(); | 1405 | loadConfiguration(); | ||
1333 | 1406 | | |||
1407 | // load new titlebar colours into tools area animations | ||||
1408 | _toolsAreaManager->updateAnimations(); | ||||
1409 | | ||||
1410 | // trigger update of tools area | ||||
1411 | emit _toolsAreaManager->toolbarUpdated(); | ||||
1412 | | ||||
1334 | } | 1413 | } | ||
1335 | 1414 | | |||
1336 | //____________________________________________________________________ | 1415 | //____________________________________________________________________ | ||
1337 | QIcon Style::standardIconImplementation( StandardPixmap standardPixmap, const QStyleOption* option, const QWidget* widget ) const | 1416 | QIcon Style::standardIconImplementation( StandardPixmap standardPixmap, const QStyleOption* option, const QWidget* widget ) const | ||
1338 | { | 1417 | { | ||
1339 | 1418 | | |||
1340 | // lookup cache | 1419 | // lookup cache | ||
1341 | if( _iconCache.contains( standardPixmap ) ) return _iconCache.value( standardPixmap ); | 1420 | if( _iconCache.contains( standardPixmap ) ) return _iconCache.value( standardPixmap ); | ||
Show All 34 Lines | |||||
1376 | } | 1455 | } | ||
1377 | 1456 | | |||
1378 | //_____________________________________________________________________ | 1457 | //_____________________________________________________________________ | ||
1379 | void Style::loadConfiguration() | 1458 | void Style::loadConfiguration() | ||
1380 | { | 1459 | { | ||
1381 | 1460 | | |||
1382 | // load helper configuration | 1461 | // load helper configuration | ||
1383 | _helper->loadConfig(); | 1462 | _helper->loadConfig(); | ||
1463 | _helper->setToolsAreaEnabled(StyleConfigData::toolsAreaEnabled() ); | ||||
1384 | 1464 | | |||
1385 | // reinitialize engines | 1465 | // reinitialize engines | ||
1386 | _animations->setupEngines(); | 1466 | _animations->setupEngines(); | ||
1387 | _windowManager->initialize(); | 1467 | _windowManager->initialize(); | ||
1388 | 1468 | | |||
1389 | // mnemonics | 1469 | // mnemonics | ||
1390 | _mnemonics->setMode( StyleConfigData::mnemonicsMode() ); | 1470 | _mnemonics->setMode( StyleConfigData::mnemonicsMode() ); | ||
1391 | 1471 | | |||
▲ Show 20 Lines • Show All 2828 Lines • ▼ Show 20 Line(s) | |||||
4220 | bool Style::drawToolButtonLabelControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | 4300 | bool Style::drawToolButtonLabelControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||
4221 | { | 4301 | { | ||
4222 | 4302 | | |||
4223 | // cast option and check | 4303 | // cast option and check | ||
4224 | const auto toolButtonOption( qstyleoption_cast<const QStyleOptionToolButton*>(option) ); | 4304 | const auto toolButtonOption( qstyleoption_cast<const QStyleOptionToolButton*>(option) ); | ||
4225 | 4305 | | |||
4226 | // copy rect and palette | 4306 | // copy rect and palette | ||
4227 | const auto& rect = option->rect; | 4307 | const auto& rect = option->rect; | ||
4228 | const auto& palette = option->palette; | | |||
4229 | 4308 | | |||
4230 | // state | 4309 | // state | ||
4231 | const State& state( option->state ); | 4310 | const State& state( option->state ); | ||
4232 | const bool enabled( state & State_Enabled ); | 4311 | const bool enabled( state & State_Enabled ); | ||
4233 | const bool sunken( state & (State_On | State_Sunken) ); | 4312 | const bool sunken( state & (State_On | State_Sunken) ); | ||
4234 | const bool mouseOver( enabled && (option->state & State_MouseOver) ); | 4313 | const bool mouseOver( enabled && (option->state & State_MouseOver) ); | ||
4235 | const bool flat( state & State_AutoRaise ); | 4314 | const bool flat( state & State_AutoRaise ); | ||
4236 | 4315 | | |||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | 4401 | } else if( hasIcon && iconRect.isValid() ) { | |||
4324 | // icon state and mode | 4403 | // icon state and mode | ||
4325 | const QIcon::State iconState( sunken ? QIcon::On : QIcon::Off ); | 4404 | const QIcon::State iconState( sunken ? QIcon::On : QIcon::Off ); | ||
4326 | QIcon::Mode iconMode; | 4405 | QIcon::Mode iconMode; | ||
4327 | if( !enabled ) iconMode = QIcon::Disabled; | 4406 | if( !enabled ) iconMode = QIcon::Disabled; | ||
4328 | else if( (!flat && hasFocus) || (flat && (state & State_Sunken) && !mouseOver) ) iconMode = QIcon::Selected; | 4407 | else if( (!flat && hasFocus) || (flat && (state & State_Sunken) && !mouseOver) ) iconMode = QIcon::Selected; | ||
4329 | else if( mouseOver && flat ) iconMode = QIcon::Active; | 4408 | else if( mouseOver && flat ) iconMode = QIcon::Active; | ||
4330 | else iconMode = QIcon::Normal; | 4409 | else iconMode = QIcon::Normal; | ||
4331 | 4410 | | |||
4332 | const QPixmap pixmap = _helper->coloredIcon(toolButtonOption->icon, toolButtonOption->palette, iconSize, iconMode, iconState); | 4411 | QPixmap pixmap = toolButtonOption->icon.pixmap( iconSize, iconMode, iconState ); | ||
4412 | if (_helper->isInToolsArea(widget)) { | ||||
4413 | KIconLoader::global()->setCustomPalette(widget->palette()); | ||||
4414 | pixmap = toolButtonOption->icon.pixmap( iconSize, iconMode, iconState ); | ||||
4415 | KIconLoader::global()->resetPalette(); | ||||
4416 | } | ||||
4333 | drawItemPixmap( painter, iconRect, Qt::AlignCenter, pixmap ); | 4417 | drawItemPixmap( painter, iconRect, Qt::AlignCenter, pixmap ); | ||
4334 | 4418 | | |||
4335 | } | 4419 | } | ||
4336 | 4420 | | |||
4337 | // render text | 4421 | // render text | ||
4338 | if( hasText && textRect.isValid() ) | 4422 | if( hasText && textRect.isValid() ) | ||
4339 | { | 4423 | { | ||
4340 | | ||||
4341 | QPalette::ColorRole textRole( QPalette::ButtonText ); | 4424 | QPalette::ColorRole textRole( QPalette::ButtonText ); | ||
4342 | if( flat ) textRole = ( ((hasFocus&&sunken) || (state & State_Sunken))&&!mouseOver) ? QPalette::HighlightedText: QPalette::WindowText; | 4425 | if( flat ) textRole = ( ((hasFocus&&sunken) || (state & State_Sunken))&&!mouseOver) ? QPalette::HighlightedText: QPalette::WindowText; | ||
4343 | else if( hasFocus&&!mouseOver ) textRole = QPalette::HighlightedText; | 4426 | else if( hasFocus&&!mouseOver ) textRole = QPalette::HighlightedText; | ||
4344 | 4427 | | |||
4428 | auto palette = option->palette; | ||||
4429 | | ||||
4430 | if (_helper->isInToolsArea(widget)) { | ||||
4431 | palette.setColor(QPalette::ButtonText, _helper->titleBarTextColor(widget->isActiveWindow())); | ||||
4432 | palette.setColor(QPalette::WindowText, _helper->titleBarTextColor(widget->isActiveWindow())); | ||||
4433 | } | ||||
4434 | | ||||
4345 | painter->setFont(toolButtonOption->font); | 4435 | painter->setFont(toolButtonOption->font); | ||
4346 | drawItemText( painter, textRect, textFlags, palette, enabled, toolButtonOption->text, textRole ); | 4436 | drawItemText( painter, textRect, textFlags, palette, enabled, toolButtonOption->text, textRole ); | ||
4347 | 4437 | | |||
4348 | } | 4438 | } | ||
4349 | 4439 | | |||
4350 | return true; | 4440 | return true; | ||
4351 | 4441 | | |||
4352 | } | 4442 | } | ||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Line(s) | |||||
4495 | { | 4585 | { | ||
4496 | 4586 | | |||
4497 | // cast option and check | 4587 | // cast option and check | ||
4498 | const auto menuItemOption = qstyleoption_cast<const QStyleOptionMenuItem*>( option ); | 4588 | const auto menuItemOption = qstyleoption_cast<const QStyleOptionMenuItem*>( option ); | ||
4499 | if( !menuItemOption ) return true; | 4589 | if( !menuItemOption ) return true; | ||
4500 | 4590 | | |||
4501 | // copy rect and palette | 4591 | // copy rect and palette | ||
4502 | const auto& rect( option->rect ); | 4592 | const auto& rect( option->rect ); | ||
4503 | const auto& palette( option->palette ); | 4593 | auto palette( option->palette ); | ||
4594 | | ||||
4595 | if (_helper->isInToolsArea(widget)) { | ||||
4596 | palette.setColor(QPalette::WindowText, _helper->titleBarTextColor(widget->isActiveWindow())); | ||||
4597 | } | ||||
4504 | 4598 | | |||
4505 | // store state | 4599 | // store state | ||
4506 | const State& state( option->state ); | 4600 | const State& state( option->state ); | ||
4507 | const bool enabled( state & State_Enabled ); | 4601 | const bool enabled( state & State_Enabled ); | ||
4508 | const bool selected( enabled && (state & State_Selected) ); | 4602 | const bool selected( enabled && (state & State_Selected) ); | ||
4509 | const bool sunken( enabled && (state & State_Sunken) ); | 4603 | const bool sunken( enabled && (state & State_Sunken) ); | ||
4510 | const bool useStrongFocus( StyleConfigData::menuItemDrawStrongFocus() ); | 4604 | const bool useStrongFocus( StyleConfigData::menuItemDrawStrongFocus() ); | ||
4511 | 4605 | | |||
4606 | painter->save(); | ||||
4607 | painter->setRenderHints( QPainter::Antialiasing ); | ||||
4608 | | ||||
4512 | // render hover and focus | 4609 | // render hover and focus | ||
4513 | if( useStrongFocus && ( selected || sunken ) ) | 4610 | if( useStrongFocus && ( selected || sunken ) ) | ||
4514 | { | 4611 | { | ||
4515 | 4612 | | |||
4516 | QColor outlineColor; | 4613 | QColor outlineColor; | ||
4517 | if( sunken ) outlineColor = _helper->focusColor( palette ); | 4614 | if( sunken ) outlineColor = _helper->focusColor( palette ); | ||
4518 | else if( selected ) outlineColor = _helper->hoverColor( palette ); | 4615 | else if( selected ) outlineColor = _helper->hoverColor( palette ); | ||
4519 | _helper->renderFocusRect( painter, rect, outlineColor ); | 4616 | _helper->renderFocusRect( painter, rect, outlineColor ); | ||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 4675 | { | |||
4582 | else if( selected ) outlineColor = _helper->hoverColor( palette ); | 4679 | else if( selected ) outlineColor = _helper->hoverColor( palette ); | ||
4583 | 4680 | | |||
4584 | _helper->renderFocusLine( painter, textRect, outlineColor ); | 4681 | _helper->renderFocusLine( painter, textRect, outlineColor ); | ||
4585 | 4682 | | |||
4586 | } | 4683 | } | ||
4587 | 4684 | | |||
4588 | } | 4685 | } | ||
4589 | 4686 | | |||
4590 | return true; | 4687 | painter->restore(); | ||
4591 | 4688 | | |||
4689 | return true; | ||||
4592 | } | 4690 | } | ||
4593 | 4691 | | |||
4594 | 4692 | | |||
4595 | //___________________________________________________________________________________ | 4693 | //___________________________________________________________________________________ | ||
4596 | bool Style::drawMenuItemControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | 4694 | bool Style::drawMenuItemControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||
4597 | { | 4695 | { | ||
4598 | 4696 | | |||
4599 | // cast option and check | 4697 | // cast option and check | ||
▲ Show 20 Lines • Show All 203 Lines • ▼ Show 20 Line(s) | 4862 | { | |||
4803 | 4901 | | |||
4804 | } | 4902 | } | ||
4805 | 4903 | | |||
4806 | } | 4904 | } | ||
4807 | 4905 | | |||
4808 | return true; | 4906 | return true; | ||
4809 | } | 4907 | } | ||
4810 | 4908 | | |||
4909 | bool Style::drawToolBarControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||||
4910 | { | ||||
4911 | Q_UNUSED(option) | ||||
4912 | Q_UNUSED(painter) | ||||
4913 | auto toolbar = const_cast<QWidget*>(widget); | ||||
4914 | | ||||
4915 | if (!_helper->isInToolsArea(widget)) { | ||||
4916 | if (_toolsAreaManager->widgetHasCorrectPaletteSet(toolbar)) { | ||||
4917 | toolbar->setPalette(toolbar->parentWidget()->palette()); | ||||
4918 | } | ||||
4919 | return true; | ||||
4920 | } | ||||
4921 | | ||||
4922 | if (!_toolsAreaManager->widgetHasCorrectPaletteSet(widget)) { | ||||
4923 | auto palette = toolbar->palette(); | ||||
4924 | palette.setColor( QPalette::Window, _toolsAreaManager->background(widget) ); | ||||
4925 | palette.setColor( QPalette::WindowText, _toolsAreaManager->foreground(widget) ); | ||||
4926 | toolbar->setPalette(palette); | ||||
4927 | } | ||||
4928 | | ||||
4929 | return true; | ||||
4930 | } | ||||
4931 | | ||||
4932 | bool Style::drawMenuBarEmptyAreaControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||||
4933 | { | ||||
4934 | Q_UNUSED(option) | ||||
4935 | if (!_helper->isInToolsArea(widget)) { | ||||
4936 | return true; | ||||
4937 | } | ||||
4938 | | ||||
4939 | painter->save(); | ||||
4940 | painter->restore(); | ||||
4941 | return true; | ||||
4942 | } | ||||
4943 | | ||||
4811 | //___________________________________________________________________________________ | 4944 | //___________________________________________________________________________________ | ||
4812 | bool Style::drawProgressBarControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | 4945 | bool Style::drawProgressBarControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||
4813 | { | 4946 | { | ||
4814 | 4947 | | |||
4815 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | 4948 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | ||
4816 | if( !progressBarOption ) return true; | 4949 | if( !progressBarOption ) return true; | ||
4817 | 4950 | | |||
4818 | // render groove | 4951 | // render groove | ||
▲ Show 20 Lines • Show All 2314 Lines • Show Last 20 Lines |