Changeset 90606 in vbox
- Timestamp:
- Aug 10, 2021 4:07:13 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 146217
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/networking/UIUpdateManager.cpp
r90604 r90606 26 26 #include "UIMessageCenter.h" 27 27 #include "UIModalWindowManager.h" 28 #include "UINewVersionChecker.h"29 28 #include "UINotificationCenter.h" 30 29 #include "UIUpdateDefs.h" … … 46 45 * @param fForcedCall Brings whether this customer has forced privelegies. */ 47 46 UIUpdateStepVirtualBox(bool fForcedCall); 48 /** Destructs extension step. */49 virtual ~UIUpdateStepVirtualBox() /* override final */;50 47 51 48 /** Executes the step. */ … … 54 51 private: 55 52 56 /** Holds the new version checker instance. */57 UINewVersionChecker *m_pNewVersionChecker;53 /** Holds whether this customer has forced privelegies. */ 54 bool m_fForcedCall; 58 55 }; 59 56 … … 89 86 90 87 UIUpdateStepVirtualBox::UIUpdateStepVirtualBox(bool fForcedCall) 91 : m_pNewVersionChecker(0) 92 { 93 m_pNewVersionChecker = new UINewVersionChecker(fForcedCall); 94 if (m_pNewVersionChecker) 95 { 96 connect(m_pNewVersionChecker, &UINewVersionChecker::sigProgressFailed, 97 this, &UIUpdateStepVirtualBox::sigStepFinished); 98 connect(m_pNewVersionChecker, &UINewVersionChecker::sigProgressCanceled, 99 this, &UIUpdateStepVirtualBox::sigStepFinished); 100 connect(m_pNewVersionChecker, &UINewVersionChecker::sigProgressFinished, 101 this, &UIUpdateStepVirtualBox::sigStepFinished); 102 } 103 } 104 105 UIUpdateStepVirtualBox::~UIUpdateStepVirtualBox() 106 { 107 delete m_pNewVersionChecker; 108 m_pNewVersionChecker = 0; 88 : m_fForcedCall(fForcedCall) 89 { 109 90 } 110 91 111 92 void UIUpdateStepVirtualBox::exec() 112 93 { 113 m_pNewVersionChecker->start(); 94 /* Return if already checking: */ 95 if (UINotificationNewVersionCheckerVirtualBox::exists()) 96 { 97 // @todo show notification-center 98 emit sigStepFinished(); 99 return; 100 } 101 102 /* Check for new VirtualBox version: */ 103 UINotificationNewVersionCheckerVirtualBox *pNotification = 104 UINotificationNewVersionCheckerVirtualBox::instance(m_fForcedCall); 105 /* Handle any signal as step-finished: */ 106 connect(pNotification, &UINotificationNewVersionCheckerVirtualBox::sigProgressFailed, 107 this, &UIUpdateStepVirtualBox::sigStepFinished); 108 connect(pNotification, &UINotificationNewVersionCheckerVirtualBox::sigProgressCanceled, 109 this, &UIUpdateStepVirtualBox::sigStepFinished); 110 connect(pNotification, &UINotificationNewVersionCheckerVirtualBox::sigProgressFinished, 111 this, &UIUpdateStepVirtualBox::sigStepFinished); 112 /* Append and start notification: */ 113 gpNotificationCenter->append(pNotification); 114 114 } 115 115 -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObject.cpp
r90600 r90606 21 21 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 22 22 # include "UIDownloader.h" 23 # include "UINewVersionChecker.h" 23 24 #endif 24 25 … … 194 195 } 195 196 197 198 /********************************************************************************************************************************* 199 * Class UINotificationNewVersionChecker implementation. * 200 *********************************************************************************************************************************/ 201 202 UINotificationNewVersionChecker::UINotificationNewVersionChecker() 203 : m_pChecker(0) 204 { 205 } 206 207 UINotificationNewVersionChecker::~UINotificationNewVersionChecker() 208 { 209 delete m_pChecker; 210 m_pChecker = 0; 211 } 212 213 QString UINotificationNewVersionChecker::error() const 214 { 215 return m_strError; 216 } 217 218 bool UINotificationNewVersionChecker::isCritical() const 219 { 220 return m_pChecker ? m_pChecker->isItForcedCall() : true; 221 } 222 223 void UINotificationNewVersionChecker::handle() 224 { 225 /* Prepare new-version-checker: */ 226 m_pChecker = createChecker(); 227 if (m_pChecker) 228 { 229 connect(m_pChecker, &UINewVersionChecker::sigProgressFailed, 230 this, &UINotificationNewVersionChecker::sltHandleProgressFailed); 231 connect(m_pChecker, &UINewVersionChecker::sigProgressCanceled, 232 this, &UINotificationNewVersionChecker::sltHandleProgressCanceled); 233 connect(m_pChecker, &UINewVersionChecker::sigProgressFinished, 234 this, &UINotificationNewVersionChecker::sltHandleProgressFinished); 235 236 /* And start it finally: */ 237 m_pChecker->start(); 238 } 239 } 240 241 void UINotificationNewVersionChecker::close() 242 { 243 /* Cancel new-version-checker: */ 244 if (m_pChecker) 245 m_pChecker->cancel(); 246 /* Call to base-class: */ 247 UINotificationObject::close(); 248 } 249 250 void UINotificationNewVersionChecker::sltHandleProgressFailed(const QString &strError) 251 { 252 delete m_pChecker; 253 m_pChecker = 0; 254 m_strError = strError; 255 emit sigProgressFailed(); 256 } 257 258 void UINotificationNewVersionChecker::sltHandleProgressCanceled() 259 { 260 delete m_pChecker; 261 m_pChecker = 0; 262 emit sigProgressCanceled(); 263 } 264 265 void UINotificationNewVersionChecker::sltHandleProgressFinished() 266 { 267 delete m_pChecker; 268 m_pChecker = 0; 269 emit sigProgressFinished(); 270 } 271 196 272 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObject.h
r90600 r90606 36 36 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 37 37 class UIDownloader; 38 class UINewVersionChecker; 38 39 #endif 39 40 … … 194 195 QString m_strError; 195 196 }; 197 198 /** UINotificationObject extension for notification-new-version-checker. */ 199 class SHARED_LIBRARY_STUFF UINotificationNewVersionChecker : public UINotificationObject 200 { 201 Q_OBJECT; 202 203 signals: 204 205 /** Notifies listeners about progress failed. */ 206 void sigProgressFailed(); 207 /** Notifies listeners about progress canceled. */ 208 void sigProgressCanceled(); 209 /** Notifies listeners about progress finished. */ 210 void sigProgressFinished(); 211 212 public: 213 214 /** Constructs notification-new-version-checker. */ 215 UINotificationNewVersionChecker(); 216 /** Destructs notification-new-version-checker. */ 217 virtual ~UINotificationNewVersionChecker() /* override final */; 218 219 /** Creates and returns started checker-wrapper. */ 220 virtual UINewVersionChecker *createChecker() = 0; 221 222 /** Returns error-message if any. */ 223 QString error() const; 224 225 /** Returns whether object is critical. */ 226 virtual bool isCritical() const; 227 /** Handles notification-object being added. */ 228 virtual void handle() /* override final */; 229 230 public slots: 231 232 /** Stops the checker and notifies model about closing. */ 233 virtual void close() /* override final */; 234 235 private slots: 236 237 /** Handles signal about progress failed. 238 * @param strError Brings error message if any. */ 239 void sltHandleProgressFailed(const QString &strError); 240 /** Handles signal about progress failed. */ 241 void sltHandleProgressCanceled(); 242 /** Handles signal about progress failed. */ 243 void sltHandleProgressFinished(); 244 245 private: 246 247 /** Holds the instance of checker being wrapped by this notification-new-version-checker. */ 248 UINewVersionChecker *m_pChecker; 249 250 /** Holds the error message is any. */ 251 QString m_strError; 252 }; 196 253 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 197 254 -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjectItem.cpp
r90601 r90606 372 372 } 373 373 374 375 /********************************************************************************************************************************* 376 * Class UINotificationNewVersionCheckerItem implementation. * 377 *********************************************************************************************************************************/ 378 379 UINotificationNewVersionCheckerItem::UINotificationNewVersionCheckerItem(QWidget *pParent, UINotificationNewVersionChecker *pChecker /* = 0 */) 380 : UINotificationObjectItem(pParent, pChecker) 381 , m_pProgressBar(0) 382 { 383 /* Main layout was prepared in base-class: */ 384 if (m_pLayoutMain) 385 { 386 /* Name label was prepared in base-class: */ 387 if (m_pLabelName) 388 m_pLabelName->setText(checker()->name()); 389 /* Details label was prepared in base-class: */ 390 if (m_pLabelDetails) 391 { 392 int iHint = m_pLabelName->minimumSizeHint().width() 393 + m_pLayoutUpper->spacing() 394 + m_pButtonClose->minimumSizeHint().width(); 395 m_pLabelDetails->setMinimumTextWidth(iHint); 396 updateDetails(); 397 } 398 399 /* Prepare check-box: */ 400 m_pProgressBar = new QProgressBar(this); 401 if (m_pProgressBar) 402 { 403 m_pProgressBar->setMaximum(0); 404 m_pLayoutMain->addWidget(m_pProgressBar); 405 } 406 } 407 408 /* Prepare checker connections: */ 409 connect(checker(), &UINotificationNewVersionChecker::sigProgressFailed, 410 this, &UINotificationNewVersionCheckerItem::sltHandleProgressNotFinished); 411 connect(checker(), &UINotificationNewVersionChecker::sigProgressCanceled, 412 this, &UINotificationNewVersionCheckerItem::sltHandleProgressNotFinished); 413 connect(checker(), &UINotificationNewVersionChecker::sigProgressFinished, 414 this, &UINotificationNewVersionCheckerItem::sltHandleProgressFinished); 415 } 416 417 void UINotificationNewVersionCheckerItem::sltHandleProgressNotFinished() 418 { 419 /* Finalize progress-bar state: */ 420 if (m_pProgressBar) 421 m_pProgressBar->hide(); 422 /* Update details with error text if any: */ 423 if (m_pLabelDetails) 424 updateDetails(); 425 } 426 427 void UINotificationNewVersionCheckerItem::sltHandleProgressFinished() 428 { 429 /* Finalize progress-bar state: */ 430 if (m_pProgressBar) 431 { 432 m_pProgressBar->setMaximum(1); 433 m_pProgressBar->setValue(1); 434 } 435 /* Update details with error text if any: */ 436 if (m_pLabelDetails) 437 updateDetails(); 438 } 439 440 UINotificationNewVersionChecker *UINotificationNewVersionCheckerItem::checker() const 441 { 442 return qobject_cast<UINotificationNewVersionChecker*>(m_pObject); 443 } 444 445 void UINotificationNewVersionCheckerItem::updateDetails() 446 { 447 AssertPtrReturnVoid(m_pLabelDetails); 448 const QString strDetails = checker()->details(); 449 const QString strError = checker()->error(); 450 const QString strFullDetails = strError.isNull() 451 ? strDetails 452 : QString("%1<br>%2").arg(strDetails, strError); 453 m_pLabelDetails->setText(strFullDetails); 454 if (!strError.isEmpty()) 455 { 456 m_fToggled = true; 457 m_pLabelDetails->setVisible(m_fToggled); 458 } 459 } 460 374 461 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 375 462 … … 387 474 else if (pObject->inherits("UINotificationDownloader")) 388 475 return new UINotificationDownloaderItem(pParent, static_cast<UINotificationDownloader*>(pObject)); 476 else if (pObject->inherits("UINotificationNewVersionChecker")) 477 return new UINotificationNewVersionCheckerItem(pParent, static_cast<UINotificationNewVersionChecker*>(pObject)); 389 478 #endif 390 479 /* Handle defaults: */ -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjectItem.h
r90601 r90606 36 36 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 37 37 class UINotificationDownloader; 38 class UINotificationNewVersionChecker; 38 39 #endif 39 40 … … 143 144 QProgressBar *m_pProgressBar; 144 145 }; 146 147 /** UINotificationObjectItem extension for notification-new-version-checker. */ 148 class UINotificationNewVersionCheckerItem : public UINotificationObjectItem 149 { 150 Q_OBJECT; 151 152 public: 153 154 /** Constructs notification-new-version-checker item, passing @a pParent to the base-class. 155 * @param pChecker Brings the notification-new-version-checker this item created for. */ 156 UINotificationNewVersionCheckerItem(QWidget *pParent, UINotificationNewVersionChecker *pChecker = 0); 157 158 private slots: 159 160 /** Handles signal about progress NOT finished. */ 161 void sltHandleProgressNotFinished(); 162 /** Handles signal about progress finished. */ 163 void sltHandleProgressFinished(); 164 165 private: 166 167 /** Holds the notification-new-version-checker this item created for. */ 168 UINotificationNewVersionChecker *checker() const; 169 170 /** Updates details. */ 171 void updateDetails(); 172 173 /** Holds the progress-bar instance. */ 174 QProgressBar *m_pProgressBar; 175 }; 145 176 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 146 177 -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r90592 r90606 27 27 # include "UIDownloaderGuestAdditions.h" 28 28 # include "UIDownloaderUserManual.h" 29 # include "UINewVersionChecker.h" 29 30 #endif 30 31 … … 1662 1663 } 1663 1664 1665 1666 /********************************************************************************************************************************* 1667 * Class UINotificationNewVersionCheckerVirtualBox implementation. * 1668 *********************************************************************************************************************************/ 1669 1670 /* static */ 1671 UINotificationNewVersionCheckerVirtualBox *UINotificationNewVersionCheckerVirtualBox::s_pInstance = 0; 1672 1673 /* static */ 1674 UINotificationNewVersionCheckerVirtualBox *UINotificationNewVersionCheckerVirtualBox::instance(bool fForcedCall) 1675 { 1676 if (!s_pInstance) 1677 new UINotificationNewVersionCheckerVirtualBox(fForcedCall); 1678 return s_pInstance; 1679 } 1680 1681 /* static */ 1682 bool UINotificationNewVersionCheckerVirtualBox::exists() 1683 { 1684 return !!s_pInstance; 1685 } 1686 1687 UINotificationNewVersionCheckerVirtualBox::UINotificationNewVersionCheckerVirtualBox(bool fForcedCall) 1688 : m_fForcedCall(fForcedCall) 1689 { 1690 s_pInstance = this; 1691 } 1692 1693 UINotificationNewVersionCheckerVirtualBox::~UINotificationNewVersionCheckerVirtualBox() 1694 { 1695 s_pInstance = 0; 1696 } 1697 1698 QString UINotificationNewVersionCheckerVirtualBox::name() const 1699 { 1700 return UINotificationDownloader::tr("Check for New Version ..."); 1701 } 1702 1703 QString UINotificationNewVersionCheckerVirtualBox::details() const 1704 { 1705 return UINotificationProgress::tr("<b>Link:</b> %1").arg(m_strUrl); 1706 } 1707 1708 UINewVersionChecker *UINotificationNewVersionCheckerVirtualBox::createChecker() 1709 { 1710 /* Create and configure the new VirtualBox version checker: */ 1711 UINewVersionChecker *pChecker = new UINewVersionChecker(m_fForcedCall); 1712 if (pChecker) 1713 { 1714 m_strUrl = pChecker->url().toString(); 1715 return pChecker; 1716 } 1717 return 0; 1718 } 1719 1664 1720 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r90605 r90606 1257 1257 QString m_strFileName; 1258 1258 }; 1259 1260 /** UINotificationNewVersionChecker extension for VirtualBox new version check functionality. */ 1261 class SHARED_LIBRARY_STUFF UINotificationNewVersionCheckerVirtualBox : public UINotificationNewVersionChecker 1262 { 1263 Q_OBJECT; 1264 1265 public: 1266 1267 /** Returns singleton instance, creates if necessary. 1268 * @param fForcedCall Brings whether this customer has forced privelegies. */ 1269 static UINotificationNewVersionCheckerVirtualBox *instance(bool fForcedCall); 1270 /** Returns whether singleton instance already created. */ 1271 static bool exists(); 1272 1273 /** Destructs VirtualBox notification-new-version-checker. 1274 * @note Notification-center can destroy us at any time. */ 1275 virtual ~UINotificationNewVersionCheckerVirtualBox() /* override final */; 1276 1277 protected: 1278 1279 /** Constructs VirtualBox notification-new-version-checker. 1280 * @param fForcedCall Brings whether this customer has forced privelegies. */ 1281 UINotificationNewVersionCheckerVirtualBox(bool fForcedCall); 1282 1283 /** Returns object name. */ 1284 virtual QString name() const /* override final */; 1285 /** Returns object details. */ 1286 virtual QString details() const /* override final */; 1287 /** Creates and returns started new-version-checker. */ 1288 virtual UINewVersionChecker *createChecker() /* override final */; 1289 1290 private: 1291 1292 /** Holds the singleton instance. */ 1293 static UINotificationNewVersionCheckerVirtualBox *s_pInstance; 1294 1295 /** Holds whether this customer has forced privelegies. */ 1296 bool m_fForcedCall; 1297 1298 /** Holds the url. */ 1299 QString m_strUrl; 1300 }; 1259 1301 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 1260 1302
Note:
See TracChangeset
for help on using the changeset viewer.