- Timestamp:
- Aug 2, 2021 5:18:43 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r90358 r90484 1023 1023 src/medium/viso/UIVisoHostBrowser.cpp \ 1024 1024 src/medium/viso/UIVisoBrowserBase.cpp \ 1025 src/notificationcenter/UINotificationCenter.cpp \ 1025 1026 src/settings/editors/UIBaseMemoryEditor.cpp \ 1026 1027 src/settings/editors/UIBootOrderEditor.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationCenter.cpp
r90464 r90484 40 40 41 41 42 /** QScrollArea extension to make notification scroll-area more versatile. */ 43 class UINotificationScrollArea : public QScrollArea 44 { 45 Q_OBJECT; 46 47 public: 48 49 /** Creates notification scroll-area passing @a pParent to the base-class. */ 50 UINotificationScrollArea(QWidget *pParent = 0); 51 52 /** Returns minimum size-hint. */ 53 virtual QSize minimumSizeHint() const /* override final */; 54 55 /** Assigns scrollable @a pWidget. 56 * @note Keep in mind that's an override, but NOT a virtual method. */ 57 void setWidget(QWidget *pWidget); 58 59 protected: 60 61 /** Preprocesses @a pEvent for registered @a pWatched object. */ 62 virtual bool eventFilter(QObject *pWatched, QEvent *pEvent) /* override final */; 63 }; 64 65 66 /********************************************************************************************************************************* 67 * Class UINotificationScrollArea implementation. * 68 *********************************************************************************************************************************/ 69 70 UINotificationScrollArea::UINotificationScrollArea(QWidget *pParent /* = 0 */) 71 : QScrollArea(pParent) 72 { 73 setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); 74 } 75 76 QSize UINotificationScrollArea::minimumSizeHint() const 77 { 78 /* So, here is the logic, 79 * we are taking width from widget if it's present, 80 * while keeping height calculated by the base-class. */ 81 const QSize msh = QScrollArea::minimumSizeHint(); 82 return widget() ? QSize(widget()->minimumSizeHint().width(), msh.height()) : msh; 83 } 84 85 void UINotificationScrollArea::setWidget(QWidget *pWidget) 86 { 87 /* We'd like to listen for a new widget's events: */ 88 if (widget()) 89 widget()->removeEventFilter(this); 90 pWidget->installEventFilter(this); 91 92 /* Call to base-class: */ 93 QScrollArea::setWidget(pWidget); 94 } 95 96 bool UINotificationScrollArea::eventFilter(QObject *pWatched, QEvent *pEvent) 97 { 98 /* For listened widget: */ 99 if (pWatched == widget()) 100 { 101 switch (pEvent->type()) 102 { 103 /* We'd like to handle layout-request events: */ 104 case QEvent::LayoutRequest: 105 updateGeometry(); 106 break; 107 default: 108 break; 109 } 110 } 111 112 /* Call to base-class: */ 113 return QScrollArea::eventFilter(pWatched, pEvent); 114 } 115 116 117 /********************************************************************************************************************************* 118 * Class UINotificationCenter implementation. * 119 *********************************************************************************************************************************/ 120 42 121 /* static */ 43 122 UINotificationCenter *UINotificationCenter::s_pInstance = 0; … … 127 206 switch (pEvent->type()) 128 207 { 208 /* When we are being asked to update layout 209 * we want to adjust overlay accordingly. */ 210 case QEvent::LayoutRequest: 211 { 212 adjustGeometry(); 213 break; 214 } 129 215 /* When we are being resized or moved we want 130 216 * to adjust transparency mask accordingly. */ … … 233 319 234 320 /* Create items scroll-area: */ 235 QScrollArea *pScrollAreaItems = new QScrollArea(this);321 UINotificationScrollArea *pScrollAreaItems = new UINotificationScrollArea(this); 236 322 if (pScrollAreaItems) 237 323 { … … 446 532 setMask(region); 447 533 } 534 535 536 #include "UINotificationCenter.moc"
Note:
See TracChangeset
for help on using the changeset viewer.