|
|
@ -219,21 +219,15 @@ void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
#ifndef DISABLE_GUI |
|
|
|
// Get screen center
|
|
|
|
QPoint Utils::Misc::screenCenter(const QWidget *w) |
|
|
|
QPoint Utils::Misc::screenCenter(QWidget *win) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
int scrn = 0; |
|
|
|
// Returns the QPoint which the widget will be placed center on screen (where parent resides)
|
|
|
|
const QWidget *w = win->window(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (w) |
|
|
|
QWidget *parent = w->parentWidget(); |
|
|
|
scrn = QApplication::desktop()->screenNumber(w); |
|
|
|
QDesktopWidget *desktop = QApplication::desktop(); |
|
|
|
else if (QApplication::desktop()->isVirtualDesktop()) |
|
|
|
int scrn = desktop->screenNumber(parent); // fallback to `primaryScreen` when parent is invalid
|
|
|
|
scrn = QApplication::desktop()->screenNumber(QCursor::pos()); |
|
|
|
QRect r = desktop->availableGeometry(scrn); |
|
|
|
else |
|
|
|
return QPoint(r.x() + (r.width() - w->frameSize().width()) / 2, r.y() + (r.height() - w->frameSize().height()) / 2); |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|