]> git.sesse.net Git - vlc/commitdiff
Qt: use qt QStyle to center dialogs on screen
authorJean-Baptiste Kempf <jb@videolan.org>
Tue, 9 Mar 2010 11:39:40 +0000 (12:39 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Tue, 9 Mar 2010 11:40:38 +0000 (12:40 +0100)
modules/gui/qt4/util/qvlcframe.hpp

index 39d6e55207be700c51d1a6b9938cae0d33b31d37..6bb960fccce5f7ffb98a734aca0c72b57bc90f3d 100644 (file)
 
 #include <QWidget>
 #include <QDialog>
-#include <QSpacerItem>
 #include <QHBoxLayout>
 #include <QApplication>
 #include <QMainWindow>
-#include <QPushButton>
 #include <QKeyEvent>
 #include <QDesktopWidget>
 #include <QSettings>
+#include <QStyle>
 
 #include "qt4.hpp"
 
@@ -76,7 +75,7 @@ class QVLCTools
             widget->resize(defSize);
 
             if(defPos.x() == 0 && defPos.y()==0)
-               centerWidgetOnScreen(widget);
+               widget->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, widget->size(), qApp->desktop()->availableGeometry()));
             return true;
           }
           return false;
@@ -97,19 +96,6 @@ class QVLCTools
 
          return defaultUsed;
        }
-
-      /*
-        call this method for a window or dialog to show it centred on
-        current screen
-      */
-      static void centerWidgetOnScreen(QWidget *widget)
-      {
-         QDesktopWidget * const desktop = QApplication::desktop();
-         QRect screenRect = desktop->availableGeometry(widget);
-         QPoint p1 = widget->frameGeometry().center();
-
-         widget->move ( screenRect.center() - p1 );
-      }
 };
 
 class QVLCFrame : public QWidget