VirtualBox

Changeset 92295 in vbox for trunk


Ignore:
Timestamp:
Nov 9, 2021 2:32:19 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: UINotificationCenter: Adding a button for removing finished notifications, one to rule them all.

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

Legend:

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

    r92294 r92295  
    152152    , m_pOpenButton(0)
    153153    , m_pKeepButton(0)
     154    , m_pRemoveFinishedButton(0)
    154155    , m_pLayoutItems(0)
    155156    , m_pStateMachineSliding(0)
     
    279280    if (m_pKeepButton)
    280281        m_pKeepButton->setToolTip(tr("Keep finished progresses"));
     282    if (m_pRemoveFinishedButton)
     283        m_pRemoveFinishedButton->setToolTip(tr("Delete finished notifications"));
    281284}
    282285
     
    362365}
    363366
     367void UINotificationCenter::sltHandleRemoveFinishedButtonClicked()
     368{
     369    m_pModel->revokeFinishedObjects();
     370}
     371
    364372void UINotificationCenter::sltHandleOpenTimerTimeout()
    365373{
     
    469477                m_pLayoutButtons->addWidget(m_pOpenButton);
    470478            }
     479
     480            /* Add stretch: */
     481            m_pLayoutButtons->addStretch(1);
    471482
    472483            /* Prepare keep-button: */
     
    481492            }
    482493
    483             m_pLayoutButtons->addStretch();
     494            /* Prepare remove-finished-button: */
     495            m_pRemoveFinishedButton = new QIToolButton(this);
     496            if (m_pRemoveFinishedButton)
     497            {
     498                m_pRemoveFinishedButton->setIcon(UIIconPool::iconSet(":/edata_remove_16px_x3.png"));
     499                connect(m_pRemoveFinishedButton, &QIToolButton::clicked, this, &UINotificationCenter::sltHandleRemoveFinishedButtonClicked);
     500                m_pLayoutButtons->addWidget(m_pRemoveFinishedButton);
     501            }
    484502
    485503            /* Add to layout: */
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationCenter.h

    r92012 r92295  
    105105    /** Toggles notification-progresses keep approach. */
    106106    void sltHandleKeepButtonToggled(bool fToggled);
     107    /** Removes finished notifications. */
     108    void sltHandleRemoveFinishedButtonClicked();
    107109
    108110    /** Handles open-timer timeout. */
     
    154156    /** Holds the buttons layout instance. */
    155157    QHBoxLayout  *m_pLayoutButtons;
    156     /** Holds the open button instance. */
     158    /** Holds the open-button instance. */
    157159    QIToolButton *m_pOpenButton;
    158     /** Holds the keep button instance. */
     160    /** Holds the keep-button instance. */
    159161    QIToolButton *m_pKeepButton;
     162    /** Holds the remove-finished-button instance. */
     163    QIToolButton *m_pRemoveFinishedButton;
    160164    /** Holds the items layout instance. */
    161165    QVBoxLayout  *m_pLayoutItems;
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationModel.cpp

    r91225 r92295  
    7474}
    7575
     76void UINotificationModel::revokeFinishedObjects()
     77{
     78    /* Check whether there are done objects: */
     79    bool fChanged = false;
     80    foreach (const QUuid &uId, m_ids)
     81    {
     82        UINotificationObject *pObject = m_objects.value(uId);
     83        AssertPtrReturnVoid(pObject);
     84        if (pObject->isDone())
     85        {
     86            /* Remove ID and object: */
     87            delete m_objects.take(uId);
     88            m_ids.removeAll(uId);
     89            fChanged = true;
     90        }
     91    }
     92    /* Notify listeners: */
     93    if (fChanged)
     94        emit sigChanged();
     95}
     96
    7697QList<QUuid> UINotificationModel::ids() const
    7798{
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationModel.h

    r91225 r92295  
    5757    /** Returns whether there is a notification object referenced by @a uId. */
    5858    bool hasObject(const QUuid &uId) const;
     59    /** Revokes finished notification objects. */
     60    void revokeFinishedObjects();
    5961
    6062    /** 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