Index: /trunk/src/VBox/Frontends/VirtualBox4/include/QIMainDialog.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/include/QIMainDialog.h	(revision 10933)
+++ /trunk/src/VBox/Frontends/VirtualBox4/include/QIMainDialog.h	(revision 10934)
@@ -38,10 +38,10 @@
 public:
 
-    QIMainDialog (QWidget *aParent = NULL, Qt::WindowFlags aFlags = Qt::Dialog);
+    QIMainDialog (QWidget *aParent = 0, Qt::WindowFlags aFlags = Qt::Dialog);
 
     QDialog::DialogCode exec();
     QDialog::DialogCode result() const;
 
-    void setFileForProxyIcon (const QString& aFile);
+    void setFileForProxyIcon (const QString &aFile);
     QString fileForProxyIcon () const;
 
@@ -49,5 +49,5 @@
     bool isSizeGripEnabled () const;
 
-    void setDefaultButton (QPushButton* aButton);
+    void setDefaultButton (QPushButton *aButton);
     QPushButton* defaultButton () const;
 
Index: /trunk/src/VBox/Frontends/VirtualBox4/src/QIMainDialog.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/src/QIMainDialog.cpp	(revision 10933)
+++ /trunk/src/VBox/Frontends/VirtualBox4/src/QIMainDialog.cpp	(revision 10934)
@@ -38,6 +38,7 @@
 #include <QDialogButtonBox>
 
-QIMainDialog::QIMainDialog (QWidget *aParent /* = NULL */, Qt::WindowFlags aFlags /* = Qt::Dialog */)
-    : QMainWindow (aParent, aFlags) 
+QIMainDialog::QIMainDialog (QWidget *aParent /* = 0 */,
+                            Qt::WindowFlags aFlags /* = Qt::Dialog */)
+    : QMainWindow (aParent, aFlags)
     , mRescode (QDialog::Rejected)
 {
@@ -53,5 +54,5 @@
     bool deleteOnClose = testAttribute (Qt::WA_DeleteOnClose);
     setAttribute (Qt::WA_DeleteOnClose, false);
-    bool wasShowModal = testAttribute (Qt::WA_ShowModal); 
+    bool wasShowModal = testAttribute (Qt::WA_ShowModal);
     setAttribute (Qt::WA_ShowModal, true);
 
@@ -70,5 +71,5 @@
         return QDialog::Rejected;
     QDialog::DialogCode res = result();
-    /* Set the old show modal attribute */ 
+    /* Set the old show modal attribute */
     setAttribute (Qt::WA_ShowModal, wasShowModal);
     /* Delete us in the case we should do so on close */
@@ -79,7 +80,7 @@
 }
 
-QDialog::DialogCode QIMainDialog::result() const 
-{ 
-    return mRescode; 
+QDialog::DialogCode QIMainDialog::result() const
+{
+    return mRescode;
 }
 
@@ -89,5 +90,5 @@
 }
 
-QString QIMainDialog::fileForProxyIcon () const
+QString QIMainDialog::fileForProxyIcon() const
 {
     return mFileForProxyIcon;
@@ -106,5 +107,5 @@
 }
 
-bool QIMainDialog::isSizeGripEnabled () const
+bool QIMainDialog::isSizeGripEnabled() const
 {
     return mSizeGrip;
@@ -127,5 +128,5 @@
     /* Exit from the event loop if there is any and we are changing our state
      * from visible to invisible. */
-    if(mEventLoop && !aVisible)
+    if (mEventLoop && !aVisible)
         mEventLoop->exit();
 }
@@ -133,77 +134,77 @@
 bool QIMainDialog::event (QEvent *aEvent)
 {
-     switch (aEvent->type()) 
+     switch (aEvent->type())
      {
 #ifdef Q_WS_MAC
-          case QEvent::IconDrag: 
+          case QEvent::IconDrag:
+          {
+              Qt::KeyboardModifiers currentModifiers = qApp->keyboardModifiers();
+
+              if (currentModifiers == Qt::NoModifier)
               {
-                  Qt::KeyboardModifiers currentModifiers = qApp->keyboardModifiers();
-
-                  if (currentModifiers == Qt::NoModifier) 
+                  if (!mFileForProxyIcon.isEmpty())
                   {
-                      if (!mFileForProxyIcon.isEmpty())
+                      aEvent->accept();
+                      /* Create a drag object we can use */
+                      QDrag *drag = new QDrag (this);
+                      QMimeData *data = new QMimeData();
+                      /* Set the appropriate url data */
+                      data->setUrls (QList<QUrl>() << QUrl::fromLocalFile (mFileForProxyIcon));
+                      drag->setMimeData (data);
+                      /* Make a nice looking DnD icon */
+                      QFileInfo fi (mFileForProxyIcon);
+                      QPixmap cursorPixmap (::darwinCreateDragPixmap (QPixmap (windowIcon().pixmap (16, 16)), fi.fileName()));
+                      drag->setPixmap (cursorPixmap);
+                      drag->setHotSpot (QPoint (5, cursorPixmap.height() - 5));
+                      /* Start the DnD action */
+                      drag->start (Qt::LinkAction | Qt::CopyAction);
+                      return true;
+                  }
+              }
+#if QT_VERSION < 0x040400
+              else if (currentModifiers == Qt::ShiftModifier)
+#else
+              else if (currentModifiers == Qt::ControlModifier)
+#endif
+              {
+                  if (!mFileForProxyIcon.isEmpty())
+                  {
+                      aEvent->accept();
+                      /* Create the proxy icon menu */
+                      QMenu menu (this);
+                      connect (&menu, SIGNAL (triggered (QAction*)),
+                               this, SLOT (openAction (QAction*)));
+                      /* Add the file with the disk icon to the menu */
+                      QFileInfo fi (mFileForProxyIcon);
+                      QAction *action = menu.addAction (fi.fileName());
+                      action->setIcon (windowIcon());
+                      /* Create some nice looking menu out of the other
+                       * directory parts. */
+                      QFileIconProvider fip;
+                      QDir dir (fi.absolutePath());
+                      do
                       {
-                          aEvent->accept();
-                          /* Create a drag object we can use */
-                          QDrag *drag = new QDrag (this);
-                          QMimeData *data = new QMimeData();
-                          /* Set the appropriate url data */
-                          data->setUrls(QList<QUrl>() << QUrl::fromLocalFile (mFileForProxyIcon));
-                          drag->setMimeData (data);
-                          /* Make a nice looking DnD icon */
-                          QFileInfo fi (mFileForProxyIcon);
-                          QPixmap cursorPixmap (::darwinCreateDragPixmap (QPixmap (windowIcon().pixmap (16, 16)), fi.fileName()));
-                          drag->setPixmap (cursorPixmap);
-                          drag->setHotSpot (QPoint (5, cursorPixmap.height() - 5));
-                          /* Start the DnD action */
-                          drag->start (Qt::LinkAction | Qt::CopyAction);
-                          return true;
+                          if (dir.isRoot())
+                              action = menu.addAction ("/");
+                          else
+                              action = menu.addAction (dir.dirName());
+                          action->setIcon (fip.icon (QFileInfo (dir, "")));
                       }
+                      while (dir.cdUp());
+                      /* Show the menu */
+                      menu.exec (QPoint (QCursor::pos().x() - 20, frameGeometry().y() - 5));
+                      return true;
                   }
-#if QT_VERSION < 0x040400
-                  else if (currentModifiers == Qt::ShiftModifier) 
-#else
-                  else if (currentModifiers == Qt::ControlModifier) 
-#endif
-                  {
-                      if (!mFileForProxyIcon.isEmpty())
-                      {
-                          aEvent->accept();
-                          /* Create the proxy icon menu */
-                          QMenu menu(this);
-                          connect(&menu, SIGNAL (triggered (QAction *)), 
-                                  this, SLOT (openAction (QAction *)));
-                          /* Add the file with the disk icon to the menu */
-                          QFileInfo fi (mFileForProxyIcon);
-                          QAction *action = menu.addAction (fi.fileName());
-                          action->setIcon (windowIcon());
-                          /* Create some nice looking menu out of the other
-                           * directory parts. */
-                          QFileIconProvider fip;
-                          QDir dir (fi.absolutePath());
-                          do
-                          {
-                              if (dir.isRoot())
-                                  action = menu.addAction ("/");
-                              else
-                                  action = menu.addAction (dir.dirName());
-                              action->setIcon (fip.icon (QFileInfo (dir, "")));
-                          }
-                          while (dir.cdUp());
-                          /* Show the menu */
-                          menu.exec (QPoint (QCursor::pos().x() - 20, frameGeometry().y() - 5));
-                          return true;
-                      }
-                  }
-                  break;
               }
+              break;
+          }
 #endif /* Q_WS_MAC */
-          case QEvent::Polish: 
-              {
-                  /* Initially search for the default button. */
-                  mDefaultButton = searchDefaultButton();
-                  break;
-              }
-          default: 
+          case QEvent::Polish:
+          {
+              /* Initially search for the default button. */
+              mDefaultButton = searchDefaultButton();
+              break;
+          }
+          default:
               break;
      }
@@ -216,5 +217,5 @@
 
     /* Adjust the size-grip location for the current resize event */
-    if (mSizeGrip) 
+    if (mSizeGrip)
     {
         if (isRightToLeft())
@@ -231,4 +232,8 @@
         return QMainWindow::eventFilter (aObject, aEvent);
 
+    if (qobject_cast<QWidget*> (aObject) &&
+        qobject_cast<QWidget*> (aObject)->window() != this)
+        return QMainWindow::eventFilter (aObject, aEvent);
+
     switch (aEvent->type())
     {
@@ -236,72 +241,71 @@
          * button property into the currently focused button. */
         case QEvent::FocusIn:
+        {
+            if (qobject_cast<QPushButton*> (aObject) &&
+                (aObject->parent() == centralWidget() ||
+                 qobject_cast<QDialogButtonBox*> (aObject->parent())))
             {
-                if (qobject_cast<QPushButton*> (aObject) &&
-                    (aObject->parent() == centralWidget() ||
-                     qobject_cast<QDialogButtonBox*> (aObject->parent()) != NULL))
-                {
-                    qobject_cast<QPushButton*> (aObject)->setDefault (aObject != mDefaultButton);
-                    if (mDefaultButton)
-                        mDefaultButton->setDefault (aObject == mDefaultButton);
-                }                                    
-                break;
+                qobject_cast<QPushButton*> (aObject)->setDefault (aObject != mDefaultButton);
+                if (mDefaultButton)
+                    mDefaultButton->setDefault (aObject == mDefaultButton);
             }
+            break;
+        }
         /* Auto-default button focus-out processor used to remove the "default"
          * button property from the previously focused button. */
         case QEvent::FocusOut:
+        {
+            if (qobject_cast<QPushButton*> (aObject) &&
+                (aObject->parent() == centralWidget() ||
+                 qobject_cast<QDialogButtonBox*> (aObject->parent())))
             {
-                if (qobject_cast<QPushButton*> (aObject) && 
-                    (aObject->parent() == centralWidget() ||
-                     qobject_cast<QDialogButtonBox*> (aObject->parent()) != NULL))
+                if (mDefaultButton)
+                    mDefaultButton->setDefault (aObject != mDefaultButton);
+                qobject_cast<QPushButton*> (aObject)->setDefault (aObject == mDefaultButton);
+            }
+            break;
+        }
+        case QEvent::KeyPress:
+        {
+            /* Make sure that we only proceed if no
+             * popup or other modal widgets are open. */
+            if (qApp->activePopupWidget() ||
+                (qApp->activeModalWidget() && qApp->activeModalWidget() != this))
+                break;
+
+            QKeyEvent *event = static_cast<QKeyEvent*> (aEvent);
+#ifdef Q_WS_MAC
+            if (event->modifiers() == Qt::ControlModifier &&
+                event->key() == Qt::Key_Period)
+                reject();
+            else
+#endif
+                if (event->modifiers() == Qt::NoModifier ||
+                    (event->modifiers() & Qt::KeypadModifier && event->key() == Qt::Key_Enter))
                 {
-                    if (mDefaultButton)
-                        mDefaultButton->setDefault (aObject != mDefaultButton);
-                    qobject_cast<QPushButton*> (aObject)->setDefault (aObject == mDefaultButton);
-                }                     
-                break;
-            }
-        case QEvent::KeyPress:
-            {
-                /* Make sure that we only proceed if no
-                 * popup or other modal widgets are open. */
-                if (aObject != this ||
-                    qApp->activePopupWidget() != NULL ||
-                    !(qApp->activeModalWidget() == this || 
-                      qApp->activeModalWidget() == NULL))
-                    break;
-                QKeyEvent *event = static_cast<QKeyEvent*> (aEvent);
-#ifdef Q_WS_MAC
-                if (event->modifiers() == Qt::ControlModifier && 
-                    event->key() == Qt::Key_Period)
-                    reject();
-                else
-#endif
-                    if (event->modifiers() == Qt::NoModifier ||
-                        (event->modifiers() & Qt::KeypadModifier && event->key() == Qt::Key_Enter))
+                    switch (event->key())
                     {
-                        switch (event->key())
+                        case Qt::Key_Enter:
+                        case Qt::Key_Return:
                         {
-                            case Qt::Key_Enter:
-                            case Qt::Key_Return:
-                                {
-                                    QPushButton *currentDefault = searchDefaultButton();
-                                    if (currentDefault)
-                                    {
-                                        /* We handle this, so return true after
-                                         * that. */
-                                        currentDefault->animateClick();
-                                        return true;
-                                    }
-                                    break;
-                                }
-                            case Qt::Key_Escape:
-                                {
-                                    reject();
-                                    return true;
-                                    break;
-                                }
+                            QPushButton *currentDefault = searchDefaultButton();
+                            if (currentDefault)
+                            {
+                                /* We handle this, so return true after
+                                 * that. */
+                                currentDefault->animateClick();
+                                return true;
+                            }
+                            break;
+                        }
+                        case Qt::Key_Escape:
+                        {
+                            reject();
+                            return true;
+                            break;
                         }
                     }
-            }
+                }
+        }
         default:
             break;
@@ -313,10 +317,10 @@
 {
     /* Search for the first default button in the dialog. */
-    QPushButton *button = NULL;
+    QPushButton *button = 0;
     QList<QPushButton*> list = qFindChildren<QPushButton*> (this);
     foreach (button, list)
-        if(button->isDefault() &&
-           (button->parent() == centralWidget() ||
-            qobject_cast<QDialogButtonBox*> (button->parent()) != NULL))
+        if (button->isDefault() &&
+            (button->parent() == centralWidget() ||
+             qobject_cast<QDialogButtonBox*> (button->parent())))
             break;
     return button;
@@ -324,12 +328,12 @@
 
 
-void QIMainDialog::accept() 
-{ 
-    done (QDialog::Accepted); 
-}
-
-void QIMainDialog::reject() 
-{ 
-    done (QDialog::Rejected); 
+void QIMainDialog::accept()
+{
+    done (QDialog::Accepted);
+}
+
+void QIMainDialog::reject()
+{
+    done (QDialog::Rejected);
 }
 
@@ -344,7 +348,7 @@
 }
 
-void QIMainDialog::setResult (QDialog::DialogCode aRescode) 
-{ 
-    mRescode = aRescode; 
+void QIMainDialog::setResult (QDialog::DialogCode aRescode)
+{
+    mRescode = aRescode;
 }
 
