VirtualBox

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


Ignore:
Timestamp:
Aug 6, 2013 1:58:47 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Settings dialog: New validation stuff: Step 1 (Initial implementation, #ifdef-ed).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIWidgetValidator.cpp

    r44528 r47559  
    2020#include "QIWidgetValidator.h"
    2121
    22 /* Qt includes */
     22#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     23
     24/* GUI includes: */
     25#include "UISettingsPage.h"
     26
     27UIPageValidator::UIPageValidator(QObject *pParent, UISettingsPage *pPage)
     28    : QObject(pParent)
     29    , m_pPage(pPage)
     30    , m_fIsValid(true)
     31{
     32}
     33
     34void UIPageValidator::revalidate()
     35{
     36    /* Notify listener(s) about validity change: */
     37    emit sigValidityChanged(this);
     38}
     39
     40#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     41
     42/* Qt includes: */
    2343#include <QLineEdit>
    2444#include <QComboBox>
    2545#include <QLabel>
    2646
     47/* GUI includes: */
     48#include "VBoxGlobal.h"
     49
     50/* Other VBox includes: */
    2751#include <iprt/assert.h>
    28 
    29 #include "VBoxGlobal.h"
    3052
    3153/** @class QIWidgetValidator
     
    355377 */
    356378
     379#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    357380
    358381/** @class QIULongValidator
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIWidgetValidator.h

    r44528 r47559  
    2020#define __QIWidgetValidator_h__
    2121
     22/* Qt includes: */
     23#include <QValidator>
     24
     25#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     26
     27/* Forward declarations: */
     28class UISettingsPage;
     29
     30/* Page validator prototype: */
     31class UIPageValidator : public QObject
     32{
     33    Q_OBJECT;
     34
     35signals:
     36
     37    /* Notifier: Validation stuff: */
     38    void sigValidityChanged(UIPageValidator *pValidator);
     39
     40public:
     41
     42    /* Constructor: */
     43    UIPageValidator(QObject *pParent, UISettingsPage *pPage);
     44
     45    /* API: Page stuff: */
     46    UISettingsPage* page() const { return m_pPage; }
     47
     48    /* API: Validity stuff: */
     49    bool isValid() const { return m_fIsValid; }
     50    void setValid(bool fIsValid) { m_fIsValid = fIsValid; }
     51
     52    /* API: Message stuff: */
     53    QString lastMessage() const { return m_strLastMessage; }
     54    void setLastMessage(const QString &strLastMessage) { m_strLastMessage = strLastMessage; }
     55
     56public slots:
     57
     58    /* API/Handler: Validation stuff: */
     59    void revalidate();
     60
     61private:
     62
     63    /* Variables: */
     64    UISettingsPage *m_pPage;
     65    bool m_fIsValid;
     66    QString m_strLastMessage;
     67};
     68
     69#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     70
     71/* General includes: */
    2272#include <limits.h>
    2373
    24 /* Qt includes */
    25 #include <QObject>
    26 #include <QValidator>
    27 #include <QList>
     74/* Qt includes: */
    2875#include <QPointer>
    2976
     
    87134    void doRevalidate() { emit validityChanged (this); }
    88135};
     136#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    89137
    90138class QIULongValidator : public QValidator
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp

    r45198 r47559  
    3535#include "UIToolBar.h"
    3636#include "UIIconPool.h"
     37#include "UIConverter.h"
    3738#ifdef Q_WS_MAC
    3839# include "VBoxUtils.h"
     
    164165}
    165166
     167#ifndef VBOX_WITH_NEW_SETTINGS_VALIDATOR
    166168void UISettingsDialog::sltRevalidate(QIWidgetValidator *pValidator)
    167169{
     
    189191    pValidator->setOtherValid(fValid);
    190192}
     193#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    191194
    192195void UISettingsDialog::sltCategoryChanged(int cId)
     
    273276#endif /* VBOX_GUI_WITH_TOOLBAR_SETTINGS */
    274277
     278#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     279    /* Retranslate all validators: */
     280    foreach (UIPageValidator *pValidator, findChildren<UIPageValidator*>())
     281        if (!pValidator->lastMessage().isEmpty())
     282            sltHandleValidityChange(pValidator);
     283#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    275284    /* Get the list of validators: */
    276285    QList<QIWidgetValidator*> validatorsList = findChildren<QIWidgetValidator*>();
     
    288297            sltRevalidate(pValidator);
    289298    }
     299#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    290300}
    291301
     
    365375        assignValidator(pSettingsPage);
    366376}
     377
     378#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     379void UISettingsDialog::revalidate(UIPageValidator *pValidator)
     380{
     381    /* Perform page revalidation: */
     382    UISettingsPage *pSettingsPage = pValidator->page();
     383    QString strPageTitle = m_pSelector->itemTextByPage(pSettingsPage);
     384    QString strMessageText;
     385    bool fIsValid = pSettingsPage->revalidate(strMessageText, strPageTitle);
     386
     387    /* Remember revalidation result: */
     388    pValidator->setValid(fIsValid);
     389
     390    /* Remember warning/error message: */
     391    if (strMessageText.isEmpty())
     392        pValidator->setLastMessage(QString());
     393    else
     394    {
     395        pValidator->setLastMessage(tr("On the <b>%1</b> page, %2").arg(strPageTitle, strMessageText));
     396        printf("UISettingsDialog:  Page validation failed!\n");
     397    }
     398}
     399
     400void UISettingsDialog::revalidate()
     401{
     402    /* Perform dialog revalidation: */
     403    m_fValid = true;
     404    m_fSilent = true;
     405
     406    /* Enumerating all the validators we have: */
     407    QList<UIPageValidator*> validators(findChildren<UIPageValidator*>());
     408    foreach (UIPageValidator *pValidator, validators)
     409    {
     410        /* Is current validator have something to say? */
     411        if (!pValidator->lastMessage().isEmpty())
     412        {
     413            /* What page is it related to? */
     414            UISettingsPage *pFailedSettingsPage = pValidator->page();
     415            printf("UISettingsDialog:  Dialog validation failed on page #%d (%s)\n"
     416//                   "Message: %s\n"
     417                   , pFailedSettingsPage->id()
     418                   , gpConverter->toInternalString((MachineSettingsPageType)pFailedSettingsPage->id()).toAscii().constData()
     419//                   , pValidator->lastMessage().toAscii().constData()
     420                   );
     421
     422            /* Show error first: */
     423            if (!pValidator->isValid())
     424            {
     425                m_fValid = false;
     426                setError(pValidator->lastMessage());
     427                m_pWarningPane->setWarningPixmap(m_errorIcon);
     428                m_pWarningPane->setWarningText(m_strErrorHint);
     429#ifdef Q_WS_MAC
     430                m_pWarningPane->setToolTip(m_strErrorString);
     431#endif /* Q_WS_MAC */
     432            }
     433            /* Show warning if message is not an error: */
     434            else
     435            {
     436                m_fSilent = false;
     437                setWarning(pValidator->lastMessage());
     438                m_pWarningPane->setWarningPixmap(m_warningIcon);
     439                m_pWarningPane->setWarningText(m_strWarningHint);
     440#ifdef Q_WS_MAC
     441                m_pWarningPane->setToolTip(m_strWarningString);
     442#endif /* Q_WS_MAC */
     443            }
     444
     445            /* Stop dialog revalidation on first error/warning: */
     446            if (!m_fValid || !m_fSilent)
     447                break;
     448        }
     449    }
     450
     451    /* Make sure message-pane visible if necessary: */
     452    if ((!m_fValid || !m_fSilent) && m_pStatusBar->currentIndex() == 0)
     453        m_pStatusBar->setCurrentWidget(m_pWarningPane);
     454    /* Make sure whats-this-pane visible otherwise: */
     455    else if (m_fValid && m_fSilent && m_pStatusBar->currentWidget() == m_pWarningPane)
     456        m_pStatusBar->setCurrentIndex(0);
     457
     458    /* Lock/unlock settings-page OK button according global validity status: */
     459    m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(m_fValid);
     460}
     461#endif /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     462
     463#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     464void UISettingsDialog::sltHandleValidityChange(UIPageValidator *pValidator)
     465{
     466    printf("UISettingsDialog: Revalidation requested.\n");
     467
     468    /* Determine which settings-page had called for revalidation: */
     469    UISettingsPage *pSettingsPage = pValidator->page();
     470    const QString strPageName(gpConverter->toInternalString((MachineSettingsPageType)pSettingsPage->id()));
     471
     472    /* Perform page revalidation: */
     473    printf("UISettingsDialog:  *%s* page revalidation in progress...\n",
     474           strPageName.toAscii().constData());
     475    revalidate(pValidator);
     476    printf("UISettingsDialog:  *%s* page revalidation complete!\n",
     477           strPageName.toAscii().constData());
     478
     479    /* Perform inter-page recorrelation: */
     480    printf("UISettingsDialog:  *%s* page recorrelation in progress...\n",
     481           strPageName.toAscii().constData());
     482    recorrelate(pSettingsPage);
     483    printf("UISettingsDialog:  *%s* page recorrelation complete!\n",
     484           strPageName.toAscii().constData());
     485
     486    /* Perform dialog revalidation: */
     487    printf("UISettingsDialog:  Dialog revalidation in progress...\n");
     488    revalidate();
     489    printf("UISettingsDialog:  Dialog revalidation complete!\n");
     490
     491    printf("UISettingsDialog: Revalidation processed.\n");
     492}
     493
     494#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    367495
    368496void UISettingsDialog::sltHandleValidityChanged(const QIWidgetValidator * /* pValidator */)
     
    445573    }
    446574}
     575#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    447576
    448577void UISettingsDialog::sltUpdateWhatsThis(bool fGotFocus /* = false */)
     
    596725void UISettingsDialog::assignValidator(UISettingsPage *pPage)
    597726{
     727#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     728    /* Assign validator: */
     729    UIPageValidator *pValidator = new UIPageValidator(this, pPage);
     730    connect(pValidator, SIGNAL(sigValidityChanged(UIPageValidator*)), this, SLOT(sltHandleValidityChange(UIPageValidator*)));
     731    pPage->setValidator(pValidator);
     732#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     733    /* Assign validator: */
    598734    QIWidgetValidator *pValidator = new QIWidgetValidator(m_pSelector->itemTextByPage(pPage), pPage, this);
    599735    connect(pValidator, SIGNAL(validityChanged(const QIWidgetValidator*)), this, SLOT(sltHandleValidityChanged(const QIWidgetValidator*)));
    600736    connect(pValidator, SIGNAL(isValidRequested(QIWidgetValidator*)), this, SLOT(sltRevalidate(QIWidgetValidator*)));
    601737    pPage->setValidator(pValidator);
     738#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     739
     740    // TODO: Why here?
     741    /* Configure navigation (tab-order): */
    602742    pPage->setOrderAfter(m_pSelector->widget());
    603743}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h

    r44528 r47559  
    2727
    2828/* Forward declarations: */
     29#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     30class UIPageValidator;
     31#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    2932class QIWidgetValidator;
     33#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    3034class QProgressBar;
    3135class QStackedWidget;
     
    5458protected slots:
    5559
     60#ifndef VBOX_WITH_NEW_SETTINGS_VALIDATOR
    5661    /* Validation handler: */
    5762    virtual void sltRevalidate(QIWidgetValidator *pValidator);
     63#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    5864
    5965    /* Category-change slot: */
     
    96102                 UISettingsPage* pSettingsPage = 0, int iParentId = -1);
    97103
    98     /* Settings page correlator: */
     104    /* Helpers: Validation stuff: */
    99105    virtual void recorrelate(UISettingsPage *pSettingsPage) { Q_UNUSED(pSettingsPage); }
     106#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     107    void revalidate(UIPageValidator *pValidator);
     108    void revalidate();
     109#endif /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    100110
    101111    /* Protected variables: */
     
    105115private slots:
    106116
     117#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     118    /* Handler: Validation stuff: */
     119    void sltHandleValidityChange(UIPageValidator *pValidator);
     120#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    107121    /* Slot to handle validity-changes: */
    108122    void sltHandleValidityChanged(const QIWidgetValidator *pValidator);
     123#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    109124
    110125    /* Slot to update whats-this: */
     
    120135    void showEvent(QShowEvent *pEvent);
    121136
     137    /* Helper: Validation stuff: */
    122138    void assignValidator(UISettingsPage *pPage);
    123139
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.cpp

    r47401 r47559  
    946946}
    947947
     948#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     949void UISettingsDialogMachine::recorrelate(UISettingsPage *pSettingsPage)
     950{
     951    switch (pSettingsPage->id())
     952    {
     953        /* General page correlations: */
     954        case MachineSettingsPageType_General:
     955        {
     956            /* Make changes on 'general' page influent 'display' page: */
     957            UIMachineSettingsGeneral *pGeneralPage = qobject_cast<UIMachineSettingsGeneral*>(pSettingsPage);
     958            UIMachineSettingsDisplay *pDisplayPage = qobject_cast<UIMachineSettingsDisplay*>(m_pSelector->idToPage(MachineSettingsPageType_Display));
     959            if (pGeneralPage && pDisplayPage)
     960                pDisplayPage->setGuestOSType(pGeneralPage->guestOSType());
     961            break;
     962        }
     963        /* System page correlations: */
     964        case MachineSettingsPageType_System:
     965        {
     966            /* Make changes on 'system' page influent 'general' and 'storage' page: */
     967            UIMachineSettingsSystem *pSystemPage = qobject_cast<UIMachineSettingsSystem*>(pSettingsPage);
     968            UIMachineSettingsGeneral *pGeneralPage = qobject_cast<UIMachineSettingsGeneral*>(m_pSelector->idToPage(MachineSettingsPageType_General));
     969            UIMachineSettingsStorage *pStoragePage = qobject_cast<UIMachineSettingsStorage*>(m_pSelector->idToPage(MachineSettingsPageType_Storage));
     970            if (pSystemPage)
     971            {
     972                if (pGeneralPage)
     973                    pGeneralPage->setHWVirtExEnabled(pSystemPage->isHWVirtExEnabled());
     974                if (pStoragePage)
     975                    pStoragePage->setChipsetType(pSystemPage->chipsetType());
     976            }
     977            break;
     978        }
     979        /* USB page correlations: */
     980        case MachineSettingsPageType_USB:
     981        {
     982            /* Make changes on 'usb' page influent 'system' page: */
     983            UIMachineSettingsUSB *pUsbPage = qobject_cast<UIMachineSettingsUSB*>(pSettingsPage);
     984            UIMachineSettingsSystem *pSystemPage = qobject_cast<UIMachineSettingsSystem*>(m_pSelector->idToPage(MachineSettingsPageType_System));
     985            if (pUsbPage && pSystemPage)
     986                pSystemPage->setOHCIEnabled(pUsbPage->isOHCIEnabled());
     987            break;
     988        }
     989        default:
     990            break;
     991    }
     992}
     993
     994#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     995
    948996void UISettingsDialogMachine::recorrelate(UISettingsPage *pSettingsPage)
    949997{
     
    9861034    }
    9871035}
     1036#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    9881037
    9891038void UISettingsDialogMachine::sltMarkLoaded()
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsPage.h

    r44528 r47559  
    3636
    3737/* Forward declarations: */
     38#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     39class UIPageValidator;
     40#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    3841class QIWidgetValidator;
     42#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    3943class QShowEvent;
    4044
     
    9397
    9498    /* Validation stuff: */
     99#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     100    virtual void setValidator(UIPageValidator* /* pValidator */) {}
     101#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    95102    virtual void setValidator(QIWidgetValidator* /* pValidator */) {}
     103#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    96104    virtual bool revalidate(QString& /* strWarningText */, QString& /* strTitle */) { return true; }
    97105
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp

    r47188 r47559  
    160160}
    161161
     162#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     163void UIGlobalSettingsInput::setValidator(UIPageValidator *pValidator)
     164#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    162165void UIGlobalSettingsInput::setValidator(QIWidgetValidator *pValidator)
    163 {
     166#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     167{
     168    /* Configure validation: */
    164169    m_pValidator = pValidator;
    165170    connect(m_pSelectorModel, SIGNAL(sigRevalidationRequired()), m_pValidator, SLOT(revalidate()));
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.h

    r47189 r47559  
    139139    void saveFromCacheTo(QVariant &data);
    140140
    141     /* Helpers: Validation stuff: */
     141    /* API: Validation stuff: */
     142#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     143    void setValidator(UIPageValidator *pValidator);
     144#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    142145    void setValidator(QIWidgetValidator *pValidator);
     146#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    143147    bool revalidate(QString &strWarning, QString &strTitle);
    144148
     
    151155private:
    152156
     157    /* Variable: Validation stuff: */
     158#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     159    UIPageValidator *m_pValidator;
     160#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     161    QIWidgetValidator *m_pValidator;
     162#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     163
    153164    /* Cache: */
    154     QIWidgetValidator *m_pValidator;
    155165    UISettingsCacheGlobalInput m_cache;
    156166    QTabWidget *m_pTabWidget;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.cpp

    r47191 r47559  
    275275    m_pInterfacesTree->setCurrentItem(m_pInterfacesTree->topLevelItem(0));
    276276    sltUpdateCurrentItem();
     277
     278    /* Revalidate if possible: */
     279    if (m_pValidator)
     280        m_pValidator->revalidate();
    277281}
    278282
     
    368372}
    369373
    370 /* Validation assignments: */
     374#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     375void UIGlobalSettingsNetwork::setValidator(UIPageValidator *pValidator)
     376#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    371377void UIGlobalSettingsNetwork::setValidator(QIWidgetValidator *pValidator)
    372 {
     378#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     379{
     380    /* Configure validation: */
    373381    m_pValidator = pValidator;
    374382}
     
    499507        pItem->updateInfo();
    500508        sltUpdateCurrentItem();
    501         m_pValidator->revalidate();
    502509        m_fChanged = true;
     510
     511        /* Revalidate if possible: */
     512        if (m_pValidator)
     513            m_pValidator->revalidate();
    503514    }
    504515}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.h

    r47191 r47559  
    163163    void saveFromCacheTo(QVariant &data);
    164164
    165     /* Validation stuff: */
     165    /* API: Validation stuff: */
     166#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     167    void setValidator(UIPageValidator *pValidator);
     168#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    166169    void setValidator(QIWidgetValidator *pValidator);
     170#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    167171    bool revalidate(QString &strWarning, QString &strTitle);
    168172
     
    190194    void removeListItem(UIHostInterfaceItem *pItem);
    191195
    192     /* Validator: */
     196    /* Variable: Validation stuff: */
     197#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     198    UIPageValidator *m_pValidator;
     199#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    193200    QIWidgetValidator *m_pValidator;
     201#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    194202
    195203    /* Helper actions: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.cpp

    r47196 r47559  
    7171    m_pPortEditor->setText(m_cache.m_strProxyPort);
    7272    sltProxyToggled();
     73
     74    /* Revalidate if possible: */
     75    if (m_pValidator)
     76        m_pValidator->revalidate();
    7377}
    7478
     
    100104}
    101105
     106#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     107void UIGlobalSettingsProxy::setValidator(UIPageValidator *pValidator)
     108#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    102109void UIGlobalSettingsProxy::setValidator(QIWidgetValidator *pValidator)
     110#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    103111{
    104112    /* Configure validation: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.h

    r47196 r47559  
    6161    void saveFromCacheTo(QVariant &data);
    6262
    63     /* Helper: Validation stuff: */
     63    /* API: Validation stuff: */
     64#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     65    void setValidator(UIPageValidator *pValidator);
     66#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    6467    void setValidator(QIWidgetValidator *pValidator);
     68#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    6569
    6670    /* Helper: Navigation stuff: */
     
    7882
    7983    /* Variable: Validation stuff: */
     84#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     85    UIPageValidator *m_pValidator;
     86#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    8087    QIWidgetValidator *m_pValidator;
     88#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    8189
    8290    /* Cache: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r46841 r47559  
    7070    /* Recheck video RAM requirement: */
    7171    checkVRAMRequirements();
     72
     73#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     74    /* Revalidate if possible: */
     75    if (m_pValidator)
     76        m_pValidator->revalidate();
     77#endif /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    7278}
    7379
     
    300306}
    301307
     308#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     309void UIMachineSettingsDisplay::setValidator(UIPageValidator *pValidator)
     310#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    302311void UIMachineSettingsDisplay::setValidator(QIWidgetValidator *pValidator)
    303 {
     312#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     313{
     314    /* Configure validation: */
    304315    m_pValidator = pValidator;
    305316    connect(m_pCheckbox3D, SIGNAL(stateChanged(int)), m_pValidator, SLOT(revalidate()));
     
    383394    }
    384395#endif /* VBOX_WITH_VIDEOHWACCEL */
     396
     397#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     398    /* Check VRDE server port: */
     399    if (m_pEditorRemoteDisplayPort->text().trimmed().isEmpty())
     400    {
     401        strWarning = tr("server port value was not specified.");
     402        return false;
     403    }
     404
     405    /* Check VRDE server timeout: */
     406    if (m_pEditorRemoteDisplayTimeout->text().trimmed().isEmpty())
     407    {
     408        strWarning = tr("authentication timeout value was not specified.");
     409        return false;
     410    }
     411#endif /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    385412
    386413    return true;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.h

    r47276 r47559  
    146146
    147147    /* API: Validation stuff: */
     148#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     149    void setValidator(UIPageValidator *pValidator);
     150#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    148151    void setValidator(QIWidgetValidator *pValidator);
     152#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    149153    bool revalidate(QString &strWarning, QString &strTitle);
    150154
     
    196200    static int calculateQuality(int iFrameWidth, int iFrameHeight, int iFrameRate, int iBitRate);
    197201
    198     /* Validation stuff: */
     202    /* Variable: Validation stuff: */
     203#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     204    UIPageValidator *m_pValidator;
     205#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    199206    QIWidgetValidator *m_pValidator;
     207#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     208
    200209    /* Guest OS type id: */
    201210    CGuestOSType m_guestOSType;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp

    r46141 r47559  
    2929
    3030UIMachineSettingsGeneral::UIMachineSettingsGeneral()
    31     : mValidator(0)
     31    : m_pValidator(0)
    3232    , m_fHWVirtExEnabled(false)
    3333{
     
    6363}
    6464
     65#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
    6566void UIMachineSettingsGeneral::setHWVirtExEnabled(bool fEnabled)
    6667{
     68    /* Make sure hardware virtualization extension has changed: */
     69    if (m_fHWVirtExEnabled == fEnabled)
     70        return;
     71
     72    /* Update hardware virtualization extension value: */
    6773    m_fHWVirtExEnabled = fEnabled;
    68 }
     74
     75    /* Revalidate if possible: */
     76    if (m_pValidator)
     77        m_pValidator->revalidate();
     78}
     79
     80#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     81
     82void UIMachineSettingsGeneral::setHWVirtExEnabled(bool fEnabled)
     83{
     84    m_fHWVirtExEnabled = fEnabled;
     85}
     86#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    6987
    7088bool UIMachineSettingsGeneral::is64BitOSTypeSelected() const
     
    138156
    139157    /* Revalidate if possible: */
    140     if (mValidator)
    141         mValidator->revalidate();
     158    if (m_pValidator)
     159        m_pValidator->revalidate();
    142160}
    143161
     
    215233}
    216234
    217 void UIMachineSettingsGeneral::setValidator (QIWidgetValidator *aVal)
    218 {
    219     mValidator = aVal;
    220     connect (m_pNameAndSystemEditor, SIGNAL (sigOsTypeChanged()), mValidator, SLOT (revalidate()));
     235#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     236void UIMachineSettingsGeneral::setValidator(UIPageValidator *pValidator)
     237#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     238void UIMachineSettingsGeneral::setValidator(QIWidgetValidator *pValidator)
     239#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     240{
     241    /* Configure validation: */
     242    m_pValidator = pValidator;
     243    connect(m_pNameAndSystemEditor, SIGNAL(sigOsTypeChanged()), m_pValidator, SLOT(revalidate()));
     244#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     245    connect(m_pNameAndSystemEditor, SIGNAL(sigNameChanged(const QString&)), m_pValidator, SLOT(revalidate()));
     246#endif /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    221247}
    222248
    223249bool UIMachineSettingsGeneral::revalidate(QString &strWarning, QString& /* strTitle */)
    224250{
     251#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     252    if (m_pNameAndSystemEditor->name().trimmed().isEmpty())
     253    {
     254        strWarning = tr("you have not specified name for this VM.");
     255        return false;
     256    }
     257#endif /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    225258    if (is64BitOSTypeSelected() && !m_fHWVirtExEnabled)
    226259        strWarning = tr("you have selected a 64-bit guest OS type for this VM. As such guests "
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.h

    r43459 r47559  
    106106    void saveFromCacheTo(QVariant &data);
    107107
    108     void setValidator (QIWidgetValidator *aVal);
     108    /* API: Validation stuff: */
     109#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     110    void setValidator(UIPageValidator *pValidator);
     111#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     112    void setValidator(QIWidgetValidator *pValidator);
     113#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    109114    bool revalidate(QString &strWarning, QString &strTitle);
    110115
     
    117122    void polishPage();
    118123
    119     QIWidgetValidator *mValidator;
    120     bool m_fHWVirtExEnabled;
     124    /* Variable: Validation stuff: */
     125#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     126    UIPageValidator *m_pValidator;
     127#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     128    QIWidgetValidator *m_pValidator;
     129#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    121130
    122131    /* Cache: */
     132    bool m_fHWVirtExEnabled;
    123133    UICacheSettingsMachineGeneral m_cache;
    124134};
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp

    r43459 r47559  
    161161}
    162162
     163#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     164void UIMachineSettingsNetwork::setValidator(UIPageValidator *pValidator)
     165#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    163166void UIMachineSettingsNetwork::setValidator(QIWidgetValidator *pValidator)
    164 {
     167#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     168{
     169    /* Configure validation: */
    165170    m_pValidator = pValidator;
    166171    connect(m_pMACEditor, SIGNAL(textEdited(const QString &)), m_pValidator, SLOT(revalidate()));
     
    356361    /* Update availability: */
    357362    m_pAdapterOptionsContainer->setEnabled(m_pEnableAdapterCheckBox->isChecked());
     363
    358364    /* Revalidate if possible: */
    359365    if (m_pValidator)
     
    943949}
    944950
     951#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     952void UIMachineSettingsNetworkPage::setValidator(UIPageValidator *pValidator)
     953#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    945954void UIMachineSettingsNetworkPage::setValidator(QIWidgetValidator *pValidator)
    946 {
     955#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     956{
     957    /* Configure validation: */
    947958    m_pValidator = pValidator;
    948959}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.h

    r44528 r47559  
    109109    void uploadAdapterCache(UICacheSettingsMachineNetworkAdapter &adapterCache);
    110110
    111     /* Validation stuff: */
     111    /* API: Validation stuff: */
     112#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     113    void setValidator(UIPageValidator *pValidator);
     114#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    112115    void setValidator(QIWidgetValidator *pValidator);
     116#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    113117    bool revalidate(QString &strWarning, QString &strTitle);
    114118
     
    157161    UIMachineSettingsNetworkPage *m_pParent;
    158162
    159     /* Validator: */
     163    /* Variable: Validation stuff: */
     164#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     165    UIPageValidator *m_pValidator;
     166#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    160167    QIWidgetValidator *m_pValidator;
     168#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    161169
    162170    /* Other variables: */
     
    207215    bool changed() const { return m_cache.wasChanged(); }
    208216
    209     /* Validation stuff: */
     217    /* API: Validation stuff: */
     218#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     219    void setValidator(UIPageValidator *pValidator);
     220#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    210221    void setValidator(QIWidgetValidator *pValidator);
     222#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    211223    bool revalidate(QString &strWarning, QString &strTitle);
    212224
     
    234246    static void updateGenericProperties(CNetworkAdapter &adapter, const QString &strPropText);
    235247
    236     /* Validator: */
     248    /* Variable: Validation stuff: */
     249#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     250    UIPageValidator *m_pValidator;
     251#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    237252    QIWidgetValidator *m_pValidator;
     253#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    238254
    239255    /* Tab holder: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.cpp

    r44528 r47559  
    3333UIMachineSettingsParallel::UIMachineSettingsParallel(UIMachineSettingsParallelPage *pParent)
    3434    : QIWithRetranslateUI<QWidget> (0)
     35    , m_pValidator(0)
    3536    , m_pParent(pParent)
    36     , mValidator(0)
    3737    , m_iSlot(-1)
    3838{
     
    114114}
    115115
    116 void UIMachineSettingsParallel::setValidator (QIWidgetValidator *aVal)
    117 {
    118     Assert (aVal);
    119     mValidator = aVal;
    120     connect (mLeIRQ, SIGNAL (textChanged (const QString &)),
    121              mValidator, SLOT (revalidate()));
    122     connect (mLeIOPort, SIGNAL (textChanged (const QString &)),
    123              mValidator, SLOT (revalidate()));
    124     connect (mLePath, SIGNAL (textChanged (const QString &)),
    125              mValidator, SLOT (revalidate()));
    126     mValidator->revalidate();
     116#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     117void UIMachineSettingsParallel::setValidator(UIPageValidator *pValidator)
     118#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     119void UIMachineSettingsParallel::setValidator(QIWidgetValidator *pValidator)
     120#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     121{
     122    /* Configure validation: */
     123    m_pValidator = pValidator;
     124    connect(mLeIRQ, SIGNAL(textChanged(const QString&)), m_pValidator, SLOT(revalidate()));
     125    connect(mLeIOPort, SIGNAL(textChanged(const QString&)), m_pValidator, SLOT(revalidate()));
     126    connect(mLePath, SIGNAL(textChanged(const QString&)), m_pValidator, SLOT(revalidate()));
    127127}
    128128
     
    160160    if (aOn)
    161161        mCbNumberActivated (mCbNumber->currentText());
    162     if (mValidator)
    163         mValidator->revalidate();
     162
     163    /* Revalidate if possible: */
     164    if (m_pValidator)
     165        m_pValidator->revalidate();
    164166}
    165167
     
    176178        mLeIOPort->setText ("0x" + QString::number (IOBase, 16).toUpper());
    177179    }
     180
     181#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     182    /* Revalidate if possible: */
     183    if (m_pValidator)
     184        m_pValidator->revalidate();
     185#endif /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    178186}
    179187
     
    181189/* UIMachineSettingsParallelPage stuff */
    182190UIMachineSettingsParallelPage::UIMachineSettingsParallelPage()
    183     : mValidator(0)
     191    : m_pValidator(0)
    184192    , mTabWidget(0)
    185193{
     
    256264
    257265        /* Setup page validation: */
    258         pPage->setValidator(mValidator);
     266        pPage->setValidator(m_pValidator);
    259267
    260268        /* Setup tab order: */
     
    269277
    270278    /* Revalidate if possible: */
    271     if (mValidator)
    272         mValidator->revalidate();
     279    if (m_pValidator)
     280        m_pValidator->revalidate();
    273281}
    274282
     
    329337}
    330338
    331 void UIMachineSettingsParallelPage::setValidator (QIWidgetValidator *aVal)
    332 {
    333     mValidator = aVal;
     339#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     340void UIMachineSettingsParallelPage::setValidator(UIPageValidator *pValidator)
     341#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     342void UIMachineSettingsParallelPage::setValidator(QIWidgetValidator *pValidator)
     343#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     344{
     345    /* Configure validation: */
     346    m_pValidator = pValidator;
    334347}
    335348
     
    337350{
    338351    bool valid = true;
     352#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     353    QList<QPair<QString, QString> > ports;
     354#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    339355    QStringList ports;
     356#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    340357    QStringList paths;
    341358
     
    347364            static_cast<UIMachineSettingsParallel*> (tab);
    348365
     366        if (!page->mGbParallel->isChecked())
     367            continue;
     368
     369#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     370        /* Check the predefined port attributes uniqueness: */
     371        {
     372            QString strIRQ = page->mLeIRQ->text();
     373            QString strIOPort = page->mLeIOPort->text();
     374            QPair<QString, QString> pair(strIRQ, strIOPort);
     375            valid = !strIRQ.isEmpty() && !strIOPort.isEmpty() && !ports.contains(pair);
     376            if (!valid)
     377            {
     378                if (strIRQ.isEmpty())
     379                    aWarning = tr("IRC not specified.");
     380                else if (strIOPort.isEmpty())
     381                    aWarning = tr("IO port not specified.");
     382                else
     383                    aWarning = tr ("duplicate port attributes specified.");
     384                aTitle += ": " +
     385                    vboxGlobal().removeAccelMark(mTabWidget->tabText(mTabWidget->indexOf(tab)));
     386            }
     387            ports << pair;
     388        }
     389#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    349390        /* Check the predefined port number unicity */
    350         if (page->mGbParallel->isChecked() && !page->isUserDefined())
     391        if (!page->isUserDefined())
    351392        {
    352393            QString port = page->mCbNumber->currentText();
     
    361402            ports << port;
    362403        }
     404#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    363405
    364406        /* Check the port path emptiness & unicity */
    365         if (page->mGbParallel->isChecked())
    366407        {
    367408            QString path = page->mLePath->text();
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.h

    r44528 r47559  
    8484    void uploadPortData(UICacheSettingsMachineParallelPort &portCache);
    8585
    86     void setValidator (QIWidgetValidator *aVal);
     86    /* API: Validation stuff: */
     87#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     88    void setValidator(UIPageValidator *pValidator);
     89#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     90    void setValidator(QIWidgetValidator *pValidator);
     91#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    8792
    8893    QWidget* setOrderAfter (QWidget *aAfter);
     
    102107private:
    103108
     109    /* Variable: Validation stuff: */
     110#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     111    UIPageValidator *m_pValidator;
     112#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     113    QIWidgetValidator *m_pValidator;
     114#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     115
    104116    UIMachineSettingsParallelPage *m_pParent;
    105     QIWidgetValidator *mValidator;
    106117    int m_iSlot;
    107118};
     
    135146    bool changed() const { return m_cache.wasChanged(); }
    136147
    137     void setValidator (QIWidgetValidator *aVal);
     148    /* API: Validation stuff: */
     149#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     150    void setValidator(UIPageValidator *pValidator);
     151#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     152    void setValidator(QIWidgetValidator *pValidator);
     153#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    138154    bool revalidate (QString &aWarning, QString &aTitle);
    139155
     
    144160    void polishPage();
    145161
    146     QIWidgetValidator *mValidator;
     162    /* Variable: Validation stuff: */
     163#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     164    UIPageValidator *m_pValidator;
     165#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     166    QIWidgetValidator *m_pValidator;
     167#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     168
    147169    QITabWidget *mTabWidget;
    148170
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.cpp

    r44528 r47559  
    3434UIMachineSettingsSerial::UIMachineSettingsSerial(UIMachineSettingsSerialPage *pParent)
    3535    : QIWithRetranslateUI<QWidget> (0)
     36    , m_pValidator(0)
    3637    , m_pParent(pParent)
    37     , mValidator(0)
    3838    , m_iSlot(-1)
    3939{
     
    130130}
    131131
    132 void UIMachineSettingsSerial::setValidator (QIWidgetValidator *aVal)
    133 {
    134     Assert (aVal);
    135     mValidator = aVal;
    136     connect (mLeIRQ, SIGNAL (textChanged (const QString &)),
    137              mValidator, SLOT (revalidate()));
    138     connect (mLeIOPort, SIGNAL (textChanged (const QString &)),
    139              mValidator, SLOT (revalidate()));
    140     connect (mLePath, SIGNAL (textChanged (const QString &)),
    141              mValidator, SLOT (revalidate()));
    142     mValidator->revalidate();
     132#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     133void UIMachineSettingsSerial::setValidator(UIPageValidator *pValidator)
     134#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     135void UIMachineSettingsSerial::setValidator(QIWidgetValidator *pValidator)
     136#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     137{
     138    /* Configure validation: */
     139    m_pValidator = pValidator;
     140    connect(mLeIRQ, SIGNAL(textChanged(const QString&)), m_pValidator, SLOT(revalidate()));
     141    connect(mLeIOPort, SIGNAL(textChanged(const QString&)), m_pValidator, SLOT(revalidate()));
     142    connect(mLePath, SIGNAL(textChanged(const QString&)), m_pValidator, SLOT(revalidate()));
    143143}
    144144
     
    186186        mCbModeActivated (mCbMode->currentText());
    187187    }
    188     if (mValidator)
    189         mValidator->revalidate();
     188
     189    /* Revalidate if possible: */
     190    if (m_pValidator)
     191        m_pValidator->revalidate();
    190192}
    191193
     
    202204        mLeIOPort->setText ("0x" + QString::number (IOBase, 16).toUpper());
    203205    }
     206
     207#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     208    /* Revalidate if possible: */
     209    if (m_pValidator)
     210        m_pValidator->revalidate();
     211#endif /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    204212}
    205213
     
    209217    mCbPipe->setEnabled (mode == KPortMode_HostPipe);
    210218    mLePath->setEnabled (mode != KPortMode_Disconnected);
    211     if (mValidator)
    212         mValidator->revalidate();
     219
     220    /* Revalidate if possible: */
     221    if (m_pValidator)
     222        m_pValidator->revalidate();
    213223}
    214224
     
    216226/* UIMachineSettingsSerialPage stuff */
    217227UIMachineSettingsSerialPage::UIMachineSettingsSerialPage()
    218     : mValidator(0)
     228    : m_pValidator(0)
    219229    , mTabWidget(0)
    220230{
     
    293303
    294304        /* Setup page validation: */
    295         pPage->setValidator(mValidator);
     305        pPage->setValidator(m_pValidator);
    296306
    297307        /* Setup tab order: */
     
    306316
    307317    /* Revalidate if possible: */
    308     if (mValidator)
    309         mValidator->revalidate();
     318    if (m_pValidator)
     319        m_pValidator->revalidate();
    310320}
    311321
     
    371381}
    372382
    373 void UIMachineSettingsSerialPage::setValidator (QIWidgetValidator * aVal)
    374 {
    375     mValidator = aVal;
     383#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     384void UIMachineSettingsSerialPage::setValidator(UIPageValidator *pValidator)
     385#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     386void UIMachineSettingsSerialPage::setValidator(QIWidgetValidator *pValidator)
     387#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     388{
     389    /* Configure validation: */
     390    m_pValidator = pValidator;
    376391}
    377392
     
    379394{
    380395    bool valid = true;
     396#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     397    QList<QPair<QString, QString> > ports;
     398#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    381399    QStringList ports;
     400#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    382401    QStringList paths;
    383402
     
    392411            continue;
    393412
     413#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     414        /* Check the predefined port attributes uniqueness: */
     415        {
     416            QString strIRQ = page->mLeIRQ->text();
     417            QString strIOPort = page->mLeIOPort->text();
     418            QPair<QString, QString> pair(strIRQ, strIOPort);
     419            valid = !strIRQ.isEmpty() && !strIOPort.isEmpty() && !ports.contains(pair);
     420            if (!valid)
     421            {
     422                if (strIRQ.isEmpty())
     423                    aWarning = tr("IRC not specified.");
     424                else if (strIOPort.isEmpty())
     425                    aWarning = tr("IO port not specified.");
     426                else
     427                    aWarning = tr ("duplicate port attributes specified.");
     428                aTitle += ": " +
     429                    vboxGlobal().removeAccelMark(mTabWidget->tabText(mTabWidget->indexOf(tab)));
     430            }
     431            ports << pair;
     432        }
     433#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    394434        /* Check the predefined port number unicity */
    395435        if (!page->isUserDefined())
     
    399439            if (!valid)
    400440            {
    401                 aWarning = tr ("Duplicate port number selected ");
     441                aWarning = tr ("duplicate port number specified.");
    402442                aTitle += ": " +
    403443                    vboxGlobal().removeAccelMark (mTabWidget->tabText (mTabWidget->indexOf (tab)));
     
    406446            ports << port;
    407447        }
     448#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    408449
    409450        /* Check the port path emptiness & unicity */
     
    421462                {
    422463                    aWarning = path.isEmpty() ?
    423                         tr ("Port path not specified ") :
    424                         tr ("Duplicate port path entered ");
     464                        tr ("port path not specified.") :
     465                        tr ("duplicate port path entered.");
    425466                    aTitle += ": " +
    426467                        vboxGlobal().removeAccelMark (mTabWidget->tabText (mTabWidget->indexOf (tab)));
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.h

    r44528 r47559  
    9090    void uploadPortData(UICacheSettingsMachineSerialPort &data);
    9191
    92     void setValidator (QIWidgetValidator *aVal);
     92    /* API: Validation stuff: */
     93#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     94    void setValidator(UIPageValidator *pValidator);
     95#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     96    void setValidator(QIWidgetValidator *pValidator);
     97#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    9398
    9499    QWidget* setOrderAfter (QWidget *aAfter);
     
    109114private:
    110115
     116    /* Variable: Validation stuff: */
     117#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     118    UIPageValidator *m_pValidator;
     119#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     120    QIWidgetValidator *m_pValidator;
     121#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     122
    111123    UIMachineSettingsSerialPage *m_pParent;
    112     QIWidgetValidator *mValidator;
    113124    int m_iSlot;
    114125};
     
    142153    bool changed() const { return m_cache.wasChanged(); }
    143154
    144     void setValidator (QIWidgetValidator *aVal);
     155    /* API: Validation stuff: */
     156#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     157    void setValidator(UIPageValidator *pValidator);
     158#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     159    void setValidator(QIWidgetValidator *pValidator);
     160#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    145161    bool revalidate (QString &aWarning, QString &aTitle);
    146162
     
    151167    void polishPage();
    152168
    153     QIWidgetValidator *mValidator;
     169    /* Variable: Validation stuff: */
     170#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     171    UIPageValidator *m_pValidator;
     172#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     173    QIWidgetValidator *m_pValidator;
     174#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     175
    154176    QITabWidget *mTabWidget;
    155177
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r47184 r47559  
    17191719 */
    17201720UIMachineSettingsStorage::UIMachineSettingsStorage()
    1721     : mValidator(0)
     1721    : m_pValidator(0)
    17221722    , mStorageModel(0)
    17231723    , mAddCtrAction(0), mDelCtrAction(0)
     
    18861886}
    18871887
     1888#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
    18881889void UIMachineSettingsStorage::setChipsetType(KChipsetType type)
    18891890{
     1891    /* Make sure chipset type has changed: */
     1892    if (mStorageModel->chipsetType() == type)
     1893        return;
     1894
     1895    /* Update chipset type value: */
    18901896    mStorageModel->setChipsetType(type);
    18911897    updateActionsState();
    1892 }
     1898
     1899    /* Revalidate if possible: */
     1900    if (m_pValidator)
     1901        m_pValidator->revalidate();
     1902}
     1903
     1904#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     1905
     1906void UIMachineSettingsStorage::setChipsetType(KChipsetType type)
     1907{
     1908    mStorageModel->setChipsetType(type);
     1909    updateActionsState();
     1910}
     1911#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    18931912
    18941913/* Load data to cache from corresponding external object(s),
     
    20292048
    20302049    /* Revalidate if possible: */
    2031     if (mValidator)
    2032         mValidator->revalidate();
     2050    if (m_pValidator)
     2051        m_pValidator->revalidate();
    20332052}
    20342053
     
    20982117}
    20992118
    2100 void UIMachineSettingsStorage::setValidator (QIWidgetValidator *aVal)
    2101 {
    2102     mValidator = aVal;
     2119#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     2120void UIMachineSettingsStorage::setValidator(UIPageValidator *pValidator)
     2121#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     2122void UIMachineSettingsStorage::setValidator(QIWidgetValidator *pValidator)
     2123#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     2124{
     2125    /* Configure validation: */
     2126    m_pValidator = pValidator;
    21032127}
    21042128
     
    22692293            {
    22702294                mStorageModel->setData (attIndex, attMediumId, StorageModel::R_AttMediumId);
    2271                 if (mValidator) mValidator->revalidate();
     2295
     2296                /* Revalidate if possible: */
     2297                if (m_pValidator)
     2298                    m_pValidator->revalidate();
    22722299            }
    22732300        }
     
    22882315            {
    22892316                mStorageModel->setData (attIndex, UIMedium().id(), StorageModel::R_AttMediumId);
    2290                 if (mValidator) mValidator->revalidate();
     2317
     2318                /* Revalidate if possible: */
     2319                if (m_pValidator)
     2320                    m_pValidator->revalidate();
    22912321            }
    22922322        }
     
    23372367    mStorageModel->delController (QUuid (mStorageModel->data (index, StorageModel::R_ItemId).toString()));
    23382368    emit storageChanged();
    2339     if (mValidator) mValidator->revalidate();
     2369
     2370    /* Revalidate if possible: */
     2371    if (m_pValidator)
     2372        m_pValidator->revalidate();
    23402373}
    23412374
     
    24162449                                  QUuid (mStorageModel->data (index, StorageModel::R_ItemId).toString()));
    24172450    emit storageChanged();
    2418     if (mValidator) mValidator->revalidate();
     2451
     2452    /* Revalidate if possible: */
     2453    if (m_pValidator)
     2454        m_pValidator->revalidate();
    24192455}
    24202456
     
    25422578    }
    25432579
    2544     if (mValidator) mValidator->revalidate();
     2580    /* Revalidate if possible: */
     2581    if (m_pValidator)
     2582        m_pValidator->revalidate();
    25452583
    25462584    mIsLoadingInProgress = false;
     
    30773115        mStorageModel->sort();
    30783116        emit storageChanged();
    3079         if (mValidator)
    3080             mValidator->revalidate();
     3117
     3118        /* Revalidate if possible: */
     3119        if (m_pValidator)
     3120            m_pValidator->revalidate();
    30813121    }
    30823122}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h

    r44528 r47559  
    673673    bool changed() const { return m_cache.wasChanged(); }
    674674
    675     void setValidator (QIWidgetValidator *aVal);
     675    /* API: Validation stuff: */
     676#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     677    void setValidator(UIPageValidator *pValidator);
     678#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     679    void setValidator(QIWidgetValidator *pValidator);
     680#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    676681    bool revalidate (QString &aWarning, QString &aTitle);
    677682
     
    756761    void polishPage();
    757762
    758     QIWidgetValidator *mValidator;
     763    /* Variable: Validation stuff: */
     764#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     765    UIPageValidator *m_pValidator;
     766#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     767    QIWidgetValidator *m_pValidator;
     768#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    759769
    760770    QString m_strMachineId;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp

    r47289 r47559  
    5959}
    6060
     61#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
    6162void UIMachineSettingsSystem::setOHCIEnabled(bool fEnabled)
    6263{
     64    /* Make sure OHCI status has changed: */
     65    if (m_fOHCIEnabled == fEnabled)
     66        return;
     67
     68    /* Update OHCI status value: */
    6369    m_fOHCIEnabled = fEnabled;
    64 }
     70
     71    /* Revalidate if possible: */
     72    if (m_pValidator)
     73        m_pValidator->revalidate();
     74}
     75
     76#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     77
     78void UIMachineSettingsSystem::setOHCIEnabled(bool fEnabled)
     79{
     80    m_fOHCIEnabled = fEnabled;
     81}
     82#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    6583
    6684/* Load data to cache from corresponding external object(s),
     
    279297}
    280298
     299#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     300void UIMachineSettingsSystem::setValidator(UIPageValidator *pValidator)
     301#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    281302void UIMachineSettingsSystem::setValidator(QIWidgetValidator *pValidator)
     303#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    282304{
    283305    /* Configure validation: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.h

    r47278 r47559  
    152152    void saveFromCacheTo(QVariant &data);
    153153
    154     /* Helpers: Validation stuff: */
     154    /* API: Validation stuff: */
     155#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     156    void setValidator(UIPageValidator *pValidator);
     157#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    155158    void setValidator(QIWidgetValidator *pValidator);
     159#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    156160    bool revalidate(QString &strWarning, QString &strTitle);
    157161
     
    201205
    202206    /* Variable: Validation stuff: */
     207#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     208    UIPageValidator *m_pValidator;
     209#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    203210    QIWidgetValidator *m_pValidator;
     211#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    204212
    205213    /* Variable: Boot-table stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.cpp

    r47401 r47559  
    140140UIMachineSettingsUSB::UIMachineSettingsUSB(UISettingsPageType type)
    141141    : UISettingsPage(type)
    142     , mValidator(0)
     142    , m_pValidator(0)
    143143    , m_pToolBar(0)
    144144    , mNewAction(0), mAddAction(0), mEdtAction(0), mDelAction(0)
     
    387387
    388388    /* Revalidate if possible: */
    389     if (mValidator)
    390         mValidator->revalidate();
     389    if (m_pValidator)
     390        m_pValidator->revalidate();
    391391}
    392392
     
    564564}
    565565
    566 void UIMachineSettingsUSB::setValidator (QIWidgetValidator *aVal)
    567 {
    568     mValidator = aVal;
    569     connect (mGbUSB, SIGNAL (stateChanged (int)), mValidator, SLOT (revalidate()));
    570     connect(mCbUSB2, SIGNAL(stateChanged(int)), mValidator, SLOT(revalidate()));
     566#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     567void UIMachineSettingsUSB::setValidator(UIPageValidator *pValidator)
     568#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     569void UIMachineSettingsUSB::setValidator(QIWidgetValidator *pValidator)
     570#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     571{
     572    /* Configure validation: */
     573    m_pValidator = pValidator;
     574    connect(mGbUSB, SIGNAL(stateChanged(int)), m_pValidator, SLOT(revalidate()));
     575    connect(mCbUSB2, SIGNAL(stateChanged(int)), m_pValidator, SLOT(revalidate()));
    571576}
    572577
     
    712717
    713718    /* Revalidate if possible: */
    714     if (mValidator)
    715         mValidator->revalidate();
     719    if (m_pValidator)
     720        m_pValidator->revalidate();
    716721}
    717722
     
    760765
    761766    /* Revalidate if possible: */
    762     if (mValidator)
    763         mValidator->revalidate();
     767    if (m_pValidator)
     768        m_pValidator->revalidate();
    764769}
    765770
     
    860865    if (!mTwFilters->topLevelItemCount())
    861866    {
    862         if (mValidator)
    863         {
    864             mValidator->rescan();
    865             mValidator->revalidate();
     867        /* Revalidate if possible: */
     868        if (m_pValidator)
     869        {
     870#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     871            m_pValidator->revalidate();
     872#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     873            m_pValidator->rescan();
     874            m_pValidator->revalidate();
     875#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    866876        }
    867877    }
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.h

    r44528 r47559  
    142142    bool changed() const { return m_cache.wasChanged(); }
    143143
    144     void setValidator (QIWidgetValidator *aVal);
     144    /* API: Validation stuff: */
     145#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     146    void setValidator(UIPageValidator *pValidator);
     147#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     148    void setValidator(QIWidgetValidator *pValidator);
     149#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
    145150    bool revalidate(QString &strWarningText, QString &strTitle);
    146151
     
    179184    void polishPage();
    180185
     186    /* Variable: Validation stuff: */
     187#ifdef VBOX_WITH_NEW_SETTINGS_VALIDATOR
     188    UIPageValidator *m_pValidator;
     189#else /* VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     190    QIWidgetValidator *m_pValidator;
     191#endif /* !VBOX_WITH_NEW_SETTINGS_VALIDATOR */
     192
    181193    /* Global data source: */
    182194    CSystemProperties m_properties;
     
    188200
    189201    /* Other variables: */
    190     QIWidgetValidator *mValidator;
    191202    UIToolBar *m_pToolBar;
    192203    QAction *mNewAction;
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