VirtualBox

Changeset 90679 in vbox for trunk


Ignore:
Timestamp:
Aug 13, 2021 10:45:43 AM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: Interfaces for simple message notification.

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

Legend:

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

    r90626 r90679  
    1717
    1818/* GUI includes: */
     19#include "UIExtraDataManager.h"
    1920#include "UINotificationObject.h"
    2021#include "UINotificationProgressTask.h"
     
    3637{
    3738    emit sigAboutToClose();
     39}
     40
     41
     42/*********************************************************************************************************************************
     43*   Class UINotificationSimple implementation.                                                                                   *
     44*********************************************************************************************************************************/
     45
     46UINotificationSimple::UINotificationSimple(const QString &strName,
     47                                           const QString &strDetails,
     48                                           const QString &strInternalName,
     49                                           bool fCritical /* = true */)
     50    : m_strName(strName)
     51    , m_strDetails(strDetails)
     52    , m_strInternalName(strInternalName)
     53    , m_fCritical(fCritical)
     54{
     55}
     56
     57bool UINotificationSimple::isCritical() const
     58{
     59    return m_fCritical;
     60}
     61
     62QString UINotificationSimple::name() const
     63{
     64    return m_strName;
     65}
     66
     67QString UINotificationSimple::details() const
     68{
     69    return m_strDetails;
     70}
     71
     72void UINotificationSimple::handle()
     73{
     74}
     75
     76/* static */
     77bool UINotificationSimple::isSuppressed(const QString &strInternalName)
     78{
     79    /* Sanity check: */
     80    if (strInternalName.isEmpty())
     81        return false;
     82
     83    /* Acquire and check suppressed message names: */
     84    const QStringList suppressedMessages = gEDataManager->suppressedMessages();
     85    return    suppressedMessages.contains(strInternalName)
     86           || suppressedMessages.contains("all");
    3887}
    3988
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObject.h

    r90626 r90679  
    6868};
    6969
     70/** UINotificationObject extension for notification-simple. */
     71class SHARED_LIBRARY_STUFF UINotificationSimple : public UINotificationObject
     72{
     73    Q_OBJECT;
     74
     75protected:
     76
     77    /** Constructs notification-simple.
     78      * @param  strName          Brings the message name.
     79      * @param  strDetails       Brings the message details.
     80      * @param  strInternalName  Brings the message internal name.
     81      * @param  fCritical        Brings whether message is critical. */
     82    UINotificationSimple(const QString &strName,
     83                         const QString &strDetails,
     84                         const QString &strInternalName,
     85                         bool fCritical = true);
     86
     87    /** Returns whether object is critical. */
     88    virtual bool isCritical() const /* override */;
     89    /** Returns object name. */
     90    virtual QString name() const /* override final */;
     91    /** Returns object details. */
     92    virtual QString details() const /* override final */;
     93    /** Handles notification-object being added. */
     94    virtual void handle() /* override final */;
     95
     96    /** Returns whether message with passed @a strInternalName is suppressed. */
     97    static bool isSuppressed(const QString &strInternalName);
     98
     99private:
     100
     101    /** Holds the message name. */
     102    QString  m_strName;
     103    /** Holds the message details. */
     104    QString  m_strDetails;
     105    /** Holds the message internal name. */
     106    QString  m_strInternalName;
     107    /** Holds whether message is critical. */
     108    bool     m_fCritical;
     109};
     110
    70111/** UINotificationObject extension for notification-progress. */
    71112class SHARED_LIBRARY_STUFF UINotificationProgress : public UINotificationObject
     
    101142
    102143    /** Returns whether object is critical. */
    103     virtual bool isCritical() const;
     144    virtual bool isCritical() const /* override */;
    104145    /** Handles notification-object being added. */
    105146    virtual void handle() /* override final */;
     
    163204
    164205    /** Returns whether object is critical. */
    165     virtual bool isCritical() const;
     206    virtual bool isCritical() const /* override */;
    166207    /** Handles notification-object being added. */
    167208    virtual void handle() /* override final */;
     
    226267
    227268    /** Returns whether object is critical. */
    228     virtual bool isCritical() const;
     269    virtual bool isCritical() const /* override */;
    229270    /** Handles notification-object being added. */
    230271    virtual void handle() /* override final */;
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r90663 r90679  
    2222/* GUI includes: */
    2323#include "UICommon.h"
     24#include "UINotificationCenter.h"
    2425#include "UINotificationObjects.h"
    2526#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
     
    3233/* COM includes: */
    3334#include "CConsole.h"
     35
     36
     37/*********************************************************************************************************************************
     38*   Class UINotificationMessage implementation.                                                                                  *
     39*********************************************************************************************************************************/
     40
     41/* static */
     42void UINotificationMessage::createMessage(const QString &strName,
     43                                          const QString &strDetails,
     44                                          const QString &strInternalName)
     45{
     46    /* Check if message suppressed: */
     47    if (isSuppressed(strInternalName))
     48        return;
     49
     50    /* Create message finally: */
     51    gpNotificationCenter->append(new UINotificationMessage(strName,
     52                                                           strDetails,
     53                                                           strInternalName));
     54}
    3455
    3556
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r90663 r90679  
    4444#include "CVirtualSystemDescription.h"
    4545
     46/** UINotificationObject extension for message functionality. */
     47class SHARED_LIBRARY_STUFF UINotificationMessage : public UINotificationSimple
     48{
     49    Q_OBJECT;
     50
     51public:
     52
     53protected:
     54
     55    /** Constructs message notification-object.
     56      * @param  strName          Brings the message name.
     57      * @param  strDetails       Brings the message details.
     58      * @param  strInternalName  Brings the message internal name. */
     59    UINotificationMessage(const QString &strName,
     60                                const QString &strDetails,
     61                                const QString &strInternalName)
     62        : UINotificationSimple(strName,
     63                               strDetails,
     64                               strInternalName)
     65    {}
     66
     67private:
     68
     69    /** Creates message.
     70      * @param  strName          Brings the message name.
     71      * @param  strDetails       Brings the message details.
     72      * @param  strInternalName  Brings the message internal name. */
     73    static void createMessage(const QString &strName,
     74                              const QString &strDetails,
     75                              const QString &strInternalName);
     76
     77    /** Holds the message name. */
     78    QString  m_strName;
     79    /** Holds the message details. */
     80    QString  m_strDetails;
     81    /** Holds the message internal name. */
     82    QString  m_strInternalName;
     83};
     84
    4685/** UINotificationProgress extension for medium create functionality. */
    4786class SHARED_LIBRARY_STUFF UINotificationProgressMediumCreate : public UINotificationProgress
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