mirror of
https://github.com/jaredtao/TaoQuick.git
synced 2025-01-31 21:22:58 +08:00
Merge branch 'master' of https://gitee.com/jaredtao/TaoQuick
This commit is contained in:
commit
c3032b2ec0
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <windowsx.h>
|
||||
#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();
|
||||
|
@ -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());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user