VirtualBox

Changeset 66243 in vbox


Ignore:
Timestamp:
Mar 24, 2017 12:08:14 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
114164
Message:

FE/Qt: Machine settings: Refactoring (moving some code to appropriate places).

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

Legend:

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

    r66183 r66243  
    165165}
    166166
    167 void UIMachineSettingsAudio::setOrderAfter(QWidget *pWidget)
    168 {
    169     /* Audio-page order: */
    170     setTabOrder(pWidget, m_pCheckBoxAudio);
    171     setTabOrder(m_pCheckBoxAudio, m_pComboAudioDriver);
    172     setTabOrder(m_pComboAudioDriver, m_pComboAudioController);
    173 }
    174 
    175167void UIMachineSettingsAudio::retranslateUi()
    176168{
    177169    /* Translate generated strings: */
    178170    Ui::UIMachineSettingsAudio::retranslateUi(this);
    179 
    180171
    181172    /* Translate audio-driver combo.
    182173     * Make sure this order corresponds the same in prepareComboboxes(): */
    183174    int iIndex = -1;
    184 
    185175    m_pComboAudioDriver->setItemText(++iIndex, gpConverter->toString(KAudioDriverType_Null));
    186 
    187176#ifdef Q_OS_WIN
    188177    m_pComboAudioDriver->setItemText(++iIndex, gpConverter->toString(KAudioDriverType_DirectSound));
     
    191180# endif /* VBOX_WITH_WINMM */
    192181#endif /* Q_OS_WIN */
    193 
    194182#ifdef VBOX_WITH_AUDIO_OSS
    195183    m_pComboAudioDriver->setItemText(++iIndex, gpConverter->toString(KAudioDriverType_OSS));
    196184#endif
    197 
    198185#ifdef VBOX_WITH_AUDIO_ALSA
    199186    m_pComboAudioDriver->setItemText(++iIndex, gpConverter->toString(KAudioDriverType_ALSA));
    200187#endif
    201 
    202188#ifdef VBOX_WITH_AUDIO_PULSE
    203189    m_pComboAudioDriver->setItemText(++iIndex, gpConverter->toString(KAudioDriverType_Pulse));
    204190#endif
    205 
    206191#ifdef Q_OS_MACX
    207192    m_pComboAudioDriver->setItemText(++iIndex, gpConverter->toString(KAudioDriverType_CoreAudio));
    208193#endif /* Q_OS_MACX */
    209194
    210 
    211195    /* Translate audio-controller combo.
    212196     * Make sure this order corresponds the same in prepareComboboxes(): */
    213197    iIndex = -1;
    214 
    215198    m_pComboAudioController->setItemText(++iIndex, gpConverter->toString(KAudioControllerType_HDA));
    216199    m_pComboAudioController->setItemText(++iIndex, gpConverter->toString(KAudioControllerType_AC97));
     
    242225     * Make sure this order corresponds the same in retranslateUi(): */
    243226    int iIndex = -1;
    244 
    245227    m_pComboAudioDriver->insertItem(++iIndex, "", KAudioDriverType_Null);
    246 
    247228#ifdef Q_OS_WIN
    248229    m_pComboAudioDriver->insertItem(++iIndex, "", KAudioDriverType_DirectSound);
     
    267248     * Make sure this order corresponds the same in retranslateUi(): */
    268249    iIndex = -1;
    269 
    270250    m_pComboAudioController->insertItem(++iIndex, "", KAudioControllerType_HDA);
    271251    m_pComboAudioController->insertItem(++iIndex, "", KAudioControllerType_AC97);
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.h

    r66190 r66243  
    6060    virtual void saveFromCacheTo(QVariant &data) /* overrride */;
    6161
    62     /** Defines TAB order. */
    63     virtual void setOrderAfter(QWidget *pWidget) /* override */;
    64 
    6562    /** Handles translation event. */
    6663    virtual void retranslateUi() /* override */;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r66183 r66243  
    870870    prepareVideoCaptureTab();
    871871
    872     /* Prepare validation: */
    873     prepareValidation();
    874 
    875872    /* Translate finally: */
    876873    retranslateUi();
     
    933930    vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorGuestScreenScale, 5);
    934931    connect(m_pEditorGuestScreenScale, SIGNAL(valueChanged(int)), this, SLOT(sltHandleGuestScreenScaleEditorChange()));
     932
     933    /* Prepare advanced options: */
     934    connect(m_pCheckbox3D, SIGNAL(stateChanged(int)), this, SLOT(revalidate()));
     935#ifdef VBOX_WITH_VIDEOHWACCEL
     936    connect(m_pCheckbox2DVideo, SIGNAL(stateChanged(int)), this, SLOT(revalidate()));
     937#endif
    935938}
    936939
    937940void UIMachineSettingsDisplay::prepareRemoteDisplayTab()
    938941{
    939     /* Setup validators: */
     942    /* Prepare check-box: */
     943    connect(m_pCheckboxRemoteDisplay, SIGNAL(toggled(bool)), this, SLOT(revalidate()));
     944
     945    /* Prepare port/timeout editors: */
    940946    m_pEditorRemoteDisplayPort->setValidator(new QRegExpValidator(QRegExp("(([0-9]{1,5}(\\-[0-9]{1,5}){0,1}),)*([0-9]{1,5}(\\-[0-9]{1,5}){0,1})"), this));
    941947    m_pEditorRemoteDisplayTimeout->setValidator(new QIntValidator(this));
     948    connect(m_pEditorRemoteDisplayPort, SIGNAL(textChanged(const QString &)), this, SLOT(revalidate()));
     949    connect(m_pEditorRemoteDisplayTimeout, SIGNAL(textChanged(const QString &)), this, SLOT(revalidate()));
    942950
    943951    /* Prepare auth-method combo: */
     
    10291037}
    10301038
    1031 void UIMachineSettingsDisplay::prepareValidation()
    1032 {
    1033     /* Configure validation: */
    1034     connect(m_pCheckbox3D, SIGNAL(stateChanged(int)), this, SLOT(revalidate()));
    1035 #ifdef VBOX_WITH_VIDEOHWACCEL
    1036     connect(m_pCheckbox2DVideo, SIGNAL(stateChanged(int)), this, SLOT(revalidate()));
    1037 #endif /* VBOX_WITH_VIDEOHWACCEL */
    1038     connect(m_pCheckboxRemoteDisplay, SIGNAL(toggled(bool)), this, SLOT(revalidate()));
    1039     connect(m_pEditorRemoteDisplayPort, SIGNAL(textChanged(const QString&)), this, SLOT(revalidate()));
    1040     connect(m_pEditorRemoteDisplayTimeout, SIGNAL(textChanged(const QString&)), this, SLOT(revalidate()));
    1041 }
    1042 
    10431039void UIMachineSettingsDisplay::checkVRAMRequirements()
    10441040{
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.h

    r66190 r66243  
    4747    /* API: Correlation stuff: */
    4848    void setGuestOSType(CGuestOSType guestOSType);
     49
    4950#ifdef VBOX_WITH_VIDEOHWACCEL
    5051    bool isAcceleration2DVideoSelected() const;
     
    112113    /** Prepare routine: Video Capture tab. */
    113114    void prepareVideoCaptureTab();
    114     /** Prepare routine: Validation. */
    115     void prepareValidation();
    116115
    117116    /* Helpers: Video stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsInterface.cpp

    r66183 r66243  
    312312}
    313313
    314 void UIMachineSettingsInterface::setOrderAfter(QWidget *pWidget)
    315 {
    316     /* Tab-order: */
    317     setTabOrder(pWidget, m_pCheckBoxShowMiniToolBar);
    318     setTabOrder(m_pCheckBoxShowMiniToolBar, m_pComboToolBarAlignment);
    319 }
    320 
    321314void UIMachineSettingsInterface::retranslateUi()
    322315{
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsInterface.h

    r66190 r66243  
    6161    virtual void saveFromCacheTo(QVariant &data) /* overrride */;
    6262
    63     /** Defines TAB order. */
    64     virtual void setOrderAfter(QWidget *pWidget) /* override */;
    65 
    6663    /** Handles translation event. */
    6764    virtual void retranslateUi() /* override */;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.cpp

    r66183 r66243  
    2424
    2525/* GUI includes: */
     26# include "QITabWidget.h"
    2627# include "QIWidgetValidator.h"
    27 # include "QITabWidget.h"
    2828# include "UIMachineSettingsParallel.h"
    2929# include "VBoxGlobal.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.cpp

    r66190 r66243  
    236236};
    237237
     238
    238239UIMachineSettingsSF::UIMachineSettingsSF()
    239240    : mNewAction(0), mEdtAction(0), mDelAction(0)
     
    296297}
    297298
    298 void UIMachineSettingsSF::resizeEvent (QResizeEvent *aEvent)
    299 {
    300     NOREF(aEvent);
    301     adjustList();
    302 }
    303 
    304299bool UIMachineSettingsSF::changed() const
    305300{
     
    476471}
    477472
    478 void UIMachineSettingsSF::setOrderAfter (QWidget *aWidget)
    479 {
    480     setTabOrder (aWidget, mTwFolders);
    481 }
    482 
    483473void UIMachineSettingsSF::retranslateUi()
    484474{
     
    512502    /* Update root items visibility: */
    513503    updateRootItemsVisibility();
     504}
     505
     506void UIMachineSettingsSF::showEvent (QShowEvent *aEvent)
     507{
     508    UISettingsPageMachine::showEvent (aEvent);
     509
     510    /* Connect header-resize signal just before widget is shown after all the items properly loaded and initialized. */
     511    connect (mTwFolders->header(), SIGNAL (sectionResized (int, int, int)), this, SLOT (adjustFields()));
     512
     513    /* Adjusting size after all pending show events are processed. */
     514    QTimer::singleShot (0, this, SLOT (adjustList()));
     515}
     516
     517void UIMachineSettingsSF::resizeEvent (QResizeEvent *aEvent)
     518{
     519    NOREF(aEvent);
     520    adjustList();
    514521}
    515522
     
    598605    if (aCurrentItem && aCurrentItem->parent() && !aCurrentItem->isSelected())
    599606        aCurrentItem->setSelected (true);
    600     QString key = !aCurrentItem ? QString::null : aCurrentItem->parent() ?
    601                   aCurrentItem->parent()->text (1) : aCurrentItem->text (1);
    602607    bool addEnabled = aCurrentItem;
    603608    bool removeEnabled = addEnabled && aCurrentItem->parent();
     
    677682}
    678683
    679 void UIMachineSettingsSF::showEvent (QShowEvent *aEvent)
    680 {
    681     UISettingsPageMachine::showEvent (aEvent);
    682 
    683     /* Connect header-resize signal just before widget is shown after all the items properly loaded and initialized. */
    684     connect (mTwFolders->header(), SIGNAL (sectionResized (int, int, int)), this, SLOT (adjustFields()));
    685 
    686     /* Adjusting size after all pending show events are processed. */
    687     QTimer::singleShot (0, this, SLOT (adjustList()));
    688 }
    689 
    690684SFTreeViewItem* UIMachineSettingsSF::root(UISharedFolderType sharedFolderType)
    691685{
     
    807801    }
    808802    return sharedFolders;
    809 }
    810 
    811 bool UIMachineSettingsSF::removeSharedFolder(const UISettingsCacheSharedFolder &folderCache)
    812 {
    813     /* Get shared folder data: */
    814     const UIDataSettingsSharedFolder &folderData = folderCache.base();
    815     QString strName = folderData.m_strName;
    816     QString strPath = folderData.m_strHostPath;
    817     UISharedFolderType sharedFoldersType = folderData.m_type;
    818 
    819     /* Get current shared folders: */
    820     CSharedFolderVector sharedFolders = getSharedFolders(sharedFoldersType);
    821     /* Check that such shared folder really exists: */
    822     CSharedFolder sharedFolder;
    823     for (int iSharedFolderIndex = 0; iSharedFolderIndex < sharedFolders.size(); ++iSharedFolderIndex)
    824         if (sharedFolders[iSharedFolderIndex].GetName() == strName)
    825             sharedFolder = sharedFolders[iSharedFolderIndex];
    826     if (!sharedFolder.isNull())
    827     {
    828         /* Remove existing shared folder: */
    829         switch(sharedFoldersType)
    830         {
    831             case MachineType:
    832             {
    833                 m_machine.RemoveSharedFolder(strName);
    834                 if (!m_machine.isOk())
    835                 {
    836                     /* Mark the page as failed: */
    837                     setFailed(true);
    838                     /* Show error message: */
    839                     msgCenter().cannotRemoveSharedFolder(m_machine, strName, strPath, this);
    840                     /* Finish early: */
    841                     return false;
    842                 }
    843                 break;
    844             }
    845             case ConsoleType:
    846             {
    847                 m_console.RemoveSharedFolder(strName);
    848                 if (!m_console.isOk())
    849                 {
    850                     /* Mark the page as failed: */
    851                     setFailed(true);
    852                     /* Show error message: */
    853                     msgCenter().cannotRemoveSharedFolder(m_console, strName, strPath, this);
    854                     /* Finish early: */
    855                     return false;
    856                 }
    857                 break;
    858             }
    859             default:
    860                 break;
    861         }
    862     }
    863     return true;
    864803}
    865804
     
    922861}
    923862
     863bool UIMachineSettingsSF::removeSharedFolder(const UISettingsCacheSharedFolder &folderCache)
     864{
     865    /* Get shared folder data: */
     866    const UIDataSettingsSharedFolder &folderData = folderCache.base();
     867    QString strName = folderData.m_strName;
     868    QString strPath = folderData.m_strHostPath;
     869    UISharedFolderType sharedFoldersType = folderData.m_type;
     870
     871    /* Get current shared folders: */
     872    CSharedFolderVector sharedFolders = getSharedFolders(sharedFoldersType);
     873    /* Check that such shared folder really exists: */
     874    CSharedFolder sharedFolder;
     875    for (int iSharedFolderIndex = 0; iSharedFolderIndex < sharedFolders.size(); ++iSharedFolderIndex)
     876        if (sharedFolders[iSharedFolderIndex].GetName() == strName)
     877            sharedFolder = sharedFolders[iSharedFolderIndex];
     878    if (!sharedFolder.isNull())
     879    {
     880        /* Remove existing shared folder: */
     881        switch(sharedFoldersType)
     882        {
     883            case MachineType:
     884            {
     885                m_machine.RemoveSharedFolder(strName);
     886                if (!m_machine.isOk())
     887                {
     888                    /* Mark the page as failed: */
     889                    setFailed(true);
     890                    /* Show error message: */
     891                    msgCenter().cannotRemoveSharedFolder(m_machine, strName, strPath, this);
     892                    /* Finish early: */
     893                    return false;
     894                }
     895                break;
     896            }
     897            case ConsoleType:
     898            {
     899                m_console.RemoveSharedFolder(strName);
     900                if (!m_console.isOk())
     901                {
     902                    /* Mark the page as failed: */
     903                    setFailed(true);
     904                    /* Show error message: */
     905                    msgCenter().cannotRemoveSharedFolder(m_console, strName, strPath, this);
     906                    /* Finish early: */
     907                    return false;
     908                }
     909                break;
     910            }
     911            default:
     912                break;
     913        }
     914    }
     915    return true;
     916}
     917
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.h

    r66190 r66243  
    7373    void saveFromCacheTo(UISharedFolderType sharedFoldersType);
    7474
    75     /** Defines TAB order. */
    76     virtual void setOrderAfter(QWidget *pWidget) /* override */;
    77 
    7875    /** Handles translation event. */
    7976    virtual void retranslateUi() /* override */;
     
    8178    /** Performs final page polishing. */
    8279    virtual void polishPage() /* override */;
     80
     81    /** Handles show @a pEvent. */
     82    virtual void showEvent(QShowEvent *aEvent) /* override */;
     83
     84    /** Handles resize @a pEvent. */
     85    virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
    8386
    8487private slots:
     
    97100private:
    98101
    99     void resizeEvent (QResizeEvent *aEvent);
    100 
    101     void showEvent (QShowEvent *aEvent);
    102 
    103102    SFTreeViewItem* root(UISharedFolderType type);
    104103    SFoldersNameList usedList (bool aIncludeSelected);
     
    110109    CSharedFolderVector getSharedFolders(UISharedFolderType sharedFoldersType);
    111110
     111    bool createSharedFolder(const UISettingsCacheSharedFolder &folderCache);
    112112    bool removeSharedFolder(const UISettingsCacheSharedFolder &folderCache);
    113     bool createSharedFolder(const UISettingsCacheSharedFolder &folderCache);
    114113
    115114    QAction  *mNewAction;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r66190 r66243  
    197197};
    198198UIIconPoolStorageSettings* iconPool() { return UIIconPoolStorageSettings::instance(); }
     199
    199200
    200201/* static */
     
    443444}
    444445
     446
    445447/* IDE Controller Type */
    446448IDEControllerType::IDEControllerType (KStorageControllerType aSubType)
     
    459461}
    460462
     463
    461464/* SATA Controller Type */
    462465SATAControllerType::SATAControllerType (KStorageControllerType aSubType)
     
    475478}
    476479
     480
    477481/* SCSI Controller Type */
    478482SCSIControllerType::SCSIControllerType (KStorageControllerType aSubType)
     
    491495}
    492496
     497
    493498/* Floppy Controller Type */
    494499FloppyControllerType::FloppyControllerType (KStorageControllerType aSubType)
     
    507512}
    508513
     514
    509515/* SAS Controller Type */
    510516SASControllerType::SASControllerType (KStorageControllerType aSubType)
     
    523529}
    524530
     531
    525532/* USB Controller Type */
    526533USBStorageControllerType::USBStorageControllerType (KStorageControllerType aSubType)
     
    539546}
    540547
     548
    541549/* NVMe Controller Type */
    542550NVMeStorageControllerType::NVMeStorageControllerType (KStorageControllerType aSubType)
     
    554562    return 1;
    555563}
     564
    556565
    557566/* Abstract Item */
     
    600609}
    601610
     611
    602612/* Root Item */
    603613RootItem::RootItem(QITreeView *pParent)
     
    676686    mControllers.removeAll (aItem);
    677687}
     688
    678689
    679690/* Controller Item */
     
    873884}
    874885
     886
    875887/* Attachment Item */
    876888AttachmentItem::AttachmentItem (AbstractItem *aParent, KDeviceType aDeviceType)
     
    11351147{
    11361148}
     1149
    11371150
    11381151/* Storage model */
     
    19671980}
    19681981
     1982
    19691983/* Storage Delegate */
    19701984StorageDelegate::StorageDelegate (QObject *aParent)
     
    20742088}
    20752089
     2090
    20762091/**
    20772092 * UI Medium ID Holder.
     
    21162131    , mAddHDAttAction(0), mAddCDAttAction(0), mAddFDAttAction(0)
    21172132    , m_pMediumIdHolder(new UIMediumIDHolder(this))
     2133    , mIsPolished(false)
    21182134    , mIsLoadingInProgress(0)
    2119     , mIsPolished(false)
    2120     , mDisableStaticControls(0)
    21212135    , m_pCache(new UISettingsCacheMachineStorage)
    21222136{
     
    26082622}
    26092623
     2624void UIMachineSettingsStorage::setConfigurationAccessLevel(ConfigurationAccessLevel newConfigurationAccessLevel)
     2625{
     2626    /* Update model 'configuration access level': */
     2627    mStorageModel->setConfigurationAccessLevel(newConfigurationAccessLevel);
     2628    /* Update 'configuration access level' of base class: */
     2629    UISettingsPageMachine::setConfigurationAccessLevel(newConfigurationAccessLevel);
     2630}
     2631
    26102632void UIMachineSettingsStorage::retranslateUi()
    26112633{
     
    28282850{
    28292851    QModelIndex index = mTwStorageTree->currentIndex();
    2830     if (!mStorageModel->data (index, StorageModel::R_IsController).toBool()) return;
     2852    if (!mStorageModel->data (index, StorageModel::R_IsController).toBool())
     2853        return;
    28312854
    28322855    mStorageModel->delController (QUuid (mStorageModel->data (index, StorageModel::R_ItemId).toString()));
     
    30643087{
    30653088    QModelIndex index = mTwStorageTree->currentIndex();
    3066     if (mIsLoadingInProgress || !index.isValid() || index == mStorageModel->root()) return;
     3089    if (mIsLoadingInProgress || !index.isValid() || index == mStorageModel->root())
     3090        return;
    30673091
    30683092    QObject *sdr = sender();
     
    33653389void UIMachineSettingsStorage::onDrawItemBranches (QPainter *aPainter, const QRect &aRect, const QModelIndex &aIndex)
    33663390{
    3367     if (!aIndex.parent().isValid() || !aIndex.parent().parent().isValid()) return;
     3391    if (!aIndex.parent().isValid() || !aIndex.parent().parent().isValid())
     3392        return;
    33683393
    33693394    aPainter->save();
     
    38433868        KStorageBus controllerBus = controllerData.m_controllerBus;
    38443869        KStorageControllerType controllerType = controllerData.m_controllerType;
     3870        bool fUseHostIOCache = controllerData.m_fUseHostIOCache;
    38453871        ULONG uPortCount = controllerData.m_uPortCount;
    3846         bool fUseHostIOCache = controllerData.m_fUseHostIOCache;
    38473872
    38483873        /* Check that storage controller doesn't exists: */
     
    38993924        KStorageBus controllerBus = controllerData.m_controllerBus;
    39003925        KStorageControllerType controllerType = controllerData.m_controllerType;
     3926        bool fUseHostIOCache = controllerData.m_fUseHostIOCache;
    39013927        ULONG uPortCount = controllerData.m_uPortCount;
    3902         bool fUseHostIOCache = controllerData.m_fUseHostIOCache;
    39033928
    39043929        /* Check that controller exists: */
     
    41854210}
    41864211
    4187 void UIMachineSettingsStorage::setConfigurationAccessLevel(ConfigurationAccessLevel newConfigurationAccessLevel)
    4188 {
    4189     /* Update model 'configuration access level': */
    4190     mStorageModel->setConfigurationAccessLevel(newConfigurationAccessLevel);
    4191     /* Update 'configuration access level' of base class: */
    4192     UISettingsPageMachine::setConfigurationAccessLevel(newConfigurationAccessLevel);
    4193 }
    4194 
    41954212# include "UIMachineSettingsStorage.moc"
    41964213
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h

    r66190 r66243  
    591591
    592592    void paint (QPainter *aPainter, const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const;
    593 
    594     bool mDisableStaticControls;
    595593};
    596594
     
    601599{
    602600    Q_OBJECT;
     601
     602signals:
     603
     604    void storageChanged();
    603605
    604606public:
     
    610612
    611613    void setChipsetType(KChipsetType type);
    612 
    613 signals:
    614 
    615     void storageChanged();
    616614
    617615protected:
     
    636634    /** Performs validation, updates @a messages list if something is wrong. */
    637635    virtual bool validate(QList<UIValidationMessage> &messages) /* override */;
     636
     637    /** Defines the configuration access @a enmLevel. */
     638    virtual void setConfigurationAccessLevel(ConfigurationAccessLevel enmLevel) /* override */;
    638639
    639640    /** Handles translation event. */
     
    721722    bool isControllerCouldBeUpdated(const UISettingsCacheMachineStorageController &controllerCache) const;
    722723    bool isAttachmentCouldBeUpdated(const UISettingsCacheMachineStorageAttachment &attachmentCache) const;
    723 
    724     /** Defines configuration access level. */
    725     void setConfigurationAccessLevel(ConfigurationAccessLevel configurationAccessLevel);
    726724
    727725    QString m_strMachineId;
     
    751749    UIMediumIDHolder *m_pMediumIdHolder;
    752750
    753     bool mIsLoadingInProgress;
    754     bool mIsPolished;
    755     bool mDisableStaticControls;
     751    bool  mIsPolished;
     752    bool  mIsLoadingInProgress;
    756753
    757754    /** Holds the page data cache instance. */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp

    r66183 r66243  
    632632}
    633633
    634 void UIMachineSettingsSystem::sltHandleMemorySizeSliderChange()
    635 {
    636     /* Apply new memory-size value: */
    637     m_pEditorMemorySize->blockSignals(true);
    638     m_pEditorMemorySize->setValue(m_pSliderMemorySize->value());
    639     m_pEditorMemorySize->blockSignals(false);
    640 
    641     /* Revalidate: */
    642     revalidate();
    643 }
    644 
    645 void UIMachineSettingsSystem::sltHandleMemorySizeEditorChange()
    646 {
    647     /* Apply new memory-size value: */
    648     m_pSliderMemorySize->blockSignals(true);
    649     m_pSliderMemorySize->setValue(m_pEditorMemorySize->value());
    650     m_pSliderMemorySize->blockSignals(false);
    651 
    652     /* Revalidate: */
    653     revalidate();
    654 }
    655 
    656 void UIMachineSettingsSystem::sltCurrentBootItemChanged(int iCurrentItem)
    657 {
    658     /* Update boot-order tool-buttons: */
    659     bool fEnabledUP = iCurrentItem > 0;
    660     bool fEnabledDOWN = iCurrentItem < mTwBootOrder->count() - 1;
    661     if ((mTbBootItemUp->hasFocus() && !fEnabledUP) ||
    662         (mTbBootItemDown->hasFocus() && !fEnabledDOWN))
    663         mTwBootOrder->setFocus();
    664     mTbBootItemUp->setEnabled(fEnabledUP);
    665     mTbBootItemDown->setEnabled(fEnabledDOWN);
    666 }
    667 
    668 void UIMachineSettingsSystem::sltHandleCPUCountSliderChange()
    669 {
    670     /* Apply new memory-size value: */
    671     m_pEditorCPUCount->blockSignals(true);
    672     m_pEditorCPUCount->setValue(m_pSliderCPUCount->value());
    673     m_pEditorCPUCount->blockSignals(false);
    674 
    675     /* Revalidate: */
    676     revalidate();
    677 }
    678 
    679 void UIMachineSettingsSystem::sltHandleCPUCountEditorChange()
    680 {
    681     /* Apply new memory-size value: */
    682     m_pSliderCPUCount->blockSignals(true);
    683     m_pSliderCPUCount->setValue(m_pEditorCPUCount->value());
    684     m_pSliderCPUCount->blockSignals(false);
    685 
    686     /* Revalidate: */
    687     revalidate();
    688 }
    689 
    690 void UIMachineSettingsSystem::sltHandleCPUExecCapSliderChange()
    691 {
    692     /* Apply new memory-size value: */
    693     m_pEditorCPUExecCap->blockSignals(true);
    694     m_pEditorCPUExecCap->setValue(m_pSliderCPUExecCap->value());
    695     m_pEditorCPUExecCap->blockSignals(false);
    696 
    697     /* Revalidate: */
    698     revalidate();
    699 }
    700 
    701 void UIMachineSettingsSystem::sltHandleCPUExecCapEditorChange()
    702 {
    703     /* Apply new memory-size value: */
    704     m_pSliderCPUExecCap->blockSignals(true);
    705     m_pSliderCPUExecCap->setValue(m_pEditorCPUExecCap->value());
    706     m_pSliderCPUExecCap->blockSignals(false);
    707 
    708     /* Revalidate: */
    709     revalidate();
    710 }
    711 
    712 void UIMachineSettingsSystem::prepare()
    713 {
    714     /* Apply UI decorations: */
    715     Ui::UIMachineSettingsSystem::setupUi(this);
    716 
    717     /* Prepare tabs: */
    718     prepareTabMotherboard();
    719     prepareTabProcessor();
    720     prepareTabAcceleration();
    721 
    722     /* Prepare validation: */
    723     prepareValidation();
    724 
    725     /* Retranslate finally: */
    726     retranslateUi();
    727 }
    728 
    729 void UIMachineSettingsSystem::prepareTabMotherboard()
    730 {
    731     /* Load configuration: */
    732     CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties();
    733 
    734     /* Preconfigure memory-size editor: */
    735     m_pEditorMemorySize->setMinimum(m_pSliderMemorySize->minRAM());
    736     m_pEditorMemorySize->setMaximum(m_pSliderMemorySize->maxRAM());
    737     vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorMemorySize, 5);
    738 
    739     /* Preconfigure boot-table widgets: */
    740     mTbBootItemUp->setIcon(UIIconPool::iconSet(":/list_moveup_16px.png", ":/list_moveup_disabled_16px.png"));
    741     mTbBootItemDown->setIcon(UIIconPool::iconSet(":/list_movedown_16px.png", ":/list_movedown_disabled_16px.png"));
    742 #ifdef VBOX_WS_MAC
    743     /* We need a little space for the focus rect: */
    744     m_pLayoutBootOrder->setContentsMargins(3, 3, 3, 3);
    745     m_pLayoutBootOrder->setSpacing(3);
    746 #endif /* VBOX_WS_MAC */
    747     /* Install global event filter
    748      * to handle boot-table focus in/out events: */
    749     /// @todo Get rid of that *crap*!
    750     qApp->installEventFilter(this);
    751 
    752     /* Populate possible boot items list.
    753      * Currently, it seems, we are supporting only 4 possible boot device types:
    754      * 1. Floppy, 2. DVD-ROM, 3. Hard Disk, 4. Network.
    755      * But maximum boot devices count supported by machine
    756      * should be retrieved through the ISystemProperties getter.
    757      * Moreover, possible boot device types are not listed in some separate Main vector,
    758      * so we should get them (randomely?) from the list of all device types.
    759      * Until there will be separate Main getter for list of supported boot device types,
    760      * this list will be hard-coded here... */
    761     int iPossibleBootListSize = qMin((ULONG)4, properties.GetMaxBootPosition());
    762     for (int iBootPosition = 1; iBootPosition <= iPossibleBootListSize; ++iBootPosition)
    763     {
    764         switch (iBootPosition)
    765         {
    766             case 1: m_possibleBootItems << KDeviceType_Floppy; break;
    767             case 2: m_possibleBootItems << KDeviceType_DVD; break;
    768             case 3: m_possibleBootItems << KDeviceType_HardDisk; break;
    769             case 4: m_possibleBootItems << KDeviceType_Network; break;
    770             default: break;
    771         }
    772     }
    773     /* Add all available devices types, so we could initially calculate the right size: */
    774     for (int i = 0; i < m_possibleBootItems.size(); ++i)
    775     {
    776         QListWidgetItem *pItem = new UIBootTableItem(m_possibleBootItems[i]);
    777         mTwBootOrder->addItem(pItem);
    778     }
    779 
    780     /* Populate 'chipset type' combo: */
    781     m_pComboChipsetType->addItem(gpConverter->toString(KChipsetType_PIIX3), QVariant(KChipsetType_PIIX3));
    782     m_pComboChipsetType->addItem(gpConverter->toString(KChipsetType_ICH9), QVariant(KChipsetType_ICH9));
    783 
    784     /* Preconfigure 'pointing HID type' combo: */
    785     m_pComboPointingHIDType->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    786 
    787     /* Install memory-size widget connections: */
    788     connect(m_pSliderMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleMemorySizeSliderChange()));
    789     connect(m_pEditorMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleMemorySizeEditorChange()));
    790 
    791     /* Install boot-table connections: */
    792     connect(mTbBootItemUp, SIGNAL(clicked()), mTwBootOrder, SLOT(sltMoveItemUp()));
    793     connect(mTbBootItemDown, SIGNAL(clicked()), mTwBootOrder, SLOT(sltMoveItemDown()));
    794     connect(mTwBootOrder, SIGNAL(sigRowChanged(int)), this, SLOT(sltCurrentBootItemChanged(int)));
    795 }
    796 
    797 void UIMachineSettingsSystem::prepareTabProcessor()
    798 {
    799     /* Load configuration: */
    800     CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties();
    801     uint hostCPUs = vboxGlobal().host().GetProcessorOnlineCoreCount();
    802     m_uMinGuestCPU = properties.GetMinGuestCPUCount();
    803     m_uMaxGuestCPU = qMin(2 * hostCPUs, (uint)properties.GetMaxGuestCPUCount());
    804     m_uMinGuestCPUExecCap = 1;
    805     m_uMedGuestCPUExecCap = 40;
    806     m_uMaxGuestCPUExecCap = 100;
    807 
    808     /* Preconfigure CPU-count slider: */
    809     m_pSliderCPUCount->setPageStep(1);
    810     m_pSliderCPUCount->setSingleStep(1);
    811     m_pSliderCPUCount->setTickInterval(1);
    812     m_pSliderCPUCount->setMinimum(m_uMinGuestCPU);
    813     m_pSliderCPUCount->setMaximum(m_uMaxGuestCPU);
    814     m_pSliderCPUCount->setOptimalHint(1, hostCPUs);
    815     m_pSliderCPUCount->setWarningHint(hostCPUs, m_uMaxGuestCPU);
    816 
    817     /* Preconfigure CPU-count editor: */
    818     m_pEditorCPUCount->setMinimum(m_uMinGuestCPU);
    819     m_pEditorCPUCount->setMaximum(m_uMaxGuestCPU);
    820     vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorCPUCount, 4);
    821 
    822     /* Preconfigure CPU-execution-cap slider: */
    823     m_pSliderCPUExecCap->setPageStep(10);
    824     m_pSliderCPUExecCap->setSingleStep(1);
    825     m_pSliderCPUExecCap->setTickInterval(10);
    826     /* Setup the scale so that ticks are at page step boundaries: */
    827     m_pSliderCPUExecCap->setMinimum(m_uMinGuestCPUExecCap);
    828     m_pSliderCPUExecCap->setMaximum(m_uMaxGuestCPUExecCap);
    829     m_pSliderCPUExecCap->setWarningHint(m_uMinGuestCPUExecCap, m_uMedGuestCPUExecCap);
    830     m_pSliderCPUExecCap->setOptimalHint(m_uMedGuestCPUExecCap, m_uMaxGuestCPUExecCap);
    831 
    832     /* Preconfigure CPU-execution-cap editor: */
    833     m_pEditorCPUExecCap->setMinimum(m_uMinGuestCPUExecCap);
    834     m_pEditorCPUExecCap->setMaximum(m_uMaxGuestCPUExecCap);
    835     vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorCPUExecCap, 4);
    836 
    837     /* Install CPU widget connections: */
    838     connect(m_pSliderCPUCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleCPUCountSliderChange()));
    839     connect(m_pEditorCPUCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleCPUCountEditorChange()));
    840     connect(m_pSliderCPUExecCap, SIGNAL(valueChanged(int)), this, SLOT(sltHandleCPUExecCapSliderChange()));
    841     connect(m_pEditorCPUExecCap, SIGNAL(valueChanged(int)), this, SLOT(sltHandleCPUExecCapEditorChange()));
    842 }
    843 
    844 void UIMachineSettingsSystem::prepareTabAcceleration()
    845 {
    846     /* Populate 'paravirt provider' combo: */
    847     m_pComboParavirtProvider->addItem(gpConverter->toString(KParavirtProvider_None), QVariant(KParavirtProvider_None));
    848     m_pComboParavirtProvider->addItem(gpConverter->toString(KParavirtProvider_Default), QVariant(KParavirtProvider_Default));
    849     m_pComboParavirtProvider->addItem(gpConverter->toString(KParavirtProvider_Legacy), QVariant(KParavirtProvider_Legacy));
    850     m_pComboParavirtProvider->addItem(gpConverter->toString(KParavirtProvider_Minimal), QVariant(KParavirtProvider_Minimal));
    851     m_pComboParavirtProvider->addItem(gpConverter->toString(KParavirtProvider_HyperV), QVariant(KParavirtProvider_HyperV));
    852     m_pComboParavirtProvider->addItem(gpConverter->toString(KParavirtProvider_KVM), QVariant(KParavirtProvider_KVM));
    853 
    854     /* Hide VT-x/AMD-V checkbox when raw-mode is not supported: */
    855 #ifndef VBOX_WITH_RAW_MODE
    856     m_pWidgetPlaceholder->setVisible(false);
    857     m_pCheckBoxVirtualization->setVisible(false);
    858 #endif /* !VBOX_WITH_RAW_MODE */
    859 }
    860 
    861 void UIMachineSettingsSystem::prepareValidation()
    862 {
    863     /* Prepare validation: */
    864     connect(m_pComboChipsetType, SIGNAL(currentIndexChanged(int)), this, SLOT(revalidate()));
    865     connect(m_pComboPointingHIDType, SIGNAL(currentIndexChanged(int)), this, SLOT(revalidate()));
    866     connect(m_pCheckBoxApic, SIGNAL(stateChanged(int)), this, SLOT(revalidate()));
    867     connect(m_pCheckBoxVirtualization, SIGNAL(stateChanged(int)), this, SLOT(revalidate()));
    868 }
    869 
    870 void UIMachineSettingsSystem::repopulateComboPointingHIDType()
    871 {
    872     /* Is there any value currently present/selected? */
    873     KPointingHIDType currentValue = KPointingHIDType_None;
    874     {
    875         int iCurrentIndex = m_pComboPointingHIDType->currentIndex();
    876         if (iCurrentIndex != -1)
    877             currentValue = (KPointingHIDType)m_pComboPointingHIDType->itemData(iCurrentIndex).toInt();
    878     }
    879 
    880     /* Clear combo: */
    881     m_pComboPointingHIDType->clear();
    882 
    883     /* Repopulate combo taking into account currently cached value: */
    884     KPointingHIDType cachedValue = m_pCache->base().m_pointingHIDType;
    885     {
    886         /* "PS/2 Mouse" value is always here: */
    887         m_pComboPointingHIDType->addItem(gpConverter->toString(KPointingHIDType_PS2Mouse), (int)KPointingHIDType_PS2Mouse);
    888 
    889         /* "USB Mouse" value is here only if it is currently selected: */
    890         if (cachedValue == KPointingHIDType_USBMouse)
    891             m_pComboPointingHIDType->addItem(gpConverter->toString(KPointingHIDType_USBMouse), (int)KPointingHIDType_USBMouse);
    892 
    893         /* "USB Mouse/Tablet" value is always here: */
    894         m_pComboPointingHIDType->addItem(gpConverter->toString(KPointingHIDType_USBTablet), (int)KPointingHIDType_USBTablet);
    895 
    896         /* "PS/2 and USB Mouse" value is here only if it is currently selected: */
    897         if (cachedValue == KPointingHIDType_ComboMouse)
    898             m_pComboPointingHIDType->addItem(gpConverter->toString(KPointingHIDType_ComboMouse), (int)KPointingHIDType_ComboMouse);
    899 
    900         /* "USB Multi-Touch Mouse/Tablet" value is always here: */
    901         m_pComboPointingHIDType->addItem(gpConverter->toString(KPointingHIDType_USBMultiTouch), (int)KPointingHIDType_USBMultiTouch);
    902     }
    903 
    904     /* Was there any value previously present/selected? */
    905     if (currentValue != KPointingHIDType_None)
    906     {
    907         int iPreviousIndex = m_pComboPointingHIDType->findData((int)currentValue);
    908         if (iPreviousIndex != -1)
    909             m_pComboPointingHIDType->setCurrentIndex(iPreviousIndex);
    910     }
    911 }
    912 
    913 void UIMachineSettingsSystem::retranslateComboChipsetType()
    914 {
    915     /* For each the element in KChipsetType enum: */
    916     for (int iIndex = (int)KChipsetType_Null; iIndex < (int)KChipsetType_Max; ++iIndex)
    917     {
    918         /* Cast to the corresponding type: */
    919         KChipsetType type = (KChipsetType)iIndex;
    920         /* Look for the corresponding item: */
    921         int iCorrespondingIndex = m_pComboChipsetType->findData((int)type);
    922         /* Re-translate if corresponding item was found: */
    923         if (iCorrespondingIndex != -1)
    924             m_pComboChipsetType->setItemText(iCorrespondingIndex, gpConverter->toString(type));
    925     }
    926 }
    927 
    928 void UIMachineSettingsSystem::retranslateComboPointingHIDType()
    929 {
    930     /* For each the element in KPointingHIDType enum: */
    931     for (int iIndex = (int)KPointingHIDType_None; iIndex < (int)KPointingHIDType_Max; ++iIndex)
    932     {
    933         /* Cast to the corresponding type: */
    934         KPointingHIDType type = (KPointingHIDType)iIndex;
    935         /* Look for the corresponding item: */
    936         int iCorrespondingIndex = m_pComboPointingHIDType->findData((int)type);
    937         /* Re-translate if corresponding item was found: */
    938         if (iCorrespondingIndex != -1)
    939             m_pComboPointingHIDType->setItemText(iCorrespondingIndex, gpConverter->toString(type));
    940     }
    941 }
    942 
    943 void UIMachineSettingsSystem::retranslateComboParavirtProvider()
    944 {
    945     /* For each the element in KParavirtProvider enum: */
    946     for (int iIndex = (int)KParavirtProvider_None; iIndex < (int)KParavirtProvider_Max; ++iIndex)
    947     {
    948         /* Cast to the corresponding type: */
    949         KParavirtProvider type = (KParavirtProvider)iIndex;
    950         /* Look for the corresponding item: */
    951         int iCorrespondingIndex = m_pComboParavirtProvider->findData((int)type);
    952         /* Re-translate if corresponding item was found: */
    953         if (iCorrespondingIndex != -1)
    954             m_pComboParavirtProvider->setItemText(iCorrespondingIndex, gpConverter->toString(type));
    955     }
    956 }
    957 
    958 void UIMachineSettingsSystem::adjustBootOrderTWSize()
    959 {
    960     /* Adjust boot-table size: */
    961     mTwBootOrder->adjustSizeToFitContent();
    962     /* Update the layout system */
    963     if (m_pTabMotherboard->layout())
    964     {
    965         m_pTabMotherboard->layout()->activate();
    966         m_pTabMotherboard->layout()->update();
    967     }
    968 }
    969 
    970634bool UIMachineSettingsSystem::eventFilter(QObject *pObject, QEvent *pEvent)
    971635{
     
    1008672}
    1009673
     674void UIMachineSettingsSystem::sltHandleMemorySizeSliderChange()
     675{
     676    /* Apply new memory-size value: */
     677    m_pEditorMemorySize->blockSignals(true);
     678    m_pEditorMemorySize->setValue(m_pSliderMemorySize->value());
     679    m_pEditorMemorySize->blockSignals(false);
     680
     681    /* Revalidate: */
     682    revalidate();
     683}
     684
     685void UIMachineSettingsSystem::sltHandleMemorySizeEditorChange()
     686{
     687    /* Apply new memory-size value: */
     688    m_pSliderMemorySize->blockSignals(true);
     689    m_pSliderMemorySize->setValue(m_pEditorMemorySize->value());
     690    m_pSliderMemorySize->blockSignals(false);
     691
     692    /* Revalidate: */
     693    revalidate();
     694}
     695
     696void UIMachineSettingsSystem::sltCurrentBootItemChanged(int iCurrentItem)
     697{
     698    /* Update boot-order tool-buttons: */
     699    bool fEnabledUP = iCurrentItem > 0;
     700    bool fEnabledDOWN = iCurrentItem < mTwBootOrder->count() - 1;
     701    if ((mTbBootItemUp->hasFocus() && !fEnabledUP) ||
     702        (mTbBootItemDown->hasFocus() && !fEnabledDOWN))
     703        mTwBootOrder->setFocus();
     704    mTbBootItemUp->setEnabled(fEnabledUP);
     705    mTbBootItemDown->setEnabled(fEnabledDOWN);
     706}
     707
     708void UIMachineSettingsSystem::sltHandleCPUCountSliderChange()
     709{
     710    /* Apply new memory-size value: */
     711    m_pEditorCPUCount->blockSignals(true);
     712    m_pEditorCPUCount->setValue(m_pSliderCPUCount->value());
     713    m_pEditorCPUCount->blockSignals(false);
     714
     715    /* Revalidate: */
     716    revalidate();
     717}
     718
     719void UIMachineSettingsSystem::sltHandleCPUCountEditorChange()
     720{
     721    /* Apply new memory-size value: */
     722    m_pSliderCPUCount->blockSignals(true);
     723    m_pSliderCPUCount->setValue(m_pEditorCPUCount->value());
     724    m_pSliderCPUCount->blockSignals(false);
     725
     726    /* Revalidate: */
     727    revalidate();
     728}
     729
     730void UIMachineSettingsSystem::sltHandleCPUExecCapSliderChange()
     731{
     732    /* Apply new memory-size value: */
     733    m_pEditorCPUExecCap->blockSignals(true);
     734    m_pEditorCPUExecCap->setValue(m_pSliderCPUExecCap->value());
     735    m_pEditorCPUExecCap->blockSignals(false);
     736
     737    /* Revalidate: */
     738    revalidate();
     739}
     740
     741void UIMachineSettingsSystem::sltHandleCPUExecCapEditorChange()
     742{
     743    /* Apply new memory-size value: */
     744    m_pSliderCPUExecCap->blockSignals(true);
     745    m_pSliderCPUExecCap->setValue(m_pEditorCPUExecCap->value());
     746    m_pSliderCPUExecCap->blockSignals(false);
     747
     748    /* Revalidate: */
     749    revalidate();
     750}
     751
     752void UIMachineSettingsSystem::prepare()
     753{
     754    /* Apply UI decorations: */
     755    Ui::UIMachineSettingsSystem::setupUi(this);
     756
     757    /* Prepare tabs: */
     758    prepareTabMotherboard();
     759    prepareTabProcessor();
     760    prepareTabAcceleration();
     761
     762    /* Retranslate finally: */
     763    retranslateUi();
     764}
     765
     766void UIMachineSettingsSystem::prepareTabMotherboard()
     767{
     768    /* Load configuration: */
     769    CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties();
     770
     771    /* Preconfigure memory-size editor: */
     772    m_pEditorMemorySize->setMinimum(m_pSliderMemorySize->minRAM());
     773    m_pEditorMemorySize->setMaximum(m_pSliderMemorySize->maxRAM());
     774    vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorMemorySize, 5);
     775
     776    /* Preconfigure boot-table widgets: */
     777    mTbBootItemUp->setIcon(UIIconPool::iconSet(":/list_moveup_16px.png", ":/list_moveup_disabled_16px.png"));
     778    mTbBootItemDown->setIcon(UIIconPool::iconSet(":/list_movedown_16px.png", ":/list_movedown_disabled_16px.png"));
     779#ifdef VBOX_WS_MAC
     780    /* We need a little space for the focus rect: */
     781    m_pLayoutBootOrder->setContentsMargins(3, 3, 3, 3);
     782    m_pLayoutBootOrder->setSpacing(3);
     783#endif /* VBOX_WS_MAC */
     784    /* Install global event filter
     785     * to handle boot-table focus in/out events: */
     786    /// @todo Get rid of that *crap*!
     787    qApp->installEventFilter(this);
     788
     789    /* Populate possible boot items list.
     790     * Currently, it seems, we are supporting only 4 possible boot device types:
     791     * 1. Floppy, 2. DVD-ROM, 3. Hard Disk, 4. Network.
     792     * But maximum boot devices count supported by machine
     793     * should be retrieved through the ISystemProperties getter.
     794     * Moreover, possible boot device types are not listed in some separate Main vector,
     795     * so we should get them (randomely?) from the list of all device types.
     796     * Until there will be separate Main getter for list of supported boot device types,
     797     * this list will be hard-coded here... */
     798    int iPossibleBootListSize = qMin((ULONG)4, properties.GetMaxBootPosition());
     799    for (int iBootPosition = 1; iBootPosition <= iPossibleBootListSize; ++iBootPosition)
     800    {
     801        switch (iBootPosition)
     802        {
     803            case 1: m_possibleBootItems << KDeviceType_Floppy; break;
     804            case 2: m_possibleBootItems << KDeviceType_DVD; break;
     805            case 3: m_possibleBootItems << KDeviceType_HardDisk; break;
     806            case 4: m_possibleBootItems << KDeviceType_Network; break;
     807            default: break;
     808        }
     809    }
     810    /* Add all available devices types, so we could initially calculate the right size: */
     811    for (int i = 0; i < m_possibleBootItems.size(); ++i)
     812    {
     813        QListWidgetItem *pItem = new UIBootTableItem(m_possibleBootItems[i]);
     814        mTwBootOrder->addItem(pItem);
     815    }
     816
     817    /* Populate 'chipset type' combo: */
     818    m_pComboChipsetType->addItem(gpConverter->toString(KChipsetType_PIIX3), QVariant(KChipsetType_PIIX3));
     819    m_pComboChipsetType->addItem(gpConverter->toString(KChipsetType_ICH9), QVariant(KChipsetType_ICH9));
     820    connect(m_pComboChipsetType, SIGNAL(currentIndexChanged(int)), this, SLOT(revalidate()));
     821
     822    /* Preconfigure 'pointing HID type' combo: */
     823    m_pComboPointingHIDType->setSizeAdjustPolicy(QComboBox::AdjustToContents);
     824    connect(m_pComboPointingHIDType, SIGNAL(currentIndexChanged(int)), this, SLOT(revalidate()));
     825
     826    /* Install memory-size widget connections: */
     827    connect(m_pSliderMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleMemorySizeSliderChange()));
     828    connect(m_pEditorMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleMemorySizeEditorChange()));
     829
     830    /* Install boot-table connections: */
     831    connect(mTbBootItemUp, SIGNAL(clicked()), mTwBootOrder, SLOT(sltMoveItemUp()));
     832    connect(mTbBootItemDown, SIGNAL(clicked()), mTwBootOrder, SLOT(sltMoveItemDown()));
     833    connect(mTwBootOrder, SIGNAL(sigRowChanged(int)), this, SLOT(sltCurrentBootItemChanged(int)));
     834
     835    /* Advanced options: */
     836    connect(m_pCheckBoxApic, SIGNAL(stateChanged(int)), this, SLOT(revalidate()));
     837}
     838
     839void UIMachineSettingsSystem::prepareTabProcessor()
     840{
     841    /* Load configuration: */
     842    CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties();
     843    uint hostCPUs = vboxGlobal().host().GetProcessorOnlineCoreCount();
     844    m_uMinGuestCPU = properties.GetMinGuestCPUCount();
     845    m_uMaxGuestCPU = qMin(2 * hostCPUs, (uint)properties.GetMaxGuestCPUCount());
     846    m_uMinGuestCPUExecCap = 1;
     847    m_uMedGuestCPUExecCap = 40;
     848    m_uMaxGuestCPUExecCap = 100;
     849
     850    /* Preconfigure CPU-count slider: */
     851    m_pSliderCPUCount->setPageStep(1);
     852    m_pSliderCPUCount->setSingleStep(1);
     853    m_pSliderCPUCount->setTickInterval(1);
     854    m_pSliderCPUCount->setMinimum(m_uMinGuestCPU);
     855    m_pSliderCPUCount->setMaximum(m_uMaxGuestCPU);
     856    m_pSliderCPUCount->setOptimalHint(1, hostCPUs);
     857    m_pSliderCPUCount->setWarningHint(hostCPUs, m_uMaxGuestCPU);
     858
     859    /* Preconfigure CPU-count editor: */
     860    m_pEditorCPUCount->setMinimum(m_uMinGuestCPU);
     861    m_pEditorCPUCount->setMaximum(m_uMaxGuestCPU);
     862    vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorCPUCount, 4);
     863
     864    /* Preconfigure CPU-execution-cap slider: */
     865    m_pSliderCPUExecCap->setPageStep(10);
     866    m_pSliderCPUExecCap->setSingleStep(1);
     867    m_pSliderCPUExecCap->setTickInterval(10);
     868    /* Setup the scale so that ticks are at page step boundaries: */
     869    m_pSliderCPUExecCap->setMinimum(m_uMinGuestCPUExecCap);
     870    m_pSliderCPUExecCap->setMaximum(m_uMaxGuestCPUExecCap);
     871    m_pSliderCPUExecCap->setWarningHint(m_uMinGuestCPUExecCap, m_uMedGuestCPUExecCap);
     872    m_pSliderCPUExecCap->setOptimalHint(m_uMedGuestCPUExecCap, m_uMaxGuestCPUExecCap);
     873
     874    /* Preconfigure CPU-execution-cap editor: */
     875    m_pEditorCPUExecCap->setMinimum(m_uMinGuestCPUExecCap);
     876    m_pEditorCPUExecCap->setMaximum(m_uMaxGuestCPUExecCap);
     877    vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorCPUExecCap, 4);
     878
     879    /* Install CPU widget connections: */
     880    connect(m_pSliderCPUCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleCPUCountSliderChange()));
     881    connect(m_pEditorCPUCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleCPUCountEditorChange()));
     882    connect(m_pSliderCPUExecCap, SIGNAL(valueChanged(int)), this, SLOT(sltHandleCPUExecCapSliderChange()));
     883    connect(m_pEditorCPUExecCap, SIGNAL(valueChanged(int)), this, SLOT(sltHandleCPUExecCapEditorChange()));
     884}
     885
     886void UIMachineSettingsSystem::prepareTabAcceleration()
     887{
     888    /* Populate 'paravirt provider' combo: */
     889    m_pComboParavirtProvider->addItem(gpConverter->toString(KParavirtProvider_None), QVariant(KParavirtProvider_None));
     890    m_pComboParavirtProvider->addItem(gpConverter->toString(KParavirtProvider_Default), QVariant(KParavirtProvider_Default));
     891    m_pComboParavirtProvider->addItem(gpConverter->toString(KParavirtProvider_Legacy), QVariant(KParavirtProvider_Legacy));
     892    m_pComboParavirtProvider->addItem(gpConverter->toString(KParavirtProvider_Minimal), QVariant(KParavirtProvider_Minimal));
     893    m_pComboParavirtProvider->addItem(gpConverter->toString(KParavirtProvider_HyperV), QVariant(KParavirtProvider_HyperV));
     894    m_pComboParavirtProvider->addItem(gpConverter->toString(KParavirtProvider_KVM), QVariant(KParavirtProvider_KVM));
     895
     896    /* Hide VT-x/AMD-V checkbox when raw-mode is not supported: */
     897#ifndef VBOX_WITH_RAW_MODE
     898    m_pWidgetPlaceholder->setVisible(false);
     899    m_pCheckBoxVirtualization->setVisible(false);
     900#endif /* !VBOX_WITH_RAW_MODE */
     901
     902    /* Advanced options: */
     903    connect(m_pCheckBoxVirtualization, SIGNAL(stateChanged(int)), this, SLOT(revalidate()));
     904}
     905
     906void UIMachineSettingsSystem::repopulateComboPointingHIDType()
     907{
     908    /* Is there any value currently present/selected? */
     909    KPointingHIDType currentValue = KPointingHIDType_None;
     910    {
     911        int iCurrentIndex = m_pComboPointingHIDType->currentIndex();
     912        if (iCurrentIndex != -1)
     913            currentValue = (KPointingHIDType)m_pComboPointingHIDType->itemData(iCurrentIndex).toInt();
     914    }
     915
     916    /* Clear combo: */
     917    m_pComboPointingHIDType->clear();
     918
     919    /* Repopulate combo taking into account currently cached value: */
     920    KPointingHIDType cachedValue = m_pCache->base().m_pointingHIDType;
     921    {
     922        /* "PS/2 Mouse" value is always here: */
     923        m_pComboPointingHIDType->addItem(gpConverter->toString(KPointingHIDType_PS2Mouse), (int)KPointingHIDType_PS2Mouse);
     924
     925        /* "USB Mouse" value is here only if it is currently selected: */
     926        if (cachedValue == KPointingHIDType_USBMouse)
     927            m_pComboPointingHIDType->addItem(gpConverter->toString(KPointingHIDType_USBMouse), (int)KPointingHIDType_USBMouse);
     928
     929        /* "USB Mouse/Tablet" value is always here: */
     930        m_pComboPointingHIDType->addItem(gpConverter->toString(KPointingHIDType_USBTablet), (int)KPointingHIDType_USBTablet);
     931
     932        /* "PS/2 and USB Mouse" value is here only if it is currently selected: */
     933        if (cachedValue == KPointingHIDType_ComboMouse)
     934            m_pComboPointingHIDType->addItem(gpConverter->toString(KPointingHIDType_ComboMouse), (int)KPointingHIDType_ComboMouse);
     935
     936        /* "USB Multi-Touch Mouse/Tablet" value is always here: */
     937        m_pComboPointingHIDType->addItem(gpConverter->toString(KPointingHIDType_USBMultiTouch), (int)KPointingHIDType_USBMultiTouch);
     938    }
     939
     940    /* Was there any value previously present/selected? */
     941    if (currentValue != KPointingHIDType_None)
     942    {
     943        int iPreviousIndex = m_pComboPointingHIDType->findData((int)currentValue);
     944        if (iPreviousIndex != -1)
     945            m_pComboPointingHIDType->setCurrentIndex(iPreviousIndex);
     946    }
     947}
     948
     949void UIMachineSettingsSystem::retranslateComboChipsetType()
     950{
     951    /* For each the element in KChipsetType enum: */
     952    for (int iIndex = (int)KChipsetType_Null; iIndex < (int)KChipsetType_Max; ++iIndex)
     953    {
     954        /* Cast to the corresponding type: */
     955        KChipsetType type = (KChipsetType)iIndex;
     956        /* Look for the corresponding item: */
     957        int iCorrespondingIndex = m_pComboChipsetType->findData((int)type);
     958        /* Re-translate if corresponding item was found: */
     959        if (iCorrespondingIndex != -1)
     960            m_pComboChipsetType->setItemText(iCorrespondingIndex, gpConverter->toString(type));
     961    }
     962}
     963
     964void UIMachineSettingsSystem::retranslateComboPointingHIDType()
     965{
     966    /* For each the element in KPointingHIDType enum: */
     967    for (int iIndex = (int)KPointingHIDType_None; iIndex < (int)KPointingHIDType_Max; ++iIndex)
     968    {
     969        /* Cast to the corresponding type: */
     970        KPointingHIDType type = (KPointingHIDType)iIndex;
     971        /* Look for the corresponding item: */
     972        int iCorrespondingIndex = m_pComboPointingHIDType->findData((int)type);
     973        /* Re-translate if corresponding item was found: */
     974        if (iCorrespondingIndex != -1)
     975            m_pComboPointingHIDType->setItemText(iCorrespondingIndex, gpConverter->toString(type));
     976    }
     977}
     978
     979void UIMachineSettingsSystem::retranslateComboParavirtProvider()
     980{
     981    /* For each the element in KParavirtProvider enum: */
     982    for (int iIndex = (int)KParavirtProvider_None; iIndex < (int)KParavirtProvider_Max; ++iIndex)
     983    {
     984        /* Cast to the corresponding type: */
     985        KParavirtProvider type = (KParavirtProvider)iIndex;
     986        /* Look for the corresponding item: */
     987        int iCorrespondingIndex = m_pComboParavirtProvider->findData((int)type);
     988        /* Re-translate if corresponding item was found: */
     989        if (iCorrespondingIndex != -1)
     990            m_pComboParavirtProvider->setItemText(iCorrespondingIndex, gpConverter->toString(type));
     991    }
     992}
     993
     994void UIMachineSettingsSystem::adjustBootOrderTWSize()
     995{
     996    /* Adjust boot-table size: */
     997    mTwBootOrder->adjustSizeToFitContent();
     998    /* Update the layout system */
     999    if (m_pTabMotherboard->layout())
     1000    {
     1001        m_pTabMotherboard->layout()->activate();
     1002        m_pTabMotherboard->layout()->update();
     1003    }
     1004}
     1005
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.h

    r66190 r66243  
    7878    virtual void polishPage() /* override */;
    7979
     80    /** Preprocesses any Qt @a pEvent for passed @a pObject. */
     81    virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
     82
    8083private slots:
    8184
     
    100103    void prepareTabProcessor();
    101104    void prepareTabAcceleration();
    102     void prepareValidation();
    103105
    104106    /* Helper: Pointing HID type combo stuff: */
     
    112114    /* Helper: Boot-table stuff: */
    113115    void adjustBootOrderTWSize();
    114 
    115     /* Handler: Event-filtration stuff: */
    116     bool eventFilter(QObject *aObject, QEvent *aEvent);
    117116
    118117    /* Variable: Boot-table stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.cpp

    r66190 r66243  
    3737/* COM includes: */
    3838# include "CConsole.h"
     39# include "CExtPack.h"
     40# include "CExtPackManager.h"
     41# include "CHostUSBDevice.h"
     42# include "CHostUSBDeviceFilter.h"
    3943# include "CUSBController.h"
    40 # include "CUSBDeviceFilters.h"
    4144# include "CUSBDevice.h"
    4245# include "CUSBDeviceFilter.h"
    43 # include "CHostUSBDevice.h"
    44 # include "CHostUSBDeviceFilter.h"
    45 # include "CExtPackManager.h"
    46 # include "CExtPack.h"
     46# include "CUSBDeviceFilters.h"
    4747
    4848#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    328328
    329329    /* Setup connections */
     330    connect(mGbUSB, SIGNAL(stateChanged(int)), this, SLOT(revalidate()));
     331    connect(mRbUSB1, SIGNAL(toggled(bool)), this, SLOT(revalidate()));
     332    connect(mRbUSB2, SIGNAL(toggled(bool)), this, SLOT(revalidate()));
     333    connect(mRbUSB3, SIGNAL(toggled(bool)), this, SLOT(revalidate()));
     334
    330335    connect (mGbUSB, SIGNAL (toggled (bool)),
    331336             this, SLOT (usbAdapterToggled (bool)));
     
    357362    /* Setup dialog */
    358363    mTwFilters->header()->hide();
    359 
    360     /* Prepare validation: */
    361     prepareValidation();
    362364
    363365    /* Applying language settings */
     
    785787}
    786788
     789void UIMachineSettingsUSB::showContextMenu(const QPoint &pos)
     790{
     791    QMenu menu;
     792    if (mTwFilters->isEnabled())
     793    {
     794        menu.addAction(mNewAction);
     795        menu.addAction(mAddAction);
     796        menu.addSeparator();
     797        menu.addAction(mEdtAction);
     798        menu.addSeparator();
     799        menu.addAction(mDelAction);
     800        menu.addSeparator();
     801        menu.addAction(mMupAction);
     802        menu.addAction(mMdnAction);
     803    }
     804    if (!menu.isEmpty())
     805        menu.exec(mTwFilters->mapToGlobal(pos));
     806}
     807
     808void UIMachineSettingsUSB::sltUpdateActivityState(QTreeWidgetItem *pChangedItem)
     809{
     810    /* Check changed USB filter item: */
     811    Assert(pChangedItem);
     812
     813    /* Delete corresponding items: */
     814    UIDataSettingsMachineUSBFilter &data = m_filters[mTwFilters->indexOfTopLevelItem(pChangedItem)];
     815    data.m_fActive = pChangedItem->checkState(0) == Qt::Checked;
     816}
     817
    787818void UIMachineSettingsUSB::newClicked()
    788819{
     
    946977}
    947978
    948 void UIMachineSettingsUSB::showContextMenu(const QPoint &pos)
    949 {
    950     QMenu menu;
    951     if (mTwFilters->isEnabled())
    952     {
    953         menu.addAction(mNewAction);
    954         menu.addAction(mAddAction);
    955         menu.addSeparator();
    956         menu.addAction(mEdtAction);
    957         menu.addSeparator();
    958         menu.addAction(mDelAction);
    959         menu.addSeparator();
    960         menu.addAction(mMupAction);
    961         menu.addAction(mMdnAction);
    962     }
    963     if (!menu.isEmpty())
    964         menu.exec(mTwFilters->mapToGlobal(pos));
    965 }
    966 
    967 void UIMachineSettingsUSB::sltUpdateActivityState(QTreeWidgetItem *pChangedItem)
    968 {
    969     /* Check changed USB filter item: */
    970     Assert(pChangedItem);
    971 
    972     /* Delete corresponding items: */
    973     UIDataSettingsMachineUSBFilter &data = m_filters[mTwFilters->indexOfTopLevelItem(pChangedItem)];
    974     data.m_fActive = pChangedItem->checkState(0) == Qt::Checked;
    975 }
    976 
    977 void UIMachineSettingsUSB::prepareValidation()
    978 {
    979     /* Prepare validation: */
    980     connect(mGbUSB, SIGNAL(stateChanged(int)), this, SLOT(revalidate()));
    981     connect(mRbUSB1, SIGNAL(toggled(bool)), this, SLOT(revalidate()));
    982     connect(mRbUSB2, SIGNAL(toggled(bool)), this, SLOT(revalidate()));
    983     connect(mRbUSB3, SIGNAL(toggled(bool)), this, SLOT(revalidate()));
    984 }
    985 
    986979void UIMachineSettingsUSB::addUSBFilter(const UIDataSettingsMachineUSBFilter &usbFilterData, bool fIsNew)
    987980{
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.h

    r66190 r66243  
    4040public:
    4141
    42     enum RemoteMode
    43     {
    44         ModeAny = 0,
    45         ModeOn,
    46         ModeOff
    47     };
     42    enum { ModeAny, ModeOn, ModeOff };
    4843
    4944    /** Constructs USB settings page. */
     
    8883
    8984    void usbAdapterToggled(bool fEnabled);
     85
    9086    void currentChanged (QTreeWidgetItem *aItem = 0);
     87    void showContextMenu(const QPoint &pos);
     88    void sltUpdateActivityState(QTreeWidgetItem *pChangedItem);
    9189
    9290    void newClicked();
     
    9795    void mupClicked();
    9896    void mdnClicked();
    99     void showContextMenu(const QPoint &pos);
    100     void sltUpdateActivityState(QTreeWidgetItem *pChangedItem);
    10197
    10298private:
    103 
    104     /* Helper: Prepare stuff: */
    105     void prepareValidation();
    10699
    107100    void addUSBFilter(const UIDataSettingsMachineUSBFilter &usbFilterData, bool fIsNew);
     
    119112    QAction *mMdnAction;
    120113    VBoxUSBMenu *mUSBDevicesMenu;
     114
    121115    QString mUSBFilterName;
     116
    122117    QList<UIDataSettingsMachineUSBFilter> m_filters;
    123118
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette