modify can not scale bug
This commit is contained in:
parent
77e8cb3b9e
commit
d3999a80d2
@ -54,7 +54,13 @@ void FrameTitleBar::SetMainWidget(QWidget* widget) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void FrameTitleBar::OnMaximized(bool maximized) {
|
void FrameTitleBar::OnMaximized(bool maximized) {
|
||||||
ui->sys_max->setVisible(!maximized);
|
// 根据配置位决定是否显示最大/还原按钮,并切换图标
|
||||||
|
const bool hasMaxButton = (ftbButton_ & FTB_MAX) != 0;
|
||||||
|
ui->sys_max->setVisible(hasMaxButton);
|
||||||
|
if (!hasMaxButton) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ui->sys_max->setIcon(QPixmap(maximized ? ":/res/sys_restore.png" : ":/res/sys_max.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton* FrameTitleBar::InsertPushButtonMenu(const QString& name, int index) {
|
QPushButton* FrameTitleBar::InsertPushButtonMenu(const QString& name, int index) {
|
||||||
|
|||||||
@ -32,18 +32,18 @@ bool FramelessDelegate::nativeEvent(const QByteArray & eventType, void* message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FramelessDelegate::SetTitleBar(FrameTitleBar* titleBar) {
|
void FramelessDelegate::SetTitleBar(FrameTitleBar* titleBar) {
|
||||||
/* if (nullptr == titleBar || titleBar_ == titleBar) {
|
if (nullptr == titleBar || titleBar_ == titleBar) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (nullptr != titleBar_) {
|
if (nullptr != titleBar_) {
|
||||||
titleBar_->removeEventFilter(this);
|
titleBar_->removeEventFilter(this);
|
||||||
titleBar_->deleteLater();
|
|
||||||
}
|
}
|
||||||
titleBar_ = titleBar;
|
titleBar_ = titleBar;
|
||||||
|
|
||||||
if (nullptr != titleBar_) {
|
if (nullptr != titleBar_) {
|
||||||
|
// 跟踪标题栏显示/隐藏,以便在显示时注册为可移动区域
|
||||||
titleBar_->installEventFilter(this);
|
titleBar_->installEventFilter(this);
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessDelegate::SetTitle(const QString& title) {
|
void FramelessDelegate::SetTitle(const QString& title) {
|
||||||
@ -60,8 +60,6 @@ bool FramelessDelegate::eventFilter(QObject* watched, QEvent* event) {
|
|||||||
OnHide();
|
OnHide();
|
||||||
} else if (QEvent::Close == event->type()) {
|
} else if (QEvent::Close == event->type()) {
|
||||||
OnClose();
|
OnClose();
|
||||||
} else if (QEvent::WinIdChange == event->type()) {
|
|
||||||
isFirstShow_ = true;
|
|
||||||
}
|
}
|
||||||
//#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
//#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
else if (QEvent::ScreenChangeInternal == event->type()) {
|
else if (QEvent::ScreenChangeInternal == event->type()) {
|
||||||
|
|||||||
@ -358,6 +358,8 @@ void FramelessDelegateWin::SetNativeWindowLong() {
|
|||||||
}
|
}
|
||||||
HWND hwnd = reinterpret_cast<HWND>(mainWidget_->winId());
|
HWND hwnd = reinterpret_cast<HWND>(mainWidget_->winId());
|
||||||
unsigned long style = BorderlessFlag;
|
unsigned long style = BorderlessFlag;
|
||||||
|
// 避免父窗口与子窗口重叠绘制导致闪烁,启用剪裁样式
|
||||||
|
style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
|
||||||
|
|
||||||
if (!mainWidget_->windowFlags().testFlag(Qt::WindowMinimizeButtonHint) ||
|
if (!mainWidget_->windowFlags().testFlag(Qt::WindowMinimizeButtonHint) ||
|
||||||
mainWidget_->maximumSize() != QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)) {
|
mainWidget_->maximumSize() != QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)) {
|
||||||
|
|||||||
@ -8,6 +8,9 @@ FramelessWindow::FramelessWindow(QWidget* parent)
|
|||||||
: QFrame(parent) {
|
: QFrame(parent) {
|
||||||
setWindowFlags(windowFlags() | Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
|
setWindowFlags(windowFlags() | Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
|
||||||
|
|
||||||
|
// 初始化平台相关的无边框委托,用于命中测试和缩放。
|
||||||
|
delegate_ = FramelessDelegate::Create(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FramelessWindow::~FramelessWindow() {
|
FramelessWindow::~FramelessWindow() {
|
||||||
@ -15,6 +18,10 @@ FramelessWindow::~FramelessWindow() {
|
|||||||
|
|
||||||
void FramelessWindow::SetTitleBar(FrameTitleBar* titleBar) {
|
void FramelessWindow::SetTitleBar(FrameTitleBar* titleBar) {
|
||||||
titleBar->SetMainWidget(this);
|
titleBar->SetMainWidget(this);
|
||||||
|
if (delegate_) {
|
||||||
|
// 通知委托当前标题栏,以便把它作为可拖动区域处理。
|
||||||
|
delegate_->SetTitleBar(titleBar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
@ -22,5 +29,9 @@ bool FramelessWindow::nativeEvent(const QByteArray& eventType, void* message, qi
|
|||||||
#else
|
#else
|
||||||
bool FramelessWindow::nativeEvent(const QByteArray & eventType, void* message, long* result) {
|
bool FramelessWindow::nativeEvent(const QByteArray & eventType, void* message, long* result) {
|
||||||
#endif
|
#endif
|
||||||
|
// 先让无边框委托处理原生事件(如 WM_NCHITTEST 以支持边缘拖动缩放)。
|
||||||
|
if (delegate_ && delegate_->nativeEvent(eventType, message, result)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return QFrame::nativeEvent(eventType, message, result);
|
return QFrame::nativeEvent(eventType, message, result);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user