diff --git a/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView.h b/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView.h index 1667f70..92c8e40 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView.h +++ b/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView.h @@ -25,33 +25,12 @@ public slots: void setIsMax(bool isMax); void setTitleItem(QQuickItem* item); - //设置圆角 - void setCornerRadius(int radius) - { - QRect rect(QPoint(), this->geometry().size()); - QRect circleRect(0, 0, radius * 2, radius * 2); - - QRegion region(circleRect, QRegion::Ellipse); - - circleRect.moveRight(rect.right()); - region += QRegion(circleRect, QRegion::Ellipse); - - circleRect.moveBottom(rect.bottom()); - region += QRegion(circleRect, QRegion::Ellipse); - - circleRect.moveLeft(rect.left()); - region += QRegion(circleRect, QRegion::Ellipse); - - region += QRegion(rect.adjusted(radius, 0, -radius, 0), QRegion::Rectangle); - region += QRegion(rect.adjusted(0, radius, 0, -radius), QRegion::Rectangle); - - this->setMask(region); - } signals: void isMaxChanged(bool isMax); void mousePressed(int xPos, int yPos, int button); protected: + void resizeEvent(QResizeEvent *e) override; # if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override; # else diff --git a/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_unix.cpp b/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_unix.cpp index 7db7c9e..8eae7e7 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_unix.cpp +++ b/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_unix.cpp @@ -78,3 +78,7 @@ bool TaoFrameLessView::nativeEvent(const QByteArray &eventType, void *message, l return Super::nativeEvent(eventType, message, result); } +void TaoFrameLessView::resizeEvent(QResizeEvent *e) +{ + Super::resizeEvent(e); +} diff --git a/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_win.cpp b/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_win.cpp index 8e6c17d..534a9c8 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_win.cpp +++ b/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_win.cpp @@ -12,6 +12,7 @@ #include #pragma comment(lib, "Dwmapi.lib") // Adds missing library, fixes error LNK2019: unresolved #pragma comment(lib, "User32.lib") +#pragma comment(lib, "Gdi32.lib") // we cannot just use WS_POPUP style // WS_THICKFRAME: without this the window cannot be resized and so aero snap, de-maximizing and minimizing won't work // WS_SYSMENU: enables the context menu with the move, close, maximize, minize... commands (shift + right-click on the task bar item) @@ -111,7 +112,7 @@ TaoFrameLessView::TaoFrameLessView(QWindow *parent) : QQuickView(parent), d(new setFlags(Qt::CustomizeWindowHint | Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint); setResizeMode(SizeRootObjectToView); - // d->setBorderLess((HWND)(winId()), d->borderless); + d->setBorderLess((HWND)(winId()), d->borderless); d->setBorderLessShadow((HWND)(winId()), d->borderless_shadow); setIsMax(isMaxWin(this)); @@ -170,6 +171,13 @@ void TaoFrameLessView::setIsMax(bool isMax) emit isMaxChanged(d->m_isMax); } +void TaoFrameLessView::resizeEvent(QResizeEvent *e) +{ + SetWindowRgn(HWND(winId()), + CreateRoundRectRgn(0, 0, width(), height(), 4, 4), + true); + Super::resizeEvent(e); +} #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -242,7 +250,7 @@ bool TaoFrameLessView::nativeEvent(const QByteArray &eventType, void *message, l } if (d->m_titleItem) { - auto titlePos = d->m_titleItem->mapToGlobal(d->m_titleItem->position()); + auto titlePos = d->m_titleItem->mapToGlobal({0, 0}); titlePos = mapFromGlobal(titlePos.toPoint()); auto titleRect = QRect(titlePos.x(), titlePos.y(), d->m_titleItem->width(), d->m_titleItem->height()); double dpr = qApp->devicePixelRatio(); diff --git a/examples/TaoQuickShow/Src/main.cpp b/examples/TaoQuickShow/Src/main.cpp index ece301a..363dc9f 100644 --- a/examples/TaoQuickShow/Src/main.cpp +++ b/examples/TaoQuickShow/Src/main.cpp @@ -50,7 +50,6 @@ int main(int argc, char **argv) view.setMinimumSize({ 800, 600 }); view.resize(1440, 960); view.moveToScreenCenter(); - view.setCornerRadius(5); trans.beforeUiReady(view.rootContext(), transDir); appInfo.beforeUiReady(view.rootContext());