Commit 51d11338 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: use qt QStyle to center dialogs on screen

parent 91392b25
...@@ -26,14 +26,13 @@ ...@@ -26,14 +26,13 @@
#include <QWidget> #include <QWidget>
#include <QDialog> #include <QDialog>
#include <QSpacerItem>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QApplication> #include <QApplication>
#include <QMainWindow> #include <QMainWindow>
#include <QPushButton>
#include <QKeyEvent> #include <QKeyEvent>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QSettings> #include <QSettings>
#include <QStyle>
#include "qt4.hpp" #include "qt4.hpp"
...@@ -76,7 +75,7 @@ class QVLCTools ...@@ -76,7 +75,7 @@ class QVLCTools
widget->resize(defSize); widget->resize(defSize);
if(defPos.x() == 0 && defPos.y()==0) 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 true;
} }
return false; return false;
...@@ -97,19 +96,6 @@ class QVLCTools ...@@ -97,19 +96,6 @@ class QVLCTools
return defaultUsed; 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 class QVLCFrame : public QWidget
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment