Index: trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardDiskEditors.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardDiskEditors.cpp	(revision 90217)
+++ trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardDiskEditors.cpp	(revision 90223)
@@ -19,4 +19,6 @@
 #include <QButtonGroup>
 #include <QCheckBox>
+#include <QDir>
+#include <QFileInfo>
 #include <QLabel>
 #include <QRadioButton>
@@ -66,4 +68,9 @@
 }
 
+const CMediumFormat &UIDiskFormatsGroupBox::VDIMeiumFormat() const
+{
+    return m_comVDIMediumFormat;
+}
+
 void UIDiskFormatsGroupBox::prepare()
 {
@@ -78,14 +85,14 @@
     foreach (const CMediumFormat &format, formats)
     {
-        /* VDI goes first: */
         if (format.GetName() == "VDI")
+        {
             vdi[format.GetId()] = format;
+            m_comVDIMediumFormat = format;
+        }
         else
         {
             const QVector<KMediumFormatCapabilities> &capabilities = format.GetCapabilities();
-            /* Then goes preferred: */
             if (capabilities.contains(KMediumFormatCapabilities_Preferred))
                 preferred[format.GetId()] = format;
-            /* Then others: */
             else
                 others[format.GetId()] = format;
@@ -165,4 +172,5 @@
 }
 
+/* static */
 QString UIDiskFormatsGroupBox::defaultExtension(const CMediumFormat &mediumFormatRef)
 {
@@ -182,4 +190,9 @@
 }
 
+const QStringList UIDiskFormatsGroupBox::formatExtensions() const
+{
+    return m_formatExtensions;
+}
+
 /*********************************************************************************************************************************
 *   UIDiskVariantGroupBox implementation.                                                                                   *
@@ -220,4 +233,96 @@
 }
 
+qulonglong UIDiskVariantGroupBox::mediumVariant() const
+{
+    /* Initial value: */
+    qulonglong uMediumVariant = (qulonglong)KMediumVariant_Max;
+
+    /* Exclusive options: */
+    if (m_pFixedCheckBox && m_pFixedCheckBox->isChecked())
+        uMediumVariant = (qulonglong)KMediumVariant_Fixed;
+    else
+        uMediumVariant = (qulonglong)KMediumVariant_Standard;
+
+    /* Additional options: */
+    if (m_pSplitBox && m_pSplitBox->isChecked())
+        uMediumVariant |= (qulonglong)KMediumVariant_VmdkSplit2G;
+
+    /* Return options: */
+    return uMediumVariant;
+}
+
+void UIDiskVariantGroupBox::setMediumVariant(qulonglong uMediumVariant)
+{
+    /* Exclusive options: */
+    if (uMediumVariant & (qulonglong)KMediumVariant_Fixed)
+    {
+        m_pFixedCheckBox->click();
+        m_pFixedCheckBox->setFocus();
+    }
+
+    /* Additional options: */
+    m_pSplitBox->setChecked(uMediumVariant & (qulonglong)KMediumVariant_VmdkSplit2G);
+}
+
+void UIDiskVariantGroupBox::setWidgetVisibility(CMediumFormat &mediumFormat)
+{
+    ULONG uCapabilities = 0;
+    QVector<KMediumFormatCapabilities> capabilities;
+    capabilities = mediumFormat.GetCapabilities();
+    for (int i = 0; i < capabilities.size(); i++)
+        uCapabilities |= capabilities[i];
+
+    bool fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic;
+    bool fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed;
+    bool fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G;
+    if (m_pFixedCheckBox)
+    {
+        if (!fIsCreateDynamicPossible)
+        {
+            m_pFixedCheckBox->setChecked(true);
+            m_pFixedCheckBox->setEnabled(false);
+        }
+        if (!fIsCreateFixedPossible)
+        {
+            m_pFixedCheckBox->setChecked(false);
+            m_pFixedCheckBox->setEnabled(false);
+        }
+    }
+    if (m_pFixedCheckBox)
+        m_pFixedCheckBox->setHidden(!fIsCreateFixedPossible);
+    if (m_pSplitBox)
+        m_pSplitBox->setHidden(!fIsCreateSplitPossible);
+}
+
+void UIDiskVariantGroupBox::updateMediumVariantWidgetsAfterFormatChange(const CMediumFormat &mediumFormat)
+{
+    /* Enable/disable widgets: */
+    ULONG uCapabilities = 0;
+    QVector<KMediumFormatCapabilities> capabilities;
+    capabilities = mediumFormat.GetCapabilities();
+    for (int i = 0; i < capabilities.size(); i++)
+        uCapabilities |= capabilities[i];
+
+    bool fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic;
+    bool fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed;
+    bool fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G;
+
+    if (m_pFixedCheckBox)
+    {
+        m_pFixedCheckBox->setEnabled(fIsCreateDynamicPossible || fIsCreateFixedPossible);
+        if (!fIsCreateDynamicPossible)
+            m_pFixedCheckBox->setChecked(true);
+        if (!fIsCreateFixedPossible)
+            m_pFixedCheckBox->setChecked(false);
+    }
+    m_pSplitBox->setEnabled(fIsCreateSplitPossible);
+}
+
+bool UIDiskVariantGroupBox::isComplete() const
+{
+    /* Make sure medium variant is correct: */
+    return mediumVariant() != (qulonglong)KMediumVariant_Max;
+}
+
 
 /*********************************************************************************************************************************
@@ -286,2 +391,39 @@
         m_pLocationEditor->setText(strLocation);
 }
+
+void UIDiskSizeAndLocationGroupBox::updateLocationEditorAfterFormatChange(const CMediumFormat &mediumFormat, const QStringList &formatExtensions)
+{
+    /* Compose virtual-disk extension: */
+    QString strDefaultExtension = UIDiskFormatsGroupBox::defaultExtension(mediumFormat);
+    /* Update m_pLocationEditor's text if necessary: */
+    if (!m_pLocationEditor->text().isEmpty() && !strDefaultExtension.isEmpty())
+    {
+        QFileInfo fileInfo(m_pLocationEditor->text());
+        if (fileInfo.suffix() != strDefaultExtension)
+        {
+            QFileInfo newFileInfo(QDir(fileInfo.absolutePath()),
+                                  QString("%1.%2").
+                                  arg(stripFormatExtension(fileInfo.fileName(), formatExtensions)).
+                                  arg(strDefaultExtension));
+            m_pLocationEditor->setText(newFileInfo.absoluteFilePath());
+        }
+    }
+}
+
+/* static */
+QString UIDiskSizeAndLocationGroupBox::stripFormatExtension(const QString &strFileName, const QStringList &formatExtensions)
+{
+    QString result(strFileName);
+    foreach (const QString &strExtension, formatExtensions)
+    {
+        if (strFileName.endsWith(strExtension, Qt::CaseInsensitive))
+        {
+            /* Add the dot to extenstion: */
+            QString strExtensionWithDot(strExtension);
+            strExtensionWithDot.prepend('.');
+            int iIndex = strFileName.lastIndexOf(strExtensionWithDot, -1, Qt::CaseInsensitive);
+            result.remove(iIndex, strExtensionWithDot.length());
+        }
+    }
+    return result;
+}
Index: trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardDiskEditors.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardDiskEditors.h	(revision 90217)
+++ trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardDiskEditors.h	(revision 90223)
@@ -61,4 +61,7 @@
     CMediumFormat mediumFormat() const;
     void setMediumFormat(const CMediumFormat &mediumFormat);
+    const CMediumFormat &VDIMeiumFormat() const;
+    static QString defaultExtension(const CMediumFormat &mediumFormatRef);
+    const QStringList formatExtensions() const;
 
 private:
@@ -66,8 +69,9 @@
     void prepare();
     void addFormatButton(QVBoxLayout *pFormatLayout, CMediumFormat medFormat, bool fPreferred = false);
-    QString defaultExtension(const CMediumFormat &mediumFormatRef);
+
     virtual void retranslateUi() /* override final */;
 
     QList<CMediumFormat>  m_formats;
+    CMediumFormat m_comVDIMediumFormat;
     QStringList           m_formatNames;
     QStringList m_formatExtensions;
@@ -85,4 +89,9 @@
 
     UIDiskVariantGroupBox(QWidget *pParent = 0);
+    void updateMediumVariantWidgetsAfterFormatChange(const CMediumFormat &mediumFormat);
+    qulonglong mediumVariant() const;
+    void setMediumVariant(qulonglong uMediumVariant);
+    void setWidgetVisibility(CMediumFormat &mediumFormat);
+    bool isComplete() const;
 
 private:
@@ -110,4 +119,5 @@
     QString location() const;
     void setLocation(const QString &strLocation);
+    void updateLocationEditorAfterFormatChange(const CMediumFormat &mediumFormat, const QStringList &formatExtensions);
 
 private:
@@ -115,4 +125,7 @@
     void prepare();
     virtual void retranslateUi() /* override final */;
+    static QString stripFormatExtension(const QString &strFileName,
+                                        const QStringList &formatExtensions);
+
 
     QLabel *m_pLocationLabel;
Index: trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePageBasic.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePageBasic.cpp	(revision 90217)
+++ trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePageBasic.cpp	(revision 90223)
@@ -179,5 +179,5 @@
 };
 
-void UIWizardNewVMNameOSTypePage::onNameChanged(UINameAndSystemEditor *pNameAndSystemEditor, QString strNewName)
+void UIWizardNewVMNameOSTypePage::guessOSTypeFromName(UINameAndSystemEditor *pNameAndSystemEditor, QString strNewName)
 {
     CHost host = uiCommon().host();
@@ -366,5 +366,6 @@
 void UIWizardNewVMNameOSTypePageBasic::sltNameChanged(const QString &strNewName)
 {
-    UIWizardNewVMNameOSTypePage::onNameChanged(m_pNameAndSystemEditor, strNewName);
+    if (!m_userModifiedParameters.contains("GuestOSType"))
+        UIWizardNewVMNameOSTypePage::guessOSTypeFromName(m_pNameAndSystemEditor, strNewName);
     UIWizardNewVMNameOSTypePage::composeMachineFilePath(m_pNameAndSystemEditor, qobject_cast<UIWizardNewVM*>(wizard()));
     emit completeChanged();
@@ -379,11 +380,7 @@
 void UIWizardNewVMNameOSTypePageBasic::sltOsTypeChanged()
 {
-    /* If the user manually edited the OS type, we didn't want our automatic OS type guessing anymore.
-     * So simply disconnect the text-edit signal. */
+    m_userModifiedParameters << "GuestOSType";
     if (m_pNameAndSystemEditor)
-    {
-        m_pNameAndSystemEditor->disconnect(SIGNAL(sigNameChanged(const QString &)), this, SLOT(sltNameChanged(const QString &)));
         newVMWizardPropertySet(GuestOSType, m_pNameAndSystemEditor->type());
-    }
 }
 
@@ -453,6 +450,6 @@
     if (pWizard)
     {
-        if (!pWizard->detectedOSTypeId().isEmpty())
-            UIWizardNewVMNameOSTypePage::onNameChanged(m_pNameAndSystemEditor, pWizard->detectedOSTypeId());
+        if (!pWizard->detectedOSTypeId().isEmpty() && !m_userModifiedParameters.contains("GuestOSType"))
+            UIWizardNewVMNameOSTypePage::guessOSTypeFromName(m_pNameAndSystemEditor, pWizard->detectedOSTypeId());
         pWizard->setISOFilePath(strPath);
     }
Index: trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePageBasic.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePageBasic.h	(revision 90217)
+++ trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePageBasic.h	(revision 90223)
@@ -40,5 +40,5 @@
 namespace UIWizardNewVMNameOSTypePage
 {
-    void onNameChanged(UINameAndSystemEditor *pNameAndSystemEditor, QString strNewName);
+    void guessOSTypeFromName(UINameAndSystemEditor *pNameAndSystemEditor, QString strNewName);
     bool createMachineFolder(UINameAndSystemEditor *pNameAndSystemEditor,
                              UINativeWizardPage *pCaller,
@@ -104,4 +104,5 @@
         QIRichTextLabel       *m_pNameOSTypeLabel;
     /** @} */
+    QSet<QString> m_userModifiedParameters;
 };
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp	(revision 90217)
+++ trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp	(revision 90223)
@@ -120,5 +120,6 @@
 void UIWizardNewVMPageExpert::sltNameChanged(const QString &strNewName)
 {
-    UIWizardNewVMNameOSTypePage::onNameChanged(m_pNameAndSystemEditor, strNewName);
+    if (!m_userModifiedParameters.contains("GuestOSType"))
+        UIWizardNewVMNameOSTypePage::guessOSTypeFromName(m_pNameAndSystemEditor, strNewName);
     UIWizardNewVMNameOSTypePage::composeMachineFilePath(m_pNameAndSystemEditor, qobject_cast<UIWizardNewVM*>(wizard()));
     updateVirtualDiskPathFromMachinePathName();
@@ -135,7 +136,8 @@
 void UIWizardNewVMPageExpert::sltOsTypeChanged()
 {
-    // onOsTypeChanged();
-    // setOSTypeDependedValues();
-    // emit completeChanged();
+    m_userModifiedParameters << "GuestOSType";
+    if (m_pNameAndSystemEditor)
+        newVMWizardPropertySet(GuestOSType, m_pNameAndSystemEditor->type());
+    //setOSTypeDependedValues() ??!!!
 }
 
@@ -216,8 +218,8 @@
         connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged,
                 this, &UIWizardNewVMPageExpert::sltNameChanged);
-    //     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged,
-    //             this, &UIWizardNewVMPageExpert::sltPathChanged);
-    //     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged,
-    //             this, &UIWizardNewVMPageExpert::sltOsTypeChanged);
+        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged,
+                this, &UIWizardNewVMPageExpert::sltPathChanged);
+        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged,
+                this, &UIWizardNewVMPageExpert::sltOsTypeChanged);
     //     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOSFamilyChanged,
     //             this, &UIWizardNewVMPageExpert::sltOSFamilyTypeChanged);
@@ -277,17 +279,15 @@
 void UIWizardNewVMPageExpert::setOSTypeDependedValues()
 {
-    // if (!field("type").canConvert<CGuestOSType>())
-    //     return;
-
-    // /* Get recommended 'ram' field value: */
-    // CGuestOSType type = field("type").value<CGuestOSType>();
-    // ULONG recommendedRam = type.GetRecommendedRAM();
-
-    // if (m_pBaseMemoryEditor && !m_userSetWidgets.contains(m_pBaseMemoryEditor))
-    // {
-    //     m_pBaseMemoryEditor->blockSignals(true);
-    //     m_pBaseMemoryEditor->setValue(recommendedRam);
-    //     m_pBaseMemoryEditor->blockSignals(false);
-    // }
+    UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
+    AssertReturnVoid(pWizard);
+
+    /* Get recommended 'ram' field value: */
+    const CGuestOSType &type = pWizard->guestOSType();
+    ULONG recommendedRam = type.GetRecommendedRAM();
+
+    /* Set memory size of the widget and (through signals) wizard: */
+    if (m_pHardwareWidgetContainer && !m_userModifiedParameters.contains("MemorySize"))
+        m_pHardwareWidgetContainer->setMemorySize(recommendedRam);
+
 
     // KFirmwareType fwType = type.GetRecommendedFirmware();
@@ -342,4 +342,13 @@
     AssertReturnVoid(pWizard);
     /* Initialize wizard properties: */
+    if (m_pNameAndSystemEditor)
+    {
+        /* Guest OS type: */
+        newVMWizardPropertySet(GuestOSFamilyId, m_pNameAndSystemEditor->familyId());
+        newVMWizardPropertySet(GuestOSType, m_pNameAndSystemEditor->type());
+        /* Vm name, folder, file path etc. will be initilized by composeMachineFilePath: */
+    }
+
+
     if (m_pFormatButtonGroup)
         newVMWizardPropertySet(MediumFormat, m_pFormatButtonGroup->mediumFormat());
@@ -347,7 +356,8 @@
 
     // disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
-    // setOSTypeDependedValues();
+    setOSTypeDependedValues();
     // disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
     updateVirtualDiskPathFromMachinePathName();
+
     // updateWidgetAterMediumFormatChange();
     // setSkipCheckBoxEnable();
@@ -669,12 +679,10 @@
 void UIWizardNewVMPageExpert::updateWidgetAterMediumFormatChange()
 {
-    // CMediumFormat comMediumFormat = mediumFormat();
-    // if (comMediumFormat.isNull())
-    // {
-    //     AssertMsgFailed(("No medium format set!"));
-    //     return;
-    // }
-    // updateMediumVariantWidgetsAfterFormatChange(comMediumFormat);
-    // updateLocationEditorAfterFormatChange(comMediumFormat, m_formatExtensions);
+    UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
+    AssertReturnVoid(pWizard && m_pDiskVariantGroupBox && m_pSizeAndLocationGroup && m_pFormatButtonGroup);
+    const CMediumFormat &comMediumFormat = pWizard->mediumFormat();
+    AssertReturnVoid(!comMediumFormat.isNull());
+    m_pDiskVariantGroupBox->updateMediumVariantWidgetsAfterFormatChange(comMediumFormat);
+    m_pSizeAndLocationGroup->updateLocationEditorAfterFormatChange(comMediumFormat, m_pFormatButtonGroup->formatExtensions());
 }
 
