Changeset 71521 in vbox
- Timestamp:
- Mar 26, 2018 5:09:08 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.cpp
r70474 r71521 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 19 19 # include <precomp.h> 20 20 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 21 21 22 /* Qt includes: */ 22 # include <QVBoxLayout>23 # include <QScrollArea>24 23 # include <QEvent> 25 24 # include <QMainWindow> 26 25 # include <QMenuBar> 26 # include <QScrollArea> 27 27 # include <QStatusBar> 28 # include <QVBoxLayout> 28 29 29 30 /* GUI includes: */ … … 35 36 36 37 37 UIPopupStack::UIPopupStack(const QString &strID, UIPopupStackOrientation orientation)38 UIPopupStack::UIPopupStack(const QString &strID, UIPopupStackOrientation enmOrientation) 38 39 : m_strID(strID) 39 , m_ orientation(orientation)40 , m_enmOrientation(enmOrientation) 40 41 , m_pScrollArea(0) 41 42 , m_pScrollViewport(0) … … 47 48 } 48 49 49 bool UIPopupStack::exists(const QString &str PopupPaneID) const50 bool UIPopupStack::exists(const QString &strID) const 50 51 { 51 52 /* Redirect question to viewport: */ 52 return m_pScrollViewport->exists(str PopupPaneID);53 } 54 55 void UIPopupStack::createPopupPane(const QString &str PopupPaneID,53 return m_pScrollViewport->exists(strID); 54 } 55 56 void UIPopupStack::createPopupPane(const QString &strID, 56 57 const QString &strMessage, const QString &strDetails, 57 58 const QMap<int, QString> &buttonDescriptions) 58 59 { 59 60 /* Redirect request to viewport: */ 60 m_pScrollViewport->createPopupPane(str PopupPaneID,61 m_pScrollViewport->createPopupPane(strID, 61 62 strMessage, strDetails, 62 63 buttonDescriptions); … … 66 67 } 67 68 68 void UIPopupStack::updatePopupPane(const QString &str PopupPaneID,69 void UIPopupStack::updatePopupPane(const QString &strID, 69 70 const QString &strMessage, const QString &strDetails) 70 71 { 71 72 /* Redirect request to viewport: */ 72 m_pScrollViewport->updatePopupPane(str PopupPaneID,73 m_pScrollViewport->updatePopupPane(strID, 73 74 strMessage, strDetails); 74 75 } 75 76 76 void UIPopupStack::recallPopupPane(const QString &str PopupPaneID)77 void UIPopupStack::recallPopupPane(const QString &strID) 77 78 { 78 79 /* Redirect request to viewport: */ 79 m_pScrollViewport->recallPopupPane(str PopupPaneID);80 } 81 82 void UIPopupStack::setOrientation(UIPopupStackOrientation orientation)80 m_pScrollViewport->recallPopupPane(strID); 81 } 82 83 void UIPopupStack::setOrientation(UIPopupStackOrientation enmOrientation) 83 84 { 84 85 /* Make sure orientation has changed: */ 85 if (m_ orientation == orientation)86 if (m_enmOrientation == enmOrientation) 86 87 return; 87 88 88 89 /* Update orientation: */ 89 m_ orientation = orientation;90 m_enmOrientation = enmOrientation; 90 91 sltAdjustGeometry(); 91 92 } … … 109 110 /* Recalculate parent status-bar height: */ 110 111 m_iParentStatusBarHeight = parentStatusBarHeight(pParent); 112 } 113 114 bool UIPopupStack::eventFilter(QObject *pWatched, QEvent *pEvent) 115 { 116 /* Call to base-class if that is not parent event: */ 117 if (!parent() || pWatched != parent()) 118 return QWidget::eventFilter(pWatched, pEvent); 119 120 /* Handle parent geometry events: */ 121 switch (pEvent->type()) 122 { 123 case QEvent::Resize: 124 { 125 /* Propagate size: */ 126 propagateSize(); 127 /* Adjust geometry: */ 128 sltAdjustGeometry(); 129 break; 130 } 131 case QEvent::Move: 132 { 133 /* Adjust geometry: */ 134 sltAdjustGeometry(); 135 break; 136 } 137 default: 138 break; /* Shuts up MSC. */ 139 } 140 141 /* Call to base-class: */ 142 return QWidget::eventFilter(pWatched, pEvent); 143 } 144 145 void UIPopupStack::showEvent(QShowEvent*) 146 { 147 /* Propagate size: */ 148 propagateSize(); 149 /* Adjust geometry: */ 150 sltAdjustGeometry(); 111 151 } 112 152 … … 149 189 iY += geo.y(); 150 190 } 151 switch (m_ orientation)191 switch (m_enmOrientation) 152 192 { 153 193 case UIPopupStackOrientation_Top: … … 189 229 setAutoFillBackground(false); 190 230 #if defined(VBOX_WS_WIN) || defined (VBOX_WS_MAC) 191 /* Using Qt API to enable translucent background for the Win/Mac host. 192 * - Under x11 host Qt 4.8.3 has it broken wih KDE 4.9 for now: */ 231 /* Using Qt API to enable translucent background for the Win/Mac host: */ 193 232 setAttribute(Qt::WA_TranslucentBackground); 194 #endif /* VBOX_WS_WIN || VBOX_WS_MAC */233 #endif 195 234 196 235 #ifdef VBOX_WS_MAC 197 /* Do not hide popup-stack 198 * and actually the seamless machine-window too 199 * due to Qt bug on window deactivation... */ 236 /* Do not hide popup-stack: */ 200 237 setAttribute(Qt::WA_MacAlwaysShowToolWindow); 201 #endif /* VBOX_WS_MAC */238 #endif 202 239 203 240 /* Prepare content: */ … … 249 286 } 250 287 251 bool UIPopupStack::eventFilter(QObject *pWatched, QEvent *pEvent)252 {253 /* Call to base-class if that is not parent event: */254 if (!parent() || pWatched != parent())255 return QWidget::eventFilter(pWatched, pEvent);256 257 /* Handle parent geometry events: */258 switch (pEvent->type())259 {260 case QEvent::Resize:261 {262 /* Propagate size: */263 propagateSize();264 /* Adjust geometry: */265 sltAdjustGeometry();266 break;267 }268 case QEvent::Move:269 {270 /* Adjust geometry: */271 sltAdjustGeometry();272 break;273 }274 default: break; /* Shuts up MSC. */275 }276 277 /* Call to base-class: */278 return QWidget::eventFilter(pWatched, pEvent);279 }280 281 void UIPopupStack::showEvent(QShowEvent*)282 {283 /* Propagate size: */284 propagateSize();285 /* Adjust geometry: */286 sltAdjustGeometry();287 }288 289 288 void UIPopupStack::propagateSize() 290 289 { -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.h
r69500 r71521 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ UIPopupStack_h__19 #define __ UIPopupStack_h__18 #ifndef ___UIPopupStack_h___ 19 #define ___UIPopupStack_h___ 20 20 21 21 /* Qt includes: */ … … 27 27 28 28 /* Forward declaration: */ 29 class QEvent; 30 class QObject; 31 class QScrollArea; 32 class QShowEvent; 33 class QSize; 34 class QString; 29 35 class QVBoxLayout; 30 class QScrollArea;31 36 class UIPopupStackViewport; 32 37 33 /* Popup-stack prototype class:*/38 /** QWidget extension providing GUI with popup-stack prototype class. */ 34 39 class UIPopupStack : public QWidget 35 40 { … … 38 43 signals: 39 44 40 /* Notifier: Layout stuff:*/45 /** Notifies about popup-stack viewport size change. */ 41 46 void sigProposeStackViewportSize(QSize newSize); 42 47 43 /* Notifier: Popup-pane stuff:*/44 void sigPopupPaneDone(QString str PopupPaneID, int iResultCode);48 /** Asks to close popup-pane with @a strID and @a iResultCode. */ 49 void sigPopupPaneDone(QString strID, int iResultCode); 45 50 46 /* Notifier: Popup-stack stuff:*/51 /** Asks to close popup-stack with @a strID. */ 47 52 void sigRemove(QString strID); 48 53 49 54 public: 50 55 51 /* Constructor:*/52 UIPopupStack(const QString &strID, UIPopupStackOrientation orientation);56 /** Constructs popup-stack with passed @a strID and @a enmOrientation. */ 57 UIPopupStack(const QString &strID, UIPopupStackOrientation enmOrientation); 53 58 54 /* API: Popup-pane stuff: */ 55 bool exists(const QString &strPopupPaneID) const; 56 void createPopupPane(const QString &strPopupPaneID, 59 /** Returns whether pane with passed @a strID exists. */ 60 bool exists(const QString &strID) const; 61 /** Creates pane with passed @a strID, @a strMessage, @a strDetails and @a buttonDescriptions. */ 62 void createPopupPane(const QString &strID, 57 63 const QString &strMessage, const QString &strDetails, 58 64 const QMap<int, QString> &buttonDescriptions); 59 void updatePopupPane(const QString &strPopupPaneID, 65 /** Updates pane with passed @a strID, @a strMessage and @a strDetails. */ 66 void updatePopupPane(const QString &strID, 60 67 const QString &strMessage, const QString &strDetails); 61 void recallPopupPane(const QString &strPopupPaneID); 62 void setOrientation(UIPopupStackOrientation orientation); 68 /** Recalls pane with passed @a strID. */ 69 void recallPopupPane(const QString &strID); 70 /** Defines stack @a enmOrientation. */ 71 void setOrientation(UIPopupStackOrientation enmOrientation); 63 72 64 /* API: Parent stuff:*/73 /** Defines stack @a pParent*/ 65 74 void setParent(QWidget *pParent); 66 void setParent(QWidget *pParent, Qt::WindowFlags flags); 75 /** Defines stack @a pParent and @a enmFlags. */ 76 void setParent(QWidget *pParent, Qt::WindowFlags enmFlags); 77 78 protected: 79 80 /** Pre-handles standard Qt @a pEvent for passed @a pObject. */ 81 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */; 82 83 /** Handles show @a pEvent. */ 84 virtual void showEvent(QShowEvent *pEvent) /* override */; 67 85 68 86 private slots: 69 87 70 /* Handler: Layout stuff:*/88 /** Adjusts geometry. */ 71 89 void sltAdjustGeometry(); 72 90 73 /* Handlers: Popup-pane stuff: */ 74 void sltPopupPaneRemoved(QString strPopupPaneID); 91 /** Handles removal of the popup-pane with @a strID. */ 92 void sltPopupPaneRemoved(QString strID); 93 /** Handles removal of all the popup-panes. */ 75 94 void sltPopupPanesRemoved(); 76 95 77 96 private: 78 97 79 /* Helpers: Prepare stuff:*/98 /** Prepares all. */ 80 99 void prepare(); 100 /** Prepares contents. */ 81 101 void prepareContent(); 82 102 83 /* Handler: Event-filter stuff: */ 84 bool eventFilter(QObject *pWatched, QEvent *pEvent); 85 86 /* Handler: Event stuff: */ 87 void showEvent(QShowEvent *pEvent); 88 89 /* Helper: Layout stuff: */ 103 /** Propagates size. */ 90 104 void propagateSize(); 91 105 92 /* Static helpers: Prepare stuff:*/106 /** Returns @a pParent menu-bar height. */ 93 107 static int parentMenuBarHeight(QWidget *pParent); 108 /** Returns @a pParent status-bar height. */ 94 109 static int parentStatusBarHeight(QWidget *pParent); 95 110 96 /* Variable: General stuff: */ 97 QString m_strID; 98 UIPopupStackOrientation m_orientation; 111 /** Holds the stack ID. */ 112 QString m_strID; 113 /** Holds the stack orientation. */ 114 UIPopupStackOrientation m_enmOrientation; 99 115 100 /* Variables: Widget stuff: */ 101 QVBoxLayout *m_pMainLayout; 102 QScrollArea *m_pScrollArea; 116 /** Holds the main-layout instance. */ 117 QVBoxLayout *m_pMainLayout; 118 /** Holds the scroll-area instance. */ 119 QScrollArea *m_pScrollArea; 120 /** Holds the scroll-viewport instance. */ 103 121 UIPopupStackViewport *m_pScrollViewport; 104 122 105 /* Variables: Layout stuff:*/123 /** Holds the parent menu-bar height. */ 106 124 int m_iParentMenuBarHeight; 125 /** Holds the parent status-bar height. */ 107 126 int m_iParentStatusBarHeight; 108 127 }; 109 128 110 #endif /* __UIPopupStack_h__ */ 129 #endif /* !___UIPopupStack_h___ */ 130 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStackViewport.cpp
r69500 r71521 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 19 19 # include <precomp.h> 20 20 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 21 21 22 /* GUI includes: */ 23 # include "UIPopupPane.h" 22 24 # include "UIPopupStackViewport.h" 23 # include "UIPopupPane.h"24 25 25 26 /* Other VBox includes: */ … … 35 36 } 36 37 37 bool UIPopupStackViewport::exists(const QString &str PopupPaneID) const38 bool UIPopupStackViewport::exists(const QString &strID) const 38 39 { 39 40 /* Is there already popup-pane with the same ID? */ 40 return m_panes.contains(str PopupPaneID);41 } 42 43 void UIPopupStackViewport::createPopupPane(const QString &str PopupPaneID,41 return m_panes.contains(strID); 42 } 43 44 void UIPopupStackViewport::createPopupPane(const QString &strID, 44 45 const QString &strMessage, const QString &strDetails, 45 46 const QMap<int, QString> &buttonDescriptions) 46 47 { 47 48 /* Make sure there is no such popup-pane already: */ 48 if (m_panes.contains(str PopupPaneID))49 if (m_panes.contains(strID)) 49 50 { 50 51 AssertMsgFailed(("Popup-pane already exists!")); … … 53 54 54 55 /* Create new popup-pane: */ 55 UIPopupPane *pPopupPane = m_panes[str PopupPaneID] = new UIPopupPane(this,56 UIPopupPane *pPopupPane = m_panes[strID] = new UIPopupPane(this, 56 57 strMessage, strDetails, 57 58 buttonDescriptions); … … 66 67 } 67 68 68 void UIPopupStackViewport::updatePopupPane(const QString &str PopupPaneID,69 void UIPopupStackViewport::updatePopupPane(const QString &strID, 69 70 const QString &strMessage, const QString &strDetails) 70 71 { 71 72 /* Make sure there is such popup-pane already: */ 72 if (!m_panes.contains(str PopupPaneID))73 if (!m_panes.contains(strID)) 73 74 { 74 75 AssertMsgFailed(("Popup-pane doesn't exists!")); … … 77 78 78 79 /* Get existing popup-pane: */ 79 UIPopupPane *pPopupPane = m_panes[str PopupPaneID];80 UIPopupPane *pPopupPane = m_panes[strID]; 80 81 81 82 /* Update message and details: */ … … 84 85 } 85 86 86 void UIPopupStackViewport::recallPopupPane(const QString &str PopupPaneID)87 void UIPopupStackViewport::recallPopupPane(const QString &strID) 87 88 { 88 89 /* Make sure there is such popup-pane already: */ 89 if (!m_panes.contains(str PopupPaneID))90 if (!m_panes.contains(strID)) 90 91 { 91 92 AssertMsgFailed(("Popup-pane doesn't exists!")); … … 94 95 95 96 /* Get existing popup-pane: */ 96 UIPopupPane *pPopupPane = m_panes[str PopupPaneID];97 UIPopupPane *pPopupPane = m_panes[strID]; 97 98 98 99 /* Recall popup-pane: */ … … 133 134 134 135 /* Make sure the popup-pane still exists: */ 135 const QString str PopupPaneID(m_panes.key(pPopupPane, QString()));136 if (str PopupPaneID.isNull())136 const QString strID(m_panes.key(pPopupPane, QString())); 137 if (strID.isNull()) 137 138 { 138 139 AssertMsgFailed(("Popup-pane already destroyed!")); … … 141 142 142 143 /* Notify listeners about popup-pane removal: */ 143 emit sigPopupPaneDone(str PopupPaneID, iResultCode);144 emit sigPopupPaneDone(strID, iResultCode); 144 145 145 146 /* Delete popup-pane asyncronously. 146 147 * To avoid issues with events which already posted: */ 147 m_panes.remove(str PopupPaneID);148 m_panes.remove(strID); 148 149 pPopupPane->deleteLater(); 149 150 150 151 /* Notify listeners about popup-pane removed: */ 151 emit sigPopupPaneRemoved(str PopupPaneID);152 emit sigPopupPaneRemoved(strID); 152 153 153 154 /* Adjust geometry: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStackViewport.h
r69500 r71521 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ UIPopupStackViewport_h__19 #define __ UIPopupStackViewport_h__18 #ifndef ___UIPopupStackViewport_h___ 19 #define ___UIPopupStackViewport_h___ 20 20 21 21 /* Qt includes: */ … … 24 24 25 25 /* Forward declaration: */ 26 class QSize; 27 class QString; 26 28 class UIPopupPane; 27 29 28 /* Popup-stack viewport prototype class:*/30 /** QWidget extension providing GUI with popup-stack viewport prototype class. */ 29 31 class UIPopupStackViewport : public QWidget 30 32 { … … 33 35 signals: 34 36 35 /* Notifiers: Layout stuff:*/37 /** Notifies about popup-pane size change. */ 36 38 void sigProposePopupPaneSize(QSize newSize); 39 40 /** Notifies about size-hint change. */ 37 41 void sigSizeHintChanged(); 38 42 39 /* Notifiers: Popup-pane stuff: */ 40 void sigPopupPaneDone(QString strPopupPaneID, int iResultCode); 41 void sigPopupPaneRemoved(QString strPopupPaneID); 43 /** Asks to close popup-pane with @a strID and @a iResultCode. */ 44 void sigPopupPaneDone(QString strID, int iResultCode); 45 /** Notifies about popup-pane with @a strID was removed. */ 46 void sigPopupPaneRemoved(QString strID); 47 /** Notifies about popup-panes were removed. */ 42 48 void sigPopupPanesRemoved(); 43 49 44 50 public: 45 51 46 /* Constructor:*/52 /** Constructs popup-stack viewport. */ 47 53 UIPopupStackViewport(); 48 54 49 /* API: Popup-pane stuff: */ 50 bool exists(const QString &strPopupPaneID) const; 51 void createPopupPane(const QString &strPopupPaneID, 55 /** Returns whether pane with passed @a strID exists. */ 56 bool exists(const QString &strID) const; 57 /** Creates pane with passed @a strID, @a strMessage, @a strDetails and @a buttonDescriptions. */ 58 void createPopupPane(const QString &strID, 52 59 const QString &strMessage, const QString &strDetails, 53 60 const QMap<int, QString> &buttonDescriptions); 54 void updatePopupPane(const QString &strPopupPaneID, 61 /** Updates pane with passed @a strID, @a strMessage and @a strDetails. */ 62 void updatePopupPane(const QString &strID, 55 63 const QString &strMessage, const QString &strDetails); 56 void recallPopupPane(const QString &strPopupPaneID); 64 /** Recalls pane with passed @a strID. */ 65 void recallPopupPane(const QString &strID); 57 66 58 /* API: Layout stuff:*/67 /** Returns minimum size-hint. */ 59 68 QSize minimumSizeHint() const { return m_minimumSizeHint; } 60 69 61 70 public slots: 62 71 63 /* Handler: Layout stuff:*/72 /** Handle proposal for @a newSize. */ 64 73 void sltHandleProposalForSize(QSize newSize); 65 74 66 75 private slots: 67 76 68 /* Handler: Layout stuff:*/77 /** Adjusts geometry. */ 69 78 void sltAdjustGeometry(); 70 79 71 /* Handler: Popup-pane stuff:*/80 /** Handles reuqest to dismiss popup-pane with @a iButtonCode. */ 72 81 void sltPopupPaneDone(int iButtonCode); 73 82 74 83 private: 75 84 76 /* Helpers: Layout stuff:*/85 /** Updates size-hint. */ 77 86 void updateSizeHint(); 87 /** Lays the content out. */ 78 88 void layoutContent(); 79 89 80 /* Variables: Layout stuff:*/90 /** Holds the layout margin. */ 81 91 const int m_iLayoutMargin; 92 /** Holds the layout spacing. */ 82 93 const int m_iLayoutSpacing; 94 95 /** Holds the minimum size-hint. */ 83 96 QSize m_minimumSizeHint; 84 97 85 /* Variables: Children stuff:*/98 /** Holds the popup-pane instances. */ 86 99 QMap<QString, UIPopupPane*> m_panes; 87 100 }; 88 101 89 #endif /* __UIPopupStackViewport_h__ */ 102 #endif /* !___UIPopupStackViewport_h___ */ 103
Note:
See TracChangeset
for help on using the changeset viewer.