forked from github_mirror/framelesshelper
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:
parent
aa146d1893
commit
d8e07b86c4
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue