Minor tweaks

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2021-03-04 15:45:10 +08:00
parent 310b44b8c4
commit eeba7d854f
4 changed files with 13 additions and 7 deletions

View File

@ -1,6 +1,6 @@
TARGET = Quick
TEMPLATE = app
QT += quick
QT += quick quickcontrols2
HEADERS += ../../framelessquickhelper.h
SOURCES += ../../framelessquickhelper.cpp main.cpp
RESOURCES += qml.qrc

View File

@ -25,6 +25,7 @@
#include "../../framelessquickhelper.h"
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickStyle>
int main(int argc, char *argv[])
{
@ -52,6 +53,12 @@ int main(int argc, char *argv[])
QGuiApplication application(argc, argv);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QQuickStyle::setStyle(QString::fromUtf8("Basic"));
#else
QQuickStyle::setStyle(QString::fromUtf8("Default"));
#endif
QQmlApplicationEngine engine;
qmlRegisterType<FramelessQuickHelper>("wangwenx190.Utils", 1, 0, "FramelessHelper");
const QUrl mainQmlUrl(QString::fromUtf8("qrc:///qml/main.qml"));

View File

@ -172,6 +172,6 @@ Window {
Component.onCompleted: {
framelessHelper.setWindowFrameVisible(framelessHelper.canHaveWindowFrame)
framelessHelper.removeWindowFrame(true)
framelessHelper.removeWindowFrame()
}
}

View File

@ -780,10 +780,7 @@ void triggerFrameChange(const QWindow *window)
void updateFrameMargins(const QWindow *window, bool reset)
{
Q_ASSERT(window);
MARGINS margins = {0, 0, 0, 0};
if (!reset) {
margins.cyTopHeight = 1;
}
const MARGINS margins = reset ? MARGINS{0, 0, 0, 0} : MARGINS{1, 1, 1, 1};
WNEF_EXECUTE_WINAPI(DwmExtendFrameIntoClientArea,
reinterpret_cast<HWND>(window->winId()),
&margins)
@ -824,13 +821,15 @@ void installHelper(QWindow *window, const bool enable)
window, WinNativeEventFilter::SystemMetric::TitleBarHeight, true, true)
: 0;
const QMargins margins = {0, -tbh, 0, 0};
const QVariant marginsVar = QVariant::fromValue(margins);
window->setProperty("_q_windowsCustomMargins", marginsVar);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QPlatformWindow *platformWindow = window->handle();
if (platformWindow) {
QGuiApplication::platformNativeInterface()->setWindowProperty(platformWindow,
QString::fromUtf8(
"WindowsCustomMargins"),
QVariant::fromValue(margins));
marginsVar);
}
#else
auto *platformWindow = dynamic_cast<QNativeInterface::Private::QWindowsWindow *>(