[vlc-commits] commit: Qt: use qt QStyle to center dialogs on screen (Jean-Baptiste Kempf )

git at videolan.org git at videolan.org
Tue Mar 9 12:41:24 CET 2010


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Mar  9 12:39:40 2010 +0100| [51d11338e28829a71445af6162cfeff3fa1c7642] | committer: Jean-Baptiste Kempf 

Qt: use qt QStyle to center dialogs on screen

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=51d11338e28829a71445af6162cfeff3fa1c7642
---

 modules/gui/qt4/util/qvlcframe.hpp |   18 ++----------------
 1 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/modules/gui/qt4/util/qvlcframe.hpp b/modules/gui/qt4/util/qvlcframe.hpp
index 39d6e55..6bb960f 100644
--- a/modules/gui/qt4/util/qvlcframe.hpp
+++ b/modules/gui/qt4/util/qvlcframe.hpp
@@ -26,14 +26,13 @@
 
 #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



More information about the vlc-commits mailing list