~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSystem.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-30 23:27:25 UTC
  • mfrom: (0.3.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20110130232725-2ouajjd2ggdet0zd
Tags: 4.0.2-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Drop ubuntu-01-fix-build-gcc45.patch, fixed upstream.
* Drop ubuntu-02-as-needed.patch, added to the Debian package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: VBoxVMSettingsSystem.cpp $ */
2
 
/** @file
3
 
 *
4
 
 * VBox frontends: Qt4 GUI ("VirtualBox"):
5
 
 * VBoxVMSettingsSystem class implementation
6
 
 */
7
 
 
8
 
/*
9
 
 * Copyright (C) 2008-2010 Oracle Corporation
10
 
 *
11
 
 * This file is part of VirtualBox Open Source Edition (OSE), as
12
 
 * available from http://www.virtualbox.org. This file is free software;
13
 
 * you can redistribute it and/or modify it under the terms of the GNU
14
 
 * General Public License (GPL) as published by the Free Software
15
 
 * Foundation, in version 2 as it comes in the "COPYING" file of the
16
 
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17
 
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18
 
 */
19
 
 
20
 
/* Global includes */
21
 
#include <QHeaderView>
22
 
 
23
 
/* Local includes */
24
 
#include "VBoxVMSettingsSystem.h"
25
 
#include "VBoxGlobal.h"
26
 
#include "QIWidgetValidator.h"
27
 
#include <iprt/cdefs.h>
28
 
 
29
 
#define ITEM_TYPE_ROLE Qt::UserRole + 1
30
 
 
31
 
VBoxVMSettingsSystem::VBoxVMSettingsSystem()
32
 
{
33
 
    /* Apply UI decorations */
34
 
    Ui::VBoxVMSettingsSystem::setupUi (this);
35
 
 
36
 
    /* Setup constants */
37
 
    CSystemProperties sys = vboxGlobal().virtualBox().GetSystemProperties();
38
 
    uint hostCPUs = vboxGlobal().virtualBox().GetHost().GetProcessorCount();
39
 
    mMinGuestCPU = sys.GetMinGuestCPUCount();
40
 
    mMaxGuestCPU = RT_MIN (2 * hostCPUs, sys.GetMaxGuestCPUCount());
41
 
 
42
 
    /* Setup validators */
43
 
    mLeMemory->setValidator (new QIntValidator (mSlMemory->minRAM(), mSlMemory->maxRAM(), this));
44
 
    mLeCPU->setValidator (new QIntValidator (mMinGuestCPU, mMaxGuestCPU, this));
45
 
 
46
 
    /* Setup connections */
47
 
    connect (mSlMemory, SIGNAL (valueChanged (int)),
48
 
             this, SLOT (valueChangedRAM (int)));
49
 
    connect (mLeMemory, SIGNAL (textChanged (const QString&)),
50
 
             this, SLOT (textChangedRAM (const QString&)));
51
 
 
52
 
    connect (mTbBootItemUp, SIGNAL (clicked()),
53
 
             this, SLOT (moveBootItemUp()));
54
 
    connect (mTbBootItemDown, SIGNAL (clicked()),
55
 
             this, SLOT (moveBootItemDown()));
56
 
    connect (mTwBootOrder, SIGNAL (moveItemUp()),
57
 
             this, SLOT (moveBootItemUp()));
58
 
    connect (mTwBootOrder, SIGNAL (moveItemDown()),
59
 
             this, SLOT (moveBootItemDown()));
60
 
    connect (mTwBootOrder, SIGNAL (itemToggled()),
61
 
             this, SIGNAL (tableChanged()));
62
 
    connect (mTwBootOrder, SIGNAL (currentItemChanged (QTreeWidgetItem*,
63
 
                                                       QTreeWidgetItem*)),
64
 
             this, SLOT (onCurrentBootItemChanged (QTreeWidgetItem*,
65
 
                                                   QTreeWidgetItem*)));
66
 
 
67
 
    connect (mSlCPU, SIGNAL (valueChanged (int)),
68
 
             this, SLOT (valueChangedCPU (int)));
69
 
    connect (mLeCPU, SIGNAL (textChanged (const QString&)),
70
 
             this, SLOT (textChangedCPU (const QString&)));
71
 
 
72
 
    /* Setup iconsets */
73
 
    mTbBootItemUp->setIcon (VBoxGlobal::iconSet (":/list_moveup_16px.png",
74
 
                                                 ":/list_moveup_disabled_16px.png"));
75
 
    mTbBootItemDown->setIcon (VBoxGlobal::iconSet (":/list_movedown_16px.png",
76
 
                                                   ":/list_movedown_disabled_16px.png"));
77
 
 
78
 
#ifdef Q_WS_MAC
79
 
    /* We need a little space for the focus rect. */
80
 
    mLtBootOrder->setContentsMargins (3, 3, 3, 3);
81
 
    mLtBootOrder->setSpacing (3);
82
 
#endif /* Q_WS_MAC */
83
 
 
84
 
    /* Limit min/max. size of QLineEdit */
85
 
    mLeMemory->setFixedWidthByText (QString().fill ('8', 5));
86
 
    /* Ensure mLeMemory value and validation is updated */
87
 
    valueChangedRAM (mSlMemory->value());
88
 
 
89
 
    /* Setup cpu slider */
90
 
    mSlCPU->setPageStep (1);
91
 
    mSlCPU->setSingleStep (1);
92
 
    mSlCPU->setTickInterval (1);
93
 
    /* Setup the scale so that ticks are at page step boundaries */
94
 
    mSlCPU->setMinimum (mMinGuestCPU);
95
 
    mSlCPU->setMaximum (mMaxGuestCPU);
96
 
    mSlCPU->setOptimalHint (1, hostCPUs);
97
 
    mSlCPU->setWarningHint (hostCPUs, mMaxGuestCPU);
98
 
    /* Limit min/max. size of QLineEdit */
99
 
    mLeCPU->setFixedWidthByText (QString().fill ('8', 3));
100
 
    /* Ensure mLeMemory value and validation is updated */
101
 
    valueChangedCPU (mSlCPU->value());
102
 
 
103
 
    /* Install global event filter */
104
 
    qApp->installEventFilter (this);
105
 
 
106
 
    /* Applying language settings */
107
 
    retranslateUi();
108
 
}
109
 
 
110
 
bool VBoxVMSettingsSystem::isHWVirtExEnabled() const
111
 
{
112
 
    return mCbVirt->isChecked();
113
 
}
114
 
 
115
 
int VBoxVMSettingsSystem::cpuCount() const
116
 
{
117
 
    return mSlCPU->value();
118
 
}
119
 
 
120
 
bool VBoxVMSettingsSystem::isHIDEnabled() const
121
 
{
122
 
    return mCbUseAbsHID->isChecked();
123
 
}
124
 
 
125
 
void VBoxVMSettingsSystem::getFrom (const CMachine &aMachine)
126
 
{
127
 
    mMachine = aMachine;
128
 
    CBIOSSettings biosSettings = mMachine.GetBIOSSettings();
129
 
 
130
 
    /* RAM size */
131
 
    mSlMemory->setValue (aMachine.GetMemorySize());
132
 
 
133
 
    /* Boot-order */
134
 
    {
135
 
        mTwBootOrder->clear();
136
 
        /* Load boot-items of current VM */
137
 
        QStringList uniqueList;
138
 
        for (int i = 1; i <= 4; ++ i)
139
 
        {
140
 
            KDeviceType type = mMachine.GetBootOrder (i);
141
 
            if (type != KDeviceType_Null)
142
 
            {
143
 
                QString name = vboxGlobal().toString (type);
144
 
                QTreeWidgetItem *item =
145
 
                    new QTreeWidgetItem (mTwBootOrder, QStringList (name));
146
 
                QVariant vtype (type);
147
 
                item->setData (0, ITEM_TYPE_ROLE, vtype);
148
 
                item->setCheckState (0, Qt::Checked);
149
 
                uniqueList << name;
150
 
            }
151
 
        }
152
 
        /* Load other unique boot-items */
153
 
        for (int i = KDeviceType_Floppy; i < KDeviceType_USB; ++ i)
154
 
        {
155
 
            QString name = vboxGlobal().toString ((KDeviceType) i);
156
 
            if (!uniqueList.contains (name))
157
 
            {
158
 
                QTreeWidgetItem *item =
159
 
                    new QTreeWidgetItem (mTwBootOrder, QStringList (name));
160
 
                item->setData (0, ITEM_TYPE_ROLE, i);
161
 
                item->setCheckState (0, Qt::Unchecked);
162
 
                uniqueList << name;
163
 
            }
164
 
        }
165
 
        adjustBootOrderTWSize();
166
 
    }
167
 
 
168
 
    /* IO APIC */
169
 
    mCbApic->setChecked (biosSettings.GetIOAPICEnabled());
170
 
 
171
 
    /* EFI */
172
 
    mCbEFI->setChecked (mMachine.GetFirmwareType() >= KFirmwareType_EFI && mMachine.GetFirmwareType() <= KFirmwareType_EFIDUAL);
173
 
 
174
 
    /* RTC */
175
 
    bool rtcUseUTC = mMachine.GetRTCUseUTC ();
176
 
    mCbTCUseUTC->setChecked (rtcUseUTC);
177
 
 
178
 
    /* USB tablet */
179
 
    KPointingHidType pointingHid = mMachine.GetPointingHidType ();
180
 
    mCbUseAbsHID->setChecked (pointingHid == KPointingHidType_USBTablet);
181
 
 
182
 
    /* CPU count */
183
 
    bool fVTxAMDVSupported = vboxGlobal().virtualBox().GetHost()
184
 
                             .GetProcessorFeature (KProcessorFeature_HWVirtEx);
185
 
    mSlCPU->setEnabled (fVTxAMDVSupported);
186
 
    mLeCPU->setEnabled (fVTxAMDVSupported);
187
 
    mSlCPU->setValue (fVTxAMDVSupported ? aMachine.GetCPUCount() : 1);
188
 
 
189
 
    /* PAE/NX */
190
 
    bool fPAESupported = vboxGlobal().virtualBox().GetHost()
191
 
                         .GetProcessorFeature (KProcessorFeature_PAE);
192
 
    mCbPae->setEnabled (fPAESupported);
193
 
    mCbPae->setChecked (aMachine.GetCPUProperty(KCPUPropertyType_PAE));
194
 
 
195
 
    /* VT-x/AMD-V page */
196
 
    if (!fVTxAMDVSupported)
197
 
        mTwSystem->removeTab(2);
198
 
 
199
 
    /* VT-x/AMD-V */
200
 
    mCbVirt->setEnabled (fVTxAMDVSupported);
201
 
    mCbVirt->setChecked (aMachine.GetHWVirtExProperty(KHWVirtExPropertyType_Enabled));
202
 
 
203
 
    /* Nested Paging */
204
 
    mCbNestedPaging->setEnabled (fVTxAMDVSupported &&
205
 
                                 aMachine.GetHWVirtExProperty(KHWVirtExPropertyType_Enabled));
206
 
    mCbNestedPaging->setChecked (aMachine.GetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging));
207
 
 
208
 
    if (mValidator)
209
 
        mValidator->revalidate();
210
 
}
211
 
 
212
 
void VBoxVMSettingsSystem::putBackTo()
213
 
{
214
 
    CBIOSSettings biosSettings = mMachine.GetBIOSSettings();
215
 
 
216
 
    /* RAM size */
217
 
    mMachine.SetMemorySize (mSlMemory->value());
218
 
 
219
 
    /* Boot order */
220
 
    {
221
 
        /* Search for checked items */
222
 
        int index = 1;
223
 
 
224
 
        for (int i = 0; i < mTwBootOrder->topLevelItemCount(); ++ i)
225
 
        {
226
 
            QTreeWidgetItem *item = mTwBootOrder->topLevelItem (i);
227
 
            if (item->checkState (0) == Qt::Checked)
228
 
            {
229
 
                KDeviceType type = vboxGlobal().toDeviceType (item->text (0));
230
 
                mMachine.SetBootOrder (index ++, type);
231
 
            }
232
 
        }
233
 
 
234
 
        /* Search for non-checked items */
235
 
        for (int i = 0; i < mTwBootOrder->topLevelItemCount(); ++ i)
236
 
        {
237
 
            QTreeWidgetItem *item = mTwBootOrder->topLevelItem (i);
238
 
            if (item->checkState (0) != Qt::Checked)
239
 
                mMachine.SetBootOrder (index ++, KDeviceType_Null);
240
 
        }
241
 
    }
242
 
 
243
 
    /* IO APIC */
244
 
    biosSettings.SetIOAPICEnabled (mCbApic->isChecked() ||
245
 
                                   mSlCPU->value() > 1);
246
 
 
247
 
    /* EFI */
248
 
    mMachine.SetFirmwareType (mCbEFI->isChecked() ? KFirmwareType_EFI : KFirmwareType_BIOS);
249
 
 
250
 
    /* RTC */
251
 
    mMachine.SetRTCUseUTC (mCbTCUseUTC->isChecked());
252
 
 
253
 
    /* USB tablet */
254
 
    mMachine.SetPointingHidType (mCbUseAbsHID->isChecked() ? KPointingHidType_USBTablet : KPointingHidType_PS2Mouse );
255
 
 
256
 
    /* RAM size */
257
 
    mMachine.SetCPUCount (mSlCPU->value());
258
 
 
259
 
    /* PAE/NX */
260
 
    mMachine.SetCPUProperty(KCPUPropertyType_PAE, mCbPae->isChecked());
261
 
 
262
 
    /* VT-x/AMD-V */
263
 
    mMachine.SetHWVirtExProperty(KHWVirtExPropertyType_Enabled,
264
 
                                 mCbVirt->checkState() == Qt::Checked || mSlCPU->value() > 1);
265
 
 
266
 
    /* Nested Paging */
267
 
    mMachine.SetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging, mCbNestedPaging->isChecked());
268
 
}
269
 
 
270
 
void VBoxVMSettingsSystem::setValidator (QIWidgetValidator *aVal)
271
 
{
272
 
    mValidator = aVal;
273
 
    connect (mCbApic, SIGNAL (stateChanged (int)), mValidator, SLOT (revalidate()));
274
 
    connect (mCbVirt, SIGNAL (stateChanged (int)), mValidator, SLOT (revalidate()));
275
 
    connect (mCbUseAbsHID, SIGNAL (stateChanged (int)), mValidator, SLOT (revalidate()));
276
 
}
277
 
 
278
 
bool VBoxVMSettingsSystem::revalidate (QString &aWarning, QString & /* aTitle */)
279
 
{
280
 
    ulong fullSize = vboxGlobal().virtualBox().GetHost().GetMemorySize();
281
 
    if (mSlMemory->value() > (int)mSlMemory->maxRAMAlw())
282
 
    {
283
 
        aWarning = tr (
284
 
            "you have assigned more than <b>%1%</b> of your computer's memory "
285
 
            "(<b>%2</b>) to the virtual machine. Not enough memory is left "
286
 
            "for your host operating system. Please select a smaller amount.")
287
 
            .arg ((unsigned)qRound ((double)mSlMemory->maxRAMAlw() / fullSize * 100.0))
288
 
            .arg (vboxGlobal().formatSize ((uint64_t)fullSize * _1M));
289
 
        return false;
290
 
    }
291
 
    if (mSlMemory->value() > (int)mSlMemory->maxRAMOpt())
292
 
    {
293
 
        aWarning = tr (
294
 
            "you have assigned more than <b>%1%</b> of your computer's memory "
295
 
            "(<b>%2</b>) to the virtual machine. There might not be enough memory "
296
 
            "left for your host operating system. Continue at your own risk.")
297
 
            .arg ((unsigned)qRound ((double)mSlMemory->maxRAMOpt() / fullSize * 100.0))
298
 
            .arg (vboxGlobal().formatSize ((uint64_t)fullSize * _1M));
299
 
        return true;
300
 
    }
301
 
 
302
 
    /* VCPU amount test */
303
 
    int totalCPUs = vboxGlobal().virtualBox().GetHost().GetProcessorOnlineCount();
304
 
    if (mSlCPU->value() > 2 * totalCPUs)
305
 
    {
306
 
        aWarning = tr (
307
 
            "for performance reasons, the number of virtual CPUs attached to the "
308
 
            "virtual machine may not be more than twice the number of physical "
309
 
            "CPUs on the host (<b>%1</b>). Please reduce the number of virtual CPUs.")
310
 
            .arg (totalCPUs);
311
 
        return false;
312
 
    }
313
 
    if (mSlCPU->value() > totalCPUs)
314
 
    {
315
 
        aWarning = tr (
316
 
            "you have assigned more virtual CPUs to the virtual machine than "
317
 
            "the number of physical CPUs on your host system (<b>%1</b>). "
318
 
            "This is likely to degrade the performance of your virtual machine. "
319
 
            "Please consider reducing the number of virtual CPUs.")
320
 
            .arg (totalCPUs);
321
 
        return true;
322
 
    }
323
 
 
324
 
    /* VCPU IO-APIC test */
325
 
    if (mSlCPU->value() > 1 && !mCbApic->isChecked())
326
 
    {
327
 
        aWarning = tr (
328
 
            "you have assigned more than one virtual CPU to this VM. "
329
 
            "This will not work unless the IO-APIC feature is also enabled. "
330
 
            "This will be done automatically when you accept the VM Settings "
331
 
            "by pressing the OK button.");
332
 
        return true;
333
 
    }
334
 
 
335
 
    /* VCPU VT-x/AMD-V test */
336
 
    if (mSlCPU->value() > 1 && !mCbVirt->isChecked())
337
 
    {
338
 
        aWarning = tr (
339
 
            "you have assigned more than one virtual CPU to this VM. "
340
 
            "This will not work unless hardware virtualization (VT-x/AMD-V) is also enabled. "
341
 
            "This will be done automatically when you accept the VM Settings "
342
 
            "by pressing the OK button.");
343
 
        return true;
344
 
    }
345
 
 
346
 
    return true;
347
 
}
348
 
 
349
 
void VBoxVMSettingsSystem::setOrderAfter (QWidget *aWidget)
350
 
{
351
 
    setTabOrder (aWidget, mTwSystem->focusProxy());
352
 
    setTabOrder (mTwSystem->focusProxy(), mSlMemory);
353
 
    setTabOrder (mSlMemory, mLeMemory);
354
 
    setTabOrder (mLeMemory, mTwBootOrder);
355
 
    setTabOrder (mTwBootOrder, mTbBootItemUp);
356
 
    setTabOrder (mTbBootItemUp, mTbBootItemDown);
357
 
    setTabOrder (mTbBootItemDown, mCbApic);
358
 
    setTabOrder (mCbApic, mCbEFI);
359
 
 
360
 
    setTabOrder (mCbEFI, mSlCPU);
361
 
    setTabOrder (mSlCPU, mLeCPU);
362
 
    setTabOrder (mLeCPU, mCbPae);
363
 
 
364
 
    setTabOrder (mCbPae, mCbVirt);
365
 
    setTabOrder (mCbVirt, mCbNestedPaging);
366
 
}
367
 
 
368
 
void VBoxVMSettingsSystem::retranslateUi()
369
 
{
370
 
    /* Translate uic generated strings */
371
 
    Ui::VBoxVMSettingsSystem::retranslateUi (this);
372
 
 
373
 
    /* Adjust the boot order tree widget */
374
 
    mTwBootOrder->header()->setResizeMode (QHeaderView::ResizeToContents);
375
 
    mTwBootOrder->resizeColumnToContents (0);
376
 
    mTwBootOrder->updateGeometry();
377
 
    /* Retranslate the boot order items */
378
 
    QTreeWidgetItemIterator it (mTwBootOrder);
379
 
    while (*it)
380
 
    {
381
 
        QTreeWidgetItem *item = (*it);
382
 
        item->setText (0, vboxGlobal().toString (
383
 
             static_cast <KDeviceType> (item->data (0, ITEM_TYPE_ROLE).toInt())));
384
 
        ++ it;
385
 
    }
386
 
    /* Readjust the tree widget items size */
387
 
    adjustBootOrderTWSize();
388
 
 
389
 
    CSystemProperties sys = vboxGlobal().virtualBox().GetSystemProperties();
390
 
 
391
 
    /* Retranslate the memory slider legend */
392
 
    mLbMemoryMin->setText (tr ("<qt>%1&nbsp;MB</qt>").arg (mSlMemory->minRAM()));
393
 
    mLbMemoryMax->setText (tr ("<qt>%1&nbsp;MB</qt>").arg (mSlMemory->maxRAM()));
394
 
 
395
 
    /* Retranslate the cpu slider legend */
396
 
    mLbCPUMin->setText (tr ("<qt>%1&nbsp;CPU</qt>", "%1 is 1 for now").arg (mMinGuestCPU));
397
 
    mLbCPUMax->setText (tr ("<qt>%1&nbsp;CPUs</qt>", "%1 is host cpu count * 2 for now").arg (mMaxGuestCPU));
398
 
}
399
 
 
400
 
void VBoxVMSettingsSystem::valueChangedRAM (int aVal)
401
 
{
402
 
    mLeMemory->setText (QString().setNum (aVal));
403
 
}
404
 
 
405
 
void VBoxVMSettingsSystem::textChangedRAM (const QString &aText)
406
 
{
407
 
    mSlMemory->setValue (aText.toInt());
408
 
}
409
 
 
410
 
void VBoxVMSettingsSystem::moveBootItemUp()
411
 
{
412
 
    QTreeWidgetItem *item = mTwBootOrder->currentItem();
413
 
    Assert (item);
414
 
    if (!mTwBootOrder->itemAbove (item))
415
 
        return;
416
 
 
417
 
    int index = mTwBootOrder->indexOfTopLevelItem (item);
418
 
    QTreeWidgetItem *takenItem = mTwBootOrder->takeTopLevelItem (index);
419
 
    Assert (takenItem == item);
420
 
 
421
 
    mTwBootOrder->insertTopLevelItem (index - 1, takenItem);
422
 
    mTwBootOrder->setCurrentItem (item);
423
 
 
424
 
    emit tableChanged();
425
 
}
426
 
 
427
 
void VBoxVMSettingsSystem::moveBootItemDown()
428
 
{
429
 
    QTreeWidgetItem *item = mTwBootOrder->currentItem();
430
 
    Assert (item);
431
 
    if (!mTwBootOrder->itemBelow (item))
432
 
        return;
433
 
 
434
 
    int index = mTwBootOrder->indexOfTopLevelItem (item);
435
 
    QTreeWidgetItem *takenItem = mTwBootOrder->takeTopLevelItem (index);
436
 
    Assert (takenItem == item);
437
 
 
438
 
    mTwBootOrder->insertTopLevelItem (index + 1, takenItem);
439
 
    mTwBootOrder->setCurrentItem (item);
440
 
 
441
 
    emit tableChanged();
442
 
}
443
 
 
444
 
void VBoxVMSettingsSystem::onCurrentBootItemChanged (QTreeWidgetItem *aItem,
445
 
                                                     QTreeWidgetItem *)
446
 
{
447
 
    bool upEnabled   = aItem && mTwBootOrder->itemAbove (aItem);
448
 
    bool downEnabled = aItem && mTwBootOrder->itemBelow (aItem);
449
 
    if ((mTbBootItemUp->hasFocus() && !upEnabled) ||
450
 
        (mTbBootItemDown->hasFocus() && !downEnabled))
451
 
        mTwBootOrder->setFocus();
452
 
    mTbBootItemUp->setEnabled (upEnabled);
453
 
    mTbBootItemDown->setEnabled (downEnabled);
454
 
}
455
 
 
456
 
void VBoxVMSettingsSystem::adjustBootOrderTWSize()
457
 
{
458
 
    /* Calculate the optimal size of the tree widget & set it as fixed
459
 
     * size. */
460
 
 
461
 
    QAbstractItemView *iv = qobject_cast <QAbstractItemView*> (mTwBootOrder);
462
 
 
463
 
    int h = 2 * mTwBootOrder->frameWidth();
464
 
    int w = h;
465
 
#ifdef Q_WS_MAC
466
 
    int left, top, right, bottom;
467
 
    mTwBootOrder->getContentsMargins (&left, &top, &right, &bottom);
468
 
    h += top + bottom;
469
 
    w += left + right;
470
 
#else /* Q_WS_MAC */
471
 
    w += 4;
472
 
#endif /* Q_WS_MAC */
473
 
    mTwBootOrder->setFixedSize (
474
 
        iv->sizeHintForColumn (0) + w,
475
 
        iv->sizeHintForRow (0) * mTwBootOrder->topLevelItemCount() + h);
476
 
 
477
 
    /* Update the layout system */
478
 
    if (mTabMotherboard->layout())
479
 
    {
480
 
        mTabMotherboard->layout()->activate();
481
 
        mTabMotherboard->layout()->update();
482
 
    }
483
 
}
484
 
 
485
 
void VBoxVMSettingsSystem::valueChangedCPU (int aVal)
486
 
{
487
 
    mLeCPU->setText (QString().setNum (aVal));
488
 
}
489
 
 
490
 
void VBoxVMSettingsSystem::textChangedCPU (const QString &aText)
491
 
{
492
 
    mSlCPU->setValue (aText.toInt());
493
 
}
494
 
 
495
 
bool VBoxVMSettingsSystem::eventFilter (QObject *aObject, QEvent *aEvent)
496
 
{
497
 
    if (!aObject->isWidgetType())
498
 
        return QWidget::eventFilter (aObject, aEvent);
499
 
 
500
 
    QWidget *widget = static_cast<QWidget*> (aObject);
501
 
    if (widget->window() != window())
502
 
        return QWidget::eventFilter (aObject, aEvent);
503
 
 
504
 
    switch (aEvent->type())
505
 
    {
506
 
        case QEvent::FocusIn:
507
 
        {
508
 
            /* Boot Table */
509
 
            if (widget == mTwBootOrder)
510
 
            {
511
 
                if (!mTwBootOrder->currentItem())
512
 
                    mTwBootOrder->setCurrentItem (mTwBootOrder->topLevelItem (0));
513
 
                else
514
 
                    onCurrentBootItemChanged (mTwBootOrder->currentItem());
515
 
                mTwBootOrder->currentItem()->setSelected (true);
516
 
            }
517
 
            else if (widget != mTbBootItemUp && widget != mTbBootItemDown)
518
 
            {
519
 
                if (mTwBootOrder->currentItem())
520
 
                {
521
 
                    mTwBootOrder->currentItem()->setSelected (false);
522
 
                    mTbBootItemUp->setEnabled (false);
523
 
                    mTbBootItemDown->setEnabled (false);
524
 
                }
525
 
            }
526
 
            break;
527
 
        }
528
 
        default:
529
 
            break;
530
 
    }
531
 
 
532
 
    return QWidget::eventFilter (aObject, aEvent);
533
 
}
534