forked from github_mirror/framelesshelper
misc: minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
537b65e592
commit
079c8ff6b6
|
@ -87,7 +87,9 @@ find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets)
|
|||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Quick)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Quick)
|
||||
|
||||
add_subdirectory(src)
|
||||
if(TARGET Qt${QT_VERSION_MAJOR}::Core AND TARGET Qt${QT_VERSION_MAJOR}::Gui)
|
||||
add_subdirectory(src)
|
||||
endif()
|
||||
|
||||
if(FRAMELESSHELPER_BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
|
|
|
@ -42,7 +42,6 @@ FRAMELESSHELPER_CORE_API void startSystemResize(QWindow *window, const Qt::Edges
|
|||
getSystemButtonIconResource(const Global::SystemButtonType button,
|
||||
const Global::SystemTheme theme,
|
||||
const Global::ResourceType type);
|
||||
FRAMELESSHELPER_CORE_API void sendMouseReleaseEvent();
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QWindow *findWindow(const WId windowId);
|
||||
FRAMELESSHELPER_CORE_API void moveWindowToDesktopCenter(
|
||||
const Global::GetWindowScreenCallback &getWindowScreen,
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
SOFTWARE.
|
||||
]]
|
||||
|
||||
add_subdirectory(core)
|
||||
if(TARGET Qt${QT_VERSION_MAJOR}::Core AND TARGET Qt${QT_VERSION_MAJOR}::Gui)
|
||||
add_subdirectory(core)
|
||||
endif()
|
||||
|
||||
if(FRAMELESSHELPER_BUILD_WIDGETS AND TARGET Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
add_subdirectory(widgets)
|
||||
|
|
|
@ -395,17 +395,4 @@ void Utils::startSystemResize(QWindow *window, const Qt::Edges edges)
|
|||
#endif
|
||||
}
|
||||
|
||||
void Utils::sendMouseReleaseEvent()
|
||||
{
|
||||
const QWindow * const window = QGuiApplication::focusWindow();
|
||||
Q_ASSERT(window);
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
const qreal dpr = window->devicePixelRatio();
|
||||
const QPoint globalPos = QPointF(QPointF(QCursor::pos(window->screen())) * dpr).toPoint();
|
||||
const QPoint localPos = QPointF(QPointF(window->mapFromGlobal(globalPos)) * dpr).toPoint();
|
||||
x11_emulateButtonRelease(window->winId(), globalPos, localPos);
|
||||
}
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -995,7 +995,10 @@ void Utils::startSystemMove(QWindow *window)
|
|||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||
window->startSystemMove();
|
||||
#else
|
||||
sendMouseReleaseEvent();
|
||||
if (ReleaseCapture() == FALSE) {
|
||||
qWarning() << getSystemErrorMessage(kReleaseCapture);
|
||||
return;
|
||||
}
|
||||
const auto hwnd = reinterpret_cast<HWND>(window->winId());
|
||||
if (PostMessageW(hwnd, WM_SYSCOMMAND, 0xF012 /*SC_DRAGMOVE*/, 0) == FALSE) {
|
||||
qWarning() << getSystemErrorMessage(kPostMessageW);
|
||||
|
@ -1015,7 +1018,10 @@ void Utils::startSystemResize(QWindow *window, const Qt::Edges edges)
|
|||
if (edges == Qt::Edges{}) {
|
||||
return;
|
||||
}
|
||||
sendMouseReleaseEvent();
|
||||
if (ReleaseCapture() == FALSE) {
|
||||
qWarning() << getSystemErrorMessage(kReleaseCapture);
|
||||
return;
|
||||
}
|
||||
const auto hwnd = reinterpret_cast<HWND>(window->winId());
|
||||
if (PostMessageW(hwnd, WM_SYSCOMMAND, qtEdgesToWin32Orientation(edges), 0) == FALSE) {
|
||||
qWarning() << getSystemErrorMessage(kPostMessageW);
|
||||
|
@ -1126,13 +1132,6 @@ void Utils::uninstallSystemMenuHook(const WId windowId)
|
|||
g_utilsHelper()->data.remove(windowId);
|
||||
}
|
||||
|
||||
void Utils::sendMouseReleaseEvent()
|
||||
{
|
||||
if (ReleaseCapture() == FALSE) {
|
||||
qWarning() << getSystemErrorMessage(kReleaseCapture);
|
||||
}
|
||||
}
|
||||
|
||||
void Utils::tryToBeCompatibleWithQtFramelessWindowHint(const WId windowId,
|
||||
const GetWindowFlagsCallback &getWindowFlags,
|
||||
const SetWindowFlagsCallback &setWindowFlags,
|
||||
|
|
|
@ -69,6 +69,7 @@ void FramelessHelper::Quick::registerTypes(QQmlEngine *engine)
|
|||
});
|
||||
qmlRegisterAnonymousType2(QWindow, QUICK_URI_SHORT);
|
||||
qmlRegisterAnonymousType2(QQuickWindow, QUICK_URI_SHORT);
|
||||
qmlRegisterAnonymousType2(QQuickItem, QUICK_URI_SHORT);
|
||||
qmlRegisterType<FramelessQuickWindow>(QUICK_URI_EXPAND("FramelessWindow"));
|
||||
qmlRegisterType<QuickStandardMinimizeButton>(QUICK_URI_EXPAND("StandardMinimizeButton"));
|
||||
qmlRegisterType<QuickStandardMaximizeButton>(QUICK_URI_EXPAND("StandardMaximizeButton"));
|
||||
|
|
|
@ -445,6 +445,9 @@ void FramelessQuickWindowPrivate::initialize()
|
|||
QQuickItem * const rootItem = q->contentItem();
|
||||
const QQuickItemPrivate * const rootItemPrivate = QQuickItemPrivate::get(rootItem);
|
||||
m_topBorderRectangle.reset(new QQuickRectangle(rootItem));
|
||||
QQuickPen * const _border = m_topBorderRectangle->border();
|
||||
_border->setWidth(0.0);
|
||||
_border->setColor(kDefaultTransparentColor);
|
||||
const bool frameBorderVisible = [this]() -> bool {
|
||||
#ifdef Q_OS_WINDOWS
|
||||
return (Utils::isWindowFrameBorderVisible() && !Utils::isWin11OrGreater()
|
||||
|
|
|
@ -99,7 +99,7 @@ void QuickStandardCloseButton::initialize()
|
|||
connect(this, &QuickStandardCloseButton::hoveredChanged, this, &QuickStandardCloseButton::updateBackground);
|
||||
connect(this, &QuickStandardCloseButton::pressedChanged, this, &QuickStandardCloseButton::updateBackground);
|
||||
|
||||
m_tooltip.reset(new QQuickToolTip(this));
|
||||
m_tooltip = qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(this));
|
||||
m_tooltip->setText(tr("Close"));
|
||||
connect(QGuiApplication::styleHints(), &QStyleHints::mousePressAndHoldIntervalChanged, this, [this](int interval){
|
||||
Q_UNUSED(interval);
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
QT_BEGIN_NAMESPACE
|
||||
class QQuickImage;
|
||||
class QQuickRectangle;
|
||||
class QQuickToolTip;
|
||||
class QQuickToolTipAttached;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
@ -59,7 +59,7 @@ private:
|
|||
QScopedPointer<QQuickItem> m_contentItem;
|
||||
QScopedPointer<QQuickImage> m_image;
|
||||
QScopedPointer<QQuickRectangle> m_backgroundItem;
|
||||
QScopedPointer<QQuickToolTip> m_tooltip;
|
||||
QPointer<QQuickToolTipAttached> m_tooltip = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -116,7 +116,7 @@ void QuickStandardMaximizeButton::initialize()
|
|||
connect(this, &QuickStandardMaximizeButton::hoveredChanged, this, &QuickStandardMaximizeButton::updateBackground);
|
||||
connect(this, &QuickStandardMaximizeButton::pressedChanged, this, &QuickStandardMaximizeButton::updateBackground);
|
||||
|
||||
m_tooltip.reset(new QQuickToolTip(this));
|
||||
m_tooltip = qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(this));
|
||||
connect(QGuiApplication::styleHints(), &QStyleHints::mousePressAndHoldIntervalChanged, this, [this](int interval){
|
||||
Q_UNUSED(interval);
|
||||
updateToolTip();
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
QT_BEGIN_NAMESPACE
|
||||
class QQuickImage;
|
||||
class QQuickRectangle;
|
||||
class QQuickToolTip;
|
||||
class QQuickToolTipAttached;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
@ -67,7 +67,7 @@ private:
|
|||
QScopedPointer<QQuickItem> m_contentItem;
|
||||
QScopedPointer<QQuickImage> m_image;
|
||||
QScopedPointer<QQuickRectangle> m_backgroundItem;
|
||||
QScopedPointer<QQuickToolTip> m_tooltip;
|
||||
QPointer<QQuickToolTipAttached> m_tooltip = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -97,7 +97,7 @@ void QuickStandardMinimizeButton::initialize()
|
|||
connect(this, &QuickStandardMinimizeButton::hoveredChanged, this, &QuickStandardMinimizeButton::updateBackground);
|
||||
connect(this, &QuickStandardMinimizeButton::pressedChanged, this, &QuickStandardMinimizeButton::updateBackground);
|
||||
|
||||
m_tooltip.reset(new QQuickToolTip(this));
|
||||
m_tooltip = qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(this));
|
||||
m_tooltip->setText(tr("Minimize"));
|
||||
connect(QGuiApplication::styleHints(), &QStyleHints::mousePressAndHoldIntervalChanged, this, [this](int interval){
|
||||
Q_UNUSED(interval);
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
QT_BEGIN_NAMESPACE
|
||||
class QQuickImage;
|
||||
class QQuickRectangle;
|
||||
class QQuickToolTip;
|
||||
class QQuickToolTipAttached;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
@ -59,7 +59,7 @@ private:
|
|||
QScopedPointer<QQuickItem> m_contentItem;
|
||||
QScopedPointer<QQuickImage> m_image;
|
||||
QScopedPointer<QQuickRectangle> m_backgroundItem;
|
||||
QScopedPointer<QQuickToolTip> m_tooltip;
|
||||
QPointer<QQuickToolTipAttached> m_tooltip = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
Loading…
Reference in New Issue