forked from github_mirror/framelesshelper
Fix build for old Qt versions.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
af65f2d9e3
commit
47910161c9
|
@ -127,7 +127,15 @@ void FramelessHelper::moveWindowToDesktopCenter(QObject *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()) {
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||||
const QSize ss = widget->screen()->size();
|
const QSize ss = widget->screen()->size();
|
||||||
|
#else
|
||||||
|
QSize ss = {};
|
||||||
|
QWindow *window = widget->windowHandle();
|
||||||
|
if (window) {
|
||||||
|
ss = window->screen()->size();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
const int sw = ss.width();
|
const int sw = ss.width();
|
||||||
const int sh = ss.height();
|
const int sh = ss.height();
|
||||||
const int ww = widget->width();
|
const int ww = widget->width();
|
||||||
|
|
|
@ -57,7 +57,12 @@ QScreen *getCurrentScreenFromWindow(QObject *window)
|
||||||
}
|
}
|
||||||
#ifdef QT_WIDGETS_LIB
|
#ifdef QT_WIDGETS_LIB
|
||||||
else if (window->isWidgetType()) {
|
else if (window->isWidgetType()) {
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||||
return qobject_cast<QWidget *>(window)->screen();
|
return qobject_cast<QWidget *>(window)->screen();
|
||||||
|
#else
|
||||||
|
QWindow *win = qobject_cast<QWidget *>(window)->windowHandle();
|
||||||
|
return win ? win->screen() : nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -1151,7 +1151,14 @@ QString getCurrentScreenIdentifier(const HWND handle)
|
||||||
#ifdef QT_WIDGETS_LIB
|
#ifdef QT_WIDGETS_LIB
|
||||||
const QWidget *widget = QWidget::find(reinterpret_cast<WId>(handle));
|
const QWidget *widget = QWidget::find(reinterpret_cast<WId>(handle));
|
||||||
if (widget && widget->isTopLevel()) {
|
if (widget && widget->isTopLevel()) {
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||||
currentScreen = widget->screen();
|
currentScreen = widget->screen();
|
||||||
|
#else
|
||||||
|
QWindow *window = widget->windowHandle();
|
||||||
|
if (window) {
|
||||||
|
currentScreen = window->screen();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!currentScreen) {
|
if (!currentScreen) {
|
||||||
|
|
Loading…
Reference in New Issue