Add moveWindowToDesktopCenter to the quick helper.

It may be useful for Qt Quick users.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2020-05-13 21:24:51 +08:00
parent aa146d1893
commit d8e07b86c4
2 changed files with 18 additions and 3 deletions

View File

@ -263,13 +263,27 @@ void FramelessQuickHelper::removeWindowFrame(const bool center) {
#ifdef Q_OS_WINDOWS #ifdef Q_OS_WINDOWS
const auto hWnd = reinterpret_cast<HWND>(win->winId()); const auto hWnd = reinterpret_cast<HWND>(win->winId());
if (hWnd) { if (hWnd) {
WinNativeEventFilter::addFramelessWindow(hWnd, nullptr, center); WinNativeEventFilter::addFramelessWindow(hWnd);
} }
#else #else
m_framelessHelper.removeWindowFrame(win); m_framelessHelper.removeWindowFrame(win);
if (center) { #endif
FramelessHelper::moveWindowToDesktopCenter(win);
} }
if (center) {
moveWindowToDesktopCenter();
}
}
void FramelessQuickHelper::moveWindowToDesktopCenter() {
const auto win = window();
if (win) {
#ifdef Q_OS_WINDOWS
const auto hWnd = reinterpret_cast<HWND>(win->winId());
if (hWnd) {
WinNativeEventFilter::moveWindowToDesktopCenter(hWnd);
}
#else
FramelessHelper::moveWindowToDesktopCenter(win);
#endif #endif
} }
} }

View File

@ -86,6 +86,7 @@ public:
public Q_SLOTS: public Q_SLOTS:
void removeWindowFrame(const bool center = true); void removeWindowFrame(const bool center = true);
void moveWindowToDesktopCenter();
void setIgnoreAreas(const QVector<QRect> &val); void setIgnoreAreas(const QVector<QRect> &val);
void clearIgnoreAreas(); void clearIgnoreAreas();