forked from github_mirror/framelesshelper
Add a few more functions to the quick helper.
Maybe useful. Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
8ec1cfcf35
commit
e401db219d
|
@ -28,6 +28,7 @@
|
|||
#include "winnativeeventfilter.h"
|
||||
#endif
|
||||
#include <QQuickWindow>
|
||||
#include <QScreen>
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
namespace {
|
||||
|
@ -309,7 +310,40 @@ void FramelessQuickHelper::removeWindowFrame(const bool center) {
|
|||
}
|
||||
}
|
||||
|
||||
void FramelessQuickHelper::moveWindowToDesktopCenter() {
|
||||
QSize FramelessQuickHelper::desktopSize() const {
|
||||
const auto win = window();
|
||||
if (win) {
|
||||
const auto screen = win->screen();
|
||||
if (screen) {
|
||||
return screen->size();
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
QRect FramelessQuickHelper::desktopAvailableGeometry() const {
|
||||
const auto win = window();
|
||||
if (win) {
|
||||
const auto screen = win->screen();
|
||||
if (screen) {
|
||||
return screen->availableGeometry();
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
QSize FramelessQuickHelper::desktopAvailableSize() const {
|
||||
const auto win = window();
|
||||
if (win) {
|
||||
const auto screen = win->screen();
|
||||
if (screen) {
|
||||
return screen->availableSize();
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void FramelessQuickHelper::moveWindowToDesktopCenter(const bool realCenter) {
|
||||
const auto win = window();
|
||||
if (win) {
|
||||
#ifdef Q_OS_WINDOWS
|
||||
|
@ -320,6 +354,11 @@ void FramelessQuickHelper::moveWindowToDesktopCenter() {
|
|||
#else
|
||||
FramelessHelper::moveWindowToDesktopCenter(win);
|
||||
#endif
|
||||
if (!realCenter) {
|
||||
const auto dag = desktopAvailableGeometry();
|
||||
win->setX(win->x() + dag.x());
|
||||
win->setY(win->y() + dag.y());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,10 @@ public:
|
|||
|
||||
public Q_SLOTS:
|
||||
void removeWindowFrame(const bool center = true);
|
||||
void moveWindowToDesktopCenter();
|
||||
void moveWindowToDesktopCenter(const bool realCenter = true);
|
||||
QSize desktopSize() const;
|
||||
QRect desktopAvailableGeometry() const;
|
||||
QSize desktopAvailableSize() const;
|
||||
|
||||
void setIgnoreAreas(const QVector<QRect> &val);
|
||||
void clearIgnoreAreas();
|
||||
|
|
Loading…
Reference in New Issue