mirror of
https://github.com/jaredtao/TaoQuick.git
synced 2025-02-06 21:48:24 +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 setIsMax(bool isMax);
|
||||||
void setTitleItem(QQuickItem* item);
|
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:
|
signals:
|
||||||
void isMaxChanged(bool isMax);
|
void isMaxChanged(bool isMax);
|
||||||
void mousePressed(int xPos, int yPos, int button);
|
void mousePressed(int xPos, int yPos, int button);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
|
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
|
||||||
# else
|
# else
|
||||||
|
@ -78,3 +78,7 @@ bool TaoFrameLessView::nativeEvent(const QByteArray &eventType, void *message, l
|
|||||||
return Super::nativeEvent(eventType, message, result);
|
return Super::nativeEvent(eventType, message, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TaoFrameLessView::resizeEvent(QResizeEvent *e)
|
||||||
|
{
|
||||||
|
Super::resizeEvent(e);
|
||||||
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
#pragma comment(lib, "Dwmapi.lib") // Adds missing library, fixes error LNK2019: unresolved
|
#pragma comment(lib, "Dwmapi.lib") // Adds missing library, fixes error LNK2019: unresolved
|
||||||
#pragma comment(lib, "User32.lib")
|
#pragma comment(lib, "User32.lib")
|
||||||
|
#pragma comment(lib, "Gdi32.lib")
|
||||||
// we cannot just use WS_POPUP style
|
// 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_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)
|
// 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);
|
setFlags(Qt::CustomizeWindowHint | Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
|
||||||
setResizeMode(SizeRootObjectToView);
|
setResizeMode(SizeRootObjectToView);
|
||||||
|
|
||||||
// d->setBorderLess((HWND)(winId()), d->borderless);
|
d->setBorderLess((HWND)(winId()), d->borderless);
|
||||||
d->setBorderLessShadow((HWND)(winId()), d->borderless_shadow);
|
d->setBorderLessShadow((HWND)(winId()), d->borderless_shadow);
|
||||||
|
|
||||||
setIsMax(isMaxWin(this));
|
setIsMax(isMaxWin(this));
|
||||||
@ -170,6 +171,13 @@ void TaoFrameLessView::setIsMax(bool isMax)
|
|||||||
emit isMaxChanged(d->m_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)
|
#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) {
|
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());
|
titlePos = mapFromGlobal(titlePos.toPoint());
|
||||||
auto titleRect = QRect(titlePos.x(), titlePos.y(), d->m_titleItem->width(), d->m_titleItem->height());
|
auto titleRect = QRect(titlePos.x(), titlePos.y(), d->m_titleItem->width(), d->m_titleItem->height());
|
||||||
double dpr = qApp->devicePixelRatio();
|
double dpr = qApp->devicePixelRatio();
|
||||||
|
@ -50,7 +50,6 @@ int main(int argc, char **argv)
|
|||||||
view.setMinimumSize({ 800, 600 });
|
view.setMinimumSize({ 800, 600 });
|
||||||
view.resize(1440, 960);
|
view.resize(1440, 960);
|
||||||
view.moveToScreenCenter();
|
view.moveToScreenCenter();
|
||||||
view.setCornerRadius(5);
|
|
||||||
trans.beforeUiReady(view.rootContext(), transDir);
|
trans.beforeUiReady(view.rootContext(), transDir);
|
||||||
appInfo.beforeUiReady(view.rootContext());
|
appInfo.beforeUiReady(view.rootContext());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user