VirtualBox

Ignore:
Timestamp:
Jul 27, 2021 11:08:28 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: Notification signatures for Extension pack install/uninstall progress which should now go to center instead of modal dialogs.

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  
    2424
    2525/* GUI includes: */
    26 //#include "QIDialogButtonBox.h"
    27 //#include "QIInputDialog.h"
    28 //#include "QIMessageBox.h"
    2926#include "QIFileDialog.h"
    3027#include "QIToolBar.h"
     
    3633#include "UIIconPool.h"
    3734#include "UIMessageCenter.h"
    38 //#include "UIVirtualBoxEventHandler.h"
     35#include "UINotificationCenter.h"
    3936
    4037/* COM includes: */
     
    232229    /* Install the chosen package: */
    233230    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);
    265232}
    266233
     
    299266#endif
    300267
    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);
    324276            }
    325277        }
     
    375327}
    376328
     329void 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
     353void 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
    377369void UIExtensionPackManagerWidget::prepare()
    378370{
    379371    /* Prepare self: */
    380372    uiCommon().setHelpKeyword(this, "extensionsdetails"); /// @todo use proper help tag
     373    connect(&uiCommon(), &UICommon::sigExtensionPackInstalled,
     374            this, &UIExtensionPackManagerWidget::sltHandleExtensionPackInstalled);
    381375
    382376    /* Prepare stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/extensionpackmanager/UIExtensionPackManager.h

    r87354 r90352  
    8383        /** Handles context-menu request for tree-widget @a position. */
    8484        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);
    8590    /** @} */
    8691
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r90326 r90352  
    6262#include "UIFDCreationDialog.h"
    6363#include "UIIconPool.h"
     64#include "UINotificationCenter.h"
    6465#include "UIThreadPool.h"
    6566#include "UIShortcutPool.h"
     
    37793780}
    37803781
    3781 /* static */
    37823782void UICommon::doExtPackInstallation(QString const &strFilePath, QString const &strDigest,
    3783                                        QWidget *pParent, QString *pstrExtPackName) const
     3783                                     QWidget *pParent, QString *pstrExtPackName) const
    37843784{
    37853785    /* If the extension pack manager isn't available, skip any attempts to install: */
     
    38463846        strDisplayInfo.sprintf("hwnd=%#llx", (uint64_t)(uintptr_t)pParent->winId());
    38473847#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: */
    38683860    if (pstrExtPackName)
    38693861        *pstrExtPackName = strPackName;
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r90326 r90352  
    8585        /** Asks listeners to detach COM. */
    8686        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);
    8793    /** @} */
    8894
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r90344 r90352  
    354354    return comProgress;
    355355}
     356
     357
     358/*********************************************************************************************************************************
     359*   Class UINotificationProgressExtensionPackInstall implementation.                                                             *
     360*********************************************************************************************************************************/
     361
     362UINotificationProgressExtensionPackInstall::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
     375QString UINotificationProgressExtensionPackInstall::name() const
     376{
     377    return UINotificationProgress::tr("Installing package ...");
     378}
     379
     380QString UINotificationProgressExtensionPackInstall::details() const
     381{
     382    return UINotificationProgress::tr("<b>Name:</b> %1").arg(m_strExtensionPackName);
     383}
     384
     385CProgress 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
     395void UINotificationProgressExtensionPackInstall::sltHandleProgressFinished()
     396{
     397    if (error().isEmpty())
     398        emit sigExtensionPackInstalled(m_strExtensionPackName);
     399}
     400
     401
     402/*********************************************************************************************************************************
     403*   Class UINotificationProgressExtensionPackUninstall implementation.                                                           *
     404*********************************************************************************************************************************/
     405
     406UINotificationProgressExtensionPackUninstall::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
     417QString UINotificationProgressExtensionPackUninstall::name() const
     418{
     419    return UINotificationProgress::tr("Uninstalling package ...");
     420}
     421
     422QString UINotificationProgressExtensionPackUninstall::details() const
     423{
     424    return UINotificationProgress::tr("<b>Name:</b> %1").arg(m_strExtensionPackName);
     425}
     426
     427CProgress 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
     439void UINotificationProgressExtensionPackUninstall::sltHandleProgressFinished()
     440{
     441    if (error().isEmpty())
     442        emit sigExtensionPackUninstalled(m_strExtensionPackName);
     443}
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r90344 r90352  
    3030#include "CCloudClient.h"
    3131#include "CCloudMachine.h"
     32#include "CExtPackFile.h"
     33#include "CExtPackManager.h"
    3234#include "CMachine.h"
    3335#include "CMedium.h"
     
    386388};
    387389
     390/** UINotificationProgress extension for extension pack install functionality. */
     391class SHARED_LIBRARY_STUFF UINotificationProgressExtensionPackInstall : public UINotificationProgress
     392{
     393    Q_OBJECT;
     394
     395signals:
     396
     397    /** Notifies listeners about extension pack installed.
     398      * @param  strExtensionPackName  Brigns extension pack name. */
     399    void sigExtensionPackInstalled(const QString &strExtensionPackName);
     400
     401public:
     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
     413protected:
     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
     422private slots:
     423
     424    /** Handles signal about progress being finished. */
     425    void sltHandleProgressFinished();
     426
     427private:
     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. */
     440class SHARED_LIBRARY_STUFF UINotificationProgressExtensionPackUninstall : public UINotificationProgress
     441{
     442    Q_OBJECT;
     443
     444signals:
     445
     446    /** Notifies listeners about extension pack uninstalled.
     447      * @param  strExtensionPackName  Brigns extension pack name. */
     448    void sigExtensionPackUninstalled(const QString &strExtensionPackName);
     449
     450public:
     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
     460protected:
     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
     469private slots:
     470
     471    /** Handles signal about progress being finished. */
     472    void sltHandleProgressFinished();
     473
     474private:
     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
    388484#endif /* !FEQT_INCLUDED_SRC_notificationcenter_UINotificationObjects_h */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette