VirtualBox

Changeset 45225 in vbox for trunk/src


Ignore:
Timestamp:
Mar 28, 2013 11:39:58 AM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: Message-center cleanup (part 1).

Location:
trunk/src/VBox/Frontends/VirtualBox/src/globals
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r45193 r45225  
    7171#include <iprt/path.h>
    7272
    73 bool UIMessageCenter::isAnyWarningShown()
    74 {
    75     /* Check if at least one warning is alive!
    76      * All warnings are stored in m_warnings list as live pointers,
    77      * this is why if some warning was deleted from another place,
    78      * its pointer here will equal NULL... */
    79     for (int i = 0; i < m_warnings.size(); ++i)
    80         if (m_warnings[i])
    81             return true;
    82     return false;
    83 }
    84 
    85 bool UIMessageCenter::isAlreadyShown(const QString &strWarningName) const
    86 {
    87     return m_strShownWarnings.contains(strWarningName);
    88 }
    89 
    90 void UIMessageCenter::setShownStatus(const QString &strWarningName)
    91 {
    92     if (!m_strShownWarnings.contains(strWarningName))
    93         m_strShownWarnings.append(strWarningName);
    94 }
    95 
    96 void UIMessageCenter::clearShownStatus(const QString &strWarningName)
    97 {
    98     if (m_strShownWarnings.contains(strWarningName))
    99         m_strShownWarnings.removeAll(strWarningName);
    100 }
    101 
    102 void UIMessageCenter::closeAllWarnings()
    103 {
    104     /* Broadcast signal to perform emergent
    105      * closing + deleting all the opened warnings. */
    106     emit sigToCloseAllWarnings();
     73bool UIMessageCenter::warningShown(const QString &strWarningName) const
     74{
     75    return m_warnings.contains(strWarningName);
     76}
     77
     78void UIMessageCenter::setWarningShown(const QString &strWarningName, bool fWarningShown)
     79{
     80    if (fWarningShown && !m_warnings.contains(strWarningName))
     81        m_warnings.append(strWarningName);
     82    else if (!fWarningShown && m_warnings.contains(strWarningName))
     83        m_warnings.removeAll(strWarningName);
    10784}
    10885
     
    249226        pBox->setDetailsText(strDetails);
    250227
    251     /* Add to warnings: */
    252     m_warnings << pBox;
    253 
    254228    /* Show box: */
    255229    int rc = pBox->exec();
     
    258232    if (!pBox)
    259233        return rc;
    260 
    261     /* Remove from warnings: */
    262     m_warnings.removeAll(pBox);
    263234
    264235    /* Cleanup confirmation: */
     
    373344        pBox->setDetailsText(strDetails);
    374345
    375     /* Add to warnings: */
    376     m_warnings << pBox;
    377 
    378346    /* Show box: */
    379347    int rc = pBox->exec();
     
    382350    if (!pBox)
    383351        return rc;
    384 
    385     /* Remove from warnings: */
    386     m_warnings.removeAll(pBox);
    387352
    388353    /* Save option: */
     
    826791void UIMessageCenter::warnAboutStateChange(QWidget *pParent)
    827792{
    828     if (isAlreadyShown("warnAboutStateChange"))
     793    if (warningShown("warnAboutStateChange"))
    829794        return;
    830     setShownStatus("warnAboutStateChange");
     795    setWarningShown("warnAboutStateChange", true);
    831796
    832797    message(pParent ? pParent : mainWindowShown(), Warning,
     
    835800               "All other changes will be lost if you close this window now."));
    836801
    837     clearShownStatus("warnAboutStateChange");
     802    setWarningShown("warnAboutStateChange", false);
    838803}
    839804
     
    21102075void UIMessageCenter::remindAboutMouseIntegration(bool fSupportsAbsolute)
    21112076{
    2112     if (isAlreadyShown("remindAboutMouseIntegration"))
     2077    if (warningShown("remindAboutMouseIntegration"))
    21132078        return;
    2114     setShownStatus("remindAboutMouseIntegration");
     2079    setWarningShown("remindAboutMouseIntegration", true);
    21152080
    21162081    static const char *kNames [2] =
     
    21652130    }
    21662131
    2167     clearShownStatus("remindAboutMouseIntegration");
     2132    setWarningShown("remindAboutMouseIntegration", false);
    21682133}
    21692134
     
    32733238void UIMessageCenter::sltRemindAboutUnsupportedUSB2(const QString &strExtPackName, QWidget *pParent)
    32743239{
    3275     if (isAlreadyShown("sltRemindAboutUnsupportedUSB2"))
     3240    if (warningShown("sltRemindAboutUnsupportedUSB2"))
    32763241        return;
    3277     setShownStatus("sltRemindAboutUnsupportedUSB2");
     3242    setWarningShown("sltRemindAboutUnsupportedUSB2", true);
    32783243
    32793244    message(pParent ? pParent : mainMachineWindowShown(), Warning,
     
    32853250               .arg(strExtPackName));
    32863251
    3287     clearShownStatus("sltRemindAboutUnsupportedUSB2");
     3252    setWarningShown("sltRemindAboutUnsupportedUSB2", false);
    32883253}
    32893254
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r45193 r45225  
    7474    };
    7575
    76     bool isAnyWarningShown();
    77     bool isAlreadyShown(const QString &strGuardBlockName) const;
    78     void setShownStatus(const QString &strGuardBlockName);
    79     void clearShownStatus(const QString &strGuardBlockName);
    80     void closeAllWarnings();
     76    /* API: Shown warning registration stuff: */
     77    bool warningShown(const QString &strWarningName) const;
     78    void setWarningShown(const QString &strWarningName, bool fWarningShown);
    8179
    8280    int message(QWidget *pParent, Type type, const QString &strMessage,
     
    502500                                     HRESULT wrapperRC = S_OK);
    503501
    504     QStringList m_strShownWarnings;
    505     mutable QList<QPointer<QIMessageBox> > m_warnings;
     502    /* Variables: */
     503    QStringList m_warnings;
    506504};
    507505
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