VirtualBox

Ignore:
Timestamp:
Jul 19, 2013 1:21:02 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: Machine settings: System page: Cleanup/rework (part 2): Coding-style.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
Files:
2 edited

Legend:

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

    r47253 r47255  
    3535
    3636UIMachineSettingsSystem::UIMachineSettingsSystem()
    37     : mValidator(0)
    38     , mMinGuestCPU(0), mMaxGuestCPU(0)
    39     , mMinGuestCPUExecCap(0), mMedGuestCPUExecCap(0), mMaxGuestCPUExecCap(0)
     37    : m_pValidator(0)
     38    , m_uMinGuestCPU(0), m_uMaxGuestCPU(0)
     39    , m_uMinGuestCPUExecCap(0), m_uMedGuestCPUExecCap(0), m_uMaxGuestCPUExecCap(0)
    4040    , m_fOHCIEnabled(false)
    4141{
     
    4646    CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties();
    4747    uint hostCPUs = vboxGlobal().host().GetProcessorCount();
    48     mMinGuestCPU = properties.GetMinGuestCPUCount();
    49     mMaxGuestCPU = RT_MIN (2 * hostCPUs, properties.GetMaxGuestCPUCount());
    50     mMinGuestCPUExecCap = 1;
    51     mMedGuestCPUExecCap = 40;
    52     mMaxGuestCPUExecCap = 100;
     48    m_uMinGuestCPU = properties.GetMinGuestCPUCount();
     49    m_uMaxGuestCPU = RT_MIN (2 * hostCPUs, properties.GetMaxGuestCPUCount());
     50    m_uMinGuestCPUExecCap = 1;
     51    m_uMedGuestCPUExecCap = 40;
     52    m_uMaxGuestCPUExecCap = 100;
    5353
    5454    /* Populate possible boot items list.
     
    9191
    9292    /* Setup validators: */
    93     mLeMemory->setValidator (new QIntValidator (mSlMemory->minRAM(), mSlMemory->maxRAM(), this));
    94     mLeCPU->setValidator (new QIntValidator (mMinGuestCPU, mMaxGuestCPU, this));
    95     mLeCPUExecCap->setValidator(new QIntValidator(mMinGuestCPUExecCap, mMaxGuestCPUExecCap, this));
     93    mLeMemory->setValidator(new QIntValidator(mSlMemory->minRAM(), mSlMemory->maxRAM(), this));
     94    mLeCPU->setValidator(new QIntValidator(m_uMinGuestCPU, m_uMaxGuestCPU, this));
     95    mLeCPUExecCap->setValidator(new QIntValidator(m_uMinGuestCPUExecCap, m_uMaxGuestCPUExecCap, this));
    9696
    9797    /* Setup RAM connections: */
    98     connect (mSlMemory, SIGNAL (valueChanged (int)),
    99              this, SLOT (valueChangedRAM (int)));
    100     connect (mLeMemory, SIGNAL (textChanged (const QString&)),
    101              this, SLOT (textChangedRAM (const QString&)));
     98    connect(mSlMemory, SIGNAL(valueChanged(int)), this, SLOT(valueChangedRAM(int)));
     99    connect(mLeMemory, SIGNAL(textChanged(const QString&)), this, SLOT(textChangedRAM(const QString&)));
    102100
    103101    /* Setup boot-table connections: */
    104     connect (mTbBootItemUp, SIGNAL (clicked()),
    105              mTwBootOrder, SLOT(sltMoveItemUp()));
    106     connect (mTbBootItemDown, SIGNAL (clicked()),
    107              mTwBootOrder, SLOT(sltMoveItemDown()));
    108     connect (mTwBootOrder, SIGNAL (sigRowChanged(int)),
    109              this, SLOT (onCurrentBootItemChanged (int)));
     102    connect(mTbBootItemUp, SIGNAL(clicked()), mTwBootOrder, SLOT(sltMoveItemUp()));
     103    connect(mTbBootItemDown, SIGNAL(clicked()), mTwBootOrder, SLOT(sltMoveItemDown()));
     104    connect(mTwBootOrder, SIGNAL(sigRowChanged(int)), this, SLOT(onCurrentBootItemChanged(int)));
    110105
    111106    /* Setup CPU connections: */
    112     connect (mSlCPU, SIGNAL (valueChanged (int)),
    113              this, SLOT (valueChangedCPU (int)));
    114     connect (mLeCPU, SIGNAL (textChanged (const QString&)),
    115              this, SLOT (textChangedCPU (const QString&)));
     107    connect(mSlCPU, SIGNAL(valueChanged(int)), this, SLOT(valueChangedCPU(int)));
     108    connect(mLeCPU, SIGNAL(textChanged(const QString&)), this, SLOT(textChangedCPU(const QString&)));
    116109    connect(mSlCPUExecCap, SIGNAL(valueChanged(int)), this, SLOT(sltValueChangedCPUExecCap(int)));
    117110    connect(mLeCPUExecCap, SIGNAL(textChanged(const QString&)), this, SLOT(sltTextChangedCPUExecCap(const QString&)));
    118111
    119112    /* Setup boot-table iconsets: */
    120     mTbBootItemUp->setIcon(UIIconPool::iconSet(":/list_moveup_16px.png",
    121                                                ":/list_moveup_disabled_16px.png"));
    122     mTbBootItemDown->setIcon(UIIconPool::iconSet(":/list_movedown_16px.png",
    123                                                  ":/list_movedown_disabled_16px.png"));
     113    mTbBootItemUp->setIcon(UIIconPool::iconSet(":/list_moveup_16px.png", ":/list_moveup_disabled_16px.png"));
     114    mTbBootItemDown->setIcon(UIIconPool::iconSet(":/list_movedown_16px.png", ":/list_movedown_disabled_16px.png"));
    124115
    125116#ifdef Q_WS_MAC
     
    130121
    131122    /* Limit min/max size of QLineEdit: */
    132     mLeMemory->setFixedWidthByText (QString().fill ('8', 5));
     123    mLeMemory->setFixedWidthByText(QString().fill('8', 5));
    133124    /* Ensure mLeMemory value and validation is updated: */
    134     valueChangedRAM (mSlMemory->value());
     125    valueChangedRAM(mSlMemory->value());
    135126
    136127    /* Setup cpu slider: */
    137     mSlCPU->setPageStep (1);
    138     mSlCPU->setSingleStep (1);
    139     mSlCPU->setTickInterval (1);
     128    mSlCPU->setPageStep(1);
     129    mSlCPU->setSingleStep(1);
     130    mSlCPU->setTickInterval(1);
    140131    /* Setup the scale so that ticks are at page step boundaries: */
    141     mSlCPU->setMinimum (mMinGuestCPU);
    142     mSlCPU->setMaximum (mMaxGuestCPU);
    143     mSlCPU->setOptimalHint (1, hostCPUs);
    144     mSlCPU->setWarningHint (hostCPUs, mMaxGuestCPU);
     132    mSlCPU->setMinimum(m_uMinGuestCPU);
     133    mSlCPU->setMaximum(m_uMaxGuestCPU);
     134    mSlCPU->setOptimalHint(1, hostCPUs);
     135    mSlCPU->setWarningHint(hostCPUs, m_uMaxGuestCPU);
    145136    /* Limit min/max. size of QLineEdit: */
    146137    mLeCPU->setFixedWidthByText(QString().fill('8', 4));
    147138    /* Ensure mLeMemory value and validation is updated: */
    148     valueChangedCPU (mSlCPU->value());
     139    valueChangedCPU(mSlCPU->value());
    149140
    150141    /* Setup cpu cap slider: */
     
    153144    mSlCPUExecCap->setTickInterval(10);
    154145    /* Setup the scale so that ticks are at page step boundaries: */
    155     mSlCPUExecCap->setMinimum(mMinGuestCPUExecCap);
    156     mSlCPUExecCap->setMaximum(mMaxGuestCPUExecCap);
    157     mSlCPUExecCap->setWarningHint(mMinGuestCPUExecCap, mMedGuestCPUExecCap);
    158     mSlCPUExecCap->setOptimalHint(mMedGuestCPUExecCap, mMaxGuestCPUExecCap);
     146    mSlCPUExecCap->setMinimum(m_uMinGuestCPUExecCap);
     147    mSlCPUExecCap->setMaximum(m_uMaxGuestCPUExecCap);
     148    mSlCPUExecCap->setWarningHint(m_uMinGuestCPUExecCap, m_uMedGuestCPUExecCap);
     149    mSlCPUExecCap->setOptimalHint(m_uMedGuestCPUExecCap, m_uMaxGuestCPUExecCap);
    159150    /* Limit min/max. size of QLineEdit: */
    160151    mLeCPUExecCap->setFixedWidthByText(QString().fill('8', 4));
     
    163154
    164155    /* Populate chipset combo: */
    165     mCbChipset->insertItem(0, gpConverter->toString(KChipsetType_PIIX3), QVariant(KChipsetType_PIIX3));
    166     mCbChipset->insertItem(1, gpConverter->toString(KChipsetType_ICH9), QVariant(KChipsetType_ICH9));
     156    mCbChipset->addItem(gpConverter->toString(KChipsetType_PIIX3), QVariant(KChipsetType_PIIX3));
     157    mCbChipset->addItem(gpConverter->toString(KChipsetType_ICH9), QVariant(KChipsetType_ICH9));
    167158
    168159    /* Install global event filter: */
    169     qApp->installEventFilter (this);
     160    qApp->installEventFilter(this);
    170161
    171162    /* Retranslate finally: */
     
    290281
    291282    /* Revalidate if possible: */
    292     if (mValidator)
    293         mValidator->revalidate();
     283    if (m_pValidator)
     284        m_pValidator->revalidate();
    294285}
    295286
     
    382373}
    383374
    384 void UIMachineSettingsSystem::setValidator (QIWidgetValidator *aVal)
     375void UIMachineSettingsSystem::setValidator(QIWidgetValidator *pValidator)
    385376{
    386377    /* Configure validation: */
    387     mValidator = aVal;
    388     connect (mCbApic, SIGNAL (stateChanged (int)), mValidator, SLOT (revalidate()));
    389     connect (mCbVirt, SIGNAL (stateChanged (int)), mValidator, SLOT (revalidate()));
    390     connect (mCbUseAbsHID, SIGNAL (stateChanged (int)), mValidator, SLOT (revalidate()));
    391     connect(mCbChipset, SIGNAL(currentIndexChanged(int)), mValidator, SLOT(revalidate()));
    392 }
    393 
    394 bool UIMachineSettingsSystem::revalidate (QString &aWarning, QString & /* aTitle */)
     378    m_pValidator = pValidator;
     379    connect(mCbChipset, SIGNAL(currentIndexChanged(int)), m_pValidator, SLOT(revalidate()));
     380    connect(mCbApic, SIGNAL(stateChanged(int)), m_pValidator, SLOT(revalidate()));
     381    connect(mCbVirt, SIGNAL(stateChanged(int)), m_pValidator, SLOT(revalidate()));
     382    connect(mCbUseAbsHID, SIGNAL(stateChanged(int)), m_pValidator, SLOT(revalidate()));
     383}
     384
     385bool UIMachineSettingsSystem::revalidate(QString &strWarning, QString& /* strTitle */)
    395386{
    396387    /* RAM amount test: */
    397     ulong fullSize = vboxGlobal().host().GetMemorySize();
     388    ulong uFullSize = vboxGlobal().host().GetMemorySize();
    398389    if (mSlMemory->value() > (int)mSlMemory->maxRAMAlw())
    399390    {
    400         aWarning = tr (
     391        strWarning = tr(
    401392            "you have assigned more than <b>%1%</b> of your computer's memory "
    402393            "(<b>%2</b>) to the virtual machine. Not enough memory is left "
    403394            "for your host operating system. Please select a smaller amount.")
    404             .arg ((unsigned)qRound ((double)mSlMemory->maxRAMAlw() / fullSize * 100.0))
    405             .arg (vboxGlobal().formatSize ((uint64_t)fullSize * _1M));
     395            .arg((unsigned)qRound((double)mSlMemory->maxRAMAlw() / uFullSize * 100.0))
     396            .arg(vboxGlobal().formatSize((uint64_t)uFullSize * _1M));
    406397        return false;
    407398    }
    408399    if (mSlMemory->value() > (int)mSlMemory->maxRAMOpt())
    409400    {
    410         aWarning = tr (
     401        strWarning = tr(
    411402            "you have assigned more than <b>%1%</b> of your computer's memory "
    412403            "(<b>%2</b>) to the virtual machine. There might not be enough memory "
    413404            "left for your host operating system. Continue at your own risk.")
    414             .arg ((unsigned)qRound ((double)mSlMemory->maxRAMOpt() / fullSize * 100.0))
    415             .arg (vboxGlobal().formatSize ((uint64_t)fullSize * _1M));
     405            .arg((unsigned)qRound((double)mSlMemory->maxRAMOpt() / uFullSize * 100.0))
     406            .arg(vboxGlobal().formatSize((uint64_t)uFullSize * _1M));
    416407        return true;
    417408    }
    418409
    419410    /* VCPU amount test: */
    420     int totalCPUs = vboxGlobal().host().GetProcessorOnlineCount();
    421     if (mSlCPU->value() > 2 * totalCPUs)
    422     {
    423         aWarning = tr (
     411    int cTotalCPUs = vboxGlobal().host().GetProcessorOnlineCount();
     412    if (mSlCPU->value() > 2 * cTotalCPUs)
     413    {
     414        strWarning = tr(
    424415            "for performance reasons, the number of virtual CPUs attached to the "
    425416            "virtual machine may not be more than twice the number of physical "
    426417            "CPUs on the host (<b>%1</b>). Please reduce the number of virtual CPUs.")
    427             .arg (totalCPUs);
     418            .arg(cTotalCPUs);
    428419        return false;
    429420    }
    430     if (mSlCPU->value() > totalCPUs)
    431     {
    432         aWarning = tr (
     421    if (mSlCPU->value() > cTotalCPUs)
     422    {
     423        strWarning = tr(
    433424            "you have assigned more virtual CPUs to the virtual machine than "
    434425            "the number of physical CPUs on your host system (<b>%1</b>). "
    435426            "This is likely to degrade the performance of your virtual machine. "
    436427            "Please consider reducing the number of virtual CPUs.")
    437             .arg (totalCPUs);
     428            .arg(cTotalCPUs);
    438429        return true;
    439430    }
     
    442433    if (mSlCPU->value() > 1 && !mCbApic->isChecked())
    443434    {
    444         aWarning = tr (
     435        strWarning = tr(
    445436            "you have assigned more than one virtual CPU to this VM. "
    446437            "This will not work unless the IO-APIC feature is also enabled. "
     
    453444    if (mSlCPU->value() > 1 && !mCbVirt->isChecked())
    454445    {
    455         aWarning = tr (
     446        strWarning = tr(
    456447            "you have assigned more than one virtual CPU to this VM. "
    457448            "This will not work unless hardware virtualization (VT-x/AMD-V) is also enabled. "
     
    462453
    463454    /* CPU execution cap is low: */
    464     if (mSlCPUExecCap->value() < (int)mMedGuestCPUExecCap)
    465     {
    466         aWarning = tr (
     455    if (mSlCPUExecCap->value() < (int)m_uMedGuestCPUExecCap)
     456    {
     457        strWarning = tr(
    467458            "you have set the processor execution cap to a low value. "
    468459            "This can make the machine feel slow to respond.");
     
    473464    if ((KChipsetType)mCbChipset->itemData(mCbChipset->currentIndex()).toInt() == KChipsetType_ICH9 && !mCbApic->isChecked())
    474465    {
    475         aWarning = tr (
     466        strWarning = tr(
    476467            "you have assigned ICH9 chipset type to this VM. "
    477468            "It will not work properly unless the IO-APIC feature is also enabled. "
     
    484475    if (mCbUseAbsHID->isChecked() && !m_fOHCIEnabled)
    485476    {
    486         aWarning = tr (
     477        strWarning = tr(
    487478            "you have enabled a USB HID (Human Interface Device). "
    488479            "This will not work unless USB emulation is also enabled. "
     
    495486}
    496487
    497 void UIMachineSettingsSystem::setOrderAfter (QWidget *aWidget)
    498 {
    499     /* Motherboard tab-order */
    500     setTabOrder (aWidget, mTwSystem->focusProxy());
    501     setTabOrder (mTwSystem->focusProxy(), mSlMemory);
    502     setTabOrder (mSlMemory, mLeMemory);
    503     setTabOrder (mLeMemory, mTwBootOrder);
    504     setTabOrder (mTwBootOrder, mTbBootItemUp);
    505     setTabOrder (mTbBootItemUp, mTbBootItemDown);
    506     setTabOrder (mTbBootItemDown, mCbApic);
    507     setTabOrder (mCbApic, mCbEFI);
    508     setTabOrder (mCbEFI, mCbTCUseUTC);
    509     setTabOrder (mCbTCUseUTC, mCbUseAbsHID);
     488void UIMachineSettingsSystem::setOrderAfter(QWidget *pWidget)
     489{
     490    /* Motherboard tab-order: */
     491    setTabOrder(pWidget, mTwSystem->focusProxy());
     492    setTabOrder(mTwSystem->focusProxy(), mSlMemory);
     493    setTabOrder(mSlMemory, mLeMemory);
     494    setTabOrder(mLeMemory, mTwBootOrder);
     495    setTabOrder(mTwBootOrder, mTbBootItemUp);
     496    setTabOrder(mTbBootItemUp, mTbBootItemDown);
     497    setTabOrder(mTbBootItemDown, mCbChipset);
     498    setTabOrder(mCbChipset, mCbApic);
     499    setTabOrder(mCbApic, mCbEFI);
     500    setTabOrder(mCbEFI, mCbTCUseUTC);
     501    setTabOrder(mCbTCUseUTC, mCbUseAbsHID);
    510502
    511503    /* Processor tab-order: */
    512     setTabOrder (mCbUseAbsHID, mSlCPU);
    513     setTabOrder (mSlCPU, mLeCPU);
     504    setTabOrder(mCbUseAbsHID, mSlCPU);
     505    setTabOrder(mSlCPU, mLeCPU);
    514506    setTabOrder(mLeCPU, mSlCPUExecCap);
    515507    setTabOrder(mSlCPUExecCap, mLeCPUExecCap);
     
    517509
    518510    /* Acceleration tab-order: */
    519     setTabOrder (mCbPae, mCbVirt);
    520     setTabOrder (mCbVirt, mCbNestedPaging);
     511    setTabOrder(mCbPae, mCbVirt);
     512    setTabOrder(mCbVirt, mCbNestedPaging);
    521513}
    522514
     
    524516{
    525517    /* Translate uic generated strings: */
    526     Ui::UIMachineSettingsSystem::retranslateUi (this);
     518    Ui::UIMachineSettingsSystem::retranslateUi(this);
    527519
    528520    /* Readjust the tree widget items size: */
     
    530522
    531523    /* Retranslate the memory slider legend: */
    532     mLbMemoryMin->setText (tr ("<qt>%1&nbsp;MB</qt>").arg (mSlMemory->minRAM()));
    533     mLbMemoryMax->setText (tr ("<qt>%1&nbsp;MB</qt>").arg (mSlMemory->maxRAM()));
     524    mLbMemoryMin->setText(tr("<qt>%1&nbsp;MB</qt>").arg(mSlMemory->minRAM()));
     525    mLbMemoryMax->setText(tr("<qt>%1&nbsp;MB</qt>").arg(mSlMemory->maxRAM()));
    534526
    535527    /* Retranslate the cpu slider legend: */
    536     mLbCPUMin->setText (tr ("<qt>%1&nbsp;CPU</qt>", "%1 is 1 for now").arg (mMinGuestCPU));
    537     mLbCPUMax->setText (tr ("<qt>%1&nbsp;CPUs</qt>", "%1 is host cpu count * 2 for now").arg (mMaxGuestCPU));
     528    mLbCPUMin->setText(tr("<qt>%1&nbsp;CPU</qt>", "%1 is 1 for now").arg(m_uMinGuestCPU));
     529    mLbCPUMax->setText(tr("<qt>%1&nbsp;CPUs</qt>", "%1 is host cpu count * 2 for now").arg(m_uMaxGuestCPU));
    538530
    539531    /* Retranslate the cpu cap slider legend: */
    540     mLbCPUExecCapMin->setText(tr("<qt>%1%</qt>", "Min CPU execution cap in %").arg(mMinGuestCPUExecCap));
    541     mLbCPUExecCapMax->setText(tr("<qt>%1%</qt>", "Max CPU execution cap in %").arg(mMaxGuestCPUExecCap));
    542 }
    543 
    544 void UIMachineSettingsSystem::valueChangedRAM (int aVal)
    545 {
    546     mLeMemory->setText (QString().setNum (aVal));
    547 }
    548 
    549 void UIMachineSettingsSystem::textChangedRAM (const QString &aText)
    550 {
    551     mSlMemory->setValue (aText.toInt());
    552 }
    553 
    554 void UIMachineSettingsSystem::onCurrentBootItemChanged (int i)
     532    mLbCPUExecCapMin->setText(tr("<qt>%1%</qt>", "Min CPU execution cap in %").arg(m_uMinGuestCPUExecCap));
     533    mLbCPUExecCapMax->setText(tr("<qt>%1%</qt>", "Max CPU execution cap in %").arg(m_uMaxGuestCPUExecCap));
     534}
     535
     536void UIMachineSettingsSystem::valueChangedRAM(int iValue)
     537{
     538    mLeMemory->setText(QString::number(iValue));
     539}
     540
     541void UIMachineSettingsSystem::textChangedRAM(const QString &strText)
     542{
     543    mSlMemory->setValue(strText.toInt());
     544}
     545
     546void UIMachineSettingsSystem::onCurrentBootItemChanged(int iCurrentItem)
    555547{
    556548    /* Update boot-order tool-buttons: */
    557     bool upEnabled   = i > 0;
    558     bool downEnabled = i < mTwBootOrder->count() - 1;
    559     if ((mTbBootItemUp->hasFocus() && !upEnabled) ||
    560         (mTbBootItemDown->hasFocus() && !downEnabled))
     549    bool fEnabledUP = iCurrentItem > 0;
     550    bool fEnabledDOWN = iCurrentItem < mTwBootOrder->count() - 1;
     551    if ((mTbBootItemUp->hasFocus() && !fEnabledUP) ||
     552        (mTbBootItemDown->hasFocus() && !fEnabledDOWN))
    561553        mTwBootOrder->setFocus();
    562     mTbBootItemUp->setEnabled (upEnabled);
    563     mTbBootItemDown->setEnabled (downEnabled);
     554    mTbBootItemUp->setEnabled(fEnabledUP);
     555    mTbBootItemDown->setEnabled(fEnabledDOWN);
    564556}
    565557
     
    576568}
    577569
    578 void UIMachineSettingsSystem::valueChangedCPU (int aVal)
    579 {
    580     mLeCPU->setText (QString().setNum (aVal));
    581 }
    582 
    583 void UIMachineSettingsSystem::textChangedCPU (const QString &aText)
    584 {
    585     mSlCPU->setValue (aText.toInt());
     570void UIMachineSettingsSystem::valueChangedCPU(int iValue)
     571{
     572    mLeCPU->setText(QString::number(iValue));
     573}
     574
     575void UIMachineSettingsSystem::textChangedCPU(const QString &strText)
     576{
     577    mSlCPU->setValue(strText.toInt());
    586578}
    587579
    588580void UIMachineSettingsSystem::sltValueChangedCPUExecCap(int iValue)
    589581{
    590     mLeCPUExecCap->setText(QString().setNum(iValue));
     582    mLeCPUExecCap->setText(QString::number(iValue));
    591583}
    592584
     
    594586{
    595587    mSlCPUExecCap->setValue(strText.toInt());
    596 }
    597 
    598 bool UIMachineSettingsSystem::eventFilter (QObject *aObject, QEvent *aEvent)
    599 {
    600     if (!aObject->isWidgetType())
    601         return QWidget::eventFilter (aObject, aEvent);
    602 
    603     QWidget *widget = static_cast<QWidget*> (aObject);
    604     if (widget->window() != window())
    605         return QWidget::eventFilter (aObject, aEvent);
    606 
    607     switch (aEvent->type())
    608     {
    609         case QEvent::FocusIn:
    610         {
    611             /* Boot Table: */
    612             if (widget == mTwBootOrder)
    613             {
    614                 if (!mTwBootOrder->currentItem())
    615                     mTwBootOrder->setCurrentItem (mTwBootOrder->item (0));
    616                 else
    617                     onCurrentBootItemChanged (mTwBootOrder->currentRow());
    618                 mTwBootOrder->currentItem()->setSelected (true);
    619             }
    620             else if (widget != mTbBootItemUp && widget != mTbBootItemDown)
    621             {
    622                 if (mTwBootOrder->currentItem())
    623                 {
    624                     mTwBootOrder->currentItem()->setSelected (false);
    625                     mTbBootItemUp->setEnabled (false);
    626                     mTbBootItemDown->setEnabled (false);
    627                 }
    628             }
    629             break;
    630         }
    631         default:
    632             break;
    633     }
    634 
    635     return QWidget::eventFilter (aObject, aEvent);
    636588}
    637589
     
    681633}
    682634
     635bool UIMachineSettingsSystem::eventFilter(QObject *pObject, QEvent *pEvent)
     636{
     637    if (!pObject->isWidgetType())
     638        return QWidget::eventFilter(pObject, pEvent);
     639
     640    QWidget *pWidget = static_cast<QWidget*>(pObject);
     641    if (pWidget->window() != window())
     642        return QWidget::eventFilter(pObject, pEvent);
     643
     644    switch (pEvent->type())
     645    {
     646        case QEvent::FocusIn:
     647        {
     648            /* Boot Table: */
     649            if (pWidget == mTwBootOrder)
     650            {
     651                if (!mTwBootOrder->currentItem())
     652                    mTwBootOrder->setCurrentItem(mTwBootOrder->item(0));
     653                else
     654                    onCurrentBootItemChanged(mTwBootOrder->currentRow());
     655                mTwBootOrder->currentItem()->setSelected(true);
     656            }
     657            else if (pWidget != mTbBootItemUp && pWidget != mTbBootItemDown)
     658            {
     659                if (mTwBootOrder->currentItem())
     660                {
     661                    mTwBootOrder->currentItem()->setSelected(false);
     662                    mTbBootItemUp->setEnabled(false);
     663                    mTbBootItemDown->setEnabled(false);
     664                }
     665            }
     666            break;
     667        }
     668        default:
     669            break;
     670    }
     671
     672    return QWidget::eventFilter(pObject, pEvent);
     673}
     674
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.h

    r47253 r47255  
    2929    /* Default constructor: */
    3030    UIBootItemData() : m_type(KDeviceType_Null), m_fEnabled(false) {}
     31
    3132    /* Operator==: */
    3233    bool operator==(const UIBootItemData &other) const
     
    3536               (m_fEnabled == other.m_fEnabled);
    3637    }
     38
    3739    /* Variables: */
    3840    KDeviceType m_type;
     
    5961        , m_cCPUCount(-1)
    6062        , m_cCPUExecCap(-1) {}
     63
    6164    /* Functions: */
    6265    bool equal(const UIDataSettingsMachineSystem &other) const
     
    7780               (m_cCPUExecCap == other.m_cCPUExecCap);
    7881    }
     82
    7983    /* Operators: */
    8084    bool operator==(const UIDataSettingsMachineSystem &other) const { return equal(other); }
    8185    bool operator!=(const UIDataSettingsMachineSystem &other) const { return !equal(other); }
     86
    8287    /* Variables: */
    8388    QList<UIBootItemData> m_bootItems;
     
    117122protected:
    118123
    119     /* Load data to cache from corresponding external object(s),
     124    /* API: Cache stuff: */
     125    bool changed() const { return m_cache.wasChanged(); }
     126
     127    /* API: Load data to cache from corresponding external object(s),
    120128     * this task COULD be performed in other than GUI thread: */
    121129    void loadToCacheFrom(QVariant &data);
    122     /* Load data to corresponding widgets from cache,
     130    /* API: Load data to corresponding widgets from cache,
    123131     * this task SHOULD be performed in GUI thread only: */
    124132    void getFromCache();
    125133
    126     /* Save data from corresponding widgets to cache,
     134    /* API: Save data from corresponding widgets to cache,
    127135     * this task SHOULD be performed in GUI thread only: */
    128136    void putToCache();
    129     /* Save data from cache to corresponding external object(s),
     137    /* API: Save data from cache to corresponding external object(s),
    130138     * this task COULD be performed in other than GUI thread: */
    131139    void saveFromCacheTo(QVariant &data);
    132140
    133     /* API: Cache stuff: */
    134     bool changed() const { return m_cache.wasChanged(); }
    135 
    136141    /* Helpers: Validation stuff: */
    137     void setValidator (QIWidgetValidator *aVal);
    138     bool revalidate (QString &aWarning, QString &aTitle);
     142    void setValidator(QIWidgetValidator *pValidator);
     143    bool revalidate(QString &strWarning, QString &strTitle);
    139144
    140145    /* Helper: Navigation stuff: */
    141     void setOrderAfter (QWidget *aWidget);
     146    void setOrderAfter(QWidget *pWidget);
    142147
    143148    /* Helper: Translation stuff: */
     
    147152
    148153    /* Handlers: RAM stuff: */
    149     void valueChangedRAM (int aVal);
    150     void textChangedRAM (const QString &aText);
     154    void valueChangedRAM(int iValue);
     155    void textChangedRAM(const QString &strText);
    151156
    152     /* Handler: Boot stuff: */
    153     void onCurrentBootItemChanged (int);
     157    /* Handler: Boot-table stuff: */
     158    void onCurrentBootItemChanged(int iCurrentIndex);
    154159
    155160    /* Handlers: CPU stuff: */
    156     void valueChangedCPU (int aVal);
    157     void textChangedCPU (const QString &aText);
     161    void valueChangedCPU(int iValue);
     162    void textChangedCPU(const QString &strText);
    158163    void sltValueChangedCPUExecCap(int iValue);
    159164    void sltTextChangedCPUExecCap(const QString &strText);
     
    161166private:
    162167
    163     /* Handler: Event-filtration stuff: */
    164     bool eventFilter (QObject *aObject, QEvent *aEvent);
    165 
    166     /* Helper: Boot stuff: */
    167     void adjustBootOrderTWSize();
    168 
    169168    /* Handler: Polishing stuff: */
    170169    void polishPage();
    171170
     171    /* Handler: Event-filtration stuff: */
     172    bool eventFilter(QObject *aObject, QEvent *aEvent);
     173
     174    /* Helper: Boot-table stuff: */
     175    void adjustBootOrderTWSize();
     176
    172177    /* Variable: Validation stuff: */
    173     QIWidgetValidator *mValidator;
     178    QIWidgetValidator *m_pValidator;
    174179
    175180    /* Variables: CPU stuff: */
    176     uint mMinGuestCPU;
    177     uint mMaxGuestCPU;
    178     uint mMinGuestCPUExecCap;
    179     uint mMedGuestCPUExecCap;
    180     uint mMaxGuestCPUExecCap;
     181    uint m_uMinGuestCPU;
     182    uint m_uMaxGuestCPU;
     183    uint m_uMinGuestCPUExecCap;
     184    uint m_uMedGuestCPUExecCap;
     185    uint m_uMaxGuestCPUExecCap;
    181186
    182     /* Variable: Boot stuff: */
     187    /* Variable: Boot-table stuff: */
    183188    QList<KDeviceType> m_possibleBootItems;
    184189
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