- Timestamp:
- Oct 15, 2021 9:25:35 AM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationCenter.cpp
r91501 r91753 128 128 { 129 129 AssertReturnVoid(!s_pInstance); 130 new UINotificationCenter(pParent);130 s_pInstance = new UINotificationCenter(pParent); 131 131 } 132 132 … … 136 136 AssertPtrReturnVoid(s_pInstance); 137 137 delete s_pInstance; 138 s_pInstance = 0; 138 139 } 139 140 … … 142 143 { 143 144 return s_pInstance; 144 }145 146 void UINotificationCenter::setParent(QWidget *pParent)147 {148 /* Additionally hide if parent unset: */149 if (!pParent)150 setHidden(true);151 152 /* Uninstall filter from previous parent: */153 if (parent())154 parent()->removeEventFilter(this);155 156 /* Reparent: */157 QIWithRetranslateUI<QWidget>::setParent(pParent);158 159 /* Install filter to new parent: */160 if (parent())161 parent()->installEventFilter(this);162 163 /* Show only if there is something to show: */164 if (parent())165 setHidden(m_pModel->ids().isEmpty());166 }167 168 void UINotificationCenter::invoke()169 {170 /* Open if center isn't opened yet: */171 if (!m_pOpenButton->isChecked())172 m_pOpenButton->animateClick();173 }174 175 QUuid UINotificationCenter::append(UINotificationObject *pObject)176 {177 /* Sanity check: */178 AssertPtrReturn(m_pModel, QUuid());179 AssertPtrReturn(pObject, QUuid());180 181 /* Is object critical? */182 const bool fCritical = pObject->isCritical();183 /* Is object progress? */184 const bool fProgress = pObject->inherits("UINotificationProgress");185 186 /* Handle object. Be aware it can be deleted during handling! */187 const QUuid uId = m_pModel->appendObject(pObject);188 189 /* If object is critical and center isn't opened yet: */190 if (!m_pOpenButton->isChecked() && fCritical)191 {192 /* We should delay progresses for a bit: */193 const int iDelay = fProgress ? 2000 : 0;194 /* We should issue an open request: */195 AssertPtrReturn(m_pTimerOpen, uId);196 m_uOpenObjectId = uId;197 m_pTimerOpen->start(iDelay);198 }199 200 return uId;201 }202 203 void UINotificationCenter::revoke(const QUuid &uId)204 {205 AssertReturnVoid(!uId.isNull());206 return m_pModel->revokeObject(uId);207 145 } 208 146 … … 219 157 , m_pTimerOpen(0) 220 158 { 221 s_pInstance = this;222 159 prepare(); 223 160 } … … 225 162 UINotificationCenter::~UINotificationCenter() 226 163 { 227 s_pInstance = 0; 164 } 165 166 void UINotificationCenter::setParent(QWidget *pParent) 167 { 168 /* Additionally hide if parent unset: */ 169 if (!pParent) 170 setHidden(true); 171 172 /* Uninstall filter from previous parent: */ 173 if (parent()) 174 parent()->removeEventFilter(this); 175 176 /* Reparent: */ 177 QIWithRetranslateUI<QWidget>::setParent(pParent); 178 179 /* Install filter to new parent: */ 180 if (parent()) 181 parent()->installEventFilter(this); 182 183 /* Show only if there is something to show: */ 184 if (parent()) 185 setHidden(m_pModel->ids().isEmpty()); 186 } 187 188 void UINotificationCenter::invoke() 189 { 190 /* Open if center isn't opened yet: */ 191 if (!m_pOpenButton->isChecked()) 192 m_pOpenButton->animateClick(); 193 } 194 195 QUuid UINotificationCenter::append(UINotificationObject *pObject) 196 { 197 /* Sanity check: */ 198 AssertPtrReturn(m_pModel, QUuid()); 199 AssertPtrReturn(pObject, QUuid()); 200 201 /* Is object critical? */ 202 const bool fCritical = pObject->isCritical(); 203 /* Is object progress? */ 204 const bool fProgress = pObject->inherits("UINotificationProgress"); 205 206 /* Handle object. Be aware it can be deleted during handling! */ 207 const QUuid uId = m_pModel->appendObject(pObject); 208 209 /* If object is critical and center isn't opened yet: */ 210 if (!m_pOpenButton->isChecked() && fCritical) 211 { 212 /* We should delay progresses for a bit: */ 213 const int iDelay = fProgress ? 2000 : 0; 214 /* We should issue an open request: */ 215 AssertPtrReturn(m_pTimerOpen, uId); 216 m_uOpenObjectId = uId; 217 m_pTimerOpen->start(iDelay); 218 } 219 220 return uId; 221 } 222 223 void UINotificationCenter::revoke(const QUuid &uId) 224 { 225 AssertReturnVoid(!uId.isNull()); 226 return m_pModel->revokeObject(uId); 228 227 } 229 228 -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationCenter.h
r91236 r91753 63 63 static UINotificationCenter *instance(); 64 64 65 /** Constructs notification-center passing @a pParent to the base-class. */ 66 UINotificationCenter(QWidget *pParent); 67 /** Destructs notification-center. */ 68 virtual ~UINotificationCenter() /* override final */; 69 65 70 /** Defines notification-center @a pParent. */ 66 71 void setParent(QWidget *pParent); … … 75 80 76 81 protected: 77 78 /** Constructs notification-center passing @a pParent to the base-class. */79 UINotificationCenter(QWidget *pParent);80 /** Destructs notification-center. */81 virtual ~UINotificationCenter() /* override final */;82 82 83 83 /** Handles translation event. */
Note:
See TracChangeset
for help on using the changeset viewer.