VirtualBox

Changeset 90688 in vbox


Ignore:
Timestamp:
Aug 15, 2021 2:36:44 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: A possibility to dismiss shown UINotificationObject via button in UINotificationObjectItem.

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

Legend:

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

    r90485 r90688  
    1616 */
    1717
     18/* Qt includes: */
     19#include <QSet>
     20
    1821/* GUI includes: */
    1922#include "UICommon.h"
     23#include "UIExtraDataManager.h"
    2024#include "UINotificationModel.h"
    2125#include "UINotificationObject.h"
     
    7579}
    7680
    77 void UINotificationModel::sltHandleAboutToClose()
     81void UINotificationModel::sltHandleAboutToClose(bool fDismiss)
    7882{
    7983    /* Determine sender: */
    8084    UINotificationObject *pSender = qobject_cast<UINotificationObject*>(sender());
    8185    AssertPtrReturnVoid(pSender);
     86
     87    /* Dismiss message if requested: */
     88    if (fDismiss && !pSender->internalName().isEmpty())
     89    {
     90        QSet<QString> suppressedMessages = gEDataManager->suppressedMessages().toSet();
     91        suppressedMessages << pSender->internalName();
     92        gEDataManager->setSuppressedMessages(suppressedMessages.toList());
     93    }
     94
    8295    /* Revoke it from internal storage: */
    8396    const QUuid uId = m_objects.key(pSender);
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationModel.h

    r90485 r90688  
    6363private slots:
    6464
    65     /** Handles request about to close sender() notification object. */
    66     void sltHandleAboutToClose();
     65    /** Handles request about to close sender() notification object.
     66      * @param  fDismiss  Brings whether message closed as dismissed. */
     67    void sltHandleAboutToClose(bool fDismiss);
    6768
    6869    /** Handles broadcast request to detach COM stuff. */
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObject.cpp

    r90679 r90688  
    3434}
    3535
     36void UINotificationObject::dismiss()
     37{
     38    emit sigAboutToClose(true);
     39}
     40
    3641void UINotificationObject::close()
    3742{
    38     emit sigAboutToClose();
     43    emit sigAboutToClose(false);
    3944}
    4045
     
    7075}
    7176
     77QString UINotificationSimple::internalName() const
     78{
     79    return m_strInternalName;
     80}
     81
    7282void UINotificationSimple::handle()
    7383{
     
    122132{
    123133    return true;
     134}
     135
     136QString UINotificationProgress::internalName() const
     137{
     138    return QString();
    124139}
    125140
     
    195210{
    196211    return true;
     212}
     213
     214QString UINotificationDownloader::internalName() const
     215{
     216    return QString();
    197217}
    198218
     
    292312}
    293313
     314QString UINotificationNewVersionChecker::internalName() const
     315{
     316    return QString();
     317}
     318
    294319void UINotificationNewVersionChecker::handle()
    295320{
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObject.h

    r90679 r90688  
    4545signals:
    4646
    47     /** Notifies model about closing. */
    48     void sigAboutToClose();
     47    /** Notifies model about closing.
     48      * @param  fDismiss  Brings whether message closed as dismissed. */
     49    void sigAboutToClose(bool fDismiss);
    4950
    5051public:
     
    5960    /** Returns object details. */
    6061    virtual QString details() const = 0;
     62    /** Returns object internal name. */
     63    virtual QString internalName() const = 0;
    6164    /** Handles notification-object being added. */
    6265    virtual void handle() = 0;
     
    6467public slots:
    6568
     69    /** Notifies model about dismissing. */
     70    virtual void dismiss();
    6671    /** Notifies model about closing. */
    6772    virtual void close();
     
    9196    /** Returns object details. */
    9297    virtual QString details() const /* override final */;
     98    /** Returns object internal name. */
     99    virtual QString internalName() const /* override final */;
    93100    /** Handles notification-object being added. */
    94101    virtual void handle() /* override final */;
     
    143150    /** Returns whether object is critical. */
    144151    virtual bool isCritical() const /* override */;
     152    /** Returns object internal name. */
     153    virtual QString internalName() const /* override final */;
    145154    /** Handles notification-object being added. */
    146155    virtual void handle() /* override final */;
     
    205214    /** Returns whether object is critical. */
    206215    virtual bool isCritical() const /* override */;
     216    /** Returns object internal name. */
     217    virtual QString internalName() const /* override final */;
    207218    /** Handles notification-object being added. */
    208219    virtual void handle() /* override final */;
     
    268279    /** Returns whether object is critical. */
    269280    virtual bool isCritical() const /* override */;
     281    /** Returns object internal name. */
     282    virtual QString internalName() const /* override final */;
    270283    /** Handles notification-object being added. */
    271284    virtual void handle() /* override final */;
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjectItem.cpp

    r90675 r90688  
    4444    , m_pLayoutUpper(0)
    4545    , m_pLabelName(0)
     46    , m_pButtonForget(0)
    4647    , m_pButtonClose(0)
    4748    , m_pLabelDetails(0)
     
    6667                m_pLabelName->setText(m_pObject->name());
    6768                m_pLayoutUpper->addWidget(m_pLabelName);
     69            }
     70
     71            /* Prepare forget button: */
     72            if (!m_pObject->internalName().isEmpty())
     73                m_pButtonForget = new QIToolButton(this);
     74            if (m_pButtonForget)
     75            {
     76                m_pButtonForget->setIcon(UIIconPool::iconSet(":/close_popup_16px.png"));
     77                m_pButtonForget->setIconSize(QSize(10, 10));
     78                connect(m_pButtonForget, &QIToolButton::clicked,
     79                        m_pObject, &UINotificationObject::dismiss);
     80
     81                m_pLayoutUpper->addWidget(m_pButtonForget);
    6882            }
    6983
     
    92106            m_pLabelDetails->setBrowserFont(myFont);
    93107            m_pLabelDetails->setVisible(false);
    94             const int iHint = m_pLabelName->minimumSizeHint().width()
    95                             + m_pLayoutUpper->spacing()
    96                             + m_pButtonClose->minimumSizeHint().width();
     108            int iHint = m_pLabelName->minimumSizeHint().width();
     109            if (m_pButtonForget)
     110                iHint += m_pLayoutUpper->spacing() + m_pButtonForget->minimumSizeHint().width();
     111            if (m_pButtonClose)
     112                iHint += m_pLayoutUpper->spacing() + m_pButtonClose->minimumSizeHint().width();
    97113            m_pLabelDetails->setMinimumTextWidth(iHint);
    98114            m_pLabelDetails->setText(m_pObject->details());
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjectItem.h

    r90606 r90688  
    6767    /** Holds the name label instance. */
    6868    QLabel          *m_pLabelName;
     69    /** Holds the forget button instance. */
     70    QIToolButton    *m_pButtonForget;
    6971    /** Holds the close button instance. */
    7072    QIToolButton    *m_pButtonClose;
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