Moved screenCenter function to misc.h to avoid code duplication

Make sure torrent deletion dialog is now centered on screen
This commit is contained in:
Christophe Dumez 2010-01-21 22:23:13 +00:00
parent 6a6077bf1d
commit 44f6c972d4
5 changed files with 21 additions and 36 deletions

View file

@ -44,6 +44,7 @@
#include <QUrl>
#include <ctime>
#include <QDateTime>
#include <QDesktopWidget>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/date_time/posix_time/conversion.hpp>
@ -265,6 +266,22 @@ public:
#endif
}
// Get screen center
static QPoint screenCenter(QWidget *win) {
int scrn = 0;
QWidget *w = win->window();
if(w)
scrn = QApplication::desktop()->screenNumber(w);
else if(QApplication::desktop()->isVirtualDesktop())
scrn = QApplication::desktop()->screenNumber(QCursor::pos());
else
scrn = QApplication::desktop()->screenNumber(win);
QRect desk(QApplication::desktop()->availableGeometry(scrn));
return QPoint((desk.width() - win->frameGeometry().width()) / 2, (desk.height() - win->frameGeometry().height()) / 2);
}
static QString searchEngineLocation() {
QString location = QDir::cleanPath(QDesktopServicesDataLocation()
+ QDir::separator() + "search_engine");