Index: /trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.cpp	(revision 85958)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.cpp	(revision 85959)
@@ -279,11 +279,13 @@
 
 UIMachineSettingsSF::UIMachineSettingsSF()
-    : m_pActionAdd(0), m_pActionEdit(0), m_pActionRemove(0)
-    , m_pCache(0)
-    , m_pFoldersTreeWidget(0)
-    , m_pNameSeparator(0)
-    , m_pFoldersToolBar(0)
-{
-    /* Prepare: */
+    : m_pCache(0)
+    , m_pLabelSeparator(0)
+    , m_pLayoutTree(0)
+    , m_pTreeWidget(0)
+    , m_pToolBar(0)
+    , m_pActionAdd(0)
+    , m_pActionEdit(0)
+    , m_pActionRemove(0)
+{
     prepare();
 }
@@ -363,5 +365,5 @@
 {
     /* Clear list initially: */
-    m_pFoldersTreeWidget->clear();
+    m_pTreeWidget->clear();
 
     /* Update root items visibility: */
@@ -373,6 +375,6 @@
 
     /* Choose first folder as current: */
-    m_pFoldersTreeWidget->setCurrentItem(m_pFoldersTreeWidget->topLevelItem(0));
-    sltHandleCurrentItemChange(m_pFoldersTreeWidget->currentItem());
+    m_pTreeWidget->setCurrentItem(m_pTreeWidget->topLevelItem(0));
+    sltHandleCurrentItemChange(m_pTreeWidget->currentItem());
 
     /* Polish page finally: */
@@ -386,5 +388,5 @@
 
     /* For each folder type: */
-    QTreeWidgetItem *pMainRootItem = m_pFoldersTreeWidget->invisibleRootItem();
+    QTreeWidgetItem *pMainRootItem = m_pTreeWidget->invisibleRootItem();
     for (int iFolderTypeIndex = 0; iFolderTypeIndex < pMainRootItem->childCount(); ++iFolderTypeIndex)
     {
@@ -417,9 +419,8 @@
 }
 
-
 void UIMachineSettingsSF::retranslateUi()
 {
-    m_pNameSeparator->setText(tr("Shared &Folders"));
-    QTreeWidgetItem *pQTreeWidgetItem = m_pFoldersTreeWidget->headerItem();
+    m_pLabelSeparator->setText(tr("Shared &Folders"));
+    QTreeWidgetItem *pQTreeWidgetItem = m_pTreeWidget->headerItem();
     pQTreeWidgetItem->setText(4, tr("At"));
     pQTreeWidgetItem->setText(3, tr("Auto Mount"));
@@ -428,5 +429,5 @@
     pQTreeWidgetItem->setText(0, tr("Name"));
 #ifndef QT_NO_WHATSTHIS
-    m_pFoldersTreeWidget->setWhatsThis(tr("Lists all shared folders accessible to this machine. Use 'net use x: \\\\vboxsvr\\share' to access a shared folder named <i>share</i> from a DOS-like OS, or 'mount -t vboxsf share mount_point' to access it from a Linux OS. This feature requires Guest Additions."));
+    m_pTreeWidget->setWhatsThis(tr("Lists all shared folders accessible to this machine. Use 'net use x: \\\\vboxsvr\\share' to access a shared folder named <i>share</i> from a DOS-like OS, or 'mount -t vboxsf share mount_point' to access it from a Linux OS. This feature requires Guest Additions."));
 #endif // QT_NO_WHATSTHIS
 
@@ -448,7 +449,7 @@
 {
     /* Polish shared folders page availability: */
-    m_pNameSeparator->setEnabled(isMachineInValidMode());
-    m_pFoldersToolBar->setEnabled(isMachineInValidMode());
-    m_pFoldersToolBar->setEnabled(isMachineInValidMode());
+    m_pLabelSeparator->setEnabled(isMachineInValidMode());
+    m_pToolBar->setEnabled(isMachineInValidMode());
+    m_pToolBar->setEnabled(isMachineInValidMode());
 
     /* Update root items visibility: */
@@ -462,5 +463,5 @@
 
     /* Connect header-resize signal just before widget is shown after all the items properly loaded and initialized: */
-    connect(m_pFoldersTreeWidget->header(), &QHeaderView::sectionResized, this, &UIMachineSettingsSF::sltAdjustTreeFields);
+    connect(m_pTreeWidget->header(), &QHeaderView::sectionResized, this, &UIMachineSettingsSF::sltAdjustTreeFields);
 
     /* Adjusting size after all pending show events are processed: */
@@ -503,5 +504,5 @@
 
         /* Sort tree-widget before adjusting: */
-        m_pFoldersTreeWidget->sortItems(0, Qt::AscendingOrder);
+        m_pTreeWidget->sortItems(0, Qt::AscendingOrder);
         /* Adjust tree-widget finally: */
         sltAdjustTree();
@@ -512,5 +513,5 @@
 {
     /* Check current folder item: */
-    SFTreeViewItem *pItem = static_cast<SFTreeViewItem*>(m_pFoldersTreeWidget->currentItem());
+    SFTreeViewItem *pItem = static_cast<SFTreeViewItem*>(m_pTreeWidget->currentItem());
     AssertPtrReturnVoid(pItem);
     AssertPtrReturnVoid(pItem->parentItem());
@@ -555,11 +556,11 @@
 
             /* Update tree-widget: */
-            m_pFoldersTreeWidget->scrollToItem(pItem);
-            m_pFoldersTreeWidget->setCurrentItem(pItem);
+            m_pTreeWidget->scrollToItem(pItem);
+            m_pTreeWidget->setCurrentItem(pItem);
             sltHandleCurrentItemChange(pItem);
         }
 
         /* Sort tree-widget before adjusting: */
-        m_pFoldersTreeWidget->sortItems(0, Qt::AscendingOrder);
+        m_pTreeWidget->sortItems(0, Qt::AscendingOrder);
         /* Adjust tree-widget finally: */
         sltAdjustTree();
@@ -570,5 +571,5 @@
 {
     /* Check current folder item: */
-    QTreeWidgetItem *pItem = m_pFoldersTreeWidget->currentItem();
+    QTreeWidgetItem *pItem = m_pTreeWidget->currentItem();
     AssertPtrReturnVoid(pItem);
 
@@ -601,6 +602,6 @@
 {
     QMenu menu;
-    QTreeWidgetItem *pItem = m_pFoldersTreeWidget->itemAt(position);
-    if (m_pFoldersTreeWidget->isEnabled() && pItem && pItem->flags() & Qt::ItemIsSelectable)
+    QTreeWidgetItem *pItem = m_pTreeWidget->itemAt(position);
+    if (m_pTreeWidget->isEnabled() && pItem && pItem->flags() & Qt::ItemIsSelectable)
     {
         menu.addAction(m_pActionEdit);
@@ -612,5 +613,5 @@
     }
     if (!menu.isEmpty())
-        menu.exec(m_pFoldersTreeWidget->viewport()->mapToGlobal(position));
+        menu.exec(m_pTreeWidget->viewport()->mapToGlobal(position));
 }
 
@@ -628,7 +629,7 @@
      * 4 = Auto mount point
      */
-    QAbstractItemView *pItemView = m_pFoldersTreeWidget;
-    QHeaderView *pItemHeader = m_pFoldersTreeWidget->header();
-    const int iTotal = m_pFoldersTreeWidget->viewport()->width();
+    QAbstractItemView *pItemView = m_pTreeWidget;
+    QHeaderView *pItemHeader = m_pTreeWidget->header();
+    const int iTotal = m_pTreeWidget->viewport()->width();
 
     const int mw0 = qMax(pItemView->sizeHintForColumn(0), pItemHeader->sectionSizeHint(0));
@@ -668,14 +669,14 @@
     }
 #endif
-    m_pFoldersTreeWidget->setColumnWidth(0, w0);
-    m_pFoldersTreeWidget->setColumnWidth(1, w1);
-    m_pFoldersTreeWidget->setColumnWidth(2, w2);
-    m_pFoldersTreeWidget->setColumnWidth(3, w3);
-    m_pFoldersTreeWidget->setColumnWidth(4, w4);
+    m_pTreeWidget->setColumnWidth(0, w0);
+    m_pTreeWidget->setColumnWidth(1, w1);
+    m_pTreeWidget->setColumnWidth(2, w2);
+    m_pTreeWidget->setColumnWidth(3, w3);
+    m_pTreeWidget->setColumnWidth(4, w4);
 }
 
 void UIMachineSettingsSF::sltAdjustTreeFields()
 {
-    QTreeWidgetItem *pMainRoot = m_pFoldersTreeWidget->invisibleRootItem();
+    QTreeWidgetItem *pMainRoot = m_pTreeWidget->invisibleRootItem();
     for (int i = 0; i < pMainRoot->childCount(); ++i)
     {
@@ -690,57 +691,13 @@
 }
 
-void UIMachineSettingsSF::prepareWidgets()
-{
-    if (objectName().isEmpty())
-        setObjectName(QStringLiteral("UIMachineSettingsSF"));
-    resize(300, 220);
-    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
-    pMainLayout->setObjectName(QStringLiteral("pMainLayout"));
-    pMainLayout->setContentsMargins(0, 0, 0, 0);
-    m_pNameSeparator = new QILabelSeparator(this);
-    m_pNameSeparator->setObjectName(QStringLiteral("m_pNameSeparator"));
-
-    pMainLayout->addWidget(m_pNameSeparator);
-
-    QWidget *m_pFoldersTreeWidgetContainer = new QWidget(this);
-    m_pFoldersTreeWidgetContainer->setObjectName(QStringLiteral("m_pFoldersTreeWidgetContainer"));
-    QHBoxLayout *pFoldersLayout = new QHBoxLayout(m_pFoldersTreeWidgetContainer);
-    pFoldersLayout->setSpacing(3);
-    pFoldersLayout->setObjectName(QStringLiteral("pFoldersLayout"));
-    pFoldersLayout->setContentsMargins(0, 0, 0, 0);
-    m_pFoldersTreeWidget = new QITreeWidget(m_pFoldersTreeWidgetContainer);
-    m_pFoldersTreeWidget->setObjectName(QStringLiteral("m_pFoldersTreeWidget"));
-    m_pFoldersTreeWidget->setMinimumSize(QSize(0, 200));
-    m_pFoldersTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
-    m_pFoldersTreeWidget->setUniformRowHeights(true);
-    m_pFoldersTreeWidget->setAllColumnsShowFocus(true);
-
-    pFoldersLayout->addWidget(m_pFoldersTreeWidget);
-
-    m_pFoldersToolBar = new UIToolBar(m_pFoldersTreeWidgetContainer);
-    m_pFoldersToolBar->setObjectName(QStringLiteral("m_pFoldersToolBar"));
-
-    pFoldersLayout->addWidget(m_pFoldersToolBar);
-    pMainLayout->addWidget(m_pFoldersTreeWidgetContainer);
-    m_pNameSeparator->setBuddy(m_pFoldersTreeWidget);
-}
-
 void UIMachineSettingsSF::prepare()
 {
-    prepareWidgets();
-
     /* Prepare cache: */
     m_pCache = new UISettingsCacheSharedFolders;
     AssertPtrReturnVoid(m_pCache);
 
-    /* Layout created in the .ui file. */
-    {
-        /* Prepare shared folders tree: */
-        prepareFoldersTree();
-        /* Prepare shared folders toolbar: */
-        prepareFoldersToolbar();
-        /* Prepare connections: */
-        prepareConnections();
-    }
+    /* Prepare everything: */
+    prepareWidgets();
+    prepareConnections();
 
     /* Apply language settings: */
@@ -748,53 +705,84 @@
 }
 
-void UIMachineSettingsSF::prepareFoldersTree()
-{
-    /* Shared Folders tree-widget created in the .ui file. */
-    AssertPtrReturnVoid(m_pFoldersTreeWidget);
-    {
-        /* Configure tree-widget: */
-        m_pFoldersTreeWidget->header()->setSectionsMovable(false);
-    }
-}
-
-void UIMachineSettingsSF::prepareFoldersToolbar()
-{
-    /* Shared Folders toolbar created in the .ui file. */
-    AssertPtrReturnVoid(m_pFoldersToolBar);
-    {
-        /* Configure toolbar: */
+void UIMachineSettingsSF::prepareWidgets()
+{
+    /* Prepare main layout: */
+    QVBoxLayout *pLayoutMain = new QVBoxLayout(this);
+    if (pLayoutMain)
+    {
+        pLayoutMain->setContentsMargins(0, 0, 0, 0);
+
+        /* Prepare separator: */
+        m_pLabelSeparator = new QILabelSeparator(this);
+        if (m_pLabelSeparator)
+            pLayoutMain->addWidget(m_pLabelSeparator);
+
+        /* Prepare view layout: */
+        m_pLayoutTree = new QHBoxLayout;
+        if (m_pLayoutTree)
+        {
+            m_pLayoutTree->setContentsMargins(0, 0, 0, 0);
+            m_pLayoutTree->setSpacing(3);
+
+            /* Prepare tree-widget: */
+            prepareTreeWidget();
+            /* Prepare toolbar: */
+            prepareToolbar();
+
+            pLayoutMain->addLayout(m_pLayoutTree);
+        }
+    }
+}
+
+void UIMachineSettingsSF::prepareTreeWidget()
+{
+    /* Prepare shared folders tree-widget: */
+    m_pTreeWidget = new QITreeWidget(this);
+    if (m_pTreeWidget)
+    {
+        if (m_pLabelSeparator)
+            m_pLabelSeparator->setBuddy(m_pTreeWidget);
+        m_pTreeWidget->header()->setSectionsMovable(false);
+        m_pTreeWidget->setMinimumSize(QSize(0, 200));
+        m_pTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
+        m_pTreeWidget->setUniformRowHeights(true);
+        m_pTreeWidget->setAllColumnsShowFocus(true);
+
+        m_pLayoutTree->addWidget(m_pTreeWidget);
+    }
+}
+
+void UIMachineSettingsSF::prepareToolbar()
+{
+    /* Prepare shared folders toolbar: */
+    m_pToolBar = new UIToolBar(this);
+    if (m_pToolBar)
+    {
         const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
-        m_pFoldersToolBar->setIconSize(QSize(iIconMetric, iIconMetric));
-        m_pFoldersToolBar->setOrientation(Qt::Vertical);
-
-        /* Create 'Add Shared Folder' action: */
-        m_pActionAdd = m_pFoldersToolBar->addAction(UIIconPool::iconSet(":/sf_add_16px.png",
+        m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric));
+        m_pToolBar->setOrientation(Qt::Vertical);
+
+        /* Prepare 'Add Shared Folder' action: */
+        m_pActionAdd = m_pToolBar->addAction(UIIconPool::iconSet(":/sf_add_16px.png",
                                                                         ":/sf_add_disabled_16px.png"),
                                                     QString(), this, SLOT(sltAddFolder()));
-        AssertPtrReturnVoid(m_pActionAdd);
-        {
-            /* Configure action: */
+        if (m_pActionAdd)
             m_pActionAdd->setShortcuts(QList<QKeySequence>() << QKeySequence("Ins") << QKeySequence("Ctrl+N"));
-        }
-
-        /* Create 'Edit Shared Folder' action: */
-        m_pActionEdit = m_pFoldersToolBar->addAction(UIIconPool::iconSet(":/sf_edit_16px.png",
+
+        /* Prepare 'Edit Shared Folder' action: */
+        m_pActionEdit = m_pToolBar->addAction(UIIconPool::iconSet(":/sf_edit_16px.png",
                                                                          ":/sf_edit_disabled_16px.png"),
                                                      QString(), this, SLOT(sltEditFolder()));
-        AssertPtrReturnVoid(m_pActionEdit);
-        {
-            /* Configure action: */
+        if (m_pActionEdit)
             m_pActionEdit->setShortcuts(QList<QKeySequence>() << QKeySequence("Space") << QKeySequence("F2"));
-        }
-
-        /* Create 'Remove Shared Folder' action: */
-        m_pActionRemove = m_pFoldersToolBar->addAction(UIIconPool::iconSet(":/sf_remove_16px.png",
+
+        /* Prepare 'Remove Shared Folder' action: */
+        m_pActionRemove = m_pToolBar->addAction(UIIconPool::iconSet(":/sf_remove_16px.png",
                                                                            ":/sf_remove_disabled_16px.png"),
                                                        QString(), this, SLOT(sltRemoveFolder()));
-        AssertPtrReturnVoid(m_pActionRemove);
-        {
-            /* Configure action: */
+        if (m_pActionRemove)
             m_pActionRemove->setShortcuts(QList<QKeySequence>() << QKeySequence("Del") << QKeySequence("Ctrl+R"));
-        }
+
+        m_pLayoutTree->addWidget(m_pToolBar);
     }
 }
@@ -803,9 +791,9 @@
 {
     /* Configure tree-widget connections: */
-    connect(m_pFoldersTreeWidget, &QITreeWidget::currentItemChanged,
+    connect(m_pTreeWidget, &QITreeWidget::currentItemChanged,
             this, &UIMachineSettingsSF::sltHandleCurrentItemChange);
-    connect(m_pFoldersTreeWidget, &QITreeWidget::itemDoubleClicked,
+    connect(m_pTreeWidget, &QITreeWidget::itemDoubleClicked,
             this, &UIMachineSettingsSF::sltHandleDoubleClick);
-    connect(m_pFoldersTreeWidget, &QITreeWidget::customContextMenuRequested,
+    connect(m_pTreeWidget, &QITreeWidget::customContextMenuRequested,
             this, &UIMachineSettingsSF::sltHandleContextMenuRequest);
 }
@@ -822,5 +810,5 @@
     /* Search for the corresponding root item among all the top-level items: */
     SFTreeViewItem *pRootItem = 0;
-    QTreeWidgetItem *pMainRootItem = m_pFoldersTreeWidget->invisibleRootItem();
+    QTreeWidgetItem *pMainRootItem = m_pTreeWidget->invisibleRootItem();
     for (int iFolderTypeIndex = 0; iFolderTypeIndex < pMainRootItem->childCount(); ++iFolderTypeIndex)
     {
@@ -844,5 +832,5 @@
     /* Make the used names list: */
     QStringList list;
-    QTreeWidgetItemIterator it(m_pFoldersTreeWidget);
+    QTreeWidgetItemIterator it(m_pTreeWidget);
     while (*it)
     {
@@ -887,5 +875,5 @@
     {
         /* Create new shared folder type item: */
-        pRootItem = new SFTreeViewItem(m_pFoldersTreeWidget, SFTreeViewItem::FormatType_EllipsisEnd);
+        pRootItem = new SFTreeViewItem(m_pTreeWidget, SFTreeViewItem::FormatType_EllipsisEnd);
         AssertPtrReturnVoid(pRootItem);
         {
@@ -925,6 +913,6 @@
         if (fChoose)
         {
-            m_pFoldersTreeWidget->scrollToItem(pItem);
-            m_pFoldersTreeWidget->setCurrentItem(pItem);
+            m_pTreeWidget->scrollToItem(pItem);
+            m_pTreeWidget->setCurrentItem(pItem);
             sltHandleCurrentItemChange(pItem);
         }
Index: /trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.h	(revision 85958)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.h	(revision 85959)
@@ -29,4 +29,5 @@
 
 /* Forward declarations: */
+class QHBoxLayout;
 class QTreeWidgetItem;
 class QITreeWidget;
@@ -112,8 +113,8 @@
     /** Prepares Widgets. */
     void prepareWidgets();
-    /** Prepares shared folders tree. */
-    void prepareFoldersTree();
+    /** Prepares shared folders tree-wdget. */
+    void prepareTreeWidget();
     /** Prepares shared folders toolbar. */
-    void prepareFoldersToolbar();
+    void prepareToolbar();
     /** Prepares connections. */
     void prepareConnections();
@@ -150,11 +151,4 @@
     bool createSharedFolder(const UISettingsCacheSharedFolder &folderCache);
 
-    /** Holds the Add action instance. */
-    QAction *m_pActionAdd;
-    /** Holds the Edit action instance. */
-    QAction *m_pActionEdit;
-    /** Holds the Remove action instance. */
-    QAction *m_pActionRemove;
-
     /** Holds the page data cache instance. */
     UISettingsCacheSharedFolders *m_pCache;
@@ -162,7 +156,18 @@
     /** @name Widgets
       * @{ */
-        QITreeWidget *m_pFoldersTreeWidget;
-        QILabelSeparator *m_pNameSeparator;
-        UIToolBar *m_pFoldersToolBar;
+        /** Holds the widget separator instance. */
+        QILabelSeparator *m_pLabelSeparator;
+        /** Holds the tree layout instance. */
+        QHBoxLayout      *m_pLayoutTree;
+        /** Holds the tree-widget instance. */
+        QITreeWidget     *m_pTreeWidget;
+        /** Holds the toolbar instance. */
+        UIToolBar        *m_pToolBar;
+        /** Holds the Add action instance. */
+        QAction          *m_pActionAdd;
+        /** Holds the Edit action instance. */
+        QAction          *m_pActionEdit;
+        /** Holds the Remove action instance. */
+        QAction          *m_pActionRemove;
     /** @} */
 };
