- Timestamp:
- Oct 3, 2018 12:19:06 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIToolBar.cpp
r74137 r74593 24 24 # include <QMainWindow> 25 25 # include <QResizeEvent> 26 # ifdef VBOX_WS_MAC 27 # include <QPainter> 28 # endif 26 29 27 30 /* GUI includes: */ … … 37 40 : QToolBar(pParent) 38 41 , m_pMainWindow(qobject_cast<QMainWindow*>(pParent)) 42 #ifdef VBOX_WS_MAC 43 , m_fEmulateUnifiedToolbar(false) 44 #endif 39 45 { 40 46 /* Prepare: */ … … 62 68 } 63 69 70 void UIToolBar::emulateMacToolbar() 71 { 72 /* Remember request, to be used in paintEvent: */ 73 m_fEmulateUnifiedToolbar = true; 74 } 75 64 76 void UIToolBar::setShowToolBarButton(bool fShow) 65 77 { … … 71 83 // WORKAROUND: 72 84 // There is a bug in Qt Cocoa which result in showing a "more arrow" when 73 // the necessary size of the tool bar is increased. Also for some languages85 // the necessary size of the tool-bar is increased. Also for some languages 74 86 // the with doesn't match if the text increase. So manually adjust the size 75 87 // after changing the text. … … 92 104 } 93 105 106 #ifdef VBOX_WS_MAC 107 void UIToolBar::paintEvent(QPaintEvent *pEvent) 108 { 109 /* Call to base-class: */ 110 QToolBar::paintEvent(pEvent); 111 112 /* If we have request to emulate unified tool-bar: */ 113 if (m_fEmulateUnifiedToolbar) 114 { 115 /* Acquire rectangle: */ 116 const QRect rectangle = pEvent->rect(); 117 118 /* Prepare gradient: */ 119 const QColor backgroundColor = palette().color(QPalette::Active, QPalette::Mid); 120 QLinearGradient gradient(rectangle.topLeft(), rectangle.bottomLeft()); 121 gradient.setColorAt(0, backgroundColor.lighter(125)); 122 gradient.setColorAt(.65, backgroundColor.lighter(130)); 123 gradient.setColorAt(1, backgroundColor.lighter(135)); 124 125 /* Fill background: */ 126 QPainter painter(this); 127 painter.fillRect(rectangle, gradient); 128 } 129 } 130 #endif /* VBOX_WS_MAC */ 131 94 132 void UIToolBar::prepare() 95 133 { … … 109 147 setContextMenuPolicy(Qt::NoContextMenu); 110 148 } 111 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIToolBar.h
r74137 r74593 27 27 /* Forward declarations: */ 28 28 class QMainWindow; 29 class QResizeEvent; 30 class QWidget; 31 #ifdef VBOX_WS_MAC 32 class QPaintEvent; 33 #endif 29 34 30 /** QToolBar extension 31 * with few settings presets. */ 35 /** QToolBar extension with few settings presets. */ 32 36 class SHARED_LIBRARY_STUFF UIToolBar : public QToolBar 33 37 { … … 48 52 49 53 #ifdef VBOX_WS_MAC 50 /** Mac OS X: Defines whether native tool-bar should be used. */54 /** Mac OS X: Defines whether native tool-bar should be enabled. */ 51 55 void enableMacToolbar(); 56 /** Mac OS X: Defines whether native tool-bar should be emulated. */ 57 void emulateMacToolbar(); 58 52 59 /** Mac OS X: Defines whether native tool-bar button should be shown. */ 53 60 void setShowToolBarButton(bool fShow); 54 61 /** Mac OS X: Updates native tool-bar layout. */ 55 62 void updateLayout(); 56 #endif /* VBOX_WS_MAC */63 #endif 57 64 58 65 protected: … … 60 67 /** Handles resize @a pEvent. */ 61 68 virtual void resizeEvent(QResizeEvent *pEvent) /* override */; 69 70 #ifdef VBOX_WS_MAC 71 /** Handles paint @a pEvent. */ 72 virtual void paintEvent(QPaintEvent *pEvent) /* override */; 73 #endif 62 74 63 75 private: … … 68 80 /** Holds the parent main-window isntance. */ 69 81 QMainWindow *m_pMainWindow; 82 83 #ifdef VBOX_WS_MAC 84 /** Holds whether unified tool-bar should be emulated. */ 85 bool m_fEmulateUnifiedToolbar; 86 #endif 70 87 }; 71 88 72 89 #endif /* !___UIToolBar_h___ */ 73
Note:
See TracChangeset
for help on using the changeset viewer.