VirtualBox

Changeset 91225 in vbox


Ignore:
Timestamp:
Sep 14, 2021 10:32:37 AM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: Delay progress-notifications for a bit, similarly to what we have with modal progress-dialog.

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

Legend:

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

    r90627 r91225  
    2727#include <QStateMachine>
    2828#include <QStyle>
     29#include <QTimer>
    2930#include <QVBoxLayout>
    3031
     
    176177    const QUuid uId = m_pModel->appendObject(pObject);
    177178
    178     /* Open if object is critical and center isn't opened yet: */
     179    /* If object is critical and center isn't opened yet: */
    179180    if (!m_pOpenButton->isChecked() && pObject->isCritical())
    180         m_pOpenButton->animateClick();
     181    {
     182        /* We should delay progresses for a bit: */
     183        const int iDelay = pObject->inherits("UINotificationProgress") ? 2000 : 0;
     184        /* We should issue an open request: */
     185        AssertPtrReturn(m_pTimerOpen, uId);
     186        m_uOpenObjectId = uId;
     187        m_pTimerOpen->start(iDelay);
     188    }
    181189
    182190    return uId;
     
    198206    , m_pStateMachineSliding(0)
    199207    , m_iAnimatedValue(0)
     208    , m_pTimerOpen(0)
    200209{
    201210    s_pInstance = this;
     
    284293}
    285294
     295void UINotificationCenter::sltHandleOpenTimerTimeout()
     296{
     297    /* Check whether we really closed: */
     298    if (m_pOpenButton->isChecked())
     299        return;
     300
     301    /* Check whether message with particular ID exists: */
     302    if (!m_pModel->hasObject(m_uOpenObjectId))
     303        return;
     304
     305    /* Toggle open-button: */
     306    m_pOpenButton->animateClick();
     307}
     308
    286309void UINotificationCenter::sltModelChanged()
    287310{
     
    320343    prepareWidgets();
    321344    prepareStateMachineSliding();
     345    prepareOpenTimer();
    322346}
    323347
     
    456480}
    457481
     482void UINotificationCenter::prepareOpenTimer()
     483{
     484    m_pTimerOpen = new QTimer(this);
     485    if (m_pTimerOpen)
     486        connect(m_pTimerOpen, &QTimer::timeout,
     487                this, &UINotificationCenter::sltHandleOpenTimerTimeout);
     488}
     489
    458490void UINotificationCenter::paintBackground(QPainter *pPainter)
    459491{
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationCenter.h

    r90564 r91225  
    3434class QPainter;
    3535class QStateMachine;
     36class QTimer;
    3637class QVBoxLayout;
    3738class QIToolButton;
     
    9293    /** Issues request to make open button @a fToggled. */
    9394    void sltHandleOpenButtonToggled(bool fToggled);
     95    /** Handles open-timer timeout. */
     96    void sltHandleOpenTimerTimeout();
    9497
    9598    /** Handles signal about model being updated. */
     
    106109    /** Prepares sliding state-machine. */
    107110    void prepareStateMachineSliding();
     111    /** Prepares open-timer. */
     112    void prepareOpenTimer();
    108113
    109114    /** Paints background using pre-configured @a pPainter. */
     
    141146    /** Holds the sliding animation current value. */
    142147    int            m_iAnimatedValue;
     148
     149    /** Holds the open-timer instance. */
     150    QTimer *m_pTimerOpen;
     151    /** Holds the open-object ID. */
     152    QUuid   m_uOpenObjectId;
    143153};
    144154
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationModel.cpp

    r90688 r91225  
    6969}
    7070
     71bool UINotificationModel::hasObject(const QUuid &uId) const
     72{
     73    return m_objects.contains(uId);
     74}
     75
    7176QList<QUuid> UINotificationModel::ids() const
    7277{
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationModel.h

    r90688 r91225  
    5555    /** Revokes a notification object referenced by @a uId from intenal storage. */
    5656    void revokeObject(const QUuid &uId);
     57    /** Returns whether there is a notification object referenced by @a uId. */
     58    bool hasObject(const QUuid &uId) const;
    5759
    5860    /** Returns a list of registered notification object IDs. */
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