UIWizardNewVMPage1::UIWizardNewVMPage1(const QString &strGroup)
    : m_strGroup(strGroup)
{
    CHost host = vboxGlobal().host();
    m_fSupportsHWVirtEx = host.GetProcessorFeature(KProcessorFeature_HWVirtEx);
    m_fSupportsLongMode = host.GetProcessorFeature(KProcessorFeature_LongMode);
}
VBoxOSTypeSelectorWidget::VBoxOSTypeSelectorWidget (QWidget *aParent)
    : QIWithRetranslateUI <QWidget> (aParent)
    , mTxFamilyName (new QLabel (this))
    , mTxTypeName (new QLabel (this))
    , mPxTypeIcon (new QLabel (this))
    , mCbFamily (new QComboBox (this))
    , mCbType (new QComboBox (this))
    , mLayoutPosition (-1)
    , mLayoutActivated (false)
{
    /* Register CGuestOSType type */
    qRegisterMetaType<CGuestOSType>();

    /* Setup widgets */
    mTxFamilyName->setAlignment (Qt::AlignRight);
    mTxTypeName->setAlignment (Qt::AlignRight);
    mTxFamilyName->setBuddy (mCbFamily);
    mTxTypeName->setBuddy (mCbType);
    mTxFamilyName->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Fixed);
    mTxTypeName->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Fixed);
    mCbFamily->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed);
    mCbType->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed);
    mPxTypeIcon->setFixedSize (32, 32);

    /* Check if host supports (AMD-V or VT-x) and long mode */
    CHost host = vboxGlobal().host();
    m_fSupportsHWVirtEx = host.GetProcessorFeature(KProcessorFeature_HWVirtEx);
    m_fSupportsLongMode = host.GetProcessorFeature(KProcessorFeature_LongMode);

    /* Fill OS family selector */
    int maximumSize = 0;
    QFontMetrics fm (mCbFamily->font());
    QList <CGuestOSType> families (vboxGlobal().vmGuestOSFamilyList());
    for (int i = 0; i < families.size(); ++ i)
    {
        /* Search for maximum length among family names */
        QString familyName (families [i].GetFamilyDescription());
        maximumSize = maximumSize < fm.width (familyName) ?
                      fm.width (familyName) : maximumSize;
        mCbFamily->insertItem (i, familyName);
        mCbFamily->setItemData (i, families [i].GetFamilyId(), RoleTypeID);
        /* Search for maximum length among type names */
        QList <CGuestOSType> types (vboxGlobal().vmGuestOSTypeList (families [i].GetFamilyId()));
        for (int j = 0; j < types.size(); ++ j)
        {
            QString typeName (types [j].GetDescription());
            maximumSize = maximumSize < fm.width (typeName) ?
                          fm.width (typeName) : maximumSize;
        }
    }
    mCbFamily->setCurrentIndex (0);
    onFamilyChanged (mCbFamily->currentIndex());

    /* Set the minimum size for OS Type & Family selectors. */
    QStyleOptionComboBox options;
    options.initFrom (mCbFamily);
    QSize size (style()->sizeFromContents (QStyle::CT_ComboBox, &options,
                QSize (maximumSize, fm.height()), mCbFamily));
    mCbFamily->setMinimumWidth (size.width());
    mCbType->setMinimumWidth (size.width());

    /* Slots connections */
    connect (mCbFamily, SIGNAL (currentIndexChanged (int)),
             this, SLOT (onFamilyChanged (int)));
    connect (mCbType, SIGNAL (currentIndexChanged (int)),
             this, SLOT (onTypeChanged (int)));

    /* Retranslate */
    retranslateUi();
}