VirtualBox

Changeset 47944 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Aug 21, 2013 7:36:55 AM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Settings Dialog: Reworking validation mechanism to reflect all the validation warnings.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp

    r47895 r47944  
    297297    /* Perform page revalidation: */
    298298    UISettingsPage *pSettingsPage = pValidator->page();
    299     QString strPageTitle = m_pSelector->itemTextByPage(pSettingsPage);
    300     QString strMessageText;
    301     bool fIsValid = pSettingsPage->validate(strMessageText, strPageTitle);
     299    QList<UIValidationMessage> messages;
     300    bool fIsValid = pSettingsPage->validate(messages);
    302301
    303302    /* Remember revalidation result: */
     
    305304
    306305    /* Remember warning/error message: */
    307     if (strMessageText.isEmpty())
     306    if (messages.isEmpty())
    308307        pValidator->setLastMessage(QString());
    309308    else
    310309    {
    311         pValidator->setLastMessage(tr("<b>%1</b> page:<br><br>%2").arg(strPageTitle, strMessageText));
     310        /* Prepare title prefix: */
     311        // Its the only thing preventing us from moving this method to validator.
     312        const QString strTitlePrefix(m_pSelector->itemTextByPage(pSettingsPage));
     313        /* Prepare text: */
     314        QStringList text;
     315        foreach (const UIValidationMessage &message, messages)
     316        {
     317            /* Prepare title: */
     318            const QString strTitle(message.first.isNull() ? tr("<b>%1</b> page:").arg(strTitlePrefix) :
     319                                                            tr("<b>%1: %2</b> page:").arg(strTitlePrefix, message.first));
     320            /* Prepare paragraph: */
     321            QStringList paragraph(message.second);
     322            paragraph.prepend(strTitle);
     323            /* Format text for iterated message: */
     324            text << paragraph.join("<br>");
     325        }
     326        /* Remember text: */
     327        pValidator->setLastMessage(text.join("<br><br>"));
    312328        LogRel(("Settings Dialog:  Page validation FAILED: {%s}\n",
    313329                pValidator->lastMessage().toUtf8().constData()));
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsPage.h

    r47595 r47944  
    7272Q_DECLARE_METATYPE(UISettingsDataMachine);
    7373
     74/* Validation message type: */
     75typedef QPair<QString, QStringList> UIValidationMessage;
     76
    7477/* Settings page base class: */
    7578class UISettingsPage : public QIWithRetranslateUI<QWidget>
     
    9699    void setValidator(UIPageValidator *pValidator);
    97100    void setValidatorBlocked(bool fIsValidatorBlocked) { m_fIsValidatorBlocked = fIsValidatorBlocked; }
    98     virtual bool validate(QString& /* strWarningText */, QString& /* strTitle */) { return true; }
     101    virtual bool validate(QList<UIValidationMessage>& /* messages */) { return true; }
    99102
    100103    /* Navigation stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp

    r47895 r47944  
    161161}
    162162
    163 bool UIGlobalSettingsInput::validate(QString &strWarning, QString &strTitle)
    164 {
    165     /* Check for unique shortcuts: */
     163bool UIGlobalSettingsInput::validate(QList<UIValidationMessage> &messages)
     164{
     165    /* Pass by default: */
     166    bool fPass = true;
     167
     168    /* Check VirtualBox Manager page for unique shortcuts: */
    166169    if (!m_pSelectorModel->isAllShortcutsUnique())
    167170    {
    168         strTitle += ": " + VBoxGlobal::removeAccelMark(m_pTabWidget->tabText(UIHotKeyTableIndex_Selector));
    169         strWarning = tr("Some items have the same shortcuts assigned.");
    170         return false;
    171     }
    172     else if (!m_pMachineModel->isAllShortcutsUnique())
    173     {
    174         strTitle += ": " + VBoxGlobal::removeAccelMark(m_pTabWidget->tabText(UIHotKeyTableIndex_Machine));
    175         strWarning = tr("Some items have the same shortcuts assigned.");
    176         return false;
    177     }
    178 
    179     /* Pass by default: */
    180     return true;
     171        UIValidationMessage message;
     172        message.first = VBoxGlobal::removeAccelMark(m_pTabWidget->tabText(UIHotKeyTableIndex_Selector));
     173        message.second << tr("Some items have the same shortcuts assigned.");
     174        messages << message;
     175        fPass = false;
     176    }
     177
     178    /* Check Virtual Machine page for unique shortcuts: */
     179    if (!m_pMachineModel->isAllShortcutsUnique())
     180    {
     181        UIValidationMessage message;
     182        message.first = VBoxGlobal::removeAccelMark(m_pTabWidget->tabText(UIHotKeyTableIndex_Machine));
     183        message.second << tr("Some items have the same shortcuts assigned.");
     184        messages << message;
     185        fPass = false;
     186    }
     187
     188    /* Return result: */
     189    return fPass;
    181190}
    182191
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.h

    r47573 r47944  
    140140
    141141    /* API: Validation stuff: */
    142     bool validate(QString &strWarning, QString &strTitle);
     142    bool validate(QList<UIValidationMessage> &messages);
    143143
    144144    /* Helper: Navigation stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.cpp

    r47895 r47944  
    5858
    5959/* Validation stuff: */
    60 bool UIHostInterfaceItem::validate(QString &strWarning, QString&)
    61 {
     60bool UIHostInterfaceItem::validate(QList<UIValidationMessage> &messages)
     61{
     62    /* Pass by default: */
     63    bool fPass = true;
     64
     65    /* Prepare message: */
     66    UIValidationMessage message;
     67
    6268    /* Host-only interface validation: */
    6369    if (!m_data.m_interface.m_fDhcpClientEnabled)
     
    6773             QHostAddress(m_data.m_interface.m_strInterfaceAddress).protocol() != QAbstractSocket::IPv4Protocol))
    6874        {
    69             strWarning = UIGlobalSettingsNetwork::tr("The host interface <b>%1</b> does not currently have a valid IPv4 address.").arg(text(0));
    70             return false;
     75            message.second << UIGlobalSettingsNetwork::tr("The host interface <b>%1</b> does not currently have a valid IPv4 address.").arg(text(0));
     76            fPass = false;
    7177        }
    7278        if (!m_data.m_interface.m_strInterfaceMask.isEmpty() &&
     
    7480             QHostAddress(m_data.m_interface.m_strInterfaceMask).protocol() != QAbstractSocket::IPv4Protocol))
    7581        {
    76             strWarning = UIGlobalSettingsNetwork::tr("The host interface <b>%1</b> does not currently have a valid IPv4 network mask.").arg(text(0));
    77             return false;
     82            message.second << UIGlobalSettingsNetwork::tr("The host interface <b>%1</b> does not currently have a valid IPv4 network mask.").arg(text(0));
     83            fPass = false;
    7884        }
    7985        if (m_data.m_interface.m_fIpv6Supported)
     
    8389                 QHostAddress(m_data.m_interface.m_strInterfaceAddress6).protocol() != QAbstractSocket::IPv6Protocol))
    8490            {
    85                 strWarning = UIGlobalSettingsNetwork::tr("The host interface <b>%1</b> does not currently have a valid IPv6 address.").arg(text(0));
    86                 return false;
     91                message.second << UIGlobalSettingsNetwork::tr("The host interface <b>%1</b> does not currently have a valid IPv6 address.").arg(text(0));
     92                fPass = false;
    8793            }
    8894        }
     
    95101            QHostAddress(m_data.m_dhcpserver.m_strDhcpServerAddress).protocol() != QAbstractSocket::IPv4Protocol)
    96102        {
    97             strWarning = UIGlobalSettingsNetwork::tr("The host interface <b>%1</b> does not currently have a valid DHCP server address.").arg(text(0));
    98             return false;
     103            message.second << UIGlobalSettingsNetwork::tr("The host interface <b>%1</b> does not currently have a valid DHCP server address.").arg(text(0));
     104            fPass = false;
    99105        }
    100106        if (QHostAddress(m_data.m_dhcpserver.m_strDhcpServerMask) == QHostAddress::Any ||
    101107            QHostAddress(m_data.m_dhcpserver.m_strDhcpServerMask).protocol() != QAbstractSocket::IPv4Protocol)
    102108        {
    103             strWarning = UIGlobalSettingsNetwork::tr("The host interface <b>%1</b> does not currently have a valid DHCP server mask.").arg(text(0));
    104             return false;
     109            message.second << UIGlobalSettingsNetwork::tr("The host interface <b>%1</b> does not currently have a valid DHCP server mask.").arg(text(0));
     110            fPass = false;
    105111        }
    106112        if (QHostAddress(m_data.m_dhcpserver.m_strDhcpLowerAddress) == QHostAddress::Any ||
    107113            QHostAddress(m_data.m_dhcpserver.m_strDhcpLowerAddress).protocol() != QAbstractSocket::IPv4Protocol)
    108114        {
    109             strWarning = UIGlobalSettingsNetwork::tr("The host interface <b>%1</b> does not currently have a valid DHCP server lower address bound.").arg(text(0));
    110             return false;
     115            message.second << UIGlobalSettingsNetwork::tr("The host interface <b>%1</b> does not currently have a valid DHCP server lower address bound.").arg(text(0));
     116            fPass = false;
    111117        }
    112118        if (QHostAddress(m_data.m_dhcpserver.m_strDhcpUpperAddress) == QHostAddress::Any ||
    113119            QHostAddress(m_data.m_dhcpserver.m_strDhcpUpperAddress).protocol() != QAbstractSocket::IPv4Protocol)
    114120        {
    115             strWarning = UIGlobalSettingsNetwork::tr("The host interface <b>%1</b> does not currently have a valid DHCP server upper address bound.").arg(text(0));
    116             return false;
    117         }
    118     }
    119     return true;
     121            message.second << UIGlobalSettingsNetwork::tr("The host interface <b>%1</b> does not currently have a valid DHCP server upper address bound.").arg(text(0));
     122            fPass = false;
     123        }
     124    }
     125
     126    /* Serialize message: */
     127    if (!message.second.isEmpty())
     128        messages << message;
     129
     130    /* Return result: */
     131    return fPass;
    120132}
    121133
     
    371383
    372384/* Validation processing: */
    373 bool UIGlobalSettingsNetwork::validate(QString &strWarning, QString &strTitle)
     385bool UIGlobalSettingsNetwork::validate(QList<UIValidationMessage> &messages)
    374386{
    375387    /* Redirect validation to items: */
    376388    UIHostInterfaceItem *pItem = static_cast<UIHostInterfaceItem*>(m_pInterfacesTree->currentItem());
    377     return pItem ? pItem->validate(strWarning, strTitle) : true;
     389    return pItem ? pItem->validate(messages) : true;
    378390}
    379391
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.h

    r47573 r47944  
    9797
    9898    /* API: Validation stuff: */
    99     bool validate(QString &strWarning, QString &strTitle);
     99    bool validate(QList<UIValidationMessage> &messages);
    100100
    101101    /* API: Update stuff: */
     
    164164
    165165    /* API: Validation stuff: */
    166     bool validate(QString &strWarning, QString &strTitle);
     166    bool validate(QList<UIValidationMessage> &messages);
    167167
    168168    /* Navigation stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.cpp

    r47895 r47944  
    102102}
    103103
    104 bool UIGlobalSettingsProxy::validate(QString &strWarning, QString&)
     104bool UIGlobalSettingsProxy::validate(QList<UIValidationMessage> &messages)
    105105{
    106106    /* Pass if proxy is disabled: */
     
    108108        return true;
    109109
    110     /* Check for host/port values: */
     110    /* Pass by default: */
     111    bool fPass = true;
     112
     113    /* Prepare message: */
     114    UIValidationMessage message;
     115
     116    /* Check for host value: */
    111117    if (m_pHostEditor->text().trimmed().isEmpty())
    112118    {
    113         strWarning = tr("No proxy host is currently specified.");
    114         return false;
    115     }
    116     else if (m_pPortEditor->text().trimmed().isEmpty())
    117     {
    118         strWarning = tr("No proxy port is currently specified.");
    119         return false;
     119        message.second << tr("No proxy host is currently specified.");
     120        fPass = false;
    120121    }
    121122
    122     /* Pass by default: */
    123     return true;
     123    /* Check for port value: */
     124    if (m_pPortEditor->text().trimmed().isEmpty())
     125    {
     126        message.second << tr("No proxy port is currently specified.");
     127        fPass = false;
     128    }
     129
     130    /* Serialize message: */
     131    if (!message.second.isEmpty())
     132        messages << message;
     133
     134    /* Return result: */
     135    return fPass;
    124136}
    125137
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.h

    r47573 r47944  
    6262
    6363    /* API: Validation stuff: */
    64     bool validate(QString &strWarning, QString &strTitle);
     64    bool validate(QList<UIValidationMessage> &messages);
    6565
    6666    /* Helper: Navigation stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r47895 r47944  
    301301}
    302302
    303 bool UIMachineSettingsDisplay::validate(QString &strWarning, QString&)
     303bool UIMachineSettingsDisplay::validate(QList<UIValidationMessage> &messages)
    304304{
    305305    /* Check if video RAM requirement changed first: */
    306306    checkVRAMRequirements();
    307307
    308     if (m_pCheckbox3D->isChecked() && !vboxGlobal().is3DAvailable())
     308    /* Pass by default: */
     309    bool fPass = true;
     310
     311    /* Video tab: */
    309312    {
    310         strWarning = tr("The virtual machine is set to use hardware graphics acceleration. "
    311                         "However the host system does not currently provide this, "
    312                         "so you will not be able to start the machine.");
    313         return true;
    314     }
    315 
    316     /* Video RAM amount test: */
    317     if (shouldWeWarnAboutLowVideoMemory() && !m_guestOSType.isNull())
    318     {
    319         quint64 uNeedBytes = VBoxGlobal::requiredVideoMemory(m_guestOSType.GetId(), m_pEditorVideoScreenCount->value());
    320 
    321         /* Basic video RAM amount test: */
    322         if ((quint64)m_pEditorVideoMemorySize->value() * _1M < uNeedBytes)
     313        /* Prepare message: */
     314        UIValidationMessage message;
     315        message.first = VBoxGlobal::removeAccelMark(m_pTabWidget->tabText(0));
     316
     317        /* 3D acceleration test: */
     318        if (m_pCheckbox3D->isChecked() && !vboxGlobal().is3DAvailable())
    323319        {
    324             strWarning = tr("The virtual machine is currently assigned less than <b>%1</b> of video memory "
    325                             "which is the minimum amount required to switch to fullscreen or seamless mode.")
    326                             .arg(vboxGlobal().formatSize(uNeedBytes, 0, FormatSize_RoundUp));
    327             return true;
     320            message.second << tr("The virtual machine is set to use hardware graphics acceleration. "
     321                                 "However the host system does not currently provide this, "
     322                                 "so you will not be able to start the machine.");
    328323        }
    329 #ifdef VBOX_WITH_VIDEOHWACCEL
    330         /* 2D acceleration video RAM amount test: */
    331         if (m_pCheckbox2DVideo->isChecked() && m_f2DVideoAccelerationSupported)
     324
     325        /* Video RAM amount test: */
     326        if (shouldWeWarnAboutLowVideoMemory() && !m_guestOSType.isNull())
    332327        {
    333             uNeedBytes += VBoxGlobal::required2DOffscreenVideoMemory();
     328            quint64 uNeedBytes = VBoxGlobal::requiredVideoMemory(m_guestOSType.GetId(), m_pEditorVideoScreenCount->value());
     329
     330            /* Basic video RAM amount test: */
    334331            if ((quint64)m_pEditorVideoMemorySize->value() * _1M < uNeedBytes)
    335332            {
    336                 strWarning = tr("The virtual machine is currently assigned less than <b>%1</b> of video memory "
    337                                 "which is the minimum amount required for High Definition Video to be played efficiently.")
    338                                 .arg(vboxGlobal().formatSize(uNeedBytes, 0, FormatSize_RoundUp));
    339                 return true;
     333                message.second << tr("The virtual machine is currently assigned less than <b>%1</b> of video memory "
     334                                     "which is the minimum amount required to switch to fullscreen or seamless mode.")
     335                                     .arg(vboxGlobal().formatSize(uNeedBytes, 0, FormatSize_RoundUp));
    340336            }
    341         }
     337#ifdef VBOX_WITH_VIDEOHWACCEL
     338            /* 2D acceleration video RAM amount test: */
     339            else if (m_pCheckbox2DVideo->isChecked() && m_f2DVideoAccelerationSupported)
     340            {
     341                uNeedBytes += VBoxGlobal::required2DOffscreenVideoMemory();
     342                if ((quint64)m_pEditorVideoMemorySize->value() * _1M < uNeedBytes)
     343                {
     344                    message.second << tr("The virtual machine is currently assigned less than <b>%1</b> of video memory "
     345                                         "which is the minimum amount required for High Definition Video to be played efficiently.")
     346                                         .arg(vboxGlobal().formatSize(uNeedBytes, 0, FormatSize_RoundUp));
     347                }
     348            }
    342349#endif /* VBOX_WITH_VIDEOHWACCEL */
    343350#if 0
    344351# ifdef VBOX_WITH_CRHGSMI
    345         if (m_pCheckbox3D->isChecked() && m_fWddmModeSupported)
    346         {
    347             int cGuestScreenCount = m_pEditorVideoScreenCount->value();
    348             uNeedBytes += VBoxGlobal::required3DWddmOffscreenVideoMemory(m_guestOSType.GetId(), cGuestScreenCount);
    349             uNeedBytes = qMax(uNeedBytes, 128 * _1M);
    350             uNeedBytes = qMin(uNeedBytes, 256 * _1M);
    351             if ((quint64)m_pEditorVideoMemorySize->value() * _1M < uNeedBytes)
     352            /* 3D acceleration video RAM amount test: */
     353            else if (m_pCheckbox3D->isChecked() && m_fWddmModeSupported)
    352354            {
    353                 strWarning = tr("The virtual machine is set to use hardware graphics acceleration "
    354                                 "and the operating system hint is set to Windows Vista or later. "
    355                                 "For best performance you should set the machine's video memory to at least b>%1</b>.")
    356                                 .arg(vboxGlobal().formatSize(uNeedBytes, 0, FormatSize_RoundUp));
    357                 return true;
     355                int cGuestScreenCount = m_pEditorVideoScreenCount->value();
     356                uNeedBytes += VBoxGlobal::required3DWddmOffscreenVideoMemory(m_guestOSType.GetId(), cGuestScreenCount);
     357                uNeedBytes = qMax(uNeedBytes, 128 * _1M);
     358                uNeedBytes = qMin(uNeedBytes, 256 * _1M);
     359                if ((quint64)m_pEditorVideoMemorySize->value() * _1M < uNeedBytes)
     360                {
     361                    message.second << tr("The virtual machine is set to use hardware graphics acceleration "
     362                                         "and the operating system hint is set to Windows Vista or later. "
     363                                         "For best performance you should set the machine's video memory to at least b>%1</b>.")
     364                                         .arg(vboxGlobal().formatSize(uNeedBytes, 0, FormatSize_RoundUp));
     365                }
    358366            }
    359         }
    360367# endif /* VBOX_WITH_CRHGSMI */
    361368#endif /* 0 */
     369        }
     370
     371#ifdef VBOX_WITH_VIDEOHWACCEL
     372        /* 2D video acceleration is available for Windows guests only: */
     373        if (m_pCheckbox2DVideo->isChecked() && !m_f2DVideoAccelerationSupported)
     374        {
     375            message.second << tr("The virtual machine is set to use Video Stream Acceleration. "
     376                                 "As this feature only works with Windows guest systems it will be disabled.");
     377        }
     378#endif /* VBOX_WITH_VIDEOHWACCEL */
     379
     380        /* Serialize message: */
     381        if (!message.second.isEmpty())
     382            messages << message;
    362383    }
    363384
    364     /* Check mode availability: */
    365 #ifdef VBOX_WITH_VIDEOHWACCEL
    366     /* 2D video acceleration is available for Windows guests only: */
    367     if (m_pCheckbox2DVideo->isChecked() && !m_f2DVideoAccelerationSupported)
     385    /* Remote Display tab: */
    368386    {
    369         strWarning = tr("The virtual machine is set to use Video Stream Acceleration. "
    370                         "As this feature only works with Windows guest systems it will be disabled.");
    371         return true;
     387        /* Prepare message: */
     388        UIValidationMessage message;
     389        message.first = VBoxGlobal::removeAccelMark(m_pTabWidget->tabText(1));
     390
     391        /* Check VRDE server port: */
     392        if (m_pEditorRemoteDisplayPort->text().trimmed().isEmpty())
     393        {
     394            message.second << tr("The VRDE server port value is not currently specified.");
     395            fPass = false;
     396        }
     397
     398        /* Check VRDE server timeout: */
     399        if (m_pEditorRemoteDisplayTimeout->text().trimmed().isEmpty())
     400        {
     401            message.second << tr("The VRDE authentication timeout value is not currently specified.");
     402            fPass = false;
     403        }
     404
     405        /* Serialize message: */
     406        if (!message.second.isEmpty())
     407            messages << message;
    372408    }
    373 #endif /* VBOX_WITH_VIDEOHWACCEL */
    374 
    375     /* Check VRDE server port: */
    376     if (m_pEditorRemoteDisplayPort->text().trimmed().isEmpty())
    377     {
    378         strWarning = tr("The VRDE server port value is not currently specified.");
    379         return false;
    380     }
    381 
    382     /* Check VRDE server timeout: */
    383     if (m_pEditorRemoteDisplayTimeout->text().trimmed().isEmpty())
    384     {
    385         strWarning = tr("The VRDE authentication timeout value is not currently specified.");
    386         return false;
    387     }
    388 
    389     /* Pass by default: */
    390     return true;
     409
     410    /* Return result: */
     411    return fPass;
    391412}
    392413
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.h

    r47573 r47944  
    146146
    147147    /* API: Validation stuff: */
    148     bool validate(QString &strWarning, QString &strTitle);
     148    bool validate(QList<UIValidationMessage> &messages);
    149149
    150150    /* Helper: Navigation stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp

    r47895 r47944  
    224224}
    225225
    226 bool UIMachineSettingsGeneral::validate(QString &strWarning, QString&)
    227 {
     226bool UIMachineSettingsGeneral::validate(QList<UIValidationMessage> &messages)
     227{
     228    /* Pass by default: */
     229    bool fPass = true;
     230
     231    /* Prepare message: */
     232    UIValidationMessage message;
     233    message.first = VBoxGlobal::removeAccelMark(mTwGeneral->tabText(0));
     234
    228235    /* VM name validation: */
    229236    if (m_pNameAndSystemEditor->name().trimmed().isEmpty())
    230237    {
    231         strWarning = tr("No name specified for the virtual machine.");
    232         return false;
     238        message.second << tr("No name specified for the virtual machine.");
     239        fPass = false;
    233240    }
    234241
     
    236243    if (is64BitOSTypeSelected() && !m_fHWVirtExEnabled)
    237244    {
    238         strWarning = tr("The virtual machine operating system hint is set to a 64-bit type. "
    239                         "64-bit guest systems require hardware virtualization, "
    240                         "so this will be enabled automatically if you confirm the changes.");
    241         return true;
     245        message.second << tr("The virtual machine operating system hint is set to a 64-bit type. "
     246                             "64-bit guest systems require hardware virtualization, "
     247                             "so this will be enabled automatically if you confirm the changes.");
    242248    }
    243249
    244     /* Pass by default: */
    245     return true;
     250    /* Serialize message: */
     251    if (!message.second.isEmpty())
     252        messages << message;
     253
     254    /* Return result: */
     255    return fPass;
    246256}
    247257
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.h

    r47573 r47944  
    107107
    108108    /* API: Validation stuff: */
    109     bool validate(QString &strWarning, QString &strTitle);
     109    bool validate(QList<UIValidationMessage> &messages);
    110110
    111111    void setOrderAfter (QWidget *aWidget);
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp

    r47895 r47944  
    163163}
    164164
    165 bool UIMachineSettingsNetwork::validate(QString &strWarning, QString &strTitle)
     165bool UIMachineSettingsNetwork::validate(QList<UIValidationMessage> &messages)
    166166{
    167167    /* Pass if adapter is disabled: */
     
    169169        return true;
    170170
     171    /* Pass by default: */
     172    bool fPass = true;
     173
     174    /* Prepare message: */
     175    UIValidationMessage message;
     176    message.first = vboxGlobal().removeAccelMark(tabTitle());
     177
    171178    /* Validate alternatives: */
    172     bool fValid = true;
    173179    switch (attachmentType())
    174180    {
     
    177183            if (alternativeName().isNull())
    178184            {
    179                 strWarning = tr("No bridged network adapter is currently selected.");
    180                 fValid = false;
     185                message.second << tr("No bridged network adapter is currently selected.");
     186                fPass = false;
    181187            }
    182188            break;
     
    186192            if (alternativeName().isNull())
    187193            {
    188                 strWarning = tr("No internal network name is currently specified.");
    189                 fValid = false;
     194                message.second << tr("No internal network name is currently specified.");
     195                fPass = false;
    190196            }
    191197            break;
     
    195201            if (alternativeName().isNull())
    196202            {
    197                 strWarning = tr("No host-only network adapter is currently selected.");
    198                 fValid = false;
     203                message.second << tr("No host-only network adapter is currently selected.");
     204                fPass = false;
    199205            }
    200206            break;
     
    204210            if (alternativeName().isNull())
    205211            {
    206                 strWarning = tr("No generic driver is currently selected.");
    207                 fValid = false;
     212                message.second << tr("No generic driver is currently selected.");
     213                fPass = false;
    208214            }
    209215            break;
     
    214220
    215221    /* Validate MAC-address length: */
    216     if (fValid && m_pMACEditor->text().size() < 12)
    217     {
    218         strWarning = tr("The MAC address must be 12 hexadecimal digits long.");
    219         fValid = false;
    220     }
     222    if (m_pMACEditor->text().size() < 12)
     223    {
     224        message.second << tr("The MAC address must be 12 hexadecimal digits long.");
     225        fPass = false;
     226    }
     227
    221228    /* Make sure MAC-address is unicast: */
    222     if (fValid && m_pMACEditor->text().size() >= 2)
     229    if (m_pMACEditor->text().size() >= 2)
    223230    {
    224231        QRegExp validator("^[0-9A-Fa-f][02468ACEace]");
    225232        if (validator.indexIn(m_pMACEditor->text()) != 0)
    226233        {
    227             strWarning = tr("The second digit in the MAC address may not be odd as only unicast addresses are allowed.");
    228             fValid = false;
    229         }
    230     }
    231 
    232     if (!fValid)
    233         strTitle += ": " + vboxGlobal().removeAccelMark(tabTitle());
    234 
    235     return fValid;
     234            message.second << tr("The second digit in the MAC address may not be odd as only unicast addresses are allowed.");
     235            fPass = false;
     236        }
     237    }
     238
     239    /* Serialize message: */
     240    if (!message.second.isEmpty())
     241        messages << message;
     242
     243    /* Return result: */
     244    return fPass;
    236245}
    237246
     
    938947}
    939948
    940 bool UIMachineSettingsNetworkPage::validate(QString &strWarning, QString &strTitle)
     949bool UIMachineSettingsNetworkPage::validate(QList<UIValidationMessage> &messages)
    941950{
    942951    /* Pass by default: */
    943952    bool fValid = true;
    944953
    945     /* Delegate validation to adapters: */
     954    /* Delegate validation to adapter tabs: */
    946955    for (int i = 0; i < m_pTwAdapters->count(); ++i)
    947956    {
    948957        UIMachineSettingsNetwork *pTab = qobject_cast<UIMachineSettingsNetwork*>(m_pTwAdapters->widget(i));
    949         Assert(pTab);
    950         fValid = pTab->validate(strWarning, strTitle);
    951         if (!fValid)
    952             break;
    953     }
    954 
     958        AssertMsg(pTab, ("Can't get adapter tab!\n"));
     959        if (!pTab->validate(messages))
     960            fValid = false;
     961    }
     962
     963    /* Return result: */
    955964    return fValid;
    956965}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.h

    r47573 r47944  
    110110
    111111    /* API: Validation stuff: */
    112     bool validate(QString &strWarning, QString &strTitle);
     112    bool validate(QList<UIValidationMessage> &messages);
    113113
    114114    /* Navigation stuff: */
     
    207207
    208208    /* API: Validation stuff: */
    209     bool validate(QString &strWarning, QString &strTitle);
     209    bool validate(QList<UIValidationMessage> &messages);
    210210
    211211    /* Translation stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.cpp

    r47895 r47944  
    325325}
    326326
    327 bool UIMachineSettingsParallelPage::validate(QString &strWarning, QString &strTitle)
    328 {
    329     bool valid = true;
     327bool UIMachineSettingsParallelPage::validate(QList<UIValidationMessage> &messages)
     328{
     329    /* Pass by default: */
     330    bool fPass = true;
     331
     332    /* Validation stuff: */
    330333    QList<QPair<QString, QString> > ports;
    331334    QStringList paths;
    332335
    333     int index = 0;
    334     for (; index < mTabWidget->count(); ++ index)
    335     {
    336         QWidget *tab = mTabWidget->widget (index);
    337         UIMachineSettingsParallel *page =
    338             static_cast<UIMachineSettingsParallel*> (tab);
    339 
    340         if (!page->mGbParallel->isChecked())
     336    /* Validate all the ports: */
     337    for (int iIndex = 0; iIndex < mTabWidget->count(); ++iIndex)
     338    {
     339        /* Get current tab/page: */
     340        QWidget *pTab = mTabWidget->widget(iIndex);
     341        UIMachineSettingsParallel *pPage = static_cast<UIMachineSettingsParallel*> (pTab);
     342        if (!pPage->mGbParallel->isChecked())
    341343            continue;
    342344
    343         /* Check the predefined port attributes uniqueness: */
    344         {
    345             QString strIRQ = page->mLeIRQ->text();
    346             QString strIOPort = page->mLeIOPort->text();
    347             QPair<QString, QString> pair(strIRQ, strIOPort);
    348             valid = !strIRQ.isEmpty() && !strIOPort.isEmpty() && !ports.contains(pair);
    349             if (!valid)
    350             {
    351                 if (strIRQ.isEmpty())
    352                     strWarning = tr("No IRQ is currently specified.");
    353                 else if (strIOPort.isEmpty())
    354                     strWarning = tr("No I/O port is currently specified.");
    355                 else
    356                     strWarning = tr("Two or more ports have the same settings.");
    357                 strTitle += ": " +
    358                     vboxGlobal().removeAccelMark(mTabWidget->tabText(mTabWidget->indexOf(tab)));
    359             }
    360             ports << pair;
    361         }
    362 
    363         /* Check the port path emptiness & unicity */
    364         {
    365             QString path = page->mLePath->text();
    366             valid = !path.isEmpty() && !paths.contains (path);
    367             if (!valid)
    368             {
    369                 strWarning = path.isEmpty() ?
    370                     tr("No port path is currently specified.") :
    371                     tr("There are currently duplicate port paths specified.");
    372                 strTitle += ": " +
    373                     vboxGlobal().removeAccelMark (mTabWidget->tabText (mTabWidget->indexOf (tab)));
    374                 break;
    375             }
    376             paths << path;
    377         }
    378     }
    379 
    380     return valid;
     345        /* Prepare message: */
     346        UIValidationMessage message;
     347        message.first = vboxGlobal().removeAccelMark(mTabWidget->tabText(mTabWidget->indexOf(pTab)));
     348
     349        /* Check the port attribute emptiness & uniqueness: */
     350        const QString strIRQ(pPage->mLeIRQ->text());
     351        const QString strIOPort(pPage->mLeIOPort->text());
     352        const QString strPath(pPage->mLePath->text());
     353        QPair<QString, QString> pair(strIRQ, strIOPort);
     354
     355        if (strIRQ.isEmpty())
     356        {
     357            message.second << tr("No IRQ is currently specified.");
     358            fPass = false;
     359        }
     360        if (strIOPort.isEmpty())
     361        {
     362            message.second << tr("No I/O port is currently specified.");
     363            fPass = false;
     364        }
     365        if (ports.contains(pair))
     366        {
     367            message.second << tr("Two or more ports have the same settings.");
     368            fPass = false;
     369        }
     370        if (strPath.isEmpty())
     371        {
     372            message.second << tr("No port path is currently specified.");
     373            fPass = false;
     374        }
     375        if (paths.contains(strPath))
     376        {
     377            message.second << tr("There are currently duplicate port paths specified.");
     378            fPass = false;
     379        }
     380
     381        ports << pair;
     382        paths << strPath;
     383
     384        /* Serialize message: */
     385        if (!message.second.isEmpty())
     386            messages << message;
     387    }
     388
     389    /* Return result: */
     390    return fPass;
    381391}
    382392
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.h

    r47573 r47944  
    136136
    137137    /* API: Validation stuff: */
    138     bool validate(QString &strWarning, QString &strTitle);
     138    bool validate(QList<UIValidationMessage> &messages);
    139139
    140140    void retranslateUi();
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.cpp

    r47895 r47944  
    368368}
    369369
    370 bool UIMachineSettingsSerialPage::validate(QString &strWarning, QString &strTitle)
    371 {
    372     bool valid = true;
     370bool UIMachineSettingsSerialPage::validate(QList<UIValidationMessage> &messages)
     371{
     372    /* Pass by default: */
     373    bool fPass = true;
     374
     375    /* Validation stuff: */
    373376    QList<QPair<QString, QString> > ports;
    374377    QStringList paths;
    375378
    376     int index = 0;
    377     for (; index < mTabWidget->count(); ++ index)
    378     {
    379         QWidget *tab = mTabWidget->widget (index);
    380         UIMachineSettingsSerial *page =
    381             static_cast<UIMachineSettingsSerial*> (tab);
    382 
     379    /* Validate all the ports: */
     380    for (int iIndex = 0; iIndex < mTabWidget->count(); ++iIndex)
     381    {
     382        /* Get current tab/page: */
     383        QWidget *pTab = mTabWidget->widget(iIndex);
     384        UIMachineSettingsSerial *page = static_cast<UIMachineSettingsSerial*>(pTab);
    383385        if (!page->mGbSerial->isChecked())
    384386            continue;
    385387
    386         /* Check the predefined port attributes uniqueness: */
    387         {
    388             QString strIRQ = page->mLeIRQ->text();
    389             QString strIOPort = page->mLeIOPort->text();
    390             QPair<QString, QString> pair(strIRQ, strIOPort);
    391             valid = !strIRQ.isEmpty() && !strIOPort.isEmpty() && !ports.contains(pair);
    392             if (!valid)
     388        /* Prepare message: */
     389        UIValidationMessage message;
     390        message.first = vboxGlobal().removeAccelMark(mTabWidget->tabText(mTabWidget->indexOf(pTab)));
     391
     392        /* Check the port attribute emptiness & uniqueness: */
     393        const QString strIRQ(page->mLeIRQ->text());
     394        const QString strIOPort(page->mLeIOPort->text());
     395        QPair<QString, QString> pair(strIRQ, strIOPort);
     396
     397        if (strIRQ.isEmpty())
     398        {
     399            message.second << tr("No IRQ is currently specified.");
     400            fPass = false;
     401        }
     402        if (strIOPort.isEmpty())
     403        {
     404            message.second << tr("No I/O port is currently specified.");
     405            fPass = false;
     406        }
     407        if (ports.contains(pair))
     408        {
     409            message.second << tr("Two or more ports have the same settings.");
     410            fPass = false;
     411        }
     412
     413        ports << pair;
     414
     415        KPortMode mode = gpConverter->fromString<KPortMode>(page->mCbMode->currentText());
     416        if (mode != KPortMode_Disconnected)
     417        {
     418            const QString strPath(page->mLePath->text());
     419
     420            if (strPath.isEmpty())
    393421            {
    394                 if (strIRQ.isEmpty())
    395                     strWarning = tr("No IRQ is currently specified.");
    396                 else if (strIOPort.isEmpty())
    397                     strWarning = tr("No I/O port is currently specified.");
    398                 else
    399                     strWarning = tr("Two or more ports have the same settings.");
    400                 strTitle += ": " +
    401                     vboxGlobal().removeAccelMark(mTabWidget->tabText(mTabWidget->indexOf(tab)));
     422                message.second << tr("No port path is currently specified.");
     423                fPass = false;
    402424            }
    403             ports << pair;
    404         }
    405 
    406         /* Check the port path emptiness & unicity */
    407         KPortMode mode =
    408             gpConverter->fromString<KPortMode> (page->mCbMode->currentText());
    409         if (mode != KPortMode_Disconnected)
    410         {
    411             QString path = page->mLePath->text();
    412             valid = !path.isEmpty() && !paths.contains (path);
    413             if (!valid)
     425            if (paths.contains(strPath))
    414426            {
    415                 if (!page->mGbSerial->isChecked())
    416                     page->mCbMode->setCurrentIndex (KPortMode_Disconnected);
    417                 else
    418                 {
    419                     strWarning = path.isEmpty() ?
    420                         tr("No port path is currently specified.") :
    421                         tr("There are currently duplicate port paths specified.");
    422                     strTitle += ": " +
    423                         vboxGlobal().removeAccelMark (mTabWidget->tabText (mTabWidget->indexOf (tab)));
    424                     break;
    425                 }
     427                message.second << tr("There are currently duplicate port paths specified.");
     428                fPass = false;
    426429            }
    427             paths << path;
    428         }
    429     }
    430 
    431     return valid;
     430
     431            paths << strPath;
     432        }
     433
     434        /* Serialize message: */
     435        if (!message.second.isEmpty())
     436            messages << message;
     437    }
     438
     439    /* Return result: */
     440    return fPass;
    432441}
    433442
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.h

    r47573 r47944  
    143143
    144144    /* API: Validation stuff: */
    145     bool validate(QString &strWarning, QString &strTitle);
     145    bool validate(QList<UIValidationMessage> &messages);
    146146
    147147    void retranslateUi();
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r47895 r47944  
    21042104}
    21052105
    2106 bool UIMachineSettingsStorage::validate(QString &strWarning, QString&)
    2107 {
     2106bool UIMachineSettingsStorage::validate(QList<UIValidationMessage> &messages)
     2107{
     2108    /* Pass by default: */
     2109    bool fPass = true;
     2110
     2111    /* Prepare message: */
     2112    UIValidationMessage message;
     2113
    21082114    /* Check controllers for name emptiness & coincidence.
    21092115     * Check attachments for the hd presence / uniqueness. */
     
    21162122        QModelIndex ctrIndex = rootIndex.child (i, 0);
    21172123        QString ctrName = mStorageModel->data (ctrIndex, StorageModel::R_CtrName).toString();
     2124
    21182125        /* Check for name emptiness: */
    21192126        if (ctrName.isEmpty())
    21202127        {
    2121             strWarning = tr("No name is currently specified for the controller at position <b>%1</b>.").arg(i + 1);
    2122             return false;
     2128            message.second << tr("No name is currently specified for the controller at position <b>%1</b>.").arg(i + 1);
     2129            fPass = false;
    21232130        }
    21242131        /* Check for name coincidence: */
    21252132        if (names.values().contains(ctrName))
    21262133        {
    2127             strWarning = tr("The controller at position <b>%1</b> has the same name as the controller at position <b>%2</b>.")
    2128                             .arg(i + 1).arg(names.key(ctrName) + 1);
    2129             return false;
    2130         }
    2131         else names.insert(i, ctrName);
     2134            message.second << tr("The controller at position <b>%1</b> has the same name as the controller at position <b>%2</b>.")
     2135                                 .arg(i + 1).arg(names.key(ctrName) + 1);
     2136            fPass = false;
     2137        }
     2138        else
     2139            names.insert(i, ctrName);
     2140
    21322141        /* For each attachment: */
    21332142        for (int j = 0; j < mStorageModel->rowCount (ctrIndex); ++ j)
     
    21382147            QString key (mStorageModel->data (attIndex, StorageModel::R_AttMediumId).toString());
    21392148            QString value (QString ("%1 (%2)").arg (ctrName, gpConverter->toString (attSlot)));
    2140             /* Check for emptiness */
     2149            /* Check for emptiness: */
    21412150            if (vboxGlobal().findMedium (key).isNull() && attDevice == KDeviceType_HardDisk)
    21422151            {
    2143                 strWarning = tr("No hard disk is selected for <i>%1</i>.").arg (value);
    2144                 return false;
     2152                message.second << tr("No hard disk is selected for <i>%1</i>.").arg (value);
     2153                fPass = false;
    21452154            }
    2146             /* Check for coincidence */
     2155            /* Check for coincidence: */
    21472156            if (!vboxGlobal().findMedium (key).isNull() && config.contains (key))
    21482157            {
    2149                 strWarning = tr("<i>%1</i> is using a disk that is already attached to <i>%2</i>.")
    2150                                 .arg (value).arg (config [key]);
    2151                 return false;
     2158                message.second << tr("<i>%1</i> is using a disk that is already attached to <i>%2</i>.")
     2159                                     .arg (value).arg (config [key]);
     2160                fPass = false;
    21522161            }
    2153             else config.insert (key, value);
     2162            else
     2163                config.insert (key, value);
    21542164        }
    21552165    }
     
    21732183    if (!excessiveList.isEmpty())
    21742184    {
    2175         strWarning = tr("The machine currently has more storage controllers assigned than a %1 chipset supports. "
    2176                         "Please change the chipset type on the System settings page or reduce the number "
    2177                         "of the following storage controllers on the Storage settings page: %2")
    2178                         .arg(gpConverter->toString(mStorageModel->chipsetType()))
    2179                         .arg(excessiveList.join(", "));
    2180         return false;
    2181     }
    2182 
    2183     /* Pass by default: */
    2184     return true;
     2185        message.second << tr("The machine currently has more storage controllers assigned than a %1 chipset supports. "
     2186                             "Please change the chipset type on the System settings page or reduce the number "
     2187                             "of the following storage controllers on the Storage settings page: %2")
     2188                             .arg(gpConverter->toString(mStorageModel->chipsetType()))
     2189                             .arg(excessiveList.join(", "));
     2190        fPass = false;
     2191    }
     2192
     2193    /* Serialize message: */
     2194    if (!message.second.isEmpty())
     2195        messages << message;
     2196
     2197    /* Return result: */
     2198    return fPass;
    21852199}
    21862200
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h

    r47573 r47944  
    674674
    675675    /* API: Validation stuff: */
    676     bool validate(QString &strWarning, QString &strTitle);
     676    bool validate(QList<UIValidationMessage> &messages);
    677677
    678678    void retranslateUi();
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp

    r47902 r47944  
    285285}
    286286
    287 bool UIMachineSettingsSystem::validate(QString &strWarning, QString&)
    288 {
    289     /* RAM amount test: */
    290     ulong uFullSize = vboxGlobal().host().GetMemorySize();
    291     if (m_pSliderMemorySize->value() > (int)m_pSliderMemorySize->maxRAMAlw())
    292     {
    293         strWarning = tr(
    294             "More than <b>%1%</b> of the host computer's memory (<b>%2</b>) is assigned to the virtual machine. "
    295             "Not enough memory is left for the host operating system. Please select a smaller amount.")
    296             .arg((unsigned)qRound((double)m_pSliderMemorySize->maxRAMAlw() / uFullSize * 100.0))
    297             .arg(vboxGlobal().formatSize((uint64_t)uFullSize * _1M));
    298         return false;
    299     }
    300     if (m_pSliderMemorySize->value() > (int)m_pSliderMemorySize->maxRAMOpt())
    301     {
    302         strWarning = tr(
    303             "More than <b>%1%</b> of the host computer's memory (<b>%2</b>) is assigned to the virtual machine. "
    304             "There might not be enough memory left for the host operating system. Please consider selecting a smaller amount.")
    305             .arg((unsigned)qRound((double)m_pSliderMemorySize->maxRAMOpt() / uFullSize * 100.0))
    306             .arg(vboxGlobal().formatSize((uint64_t)uFullSize * _1M));
    307         return true;
    308     }
    309 
    310     /* VCPU amount test: */
    311     int cTotalCPUs = vboxGlobal().host().GetProcessorOnlineCount();
    312     if (m_pSliderCPUCount->value() > 2 * cTotalCPUs)
    313     {
    314         strWarning = tr(
    315             "For performance reasons, the number of virtual CPUs attached to the virtual machine may not be more than twice the number "
    316             "of physical CPUs on the host (<b>%1</b>). Please reduce the number of virtual CPUs.")
    317             .arg(cTotalCPUs);
    318         return false;
    319     }
    320     if (m_pSliderCPUCount->value() > cTotalCPUs)
    321     {
    322         strWarning = tr(
    323             "More virtual CPUs are assigned to the virtual machine than the number of physical CPUs on the host system (<b>%1</b>). "
    324             "This is likely to degrade the performance of your virtual machine. Please consider reducing the number of virtual CPUs.")
    325             .arg(cTotalCPUs);
    326         return true;
    327     }
    328 
    329     /* VCPU IO-APIC test: */
    330     if (m_pSliderCPUCount->value() > 1 && !m_pCheckBoxApic->isChecked())
    331     {
    332         strWarning = tr(
    333             "The IO APIC feature is not currently enabled in the Motherboard section of the System page. "
    334             "This is needed in order to support more than one virtual processor. "
    335             "It will be done automatically if you confirm your changes.");
    336         return true;
    337     }
    338 
    339     /* VCPU VT-x/AMD-V test: */
    340     if (m_pSliderCPUCount->value() > 1 && !m_pCheckBoxVirtualization->isChecked())
    341     {
    342         strWarning = tr(
    343             "Hardware virtualization is not currently enabled in the Acceleration section of the System page. "
    344             "This is needed in order to support more than one virtual processor. "
    345             "It will be done automatically if you confirm your changes.");
    346         return true;
    347     }
    348 
    349     /* CPU execution cap is low: */
    350     if (m_pSliderCPUExecCap->value() < (int)m_uMedGuestCPUExecCap)
    351     {
    352         strWarning = tr(
    353             "The processor execution cap is set to a low value. This may make the machine feel slow to respond.");
    354         return true;
    355     }
    356 
    357     /* Chipset type & IO-APIC test: */
    358     if ((KChipsetType)m_pComboChipsetType->itemData(m_pComboChipsetType->currentIndex()).toInt() == KChipsetType_ICH9 && !m_pCheckBoxApic->isChecked())
    359     {
    360         strWarning = tr(
    361             "The I/O APIC feature is not currently enabled in the Motherboard section of the System page. "
    362             "This is needed in order to support a chip set of type ICH9. "
    363             "It will be done automatically if you confirm your changes.");
    364         return true;
    365     }
    366 
    367     /* HID dependency from OHCI feature: */
    368     if (isHIDEnabled() && !m_fOHCIEnabled)
    369     {
    370         strWarning = tr(
    371             "USB controller emulation is not currently enabled on the USB page. "
    372             "This is needed to support an emulated USB input device. "
    373             "It will be done automatically if you confirm your changes.");
    374         return true;
    375     }
    376 
    377     return true;
     287bool UIMachineSettingsSystem::validate(QList<UIValidationMessage> &messages)
     288{
     289    /* Pass by default: */
     290    bool fPass = true;
     291
     292    /* Motherboard tab: */
     293    {
     294        /* Prepare message: */
     295        UIValidationMessage message;
     296        message.first = VBoxGlobal::removeAccelMark(m_pTabWidgetSystem->tabText(0));
     297
     298        /* RAM amount test: */
     299        ulong uFullSize = vboxGlobal().host().GetMemorySize();
     300        if (m_pSliderMemorySize->value() > (int)m_pSliderMemorySize->maxRAMAlw())
     301        {
     302            message.second << tr(
     303                "More than <b>%1%</b> of the host computer's memory (<b>%2</b>) is assigned to the virtual machine. "
     304                "Not enough memory is left for the host operating system. Please select a smaller amount.")
     305                .arg((unsigned)qRound((double)m_pSliderMemorySize->maxRAMAlw() / uFullSize * 100.0))
     306                .arg(vboxGlobal().formatSize((uint64_t)uFullSize * _1M));
     307            fPass = false;
     308        }
     309        else if (m_pSliderMemorySize->value() > (int)m_pSliderMemorySize->maxRAMOpt())
     310        {
     311            message.second << tr(
     312                "More than <b>%1%</b> of the host computer's memory (<b>%2</b>) is assigned to the virtual machine. "
     313                "There might not be enough memory left for the host operating system. Please consider selecting a smaller amount.")
     314                .arg((unsigned)qRound((double)m_pSliderMemorySize->maxRAMOpt() / uFullSize * 100.0))
     315                .arg(vboxGlobal().formatSize((uint64_t)uFullSize * _1M));
     316        }
     317
     318        /* Chipset type vs IO-APIC test: */
     319        if ((KChipsetType)m_pComboChipsetType->itemData(m_pComboChipsetType->currentIndex()).toInt() == KChipsetType_ICH9 && !m_pCheckBoxApic->isChecked())
     320        {
     321            message.second << tr(
     322                "The I/O APIC feature is not currently enabled in the Motherboard section of the System page. "
     323                "This is needed in order to support a chip set of type ICH9. "
     324                "It will be done automatically if you confirm your changes.");
     325        }
     326
     327        /* HID vs OHCI test: */
     328        if (isHIDEnabled() && !m_fOHCIEnabled)
     329        {
     330            message.second << tr(
     331                "USB controller emulation is not currently enabled on the USB page. "
     332                "This is needed to support an emulated USB input device. "
     333                "It will be done automatically if you confirm your changes.");
     334        }
     335
     336        /* Serialize message: */
     337        if (!message.second.isEmpty())
     338            messages << message;
     339    }
     340
     341    /* CPU tab: */
     342    {
     343        /* Prepare message: */
     344        UIValidationMessage message;
     345        message.first = VBoxGlobal::removeAccelMark(m_pTabWidgetSystem->tabText(1));
     346
     347        /* VCPU amount test: */
     348        int cTotalCPUs = vboxGlobal().host().GetProcessorOnlineCount();
     349        if (m_pSliderCPUCount->value() > 2 * cTotalCPUs)
     350        {
     351            message.second << tr(
     352                "For performance reasons, the number of virtual CPUs attached to the virtual machine may not be more than twice the number "
     353                "of physical CPUs on the host (<b>%1</b>). Please reduce the number of virtual CPUs.")
     354                .arg(cTotalCPUs);
     355            fPass = false;
     356        }
     357        else if (m_pSliderCPUCount->value() > cTotalCPUs)
     358        {
     359            message.second << tr(
     360                "More virtual CPUs are assigned to the virtual machine than the number of physical CPUs on the host system (<b>%1</b>). "
     361                "This is likely to degrade the performance of your virtual machine. Please consider reducing the number of virtual CPUs.")
     362                .arg(cTotalCPUs);
     363        }
     364
     365        /* VCPU vs IO-APIC test: */
     366        if (m_pSliderCPUCount->value() > 1 && !m_pCheckBoxApic->isChecked())
     367        {
     368            message.second << tr(
     369                "The IO APIC feature is not currently enabled in the Motherboard section of the System page. "
     370                "This is needed in order to support more than one virtual processor. "
     371                "It will be done automatically if you confirm your changes.");
     372        }
     373
     374        /* VCPU vs VT-x/AMD-V test: */
     375        if (m_pSliderCPUCount->value() > 1 && !m_pCheckBoxVirtualization->isChecked())
     376        {
     377            message.second << tr(
     378                "Hardware virtualization is not currently enabled in the Acceleration section of the System page. "
     379                "This is needed in order to support more than one virtual processor. "
     380                "It will be done automatically if you confirm your changes.");
     381        }
     382
     383        /* CPU execution cap test: */
     384        if (m_pSliderCPUExecCap->value() < (int)m_uMedGuestCPUExecCap)
     385        {
     386            message.second << tr(
     387                "The processor execution cap is set to a low value. This may make the machine feel slow to respond.");
     388        }
     389
     390        /* Serialize message: */
     391        if (!message.second.isEmpty())
     392            messages << message;
     393    }
     394
     395    /* Return result: */
     396    return fPass;
    378397}
    379398
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.h

    r47573 r47944  
    153153
    154154    /* API: Validation stuff: */
    155     bool validate(QString &strWarning, QString &strTitle);
     155    bool validate(QList<UIValidationMessage> &messages);
    156156
    157157    /* Helper: Navigation stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.cpp

    r47594 r47944  
    424424}
    425425
    426 bool UIMachineSettingsUSB::validate(QString &strWarningText, QString&)
    427 {
    428     NOREF(strWarningText);
     426bool UIMachineSettingsUSB::validate(QList<UIValidationMessage> &messages)
     427{
     428    Q_UNUSED(messages);
     429
     430    /* Pass by default: */
     431    bool fPass = true;
    429432
    430433#ifdef VBOX_WITH_EXTPACK
     
    433436    if (mGbUSB->isChecked() && mCbUSB2->isChecked() && (extPack.isNull() || !extPack.GetUsable()))
    434437    {
    435         strWarningText = tr("USB 2.0 is currently enabled for this virtual machine. "
    436                             "However, this requires the <b>%1</b> to be installed. "
    437                             "Please install the Extension Pack from the VirtualBox download site. "
    438                             "After this you will be able to re-enable USB 2.0. "
    439                             "It will be disabled in the meantime unless you cancel the current settings changes.")
    440                             .arg(GUI_ExtPackName);
     438        /* Prepare message: */
     439        UIValidationMessage message;
     440        message.second << tr("USB 2.0 is currently enabled for this virtual machine. "
     441                             "However, this requires the <b>%1</b> to be installed. "
     442                             "Please install the Extension Pack from the VirtualBox download site. "
     443                             "After this you will be able to re-enable USB 2.0. "
     444                             "It will be disabled in the meantime unless you cancel the current settings changes.")
     445                             .arg(GUI_ExtPackName);
     446        /* Serialize message: */
     447        if (!message.second.isEmpty())
     448            messages << message;
     449        /* Show message-center warning: */
    441450        msgCenter().warnAboutUnsupportedUSB2(GUI_ExtPackName, this);
     451        /* Disable USB2.0 if enabled: */
    442452        mCbUSB2->setChecked(false);
    443         return true;
    444453    }
    445454#endif /* VBOX_WITH_EXTPACK */
    446455
    447     /* Pass by default: */
    448     return true;
     456    /* Return result: */
     457    return fPass;
    449458}
    450459
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.h

    r47594 r47944  
    143143
    144144    /* API: Validation stuff: */
    145     bool validate(QString &strWarningText, QString &strTitle);
     145    bool validate(QList<UIValidationMessage> &messages);
    146146
    147147    void setOrderAfter (QWidget *aWidget);
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