forked from github_mirror/framelesshelper
UNIX helper: Use QSize instead of QRect
We only need the size, not the geometry. Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
0bb929bd95
commit
48ff3280b1
|
@ -100,9 +100,9 @@ void FramelessHelper::moveWindowToDesktopCenter(QObject *const obj) {
|
||||||
if (obj->isWindowType()) {
|
if (obj->isWindowType()) {
|
||||||
const auto window = qobject_cast<QWindow *>(obj);
|
const auto window = qobject_cast<QWindow *>(obj);
|
||||||
if (window) {
|
if (window) {
|
||||||
const QRect sg = window->screen()->geometry();
|
const QSize ss = window->screen()->size();
|
||||||
const int sw = sg.width();
|
const int sw = ss.width();
|
||||||
const int sh = sg.height();
|
const int sh = ss.height();
|
||||||
const int ww = window->width();
|
const int ww = window->width();
|
||||||
const int wh = window->height();
|
const int wh = window->height();
|
||||||
window->setX(qRound(static_cast<qreal>(sw - ww) / 2.0));
|
window->setX(qRound(static_cast<qreal>(sw - ww) / 2.0));
|
||||||
|
@ -113,9 +113,9 @@ void FramelessHelper::moveWindowToDesktopCenter(QObject *const obj) {
|
||||||
else if (obj->isWidgetType()) {
|
else if (obj->isWidgetType()) {
|
||||||
const auto widget = qobject_cast<QWidget *>(obj);
|
const auto widget = qobject_cast<QWidget *>(obj);
|
||||||
if (widget && widget->isTopLevel()) {
|
if (widget && widget->isTopLevel()) {
|
||||||
const QRect sg = widget->screen()->geometry();
|
const QSize ss = widget->screen()->size();
|
||||||
const int sw = sg.width();
|
const int sw = ss.width();
|
||||||
const int sh = sg.height();
|
const int sh = ss.height();
|
||||||
const int ww = widget->width();
|
const int ww = widget->width();
|
||||||
const int wh = widget->height();
|
const int wh = widget->height();
|
||||||
widget->move(qRound(static_cast<qreal>(sw - ww) / 2.0),
|
widget->move(qRound(static_cast<qreal>(sw - ww) / 2.0),
|
||||||
|
|
Loading…
Reference in New Issue