Changeset 90352 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jul 27, 2021 11:08:28 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensionpackmanager/UIExtensionPackManager.cpp
r87354 r90352 24 24 25 25 /* GUI includes: */ 26 //#include "QIDialogButtonBox.h"27 //#include "QIInputDialog.h"28 //#include "QIMessageBox.h"29 26 #include "QIFileDialog.h" 30 27 #include "QIToolBar.h" … … 36 33 #include "UIIconPool.h" 37 34 #include "UIMessageCenter.h" 38 //#include "UIVirtualBoxEventHandler.h"35 #include "UINotificationCenter.h" 39 36 40 37 /* COM includes: */ … … 232 229 /* Install the chosen package: */ 233 230 if (!strFilePath.isEmpty()) 234 { 235 QString strExtensionPackName; 236 uiCommon().doExtPackInstallation(strFilePath, QString(), this, &strExtensionPackName); 237 238 /* Since we might be reinstalling an existing package, we have to 239 * do a little refreshing regardless of what the user chose. */ 240 if (!strExtensionPackName.isNull()) 241 { 242 /* Remove it from the tree: */ 243 for (int i = 0; i < m_pTreeWidget->topLevelItemCount(); ++i) 244 { 245 UIItemExtensionPack *pItem = qobject_cast<UIItemExtensionPack*>(m_pTreeWidget->childItem(i)); 246 if (!strExtensionPackName.compare(pItem->name(), Qt::CaseInsensitive)) 247 { 248 delete pItem; 249 break; 250 } 251 } 252 253 /* [Re]insert it into the tree: */ 254 CExtPackManager comManager = uiCommon().virtualBox().GetExtensionPackManager(); 255 const CExtPack &comExtensionPack = comManager.Find(strExtensionPackName); 256 if (comExtensionPack.isOk()) 257 { 258 /* Load extension pack data: */ 259 UIDataExtensionPack extensionPackData; 260 loadExtensionPack(comExtensionPack, extensionPackData); 261 createItemForExtensionPack(extensionPackData, true /* choose item? */); 262 } 263 } 264 } 231 uiCommon().doExtPackInstallation(strFilePath, QString(), this, NULL); 265 232 } 266 233 … … 299 266 #endif 300 267 301 /* Uninstall extension pack finally: */ 302 CProgress comProgress = comEPManager.Uninstall(strSelectedPackageName, false /* forced removal? */, displayInfo); 303 304 /* Show error message if necessary: */ 305 if (!comEPManager.isOk() || comProgress.isNull()) 306 msgCenter().cannotUninstallExtPack(comEPManager, strSelectedPackageName, this); 307 else 308 { 309 /* Show uninstallation progress: */ 310 msgCenter().showModalProgressDialog(comProgress, tr("Extensions"), ":/progress_install_guest_additions_90px.png", this); 311 312 /* Show error message if necessary: */ 313 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 314 msgCenter().cannotUninstallExtPack(comProgress, strSelectedPackageName, this); 315 else 316 { 317 /* Remove package from tree: */ 318 delete pItem; 319 320 /* Adjust tree-widget: */ 321 sltAdjustTreeWidget(); 322 } 323 } 268 /* Uninstall extension pack: */ 269 UINotificationProgressExtensionPackUninstall *pNotification = 270 new UINotificationProgressExtensionPackUninstall(comEPManager, 271 strSelectedPackageName, 272 displayInfo); 273 connect(pNotification, &UINotificationProgressExtensionPackUninstall::sigExtensionPackUninstalled, 274 this, &UIExtensionPackManagerWidget::sltHandleExtensionPackUninstalled); 275 notificationCenter().append(pNotification); 324 276 } 325 277 } … … 375 327 } 376 328 329 void UIExtensionPackManagerWidget::sltHandleExtensionPackInstalled(const QString &strName) 330 { 331 /* Make sure the name was set: */ 332 if (strName.isNull()) 333 return; 334 335 /* Look for a list of items matching strName: */ 336 const QList<QTreeWidgetItem*> items = m_pTreeWidget->findItems(strName, Qt::MatchCaseSensitive, ExtensionPackColumn_Name); 337 /* Remove first found item from the list if present: */ 338 if (!items.isEmpty()) 339 delete items.first(); 340 341 /* [Re]insert it into the tree: */ 342 CExtPackManager comManager = uiCommon().virtualBox().GetExtensionPackManager(); 343 const CExtPack comExtensionPack = comManager.Find(strName); 344 if (comExtensionPack.isOk()) 345 { 346 /* Load extension pack data: */ 347 UIDataExtensionPack extensionPackData; 348 loadExtensionPack(comExtensionPack, extensionPackData); 349 createItemForExtensionPack(extensionPackData, true /* choose item? */); 350 } 351 } 352 353 void UIExtensionPackManagerWidget::sltHandleExtensionPackUninstalled(const QString &strName) 354 { 355 /* Make sure the name was set: */ 356 if (strName.isNull()) 357 return; 358 359 /* Look for a list of items matching strName: */ 360 const QList<QTreeWidgetItem*> items = m_pTreeWidget->findItems(strName, Qt::MatchCaseSensitive, ExtensionPackColumn_Name); 361 AssertReturnVoid(!items.isEmpty()); 362 /* Remove first found item from the list: */ 363 delete items.first(); 364 365 /* Adjust tree-widget: */ 366 sltAdjustTreeWidget(); 367 } 368 377 369 void UIExtensionPackManagerWidget::prepare() 378 370 { 379 371 /* Prepare self: */ 380 372 uiCommon().setHelpKeyword(this, "extensionsdetails"); /// @todo use proper help tag 373 connect(&uiCommon(), &UICommon::sigExtensionPackInstalled, 374 this, &UIExtensionPackManagerWidget::sltHandleExtensionPackInstalled); 381 375 382 376 /* Prepare stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/extensionpackmanager/UIExtensionPackManager.h
r87354 r90352 83 83 /** Handles context-menu request for tree-widget @a position. */ 84 84 void sltHandleContextMenuRequest(const QPoint &position); 85 86 /** Handles signal about extension pack @a strName installed. */ 87 void sltHandleExtensionPackInstalled(const QString &strName); 88 /** Handles signal about extension pack @a strName uninstalled. */ 89 void sltHandleExtensionPackUninstalled(const QString &strName); 85 90 /** @} */ 86 91 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r90326 r90352 62 62 #include "UIFDCreationDialog.h" 63 63 #include "UIIconPool.h" 64 #include "UINotificationCenter.h" 64 65 #include "UIThreadPool.h" 65 66 #include "UIShortcutPool.h" … … 3779 3780 } 3780 3781 3781 /* static */3782 3782 void UICommon::doExtPackInstallation(QString const &strFilePath, QString const &strDigest, 3783 3783 QWidget *pParent, QString *pstrExtPackName) const 3784 3784 { 3785 3785 /* If the extension pack manager isn't available, skip any attempts to install: */ … … 3846 3846 strDisplayInfo.sprintf("hwnd=%#llx", (uint64_t)(uintptr_t)pParent->winId()); 3847 3847 #endif 3848 /* Prepare installation progress: */ 3849 CProgress comProgress = comExtPackFile.Install(fReplaceIt, strDisplayInfo); 3850 if (comExtPackFile.isOk()) 3851 { 3852 /* Show installation progress: */ 3853 /** @todo move this tr into UIUpdateManager context */ 3854 msgCenter().showModalProgressDialog(comProgress, QApplication::translate("UIExtensionPackManagerWidget", 3855 "Extensions"), 3856 ":/progress_install_guest_additions_90px.png", pParent); 3857 if (!comProgress.GetCanceled()) 3858 { 3859 if (comProgress.isOk() && comProgress.GetResultCode() == 0) 3860 msgCenter().warnAboutExtPackInstalled(strPackName, pParent); 3861 else 3862 msgCenter().cannotInstallExtPack(comProgress, strFilePath, pParent); 3863 } 3864 } 3865 else 3866 msgCenter().cannotInstallExtPack(comExtPackFile, strFilePath, pParent); 3867 3848 3849 /* Install extension pack: */ 3850 UINotificationProgressExtensionPackInstall *pNotification = 3851 new UINotificationProgressExtensionPackInstall(comExtPackFile, 3852 fReplaceIt, 3853 strPackName, 3854 strDisplayInfo); 3855 connect(pNotification, &UINotificationProgressExtensionPackInstall::sigExtensionPackInstalled, 3856 this, &UICommon::sigExtensionPackInstalled); 3857 notificationCenter().append(pNotification); 3858 3859 /* Store the name: */ 3868 3860 if (pstrExtPackName) 3869 3861 *pstrExtPackName = strPackName; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h
r90326 r90352 85 85 /** Asks listeners to detach COM. */ 86 86 void sigAskToDetachCOM(); 87 /** @} */ 88 89 /** @name COM: Extension Pack stuff. 90 * @{ */ 91 /** Notifies listeners about extension pack @a strName was installed. */ 92 void sigExtensionPackInstalled(const QString &strName); 87 93 /** @} */ 88 94 -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r90344 r90352 354 354 return comProgress; 355 355 } 356 357 358 /********************************************************************************************************************************* 359 * Class UINotificationProgressExtensionPackInstall implementation. * 360 *********************************************************************************************************************************/ 361 362 UINotificationProgressExtensionPackInstall::UINotificationProgressExtensionPackInstall(const CExtPackFile &comExtPackFile, 363 bool fReplace, 364 const QString &strExtensionPackName, 365 const QString &strDisplayInfo) 366 : m_comExtPackFile(comExtPackFile) 367 , m_fReplace(fReplace) 368 , m_strExtensionPackName(strExtensionPackName) 369 , m_strDisplayInfo(strDisplayInfo) 370 { 371 connect(this, &UINotificationProgress::sigProgressFinished, 372 this, &UINotificationProgressExtensionPackInstall::sltHandleProgressFinished); 373 } 374 375 QString UINotificationProgressExtensionPackInstall::name() const 376 { 377 return UINotificationProgress::tr("Installing package ..."); 378 } 379 380 QString UINotificationProgressExtensionPackInstall::details() const 381 { 382 return UINotificationProgress::tr("<b>Name:</b> %1").arg(m_strExtensionPackName); 383 } 384 385 CProgress UINotificationProgressExtensionPackInstall::createProgress(COMResult &comResult) 386 { 387 /* Initialize progress-wrapper: */ 388 CProgress comProgress = m_comExtPackFile.Install(m_fReplace, m_strDisplayInfo); 389 /* Store COM result: */ 390 comResult = m_comExtPackFile; 391 /* Return progress-wrapper: */ 392 return comProgress; 393 } 394 395 void UINotificationProgressExtensionPackInstall::sltHandleProgressFinished() 396 { 397 if (error().isEmpty()) 398 emit sigExtensionPackInstalled(m_strExtensionPackName); 399 } 400 401 402 /********************************************************************************************************************************* 403 * Class UINotificationProgressExtensionPackUninstall implementation. * 404 *********************************************************************************************************************************/ 405 406 UINotificationProgressExtensionPackUninstall::UINotificationProgressExtensionPackUninstall(const CExtPackManager &comExtPackManager, 407 const QString &strExtensionPackName, 408 const QString &strDisplayInfo) 409 : m_comExtPackManager(comExtPackManager) 410 , m_strExtensionPackName(strExtensionPackName) 411 , m_strDisplayInfo(strDisplayInfo) 412 { 413 connect(this, &UINotificationProgress::sigProgressFinished, 414 this, &UINotificationProgressExtensionPackUninstall::sltHandleProgressFinished); 415 } 416 417 QString UINotificationProgressExtensionPackUninstall::name() const 418 { 419 return UINotificationProgress::tr("Uninstalling package ..."); 420 } 421 422 QString UINotificationProgressExtensionPackUninstall::details() const 423 { 424 return UINotificationProgress::tr("<b>Name:</b> %1").arg(m_strExtensionPackName); 425 } 426 427 CProgress UINotificationProgressExtensionPackUninstall::createProgress(COMResult &comResult) 428 { 429 /* Initialize progress-wrapper: */ 430 CProgress comProgress = m_comExtPackManager.Uninstall(m_strExtensionPackName, 431 false /* forced removal? */, 432 m_strDisplayInfo); 433 /* Store COM result: */ 434 comResult = m_comExtPackManager; 435 /* Return progress-wrapper: */ 436 return comProgress; 437 } 438 439 void UINotificationProgressExtensionPackUninstall::sltHandleProgressFinished() 440 { 441 if (error().isEmpty()) 442 emit sigExtensionPackUninstalled(m_strExtensionPackName); 443 } -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r90344 r90352 30 30 #include "CCloudClient.h" 31 31 #include "CCloudMachine.h" 32 #include "CExtPackFile.h" 33 #include "CExtPackManager.h" 32 34 #include "CMachine.h" 33 35 #include "CMedium.h" … … 386 388 }; 387 389 390 /** UINotificationProgress extension for extension pack install functionality. */ 391 class SHARED_LIBRARY_STUFF UINotificationProgressExtensionPackInstall : public UINotificationProgress 392 { 393 Q_OBJECT; 394 395 signals: 396 397 /** Notifies listeners about extension pack installed. 398 * @param strExtensionPackName Brigns extension pack name. */ 399 void sigExtensionPackInstalled(const QString &strExtensionPackName); 400 401 public: 402 403 /** Constructs extension pack install notification-progress. 404 * @param comExtPackFile Brings the extension pack file to install. 405 * @param fReplace Brings whether extension pack should be replaced. 406 * @param strExtensionPackName Brings the extension pack name. 407 * @param strDisplayInfo Brings the display info. */ 408 UINotificationProgressExtensionPackInstall(const CExtPackFile &comExtPackFile, 409 bool fReplace, 410 const QString &strExtensionPackName, 411 const QString &strDisplayInfo); 412 413 protected: 414 415 /** Returns object name. */ 416 virtual QString name() const /* override final */; 417 /** Returns object details. */ 418 virtual QString details() const /* override final */; 419 /** Creates and returns started progress-wrapper. */ 420 virtual CProgress createProgress(COMResult &comResult) /* override final */; 421 422 private slots: 423 424 /** Handles signal about progress being finished. */ 425 void sltHandleProgressFinished(); 426 427 private: 428 429 /** Holds the extension pack file to install. */ 430 CExtPackFile m_comExtPackFile; 431 /** Holds whether extension pack should be replaced. */ 432 bool m_fReplace; 433 /** Holds the extension pack name. */ 434 QString m_strExtensionPackName; 435 /** Holds the display info. */ 436 QString m_strDisplayInfo; 437 }; 438 439 /** UINotificationProgress extension for extension pack uninstall functionality. */ 440 class SHARED_LIBRARY_STUFF UINotificationProgressExtensionPackUninstall : public UINotificationProgress 441 { 442 Q_OBJECT; 443 444 signals: 445 446 /** Notifies listeners about extension pack uninstalled. 447 * @param strExtensionPackName Brigns extension pack name. */ 448 void sigExtensionPackUninstalled(const QString &strExtensionPackName); 449 450 public: 451 452 /** Constructs extension pack uninstall notification-progress. 453 * @param comExtPackManager Brings the extension pack manager. 454 * @param strExtensionPackName Brings the extension pack name. 455 * @param strDisplayInfo Brings the display info. */ 456 UINotificationProgressExtensionPackUninstall(const CExtPackManager &comExtPackManager, 457 const QString &strExtensionPackName, 458 const QString &strDisplayInfo); 459 460 protected: 461 462 /** Returns object name. */ 463 virtual QString name() const /* override final */; 464 /** Returns object details. */ 465 virtual QString details() const /* override final */; 466 /** Creates and returns started progress-wrapper. */ 467 virtual CProgress createProgress(COMResult &comResult) /* override final */; 468 469 private slots: 470 471 /** Handles signal about progress being finished. */ 472 void sltHandleProgressFinished(); 473 474 private: 475 476 /** Holds the extension pack manager. */ 477 CExtPackManager m_comExtPackManager; 478 /** Holds the extension pack name. */ 479 QString m_strExtensionPackName; 480 /** Holds the display info. */ 481 QString m_strDisplayInfo; 482 }; 483 388 484 #endif /* !FEQT_INCLUDED_SRC_notificationcenter_UINotificationObjects_h */
Note:
See TracChangeset
for help on using the changeset viewer.