modify FramelessDelegateWin
This commit is contained in:
parent
5367abc5e8
commit
9a24595873
@ -58,8 +58,10 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
|
|
||||||
MainFrame mainWindow;
|
MainFrame mainWindow;
|
||||||
splash.showMessage(("正在创建主窗口..."), Qt::AlignHCenter | Qt::AlignBottom, Qt::white);
|
splash.showMessage(("正在创建主窗口..."), Qt::AlignHCenter | Qt::AlignBottom, Qt:: white);
|
||||||
|
// 先显示窗口,再在事件循环启动后最大化,避免首次显示时原生窗口放置未就绪导致尺寸异常
|
||||||
mainWindow.showMaximized();
|
mainWindow.showMaximized();
|
||||||
|
// QTimer::singleShot(0, &mainWindow, &MainFrame::showMaximized);
|
||||||
splash.finish(&mainWindow);
|
splash.finish(&mainWindow);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -114,7 +114,6 @@ bool OEScene::AddToScene(osg::Node* node) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OEScene::SetHomeViewpoint(const osgEarth::Viewpoint& viewpoint, double duration_s) {
|
void OEScene::SetHomeViewpoint(const osgEarth::Viewpoint& viewpoint, double duration_s) {
|
||||||
return;
|
|
||||||
dyt_check(nullptr != earthManipulator_);
|
dyt_check(nullptr != earthManipulator_);
|
||||||
|
|
||||||
earthManipulator_->setViewpoint(viewpoint, duration_s);
|
earthManipulator_->setViewpoint(viewpoint, duration_s);
|
||||||
|
|||||||
@ -162,19 +162,31 @@ bool FramelessDelegateWin::nativeEvent(const QByteArray & eventType, void* messa
|
|||||||
case WM_NCHITTEST: {
|
case WM_NCHITTEST: {
|
||||||
return OnNCTitTest(msg, result);
|
return OnNCTitTest(msg, result);
|
||||||
}
|
}
|
||||||
case WM_GETMINMAXINFO:
|
case WM_GETMINMAXINFO: {
|
||||||
{
|
// 使用工作区定义最大化位置与大小,避免遮挡任务栏
|
||||||
if (::IsZoomed(msg->hwnd)) {
|
MINMAXINFO* mmi = reinterpret_cast<MINMAXINFO*>(msg->lParam);
|
||||||
RECT frame = { 0, 0, 0, 0 };
|
HMONITOR monitor = MonitorFromWindow(msg->hwnd, MONITOR_DEFAULTTONEAREST);
|
||||||
AdjustWindowRectEx(&frame, WS_OVERLAPPEDWINDOW, FALSE, 0);
|
MONITORINFO mi;
|
||||||
double dpr = mainWidget_->devicePixelRatioF();
|
::ZeroMemory(&mi, sizeof(mi));
|
||||||
|
mi.cbSize = sizeof(mi);
|
||||||
|
if (monitor && GetMonitorInfo(monitor, &mi)) {
|
||||||
|
const RECT& work = mi.rcWork;
|
||||||
|
const RECT& rcMon = mi.rcMonitor;
|
||||||
|
mmi->ptMaxPosition.x = work.left;
|
||||||
|
mmi->ptMaxPosition.y = work.top;
|
||||||
|
mmi->ptMaxSize.x = work.right - work.left;
|
||||||
|
mmi->ptMaxSize.y = work.bottom - work.top;
|
||||||
|
// 限制拖动最大尺寸为监视器大小(非必须,但较合理)
|
||||||
|
mmi->ptMaxTrackSize.x = rcMon.right - rcMon.left;
|
||||||
|
mmi->ptMaxTrackSize.y = rcMon.bottom - rcMon.top;
|
||||||
|
}
|
||||||
|
|
||||||
// 最大化时不叠加系统边框内边距,避免左右出现可见空隙
|
if (::IsZoomed(msg->hwnd)) {
|
||||||
|
// 最大化时不叠加系统边框内边距
|
||||||
frames_.setLeft(0);
|
frames_.setLeft(0);
|
||||||
frames_.setTop(0);
|
frames_.setTop(0);
|
||||||
frames_.setRight(0);
|
frames_.setRight(0);
|
||||||
frames_.setBottom(0);
|
frames_.setBottom(0);
|
||||||
|
|
||||||
mainWidget_->setContentsMargins(margins_);
|
mainWidget_->setContentsMargins(margins_);
|
||||||
justMaximized_ = true;
|
justMaximized_ = true;
|
||||||
} else {
|
} else {
|
||||||
@ -188,7 +200,8 @@ bool FramelessDelegateWin::nativeEvent(const QByteArray & eventType, void* messa
|
|||||||
if (nullptr != titleBar_ && flag) {
|
if (nullptr != titleBar_ && flag) {
|
||||||
titleBar_->OnMaximized(justMaximized_);
|
titleBar_->OnMaximized(justMaximized_);
|
||||||
}
|
}
|
||||||
return false;
|
*result = 0;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
case WM_NCLBUTTONDBLCLK: {
|
case WM_NCLBUTTONDBLCLK: {
|
||||||
*result = 0;
|
*result = 0;
|
||||||
@ -212,13 +225,13 @@ bool FramelessDelegateWin::nativeEvent(const QByteArray & eventType, void* messa
|
|||||||
|
|
||||||
void FramelessDelegateWin::OnShow() {
|
void FramelessDelegateWin::OnShow() {
|
||||||
if (isFirstShow_) {
|
if (isFirstShow_) {
|
||||||
isFirstShow_ = false;
|
|
||||||
|
|
||||||
SetNativeWindowLong();
|
SetNativeWindowLong();
|
||||||
|
isFirstShow_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mainWidget_->setAttribute(Qt::WA_Resized);
|
mainWidget_->setAttribute(Qt::WA_Resized);
|
||||||
if (!isFirstShow_ && mainWidget_->isMaximized()) {
|
// 仅当存在有效的窗口放置信息(length 已设置)时才恢复窗口位置,避免首次显示使用未初始化的数据
|
||||||
|
if (!isFirstShow_ && mainWidget_->isMaximized() && wndPlaceMent_.length == sizeof(wndPlaceMent_)) {
|
||||||
QMetaObject::invokeMethod(
|
QMetaObject::invokeMethod(
|
||||||
this,
|
this,
|
||||||
[=]() {
|
[=]() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user