mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07: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:
parent
6a6077bf1d
commit
44f6c972d4
5 changed files with 21 additions and 36 deletions
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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue