VirtualBox

Changeset 97141 in vbox


Ignore:
Timestamp:
Oct 13, 2022 4:38:35 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
154113
Message:

FE/Qt: bugref:9458: Make sure VM settings dialog changes doesn't get lost on accidental dialog closing; Warn user in case if unsaved settings present.

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

Legend:

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

    r96967 r97141  
    780780}
    781781
    782 bool UIMessageCenter::confirmSettingsReloading(QWidget *pParent /* = 0*/) const
     782bool UIMessageCenter::confirmSettingsDiscarding(QWidget *pParent /* = 0 */) const
     783{
     784    return questionBinary(pParent, MessageType_Question,
     785                          tr("<p>The machine settings were changed.</p>"
     786                             "<p>Would you like to discard the changed settings or to keep editing them?</p>"),
     787                          0 /* auto-confirm id */,
     788                          tr("Discard changes"), tr("Keep editing"));
     789
     790}
     791
     792bool UIMessageCenter::confirmSettingsReloading(QWidget *pParent /* = 0 */) const
    783793{
    784794    return questionBinary(pParent, MessageType_Question,
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r96967 r97141  
    307307        void warnAboutUnaccessibleUSB(const COMBaseWithEI &object, QWidget *pParent = 0) const;
    308308        void warnAboutStateChange(QWidget *pParent = 0) const;
     309        bool confirmSettingsDiscarding(QWidget *pParent = 0) const;
    309310        bool confirmSettingsReloading(QWidget *pParent = 0) const;
    310311        int confirmRemovingOfLastDVDDevice(QWidget *pParent = 0) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp

    r97135 r97141  
    343343}
    344344
     345void UISettingsDialog::closeEvent(QCloseEvent *pEvent)
     346{
     347    /* Check whether there are unsaved settings
     348     * which will be lost in such case: */
     349    if (   !isSettingsChanged()
     350        || msgCenter().confirmSettingsDiscarding())
     351    {
     352        /* Call to base-class: */
     353        QIWithRetranslateUI<QIMainDialog>::closeEvent(pEvent);
     354    }
     355    else
     356    {
     357        /* Otherwise ignore this: */
     358        pEvent->ignore();
     359    }
     360}
     361
    345362void UISettingsDialog::loadData(QVariant &data)
    346363{
     
    804821                                                 QDialogButtonBox::NoButton);
    805822#endif
    806                 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UISettingsDialog::reject);
     823                connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UISettingsDialog::close);
    807824                connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UISettingsDialog::accept);
    808825#ifndef VBOX_WS_MAC
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h

    r97135 r97141  
    103103    /** Handles first show @a pEvent. */
    104104    virtual void polishEvent(QShowEvent *pEvent) RT_OVERRIDE;
     105    /** Handles close @a pEvent. */
     106    virtual void closeEvent(QCloseEvent *pEvent) RT_OVERRIDE;
    105107
    106108    /** Returns the serialize process instance. */
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