- Timestamp:
- Apr 25, 2018 5:47:28 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 1 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r72026 r72027 465 465 src/runtime/UIMultiScreenLayout.h \ 466 466 src/runtime/UISession.h \ 467 src/runtime/UISlidingToolBar.h \468 467 src/runtime/UIVMCloseDialog.h \ 469 468 src/runtime/fullscreen/UIKeyboardHandlerFullscreen.h \ … … 686 685 src/widgets/UIPortForwardingTable.h \ 687 686 src/widgets/UIProgressDialog.h \ 687 src/widgets/UISlidingToolBar.h \ 688 688 src/widgets/UISpecialControls.h \ 689 689 src/widgets/UIStatusBarEditorWindow.h \ … … 795 795 src/widgets/UIPortForwardingTable.h \ 796 796 src/widgets/UIProgressDialog.h \ 797 src/widgets/UISlidingToolBar.h \ 797 798 src/widgets/UISpecialControls.h \ 798 799 src/widgets/UIStatusBarEditorWindow.h \ … … 975 976 src/runtime/UIMultiScreenLayout.cpp \ 976 977 src/runtime/UISession.cpp \ 977 src/runtime/UISlidingToolBar.cpp \978 978 src/runtime/UIVMCloseDialog.cpp \ 979 979 src/runtime/fullscreen/UIKeyboardHandlerFullscreen.cpp \ … … 1235 1235 src/widgets/UIPortForwardingTable.cpp \ 1236 1236 src/widgets/UIProgressDialog.cpp \ 1237 src/widgets/UISlidingToolBar.cpp \ 1237 1238 src/widgets/UISpecialControls.cpp \ 1238 1239 src/widgets/UIStatusBarEditorWindow.cpp \ … … 1370 1371 src/widgets/UIPortForwardingTable.cpp \ 1371 1372 src/widgets/UIProgressDialog.cpp \ 1373 src/widgets/UISlidingToolBar.cpp \ 1372 1374 src/widgets/UISpecialControls.cpp \ 1373 1375 src/widgets/UIStatusBarEditorWindow.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UISlidingToolBar.cpp
r72026 r72027 5 5 6 6 /* 7 * Copyright (C) 2014-201 7Oracle Corporation7 * Copyright (C) 2014-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 35 35 36 36 37 UISlidingToolBar::UISlidingToolBar(QWidget *pParentWidget, QWidget *pIndentWidget, QWidget *pChildWidget, Position position)37 UISlidingToolBar::UISlidingToolBar(QWidget *pParentWidget, QWidget *pIndentWidget, QWidget *pChildWidget, Position enmPosition) 38 38 : QWidget(pParentWidget, Qt::Tool | Qt::FramelessWindowHint) 39 , m_ position(position)39 , m_enmPosition(enmPosition) 40 40 , m_parentRect(pParentWidget ? pParentWidget->geometry() : QRect()) 41 41 , m_indentRect(pIndentWidget ? pIndentWidget->geometry() : QRect()) … … 50 50 } 51 51 52 #ifdef VBOX_WS_MAC 53 bool UISlidingToolBar::event(QEvent *pEvent) 54 { 55 /* Depending on event-type: */ 56 switch (pEvent->type()) 57 { 58 case QEvent::Resize: 59 case QEvent::WindowActivate: 60 { 61 // WORKAROUND: 62 // By some strange reason 63 // cocoa resets NSWindow::setHasShadow option 64 // for frameless windows on every window resize/activation. 65 // So we have to make sure window still has no shadows. 66 darwinSetWindowHasShadow(this, false); 67 break; 68 } 69 default: 70 break; 71 } 72 /* Call to base-class: */ 73 return QWidget::event(pEvent); 74 } 75 #endif /* VBOX_WS_MAC */ 76 77 void UISlidingToolBar::showEvent(QShowEvent *) 78 { 79 /* If window isn't expanded: */ 80 if (!m_fExpanded) 81 { 82 /* Start expand animation: */ 83 emit sigShown(); 84 } 85 } 86 87 void UISlidingToolBar::closeEvent(QCloseEvent *pEvent) 88 { 89 /* If window isn't expanded: */ 90 if (!m_fExpanded) 91 { 92 /* Ignore close-event: */ 93 pEvent->ignore(); 94 return; 95 } 96 97 /* If animation state is Final: */ 98 const QString strAnimationState = property("AnimationState").toString(); 99 bool fAnimationComplete = strAnimationState == "Final"; 100 if (fAnimationComplete) 101 { 102 /* Ignore close-event: */ 103 pEvent->ignore(); 104 /* And start collapse animation: */ 105 emit sigCollapse(); 106 } 107 } 108 52 109 void UISlidingToolBar::sltParentGeometryChanged(const QRect &parentRect) 53 110 { … … 62 119 void UISlidingToolBar::prepare() 63 120 { 64 /* Do not count that window as important for application, 65 * it will NOT be taken into account when other top-level windows will be closed: */ 121 /* Tell the application we are not that important: */ 66 122 setAttribute(Qt::WA_QuitOnClose, false); 67 123 /* Delete window when closed: */ … … 94 150 /* Create main-layout: */ 95 151 m_pMainLayout = new QHBoxLayout(this); 96 AssertPtrReturnVoid(m_pMainLayout);152 if (m_pMainLayout) 97 153 { 98 154 /* Configure main-layout: */ … … 101 157 /* Create area: */ 102 158 m_pArea = new QWidget; 103 AssertPtrReturnVoid(m_pArea);159 if (m_pArea) 104 160 { 105 161 /* Configure area: */ … … 110 166 m_pArea->setPalette(pal1); 111 167 /* Make sure valid child-widget passed: */ 112 AssertPtrReturnVoid(m_pWidget);168 if (m_pWidget) 113 169 { 114 170 /* Configure child-widget: */ … … 131 187 * But move sub-window to initial position: */ 132 188 const QSize sh = m_pWidget->sizeHint(); 133 switch (m_ position)189 switch (m_enmPosition) 134 190 { 135 191 case Position_Top: … … 155 211 setMask(m_pWidget->geometry()); 156 212 } 157 #endif /* VBOX_WS_X11 */213 #endif 158 214 159 215 #ifdef VBOX_WS_WIN 160 216 /* Raise tool-window for proper z-order. */ 161 217 raise(); 162 #endif /* VBOX_WS_WIN */218 #endif 163 219 164 220 /* Activate window after it was shown: */ … … 188 244 /* Adjust geometry based on parent and sub-window size-hints: */ 189 245 const QSize sh = m_pWidget->sizeHint(); 190 switch (m_ position)246 switch (m_enmPosition) 191 247 { 192 248 case Position_Top: … … 212 268 setMask(m_pWidget->geometry()); 213 269 } 214 #endif /* VBOX_WS_X11 */270 #endif 215 271 216 272 #ifdef VBOX_WS_WIN 217 273 /* Raise tool-window for proper z-order. */ 218 274 raise(); 219 #endif /* VBOX_WS_WIN */275 #endif 220 276 } 221 277 … … 228 284 /* Recalculate sub-window geometry animation boundaries based on size-hint: */ 229 285 const QSize sh = m_pWidget->sizeHint(); 230 switch (m_ position)286 switch (m_enmPosition) 231 287 { 232 288 case Position_Top: m_startWidgetGeometry = QRect(0, -sh.height(), qMax(width(), sh.width()), sh.height()); break; … … 237 293 } 238 294 239 void UISlidingToolBar::showEvent(QShowEvent*)240 {241 /* If window isn't expanded: */242 if (!m_fExpanded)243 {244 /* Start expand animation: */245 emit sigShown();246 }247 }248 249 void UISlidingToolBar::closeEvent(QCloseEvent *pEvent)250 {251 /* If window isn't expanded: */252 if (!m_fExpanded)253 {254 /* Ignore close-event: */255 pEvent->ignore();256 return;257 }258 259 /* If animation state is Final: */260 const QString strAnimationState = property("AnimationState").toString();261 bool fAnimationComplete = strAnimationState == "Final";262 if (fAnimationComplete)263 {264 /* Ignore close-event: */265 pEvent->ignore();266 /* And start collapse animation: */267 emit sigCollapse();268 }269 }270 271 #ifdef VBOX_WS_MAC272 bool UISlidingToolBar::event(QEvent *pEvent)273 {274 /* Depending on event-type: */275 switch (pEvent->type())276 {277 case QEvent::Resize:278 case QEvent::WindowActivate:279 {280 /* By some strange reason281 * cocoa resets NSWindow::setHasShadow option282 * for frameless windows on every window resize/activation.283 * So we have to make sure window still has no shadows. */284 darwinSetWindowHasShadow(this, false);285 break;286 }287 default:288 break;289 }290 /* Call to base-class: */291 return QWidget::event(pEvent);292 }293 #endif /* VBOX_WS_MAC */294 295 295 void UISlidingToolBar::setWidgetGeometry(const QRect &rect) 296 296 { … … 304 304 setMask(m_pWidget->geometry()); 305 305 } 306 #endif /* VBOX_WS_X11 */306 #endif 307 307 } 308 308 … … 312 312 return m_pWidget->geometry(); 313 313 } 314 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UISlidingToolBar.h
r72026 r72027 5 5 6 6 /* 7 * Copyright (C) 2014-201 7Oracle Corporation7 * Copyright (C) 2014-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 22 22 #include <QWidget> 23 23 24 /* GUI includes: */ 25 #include "UILibraryDefs.h" 26 24 27 /* Forward declarations: */ 28 class QCloseEvent; 29 class QEvent; 25 30 class QHBoxLayout; 31 class QRect; 32 class QShowEvent; 33 class QWidget; 26 34 class UIAnimation; 27 35 28 /** QWidget reimplementation36 /** QWidget subclass 29 37 * providing GUI with slideable tool-bar. */ 30 class UISlidingToolBar : public QWidget38 class SHARED_LIBRARY_STUFF UISlidingToolBar : public QWidget 31 39 { 32 40 Q_OBJECT; … … 53 61 }; 54 62 55 /** Constructor, passes @a pParentWidget to the QWidget constructor. 56 * @param pParentWidget is used to get parent-widget geoemtry, 57 * @param pIndentWidget is used to get indent-widget geometry, 58 * @param pChildWidget brings child-widget to be injected into tool-bar. */ 59 UISlidingToolBar(QWidget *pParentWidget, QWidget *pIndentWidget, QWidget *pChildWidget, Position position); 63 /** Constructs sliding tool-bar passing @a pParentWidget to the base-class. 64 * @param pParentWidget Brings the parent-widget geometry. 65 * @param pIndentWidget Brings the indent-widget geometry. 66 * @param pChildWidget Brings the child-widget to be injected into tool-bar. 67 * @param enmPosition Brings the tool-bar position. */ 68 UISlidingToolBar(QWidget *pParentWidget, QWidget *pIndentWidget, QWidget *pChildWidget, Position enmPosition); 69 70 protected: 71 72 #ifdef VBOX_WS_MAC 73 /** Handles any Qt @a pEvent. */ 74 virtual bool event(QEvent *pEvent) /* override */; 75 #endif 76 /** Handles show @a pEvent. */ 77 virtual void showEvent(QShowEvent *pEvent) /* override */; 78 /** Handles close @a pEvent. */ 79 virtual void closeEvent(QCloseEvent *pEvent) /* override */; 60 80 61 81 private slots: … … 74 94 private: 75 95 76 /** Prepare routine. */96 /** Prepares all. */ 77 97 void prepare(); 78 /** Prepare contents routine. */98 /** Prepares contents. */ 79 99 void prepareContents(); 80 /** Prepare geometry routine. */100 /** Prepares geometry. */ 81 101 void prepareGeometry(); 82 /** Prepare animation routine. */102 /** Prepares animation. */ 83 103 void prepareAnimation(); 84 104 85 /** Update geometry. */105 /** Updates geometry. */ 86 106 void adjustGeometry(); 87 107 /** Updates animation. */ 88 108 void updateAnimation(); 89 90 /** Show event handler. */91 virtual void showEvent(QShowEvent *pEvent);92 /** Close event handler. */93 virtual void closeEvent(QCloseEvent *pEvent);94 #ifdef VBOX_WS_MAC95 /** Common event handler. */96 virtual bool event(QEvent *pEvent);97 #endif /* VBOX_WS_MAC */98 109 99 110 /** Defines sub-window geometry. */ … … 109 120 * @{ */ 110 121 /** Holds the tool-bar position. */ 111 const Position m_position;122 const Position m_enmPosition; 112 123 /** Holds the cached parent-widget geometry. */ 113 QRect m_parentRect;124 QRect m_parentRect; 114 125 /** Holds the cached indent-widget geometry. */ 115 QRect m_indentRect;126 QRect m_indentRect; 116 127 /** @} */ 117 128 … … 121 132 UIAnimation *m_pAnimation; 122 133 /** Holds whether window is expanded. */ 123 bool m_fExpanded;134 bool m_fExpanded; 124 135 /** Holds sub-window start-geometry. */ 125 QRect m_startWidgetGeometry;136 QRect m_startWidgetGeometry; 126 137 /** Holds sub-window final-geometry. */ 127 QRect m_finalWidgetGeometry;138 QRect m_finalWidgetGeometry; 128 139 /** @} */ 129 140 … … 133 144 QHBoxLayout *m_pMainLayout; 134 145 /** Holds the area instance. */ 135 QWidget *m_pArea;146 QWidget *m_pArea; 136 147 /** Holds the child-widget reference. */ 137 QWidget *m_pWidget;148 QWidget *m_pWidget; 138 149 /** @} */ 139 150 };
Note:
See TracChangeset
for help on using the changeset viewer.