VirtualBox

Changeset 90663 in vbox for trunk


Ignore:
Timestamp:
Aug 12, 2021 1:41:42 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: Notification signature for guest additions install progress which should now go to center instead of modal dialogs.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r90645 r90663  
    14181418
    14191419/*********************************************************************************************************************************
     1420*   Class UINotificationProgressGuestAdditionsInstall implementation.                                                            *
     1421*********************************************************************************************************************************/
     1422
     1423UINotificationProgressGuestAdditionsInstall::UINotificationProgressGuestAdditionsInstall(const CGuest &comGuest,
     1424                                                                                         const QString &strSource)
     1425    : m_comGuest(comGuest)
     1426    , m_strSource(strSource)
     1427{
     1428    connect(this, &UINotificationProgress::sigProgressFinished,
     1429            this, &UINotificationProgressGuestAdditionsInstall::sltHandleProgressFinished);
     1430}
     1431
     1432QString UINotificationProgressGuestAdditionsInstall::name() const
     1433{
     1434    return UINotificationProgress::tr("Installing image ...");
     1435}
     1436
     1437QString UINotificationProgressGuestAdditionsInstall::details() const
     1438{
     1439    return UINotificationProgress::tr("<b>Name:</b> %1").arg(m_strSource);
     1440}
     1441
     1442CProgress UINotificationProgressGuestAdditionsInstall::createProgress(COMResult &comResult)
     1443{
     1444    /* Initialize progress-wrapper: */
     1445    QVector<QString> args;
     1446    QVector<KAdditionsUpdateFlag> flags;
     1447    CProgress comProgress = m_comGuest.UpdateGuestAdditions(m_strSource, args, flags);
     1448    /* Store COM result: */
     1449    comResult = m_comGuest;
     1450    /* Return progress-wrapper: */
     1451    return comProgress;
     1452}
     1453
     1454void UINotificationProgressGuestAdditionsInstall::sltHandleProgressFinished()
     1455{
     1456    if (!error().isEmpty())
     1457        emit sigGuestAdditionsInstallationFailed(m_strSource);
     1458}
     1459
     1460
     1461/*********************************************************************************************************************************
    14201462*   Class UINotificationProgressHostOnlyNetworkInterfaceCreate implementation.                                                   *
    14211463*********************************************************************************************************************************/
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r90606 r90663  
    3535#include "CExtPackFile.h"
    3636#include "CExtPackManager.h"
     37#include "CGuest.h"
    3738#include "CHost.h"
    3839#include "CHostNetworkInterface.h"
     
    10341035};
    10351036
     1037/** UINotificationProgress extension for guest additions install functionality. */
     1038class SHARED_LIBRARY_STUFF UINotificationProgressGuestAdditionsInstall : public UINotificationProgress
     1039{
     1040    Q_OBJECT;
     1041
     1042signals:
     1043
     1044    /** Notifies listeners about guest additions installation failed.
     1045      * @param  strSource  Brings the guest additions file path. */
     1046    void sigGuestAdditionsInstallationFailed(const QString &strSource);
     1047
     1048public:
     1049
     1050    /** Constructs guest additions install notification-progress.
     1051      * @param  comGuest   Brings the guest additions being installed to.
     1052      * @param  strSource  Brings the guest additions file path. */
     1053    UINotificationProgressGuestAdditionsInstall(const CGuest &comGuest,
     1054                                                const QString &strSource);
     1055
     1056protected:
     1057
     1058    /** Returns object name. */
     1059    virtual QString name() const /* override final */;
     1060    /** Returns object details. */
     1061    virtual QString details() const /* override final */;
     1062    /** Creates and returns started progress-wrapper. */
     1063    virtual CProgress createProgress(COMResult &comResult) /* override final */;
     1064
     1065private slots:
     1066
     1067    /** Handles signal about progress being finished. */
     1068    void sltHandleProgressFinished();
     1069
     1070private:
     1071
     1072    /** Holds the guest additions being installed to. */
     1073    CGuest   m_comGuest;
     1074    /** Holds the guest additions file path. */
     1075    QString  m_strSource;
     1076};
     1077
    10361078/** UINotificationProgress extension for host-only network interface create functionality. */
    10371079class SHARED_LIBRARY_STUFF UINotificationProgressHostOnlyNetworkInterfaceCreate : public UINotificationProgress
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r90567 r90663  
    470470void UISession::sltInstallGuestAdditionsFrom(const QString &strSource)
    471471{
    472     /* This flag indicates whether we want to do the usual .ISO mounting or not.
    473      * First try updating the Guest Additions directly without mounting the .ISO. */
    474     bool fDoMount = false;
    475 
    476     /* Auto-update through GUI is currently disabled. */
    477 #ifndef VBOX_WITH_ADDITIONS_AUTOUPDATE_UI
    478     fDoMount = true;
    479 #else /* VBOX_WITH_ADDITIONS_AUTOUPDATE_UI */
    480     /* Initiate installation progress: */
    481     QVector<QString> aArgs;
    482     QVector<KAdditionsUpdateFlag> aFlagsUpdate;
    483     CProgress comProgressInstall = guest().UpdateGuestAdditions(strSource, aArgs, aFlagsUpdate);
    484     if (guest().isOk() && comProgressInstall.isNotNull())
    485     {
    486         /* Show installation progress: */
    487         msgCenter().showModalProgressDialog(comProgressInstall, tr("Updating Guest Additions"),
    488                                             ":/progress_install_guest_additions_90px.png",
    489                                             0, 500 /* 500ms delay. */);
    490         if (comProgressInstall.GetCanceled())
    491             return;
    492 
    493         /* Check whether progress result isn't Ok: */
    494         const HRESULT rc = comProgressInstall.GetResultCode();
    495         if (!comProgressInstall.isOk() || rc != S_OK)
    496         {
    497             /* If we got back a VBOX_E_NOT_SUPPORTED we don't complain (guest OS simply isn't
    498              * supported yet), so silently fall back to "old" .ISO mounting method. */
    499             if (   !SUCCEEDED_WARNING(rc)
    500                 && rc != VBOX_E_NOT_SUPPORTED)
    501             {
    502                 msgCenter().cannotUpdateGuestAdditions(comProgressInstall);
    503 
    504                 /* Throw the error message into release log as well: */
    505                 const QString &strErr = comProgressInstall.GetErrorInfo().GetText();
    506                 if (!strErr.isEmpty())
    507                     LogRel(("%s\n", strErr.toLatin1().constData()));
    508             }
    509 
    510             /* Since automatic updating failed, fall back to .ISO mounting: */
    511             fDoMount = true;
    512         }
    513     }
    514 #endif /* VBOX_WITH_ADDITIONS_AUTOUPDATE_UI */
    515 
    516     /* Check whether we still want mounting? */
    517     if (!fDoMount)
    518         return;
    519 
    520     /* Mount medium add-hoc: */
     472    /* Install guest additions: */
     473    UINotificationProgressGuestAdditionsInstall *pNotification =
     474            new UINotificationProgressGuestAdditionsInstall(guest(), strSource);
     475    connect(pNotification, &UINotificationProgressGuestAdditionsInstall::sigGuestAdditionsInstallationFailed,
     476            this, &UISession::sltMountDVDAdHoc);
     477    gpNotificationCenter->append(pNotification);
     478}
     479
     480void UISession::sltMountDVDAdHoc(const QString &strSource)
     481{
    521482    mountAdHocImage(KDeviceType_DVD, UIMediumDeviceType_DVD, strSource);
    522483}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r90567 r90663  
    326326public slots:
    327327
     328    /** Handles request to install guest additions image.
     329      * @param  strSource  Brings the source of image being installed. */
    328330    void sltInstallGuestAdditionsFrom(const QString &strSource);
     331    /** Mounts DVD adhoc.
     332      * @param  strSource  Brings the source of image being mounted. */
     333    void sltMountDVDAdHoc(const QString &strSource);
    329334
    330335    /** Defines @a iKeyboardState. */
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