Index: /trunk/src/VBox/Frontends/VirtualBox/src/UIVMLogViewer.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/UIVMLogViewer.cpp	(revision 59832)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/UIVMLogViewer.cpp	(revision 59833)
@@ -48,4 +48,5 @@
 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
 
+
 /** QWidget extension
   * providing GUI for search-panel in VM Log-Viewer. */
@@ -78,24 +79,33 @@
     void find(int iButton)
     {
+        /* If button-id is 1, findNext: */
         if (iButton)
             findNext();
+        /* If button-id is 0, findBack: */
         else
             findBack();
     }
 
-    /** Handles textchanged event from search-editor.
+    /** Handles textchanged signal from search-editor.
       * @param  strSearchString  Specifies search-string. */
     void findCurrent(const QString &strSearchString)
     {
+        /* Enable/disable Next-Previous buttons as per search-string validity: */
         m_pNextPrevButtons->setEnabled(0, strSearchString.length());
         m_pNextPrevButtons->setEnabled(1, strSearchString.length());
+        /* Show/hide the warning as per search-string validity: */
         toggleWarning(!strSearchString.length());
+        /* If search-string is valid: */
         if (strSearchString.length())
             search(true, true);
+        /* If search-string is not valid, reset cursor position: */
         else
         {
+            /* Get current log-page: */
             QTextEdit *pBrowser = m_pViewer->currentLogPage();
+            /* If current log-page is valid and cursor has selection: */
             if (pBrowser && pBrowser->textCursor().hasSelection())
             {
+                /* Get cursor and reset position: */
                 QTextCursor cursor = pBrowser->textCursor();
                 cursor.setPosition(cursor.anchor());
@@ -110,7 +120,4 @@
     void prepare()
     {
-        /* Prepare main-layout: */
-        prepareMainLayout();
-
         /* Prepare widgets: */
         prepareWidgets();
@@ -123,6 +130,6 @@
     }
 
-    /** Prepares main-layout. */
-    void prepareMainLayout()
+    /** Prepares widgets. */
+    void prepareWidgets()
     {
         /* Create main-layout: */
@@ -130,123 +137,119 @@
         AssertPtrReturnVoid(m_pMainLayout);
         {
-            /* Prepare main-layout: */
+            /* Configure main-layout: */
             m_pMainLayout->setSpacing(5);
             /* Not sure 0 margins are default, but just to be safe: */
             m_pMainLayout->setContentsMargins(0, 0, 0, 0);
-        }
-    }
-
-    /** Prepares widgets. */
-    void prepareWidgets()
-    {
-        /* Create close-button: */
-        m_pCloseButton = new UIMiniCancelButton(this);
-        AssertPtrReturnVoid(m_pCloseButton);
-        {
-            /* Add close-button to main-layout: */
-            m_pMainLayout->addWidget(m_pCloseButton);
-        }
-
-        /* Create search-editor: */
-        m_pSearchEditor = new UISearchField(this);
-        AssertPtrReturnVoid(m_pSearchEditor);
-        {
-            /* Configure search-editor: */
-            m_pSearchEditor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
-            /* Add search-editor to main-layout: */
-            m_pMainLayout->addWidget(m_pSearchEditor);
-        }
-
-        /* Create search-label: */
-        m_pSearchLabel = new QLabel(this);
-        AssertPtrReturnVoid(m_pSearchLabel);
-        {
-            /* Configure search-label: */
-            m_pSearchLabel->setBuddy(m_pSearchEditor);
-            /* Prepare font: */
+
+            /* Create close-button: */
+            m_pCloseButton = new UIMiniCancelButton;
+            AssertPtrReturnVoid(m_pCloseButton);
+            {
+                /* Add close-button to main-layout: */
+                m_pMainLayout->addWidget(m_pCloseButton);
+            }
+
+            /* Create search-editor: */
+            m_pSearchEditor = new UISearchField(this);
+            AssertPtrReturnVoid(m_pSearchEditor);
+            {
+                /* Configure search-editor: */
+                m_pSearchEditor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+                /* Add search-editor to main-layout: */
+                m_pMainLayout->addWidget(m_pSearchEditor);
+            }
+
+            /* Create search-label: */
+            m_pSearchLabel = new QLabel;
+            AssertPtrReturnVoid(m_pSearchLabel);
+            {
+                /* Configure search-label: */
+                m_pSearchLabel->setBuddy(m_pSearchEditor);
+                /* Prepare font: */
 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
-            QFont font = m_pSearchLabel->font();
-            font.setPointSize(::darwinSmallFontSize());
-            m_pSearchLabel->setFont(font);
+                QFont font = m_pSearchLabel->font();
+                font.setPointSize(::darwinSmallFontSize());
+                m_pSearchLabel->setFont(font);
 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
-            /* Add search-label to main-layout: */
-            m_pMainLayout->addWidget(m_pSearchLabel);
-        }
-
-        /* Create Next/Prev button-box: */
-        m_pNextPrevButtons = new UIRoundRectSegmentedButton(this, 2);
-        AssertPtrReturnVoid(m_pNextPrevButtons);
-        {
-            /* Prepare Next/Prev button-box: */
-            m_pNextPrevButtons->setEnabled(0, false);
-            m_pNextPrevButtons->setEnabled(1, false);
+                /* Add search-label to main-layout: */
+                m_pMainLayout->addWidget(m_pSearchLabel);
+            }
+
+            /* Create Next/Prev button-box: */
+            m_pNextPrevButtons = new UIRoundRectSegmentedButton(this, 2);
+            AssertPtrReturnVoid(m_pNextPrevButtons);
+            {
+                /* Configure Next/Prev button-box: */
+                m_pNextPrevButtons->setEnabled(0, false);
+                m_pNextPrevButtons->setEnabled(1, false);
 #ifndef Q_WS_MAC
-            /* No icons on the Mac: */
-            m_pNextPrevButtons->setIcon(0, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowBack, this));
-            m_pNextPrevButtons->setIcon(1, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowForward, this));
+                /* No icons on the Mac: */
+                m_pNextPrevButtons->setIcon(0, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowBack, this));
+                m_pNextPrevButtons->setIcon(1, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowForward, this));
 #endif /* !Q_WS_MAC */
-            /* Add Next/Prev button-box to main-layout: */
-            m_pMainLayout->addWidget(m_pNextPrevButtons);
-        }
-
-        /* Create case-sensitive checkbox: */
-        m_pCaseSensitiveCheckBox = new QCheckBox(this);
-        AssertPtrReturnVoid(m_pCaseSensitiveCheckBox);
-        {
-            /* Configure focus for case-sensitive checkbox: */
-            setFocusProxy(m_pCaseSensitiveCheckBox);
-            /* Prepare font: */
+                /* Add Next/Prev button-box to main-layout: */
+                m_pMainLayout->addWidget(m_pNextPrevButtons);
+            }
+
+            /* Create case-sensitive checkbox: */
+            m_pCaseSensitiveCheckBox = new QCheckBox;
+            AssertPtrReturnVoid(m_pCaseSensitiveCheckBox);
+            {
+                /* Configure focus for case-sensitive checkbox: */
+                setFocusProxy(m_pCaseSensitiveCheckBox);
+                /* Configure font: */
 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
-            QFont font = m_pCaseSensitiveCheckBox->font();
-            font.setPointSize(::darwinSmallFontSize());
-            m_pCaseSensitiveCheckBox->setFont(font);
+                QFont font = m_pCaseSensitiveCheckBox->font();
+                font.setPointSize(::darwinSmallFontSize());
+                m_pCaseSensitiveCheckBox->setFont(font);
 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
-            /* Add case-sensitive checkbox to main-layout: */
-            m_pMainLayout->addWidget(m_pCaseSensitiveCheckBox);
-        }
-
-        /* Create warning-spacer: */
-        m_pWarningSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
-        AssertPtrReturnVoid(m_pWarningSpacer);
-        {
-            /* Add warning-spacer to main-layout: */
-            m_pMainLayout->addItem(m_pWarningSpacer);
-        }
-
-        /* Create warning-icon: */
-        m_pWarningIcon = new QLabel(this);
-        AssertPtrReturnVoid(m_pWarningIcon);
-        {
-            /* Confifure warning-icon: */
-            m_pWarningIcon->hide();
-            QIcon icon = UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_MessageBoxWarning, this);
-            if (!icon.isNull())
-                m_pWarningIcon->setPixmap(icon.pixmap(16, 16));
-            /* Add warning-icon to main-layout: */
-            m_pMainLayout->addWidget(m_pWarningIcon);
-        }
-
-        /* Create warning-label: */
-        m_pWarningLabel = new QLabel(this);
-        AssertPtrReturnVoid(m_pWarningLabel);
-        {
-            /* Configure warning-label: */
-            m_pWarningLabel->hide();
-            /* Prepare font: */
+                /* Add case-sensitive checkbox to main-layout: */
+                m_pMainLayout->addWidget(m_pCaseSensitiveCheckBox);
+            }
+
+            /* Create warning-spacer: */
+            m_pWarningSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
+            AssertPtrReturnVoid(m_pWarningSpacer);
+            {
+                /* Add warning-spacer to main-layout: */
+                m_pMainLayout->addItem(m_pWarningSpacer);
+            }
+
+            /* Create warning-icon: */
+            m_pWarningIcon = new QLabel;
+            AssertPtrReturnVoid(m_pWarningIcon);
+            {
+                /* Confifure warning-icon: */
+                m_pWarningIcon->hide();
+                QIcon icon = UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_MessageBoxWarning, this);
+                if (!icon.isNull())
+                    m_pWarningIcon->setPixmap(icon.pixmap(16, 16));
+                /* Add warning-icon to main-layout: */
+                m_pMainLayout->addWidget(m_pWarningIcon);
+            }
+
+            /* Create warning-label: */
+            m_pWarningLabel = new QLabel;
+            AssertPtrReturnVoid(m_pWarningLabel);
+            {
+                /* Configure warning-label: */
+                m_pWarningLabel->hide();
+                /* Prepare font: */
 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
-            QFont font = m_pWarningLabel->font();
-            font.setPointSize(::darwinSmallFontSize());
-            m_pWarningLabel->setFont(font);
+                QFont font = m_pWarningLabel->font();
+                font.setPointSize(::darwinSmallFontSize());
+                m_pWarningLabel->setFont(font);
 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
-            /* Add warning-label to main-layout: */
-            m_pMainLayout->addWidget(m_pWarningLabel);
-        }
-
-        /* Create spacer-item: */
-        m_pSpacerItem = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
-        AssertPtrReturnVoid(m_pSpacerItem);
-        {
-            /* Add spacer-item to main-layout: */
-            m_pMainLayout->addItem(m_pSpacerItem);
+                /* Add warning-label to main-layout: */
+                m_pMainLayout->addWidget(m_pWarningLabel);
+            }
+
+            /* Create spacer-item: */
+            m_pSpacerItem = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
+            AssertPtrReturnVoid(m_pSpacerItem);
+            {
+                /* Add spacer-item to main-layout: */
+                m_pMainLayout->addItem(m_pSpacerItem);
+            }
         }
     }
@@ -286,5 +289,5 @@
         switch (pEvent->key())
         {
-            /* Process Enter press as 'search next',
+            /* Process Enter press as 'search-next',
              * performed for any search panel widget: */
             case Qt::Key_Enter:
@@ -294,4 +297,5 @@
                     pEvent->modifiers() & Qt::KeypadModifier)
                 {
+                    /* Animate click on 'Next' button: */
                     m_pNextPrevButtons->animateClick(1);
                     return;
@@ -302,4 +306,5 @@
                 break;
         }
+        /* Call to base-class: */
         QWidget::keyPressEvent(pEvent);
     }
@@ -320,11 +325,15 @@
                 if (pKeyEvent->key() == Qt::Key_F3)
                 {
+                    /* If there is no modifier 'Key-F3' is pressed: */
                     if (pKeyEvent->QInputEvent::modifiers() == 0)
                     {
+                        /* Animate click on 'Next' button: */
                         m_pNextPrevButtons->animateClick(1);
                         return true;
                     }
+                    /* If there is 'ShiftModifier' 'Shift + Key-F3' is pressed: */
                     else if (pKeyEvent->QInputEvent::modifiers() == Qt::ShiftModifier)
                     {
+                        /* Animate click on 'Prev' button: */
                         m_pNextPrevButtons->animateClick(0);
                         return true;
@@ -337,6 +346,8 @@
                     if (m_pViewer->currentLogPage())
                     {
+                        /* Make sure current log-page is visible: */
                         if (isHidden())
                             show();
+                        /* Set focus on search-editor: */
                         m_pSearchEditor->setFocus();
                         return true;
@@ -347,9 +358,12 @@
                          pKeyEvent->key() >= Qt::Key_Exclam && pKeyEvent->key() <= Qt::Key_AsciiTilde)
                 {
+                    /* Make sure current log-page is visible: */
                     if (m_pViewer->currentLogPage())
                     {
                         if (isHidden())
                             show();
+                        /* Set focus on search-editor: */
                         m_pSearchEditor->setFocus();
+                        /* Insert the text to search-editor, which triggers the search-operation for new text: */
                         m_pSearchEditor->insert(pKeyEvent->text());
                         return true;
@@ -368,6 +382,9 @@
     void showEvent(QShowEvent *pEvent)
     {
+        /* Call to base-class: */
         QWidget::showEvent(pEvent);
+        /* Set focus on search-editor: */
         m_pSearchEditor->setFocus();
+        /* Select all the text: */
         m_pSearchEditor->selectAll();
     }
@@ -376,7 +393,11 @@
     void hideEvent(QHideEvent *pEvent)
     {
+        /* Get focus-widget: */
         QWidget *pFocus = QApplication::focusWidget();
+        /* If focus-widget is valid and child-widget of search-panel,
+         * focus next child-widget in line: */
         if (pFocus && pFocus->parent() == this)
             focusNextPrevChild(true);
+        /* Call to base-class: */
         QWidget::hideEvent(pEvent);
     }
@@ -387,17 +408,22 @@
     void search(bool fForward, bool fStartCurrent = false)
     {
+        /* Get current log-page: */
         QTextEdit *pBrowser = m_pViewer->currentLogPage();
         if (!pBrowser) return;
 
+        /* Get text-cursor and its attributes: */
         QTextCursor cursor = pBrowser->textCursor();
         int iPos = cursor.position();
         int iAnc = cursor.anchor();
 
+        /* Get the text to be searched: */
         QString strText = pBrowser->toPlainText();
         int iDiff = fStartCurrent ? 0 : 1;
 
         int iResult = -1;
+        /* If search-direction is forward and cursor position is valid: */
         if (fForward && (fStartCurrent || iPos < strText.size() - 1))
         {
+            /* Search and get the index of first match: */
             iResult = strText.indexOf(m_pSearchEditor->text(), iAnc + iDiff,
                                       m_pCaseSensitiveCheckBox->isChecked() ?
@@ -410,4 +436,5 @@
                                           Qt::CaseSensitive : Qt::CaseInsensitive);
         }
+        /* If search-direction is backward: */
         else if (!fForward && iAnc > 0)
             iResult = strText.lastIndexOf(m_pSearchEditor->text(), iAnc - 1,
@@ -415,4 +442,5 @@
                                           Qt::CaseSensitive : Qt::CaseInsensitive);
 
+        /* If the result is valid, move cursor-position: */
         if (iResult != -1)
         {
@@ -427,4 +455,5 @@
         }
 
+        /* Show/hide the warning as per search-result: */
         toggleWarning(iResult != -1);
     }
@@ -439,10 +468,15 @@
     void toggleWarning(bool fHide)
     {
+        /* Adjust size of warning-spacer accordingly: */
         m_pWarningSpacer->changeSize(fHide ? 0 : 16, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
+        /* If visible mark the error for search-editor (changes text-color): */
         if (!fHide)
             m_pSearchEditor->markError();
+        /* If hidden unmark the error for search-editor (changes text-color): */
         else
             m_pSearchEditor->unmarkError();
+        /* Show/hide the warning-icon: */
         m_pWarningIcon->setHidden(fHide);
+        /* Show/hide the warning-label: */
         m_pWarningLabel->setHidden(fHide);
     }
@@ -472,4 +506,5 @@
 };
 
+
 /** QWidget extension
   * providing GUI for filter panel in VM Log Viewer. */
@@ -551,7 +586,4 @@
     void prepare()
     {
-        /* Prepare main-layout: */
-        prepareMainLayout();
-
         /* Prepare widgets: */
         prepareWidgets();
@@ -564,6 +596,6 @@
     }
 
-    /** Prepares main-layout. */
-    void prepareMainLayout()
+    /** Prepares widgets. */
+    void prepareWidgets()
     {
         /* Create main-layout: */
@@ -575,47 +607,43 @@
             /* Not sure 0 margins are default, but just to be safe: */
             m_pMainLayout->setContentsMargins(0, 0, 0, 0);
-        }
-    }
-
-    /** Prepares widgets. */
-    void prepareWidgets()
-    {
-        /* Create close-button: */
-        m_pCloseButton = new UIMiniCancelButton(this);
-        AssertPtrReturnVoid(m_pCloseButton);
-        {
-            /* Add close-button to main-layout: */
-            m_pMainLayout->addWidget(m_pCloseButton);
-        }
-
-        /* Create filter-combobox: */
-        m_pFilterComboBox = new QComboBox(this);
-        AssertPtrReturnVoid(m_pFilterComboBox);
-        {
-            /* Configure filter-combobox: */
-            m_pFilterComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-            m_pFilterComboBox->setEditable(true);
-            QStringList strFilterPresets;
-            strFilterPresets << "" << "GUI" << "NAT" << "AHCI" << "VD" << "Audio" << "VUSB" << "SUP" << "PGM" << "HDA"
-                             << "HM" << "VMM" << "GIM" << "CPUM";
-            strFilterPresets.sort();
-            m_pFilterComboBox->addItems(strFilterPresets);
-            /* Add filter-combobox to main-layout: */
-            m_pMainLayout->addWidget(m_pFilterComboBox);
-        }
-
-        /* Create filter-label: */
-        m_pFilterLabel = new QLabel(this);
-        AssertPtrReturnVoid(m_pFilterLabel);
-        {
-            /* Configure filter-label: */
-            m_pFilterLabel->setBuddy(m_pFilterComboBox);
+
+            /* Create close-button: */
+            m_pCloseButton = new UIMiniCancelButton;
+            AssertPtrReturnVoid(m_pCloseButton);
+            {
+                /* Add close-button to main-layout: */
+                m_pMainLayout->addWidget(m_pCloseButton);
+            }
+
+            /* Create filter-combobox: */
+            m_pFilterComboBox = new QComboBox;
+            AssertPtrReturnVoid(m_pFilterComboBox);
+            {
+                /* Configure filter-combobox: */
+                m_pFilterComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+                m_pFilterComboBox->setEditable(true);
+                QStringList strFilterPresets;
+                strFilterPresets << "" << "GUI" << "NAT" << "AHCI" << "VD" << "Audio" << "VUSB" << "SUP" << "PGM" << "HDA"
+                                 << "HM" << "VMM" << "GIM" << "CPUM";
+                strFilterPresets.sort();
+                m_pFilterComboBox->addItems(strFilterPresets);
+                /* Add filter-combobox to main-layout: */
+                m_pMainLayout->addWidget(m_pFilterComboBox);
+            }
+
+            /* Create filter-label: */
+            m_pFilterLabel = new QLabel;
+            AssertPtrReturnVoid(m_pFilterLabel);
+            {
+                /* Configure filter-label: */
+                m_pFilterLabel->setBuddy(m_pFilterComboBox);
 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
-            QFont font = m_pFilterLabel->font();
-            font.setPointSize(::darwinSmallFontSize());
-            m_pFilterLabel->setFont(font);
+                QFont font = m_pFilterLabel->font();
+                font.setPointSize(::darwinSmallFontSize());
+                m_pFilterLabel->setFont(font);
 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
-            /* Add filter-label to main-layout: */
-            m_pMainLayout->addWidget(m_pFilterLabel);
+                /* Add filter-label to main-layout: */
+                m_pMainLayout->addWidget(m_pFilterLabel);
+            }
         }
     }
@@ -674,5 +702,7 @@
     void showEvent(QShowEvent *pEvent)
     {
+        /* Call to base-class: */
         QWidget::showEvent(pEvent);
+        /* Set focus to combo-box: */
         m_pFilterComboBox->setFocus();
     }
@@ -681,7 +711,11 @@
     void hideEvent(QHideEvent *pEvent)
     {
+        /* Get focused widget: */
         QWidget *pFocus = QApplication::focusWidget();
+        /* If focus-widget is valid and child-widget of search-panel,
+         * focus next child-widget in line: */
         if (pFocus && pFocus->parent() == this)
             focusNextPrevChild(true);
+        /* Call to base-class: */
         QWidget::hideEvent(pEvent);
     }
@@ -700,4 +734,9 @@
     QString m_strFilterText;
 };
+
+
+/*********************************************************************************************************************************
+*   Class UIVMLogViewer implementation.                                                                                          *
+*********************************************************************************************************************************/
 
 /** Holds the VM Log-Viewer array. */
@@ -899,5 +938,5 @@
     loadSettings();
 
-    /* Loading language constants */
+    /* Loading language constants: */
     retranslateUi();
 }
@@ -909,5 +948,5 @@
     AssertPtrReturnVoid(m_pViewerContainer);
     {
-        /* Layout VM Log-Viewer container: */
+        /* Add VM Log-Viewer container to main-layout: */
         m_pMainLayout->insertWidget(0, m_pViewerContainer);
     }
@@ -920,5 +959,5 @@
         centralWidget()->installEventFilter(m_pSearchPanel);
         m_pSearchPanel->hide();
-        /* Layout VM Log-Viewer search-panel: */
+        /* Add VM Log-Viewer search-panel to main-layout: */
         m_pMainLayout->insertWidget(1, m_pSearchPanel);
     }
@@ -931,5 +970,5 @@
         centralWidget()->installEventFilter(m_pFilterPanel);
         m_pFilterPanel->hide();
-        /* Layout VM Log-Viewer filter-panel: */
+        /* Add VM Log-Viewer filter-panel to main-layout: */
         m_pMainLayout->insertWidget(2, m_pFilterPanel);
     }
@@ -966,4 +1005,59 @@
 }
 
+void UIVMLogViewer::loadSettings()
+{
+    /* Restore window geometry: */
+    {
+        /* Getting available geometry to calculate default geometry: */
+        const QRect desktopRect = vboxGlobal().availableGeometry(this);
+        int iDefaultWidth = desktopRect.width() / 2;
+        int iDefaultHeight = desktopRect.height() * 3 / 4;
+
+        /* Calculate default width to fit 132 characters: */
+        QTextEdit *pCurrentLogPage = currentLogPage();
+        if (pCurrentLogPage)
+        {
+            iDefaultWidth = pCurrentLogPage->fontMetrics().width(QChar('x')) * 132 +
+                            pCurrentLogPage->verticalScrollBar()->width() +
+                            pCurrentLogPage->frameWidth() * 2 +
+                            10 * 2 /* m_pViewerContainer margin */ +
+                            10 * 2 /* CentralWidget margin */;
+        }
+        QRect defaultGeometry(0, 0, iDefaultWidth, iDefaultHeight);
+        defaultGeometry.moveCenter(parentWidget()->geometry().center());
+
+        /* Load geometry: */
+        m_geometry = gEDataManager->logWindowGeometry(this, defaultGeometry);
+#ifdef Q_WS_MAC
+        move(m_geometry.topLeft());
+        resize(m_geometry.size());
+#else /* !Q_WS_MAC */
+        setGeometry(m_geometry);
+#endif /* !Q_WS_MAC */
+        LogRel2(("GUI: UIVMLogViewer: Geometry loaded to: Origin=%dx%d, Size=%dx%d\n",
+                 m_geometry.x(), m_geometry.y(), m_geometry.width(), m_geometry.height()));
+
+        /* Maximize (if necessary): */
+        if (gEDataManager->logWindowShouldBeMaximized())
+            showMaximized();
+    }
+}
+
+void UIVMLogViewer::saveSettings()
+{
+    /* Save window geometry: */
+    {
+        /* Save geometry: */
+        const QRect saveGeometry = geometry();
+#ifdef Q_WS_MAC
+        gEDataManager->setLogWindowGeometry(saveGeometry, ::darwinIsWindowMaximized(this));
+#else /* !Q_WS_MAC */
+        gEDataManager->setLogWindowGeometry(saveGeometry, isMaximized());
+#endif /* !Q_WS_MAC */
+        LogRel2(("GUI: UIVMLogViewer: Geometry saved as: Origin=%dx%d, Size=%dx%d\n",
+                 saveGeometry.x(), saveGeometry.y(), saveGeometry.width(), saveGeometry.height()));
+    }
+}
+
 void UIVMLogViewer::cleanup()
 {
@@ -1006,5 +1100,5 @@
         return;
 
-    m_fIsPolished = true;   
+    m_fIsPolished = true;
 
     /* Make sure the log view widget has the focus: */
@@ -1053,6 +1147,8 @@
 QTextEdit* UIVMLogViewer::currentLogPage()
 {
+    /* If viewer-container is enabled: */
     if (m_pViewerContainer->isEnabled())
     {
+        /* Get and return current log-page: */
         QWidget *pContainer = m_pViewerContainer->currentWidget();
         QTextEdit *pBrowser = pContainer->findChild<QTextEdit*>();
@@ -1060,6 +1156,6 @@
         return pBrowser ? pBrowser : 0;
     }
-    else
-        return 0;
+    /* Return NULL by default: */
+    return 0;
 }
 
@@ -1101,59 +1197,4 @@
 }
 
-void UIVMLogViewer::loadSettings()
-{
-    /* Restore window geometry: */
-    {
-        /* Getting available geometry to calculate default geometry: */
-        const QRect desktopRect = vboxGlobal().availableGeometry(this);
-        int iDefaultWidth = desktopRect.width() / 2;
-        int iDefaultHeight = desktopRect.height() * 3 / 4;
-
-        /* Calculate default width to fit 132 characters: */
-        QTextEdit *pCurrentLogPage = currentLogPage();
-        if (pCurrentLogPage)
-        {
-            iDefaultWidth = pCurrentLogPage->fontMetrics().width(QChar('x')) * 132 +
-                pCurrentLogPage->verticalScrollBar()->width() +
-                pCurrentLogPage->frameWidth() * 2 +
-                /* m_pViewerContainer margin */ 10 * 2 +
-                /* CentralWidget margin */ 10 * 2;
-        }
-        QRect defaultGeometry(0, 0, iDefaultWidth, iDefaultHeight);
-        defaultGeometry.moveCenter(parentWidget()->geometry().center());
-
-        /* Load geometry: */
-        m_geometry = gEDataManager->logWindowGeometry(this, defaultGeometry);
-#ifdef Q_WS_MAC
-        move(m_geometry.topLeft());
-        resize(m_geometry.size());
-#else /* Q_WS_MAC */
-        setGeometry(m_geometry);
-#endif /* !Q_WS_MAC */
-        LogRel2(("GUI: UIVMLogViewer: Geometry loaded to: Origin=%dx%d, Size=%dx%d\n",
-                 m_geometry.x(), m_geometry.y(), m_geometry.width(), m_geometry.height()));
-
-        /* Maximize (if necessary): */
-        if (gEDataManager->logWindowShouldBeMaximized())
-            showMaximized();
-    }
-}
-
-void UIVMLogViewer::saveSettings()
-{
-    /* Save window geometry: */
-    {
-        /* Save geometry: */
-        const QRect saveGeometry = geometry();
-#ifdef Q_WS_MAC
-        gEDataManager->setLogWindowGeometry(saveGeometry, ::darwinIsWindowMaximized(this));
-#else /* Q_WS_MAC */
-        gEDataManager->setLogWindowGeometry(saveGeometry, isMaximized());
-#endif /* !Q_WS_MAC */
-        LogRel2(("GUI: UIVMLogViewer: Geometry saved as: Origin=%dx%d, Size=%dx%d\n",
-                 saveGeometry.x(), saveGeometry.y(), saveGeometry.width(), saveGeometry.height()));
-    }
-}
-
 #include "UIVMLogViewer.moc"
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/UIVMLogViewer.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/UIVMLogViewer.h	(revision 59832)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/UIVMLogViewer.h	(revision 59833)
@@ -73,5 +73,5 @@
     /** Handles search action triggering. */
     void search();
-    /** Handles search action triggering. */
+    /** Handles refresh action triggering. */
     void refresh();
     /** Handles close action triggering. */
@@ -84,24 +84,31 @@
 private:
 
-    /** Prepares VM Log-Viewer. */
-    void prepare();
+    /** @name Prepare/Cleanup
+      * @{ */
+        /** Prepares VM Log-Viewer. */
+        void prepare();
+        /** Prepares widgets. */
+        void prepareWidgets();
+        /** Prepares connections. */
+        void prepareConnections();
+        /** Load settings helper. */
+        void loadSettings();
 
-    /** Prepares widgets. */
-    void prepareWidgets();
+        /** Save settings helper. */
+        void saveSettings();
+        /** Cleanups VM Log-Viewer. */
+        void cleanup();
+    /** @} */
 
-    /** Prepares connections. */
-    void prepareConnections();
+    /** @name Event handling stuff.
+      * @{ */
+        /** Handles translation event. */
+        void retranslateUi();
 
-    /** Cleanups VM Log-Viewer. */
-    void cleanup();
-
-    /** Handles translation event. */
-    void retranslateUi();
-
-    /** Handles Qt show @a pEvent. */
-    void showEvent(QShowEvent *pEvent);
-
-    /** Handles Qt key-press @a pEvent. */
-    void keyPressEvent(QKeyEvent *pEvent);
+        /** Handles Qt show @a pEvent. */
+        void showEvent(QShowEvent *pEvent);
+        /** Handles Qt key-press @a pEvent. */
+        void keyPressEvent(QKeyEvent *pEvent);
+    /** @} */
 
     /** Returns the current log-page. */
@@ -111,10 +118,4 @@
     /** Returns the content of current log-page. */
     const QString& currentLog();
-
-    /** Load settings helper. */
-    void loadSettings();
-
-    /** Save settings helper. */
-    void saveSettings();
 
     /** Holds the list of all VM Log Viewers. */
@@ -142,5 +143,5 @@
     VMLogMap m_logMap;
 
-    /** Current dialog geometry. */
+    /** Holds the current dialog geometry. */
     QRect m_geometry;
 
