VirtualBox

Changeset 66501 in vbox


Ignore:
Timestamp:
Apr 10, 2017 3:23:15 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: Machine settings: Parallel page: Error handling (settings save).

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

Legend:

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

    r66497 r66501  
    5858/* COM includes: */
    5959# include "CAudioAdapter.h"
     60# include "CParallelPort.h"
    6061# include "CConsole.h"
    6162# include "CMachine.h"
     
    12211222          tr("Cannot save network adapter settings."),
    12221223          formatErrorInfo(comAdapter));
     1224}
     1225
     1226void UIMessageCenter::cannotSaveParallelSettings(const CMachine &comMachine, QWidget *pParent /* = 0 */)
     1227{
     1228    error(pParent, MessageType_Error,
     1229          tr("Cannot save parallel ports settings."),
     1230          formatErrorInfo(comMachine));
     1231}
     1232
     1233void UIMessageCenter::cannotSaveParallelPortSettings(const CParallelPort &comPort, QWidget *pParent /* = 0 */)
     1234{
     1235    error(pParent, MessageType_Error,
     1236          tr("Cannot save parallel port settings."),
     1237          formatErrorInfo(comPort));
    12231238}
    12241239
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r66497 r66501  
    249249    void cannotSaveNetworkSettings(const CMachine &comMachine, QWidget *pParent = 0);
    250250    void cannotSaveNetworkAdapterSettings(const CNetworkAdapter &comAdapter, QWidget *pParent = 0);
     251    void cannotSaveParallelSettings(const CMachine &comMachine, QWidget *pParent = 0);
     252    void cannotSaveParallelPortSettings(const CParallelPort &comPort, QWidget *pParent = 0);
    251253    void cannotAttachDevice(const CMachine &machine, UIMediumType type, const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent = 0);
    252254    bool warnAboutIncorrectPort(QWidget *pParent = 0) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.cpp

    r66460 r66501  
    2727# include "QIWidgetValidator.h"
    2828# include "UIMachineSettingsParallel.h"
     29# include "UIMessageCenter.h"
    2930# include "VBoxGlobal.h"
    3031
     
    409410    UISettingsPageMachine::fetchData(data);
    410411
    411     /* Make sure machine is offline & parallel data was changed: */
    412     if (isMachineOffline() && m_pCache->wasChanged())
    413     {
    414         /* For each parallel port: */
    415         for (int iPort = 0; iPort < m_pTabWidget->count(); ++iPort)
    416         {
    417             /* Get old parallel data from the cache: */
    418             const UIDataSettingsMachineParallelPort &oldPortData = m_pCache->base().m_ports.at(iPort);
    419             /* Get new parallel data from the cache: */
    420             const UIDataSettingsMachineParallelPort &newPortData = m_pCache->data().m_ports.at(iPort);
    421 
    422             /* Make sure port data was changed: */
    423             if (newPortData != oldPortData)
    424             {
    425                 /* Check if port still valid: */
    426                 CParallelPort comPort = m_machine.GetParallelPort(iPort);
    427                 /* Store new adapter data: */
    428                 if (!comPort.isNull())
    429                 {
    430                     /* Whether the port is enabled: */
    431                     if (   comPort.isOk()
    432                         && newPortData.m_fPortEnabled != oldPortData.m_fPortEnabled)
    433                         comPort.SetEnabled(newPortData.m_fPortEnabled);
    434                     /* Port IRQ: */
    435                     if (   comPort.isOk()
    436                         && newPortData.m_uIRQ != oldPortData.m_uIRQ)
    437                         comPort.SetIRQ(newPortData.m_uIRQ);
    438                     /* Port IO base: */
    439                     if (   comPort.isOk()
    440                         && newPortData.m_uIOBase != oldPortData.m_uIOBase)
    441                         comPort.SetIOBase(newPortData.m_uIOBase);
    442                     /* Port path: */
    443                     if (   comPort.isOk()
    444                         && newPortData.m_strPath != oldPortData.m_strPath)
    445                         comPort.SetPath(newPortData.m_strPath);
    446                 }
    447             }
    448         }
    449     }
     412    /* Update parallel data and failing state: */
     413    setFailed(!saveParallelData());
    450414
    451415    /* Upload machine to data: */
     
    589553}
    590554
     555bool UIMachineSettingsParallelPage::saveParallelData()
     556{
     557    /* Prepare result: */
     558    bool fSuccess = true;
     559    /* Save parallel settings from the cache: */
     560    if (fSuccess && isMachineInValidMode() && m_pCache->wasChanged())
     561    {
     562        /* For each port: */
     563        for (int iSlot = 0; fSuccess && iSlot < m_pTabWidget->count(); ++iSlot)
     564            fSuccess = savePortData(iSlot);
     565    }
     566    /* Return result: */
     567    return fSuccess;
     568}
     569
     570bool UIMachineSettingsParallelPage::savePortData(int iPort)
     571{
     572    /* Prepare result: */
     573    bool fSuccess = true;
     574    /* Save adapter settings from the cache: */
     575    if (fSuccess)
     576    {
     577        /* Get old parallel data from the cache: */
     578        const UIDataSettingsMachineParallelPort &oldPortData = m_pCache->base().m_ports.at(iPort);
     579        /* Get new parallel data from the cache: */
     580        const UIDataSettingsMachineParallelPort &newPortData = m_pCache->data().m_ports.at(iPort);
     581
     582        /* Make sure port data was changed: */
     583        if (newPortData != oldPortData)
     584        {
     585            /* Get parallel port for further activities: */
     586            CParallelPort comPort = m_machine.GetParallelPort(iPort);
     587            fSuccess = m_machine.isOk() && comPort.isNotNull();
     588            /* Show error message if necessary: */
     589            if (!fSuccess)
     590                msgCenter().cannotSaveParallelSettings(m_machine, this);
     591
     592            /* Save whether the port is enabled: */
     593            if (fSuccess && isMachineOffline() && newPortData.m_fPortEnabled != oldPortData.m_fPortEnabled)
     594            {
     595                comPort.SetEnabled(newPortData.m_fPortEnabled);
     596                fSuccess = comPort.isOk();
     597            }
     598            /* Save port IRQ: */
     599            if (fSuccess && isMachineOffline() && newPortData.m_uIRQ != oldPortData.m_uIRQ)
     600            {
     601                comPort.SetIRQ(newPortData.m_uIRQ);
     602                fSuccess = comPort.isOk();
     603            }
     604            /* Save port IO base: */
     605            if (fSuccess && isMachineOffline() && newPortData.m_uIOBase != oldPortData.m_uIOBase)
     606            {
     607                comPort.SetIOBase(newPortData.m_uIOBase);
     608                fSuccess = comPort.isOk();
     609            }
     610            /* Save port path: */
     611            if (fSuccess && isMachineOffline() && newPortData.m_strPath != oldPortData.m_strPath)
     612            {
     613                comPort.SetPath(newPortData.m_strPath);
     614                fSuccess = comPort.isOk();
     615            }
     616            /* Show error message if necessary: */
     617            if (!fSuccess)
     618                msgCenter().cannotSaveParallelPortSettings(comPort, this);
     619        }
     620    }
     621    /* Return result: */
     622    return fSuccess;
     623}
     624
    591625# include "UIMachineSettingsParallel.moc"
    592626
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.h

    r66365 r66501  
    7777    void cleanup();
    7878
     79    /** Saves existing parallel data from the cache. */
     80    bool saveParallelData();
     81    /** Saves existing port data from the cache. */
     82    bool savePortData(int iPort);
     83
    7984    /** Holds the tab-widget instance. */
    8085    QITabWidget *m_pTabWidget;
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