VirtualBox

Changeset 90606 in vbox


Ignore:
Timestamp:
Aug 10, 2021 4:07:13 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
146217
Message:

FE/Qt: bugref:10067: Notification signature for new version check procedure which should now go to center instead of network-request center.

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  
    2626#include "UIMessageCenter.h"
    2727#include "UIModalWindowManager.h"
    28 #include "UINewVersionChecker.h"
    2928#include "UINotificationCenter.h"
    3029#include "UIUpdateDefs.h"
     
    4645      * @param  fForcedCall  Brings whether this customer has forced privelegies. */
    4746    UIUpdateStepVirtualBox(bool fForcedCall);
    48     /** Destructs extension step. */
    49     virtual ~UIUpdateStepVirtualBox() /* override final */;
    5047
    5148    /** Executes the step. */
     
    5451private:
    5552
    56     /** Holds the new version checker instance. */
    57     UINewVersionChecker *m_pNewVersionChecker;
     53    /** Holds whether this customer has forced privelegies. */
     54    bool  m_fForcedCall;
    5855};
    5956
     
    8986
    9087UIUpdateStepVirtualBox::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{
    10990}
    11091
    11192void UIUpdateStepVirtualBox::exec()
    11293{
    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);
    114114}
    115115
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObject.cpp

    r90600 r90606  
    2121#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    2222# include "UIDownloader.h"
     23# include "UINewVersionChecker.h"
    2324#endif
    2425
     
    194195}
    195196
     197
     198/*********************************************************************************************************************************
     199*   Class UINotificationNewVersionChecker implementation.                                                                        *
     200*********************************************************************************************************************************/
     201
     202UINotificationNewVersionChecker::UINotificationNewVersionChecker()
     203    : m_pChecker(0)
     204{
     205}
     206
     207UINotificationNewVersionChecker::~UINotificationNewVersionChecker()
     208{
     209    delete m_pChecker;
     210    m_pChecker = 0;
     211}
     212
     213QString UINotificationNewVersionChecker::error() const
     214{
     215    return m_strError;
     216}
     217
     218bool UINotificationNewVersionChecker::isCritical() const
     219{
     220    return m_pChecker ? m_pChecker->isItForcedCall() : true;
     221}
     222
     223void 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
     241void 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
     250void UINotificationNewVersionChecker::sltHandleProgressFailed(const QString &strError)
     251{
     252    delete m_pChecker;
     253    m_pChecker = 0;
     254    m_strError = strError;
     255    emit sigProgressFailed();
     256}
     257
     258void UINotificationNewVersionChecker::sltHandleProgressCanceled()
     259{
     260    delete m_pChecker;
     261    m_pChecker = 0;
     262    emit sigProgressCanceled();
     263}
     264
     265void UINotificationNewVersionChecker::sltHandleProgressFinished()
     266{
     267    delete m_pChecker;
     268    m_pChecker = 0;
     269    emit sigProgressFinished();
     270}
     271
    196272#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObject.h

    r90600 r90606  
    3636#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    3737class UIDownloader;
     38class UINewVersionChecker;
    3839#endif
    3940
     
    194195    QString  m_strError;
    195196};
     197
     198/** UINotificationObject extension for notification-new-version-checker. */
     199class SHARED_LIBRARY_STUFF UINotificationNewVersionChecker : public UINotificationObject
     200{
     201    Q_OBJECT;
     202
     203signals:
     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
     212public:
     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
     230public slots:
     231
     232    /** Stops the checker and notifies model about closing. */
     233    virtual void close() /* override final */;
     234
     235private 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
     245private:
     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};
    196253#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    197254
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjectItem.cpp

    r90601 r90606  
    372372}
    373373
     374
     375/*********************************************************************************************************************************
     376*   Class UINotificationNewVersionCheckerItem implementation.                                                                    *
     377*********************************************************************************************************************************/
     378
     379UINotificationNewVersionCheckerItem::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
     417void 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
     427void 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
     440UINotificationNewVersionChecker *UINotificationNewVersionCheckerItem::checker() const
     441{
     442    return qobject_cast<UINotificationNewVersionChecker*>(m_pObject);
     443}
     444
     445void 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
    374461#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    375462
     
    387474    else if (pObject->inherits("UINotificationDownloader"))
    388475        return new UINotificationDownloaderItem(pParent, static_cast<UINotificationDownloader*>(pObject));
     476    else if (pObject->inherits("UINotificationNewVersionChecker"))
     477        return new UINotificationNewVersionCheckerItem(pParent, static_cast<UINotificationNewVersionChecker*>(pObject));
    389478#endif
    390479    /* Handle defaults: */
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjectItem.h

    r90601 r90606  
    3636#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    3737class UINotificationDownloader;
     38class UINotificationNewVersionChecker;
    3839#endif
    3940
     
    143144    QProgressBar *m_pProgressBar;
    144145};
     146
     147/** UINotificationObjectItem extension for notification-new-version-checker. */
     148class UINotificationNewVersionCheckerItem : public UINotificationObjectItem
     149{
     150    Q_OBJECT;
     151
     152public:
     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
     158private slots:
     159
     160    /** Handles signal about progress NOT finished. */
     161    void sltHandleProgressNotFinished();
     162    /** Handles signal about progress finished. */
     163    void sltHandleProgressFinished();
     164
     165private:
     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};
    145176#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    146177
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r90592 r90606  
    2727# include "UIDownloaderGuestAdditions.h"
    2828# include "UIDownloaderUserManual.h"
     29# include "UINewVersionChecker.h"
    2930#endif
    3031
     
    16621663}
    16631664
     1665
     1666/*********************************************************************************************************************************
     1667*   Class UINotificationNewVersionCheckerVirtualBox implementation.                                                              *
     1668*********************************************************************************************************************************/
     1669
     1670/* static */
     1671UINotificationNewVersionCheckerVirtualBox *UINotificationNewVersionCheckerVirtualBox::s_pInstance = 0;
     1672
     1673/* static */
     1674UINotificationNewVersionCheckerVirtualBox *UINotificationNewVersionCheckerVirtualBox::instance(bool fForcedCall)
     1675{
     1676    if (!s_pInstance)
     1677        new UINotificationNewVersionCheckerVirtualBox(fForcedCall);
     1678    return s_pInstance;
     1679}
     1680
     1681/* static */
     1682bool UINotificationNewVersionCheckerVirtualBox::exists()
     1683{
     1684    return !!s_pInstance;
     1685}
     1686
     1687UINotificationNewVersionCheckerVirtualBox::UINotificationNewVersionCheckerVirtualBox(bool fForcedCall)
     1688    : m_fForcedCall(fForcedCall)
     1689{
     1690    s_pInstance = this;
     1691}
     1692
     1693UINotificationNewVersionCheckerVirtualBox::~UINotificationNewVersionCheckerVirtualBox()
     1694{
     1695    s_pInstance = 0;
     1696}
     1697
     1698QString UINotificationNewVersionCheckerVirtualBox::name() const
     1699{
     1700    return UINotificationDownloader::tr("Check for New Version ...");
     1701}
     1702
     1703QString UINotificationNewVersionCheckerVirtualBox::details() const
     1704{
     1705    return UINotificationProgress::tr("<b>Link:</b> %1").arg(m_strUrl);
     1706}
     1707
     1708UINewVersionChecker *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
    16641720#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r90605 r90606  
    12571257    QString  m_strFileName;
    12581258};
     1259
     1260/** UINotificationNewVersionChecker extension for VirtualBox new version check functionality. */
     1261class SHARED_LIBRARY_STUFF UINotificationNewVersionCheckerVirtualBox : public UINotificationNewVersionChecker
     1262{
     1263    Q_OBJECT;
     1264
     1265public:
     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
     1277protected:
     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
     1290private:
     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};
    12591301#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    12601302
Note: See TracChangeset for help on using the changeset viewer.

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