mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 15:37:26 -06:00
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:
17
src/misc.h
17
src/misc.h
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user