fixed minimized and maximized size not saving on windows

This commit is contained in:
fourtf 2019-09-08 14:24:03 +02:00
parent 94048595f6
commit 9d2665ab17
2 changed files with 17 additions and 4 deletions

View file

@ -77,6 +77,12 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags)
// QTimer::this->scaleChangedEvent(this->getScale()); // QTimer::this->scaleChangedEvent(this->getScale());
this->resize(300, 150); this->resize(300, 150);
#ifdef USEWINSDK
this->useNextBounds_.setSingleShot(true);
QObject::connect(&this->useNextBounds_, &QTimer::timeout, this,
[this]() { this->currentBounds_ = this->nextBounds_; });
#endif
} }
void BaseWindow::setInitialBounds(const QRect &bounds) void BaseWindow::setInitialBounds(const QRect &bounds)
@ -809,8 +815,10 @@ bool BaseWindow::handleSIZE(MSG *msg)
{ {
this->ui_.windowLayout->setContentsMargins(0, 1, 0, 0); this->ui_.windowLayout->setContentsMargins(0, 1, 0, 0);
} }
if ((this->isNotMinimizedOrMaximized_ =
msg->wParam == SIZE_RESTORED)) this->isNotMinimizedOrMaximized_ = msg->wParam == SIZE_RESTORED;
if (this->isNotMinimizedOrMaximized_)
{ {
RECT rect; RECT rect;
::GetWindowRect(msg->hwnd, &rect); ::GetWindowRect(msg->hwnd, &rect);
@ -818,6 +826,7 @@ bool BaseWindow::handleSIZE(MSG *msg)
QRect(QPoint(rect.left, rect.top), QRect(QPoint(rect.left, rect.top),
QPoint(rect.right - 1, rect.bottom - 1)); QPoint(rect.right - 1, rect.bottom - 1));
} }
this->useNextBounds_.stop();
} }
} }
return false; return false;
@ -833,8 +842,10 @@ bool BaseWindow::handleMOVE(MSG *msg)
{ {
RECT rect; RECT rect;
::GetWindowRect(msg->hwnd, &rect); ::GetWindowRect(msg->hwnd, &rect);
this->currentBounds_ = QRect(QPoint(rect.left, rect.top), this->nextBounds_ = QRect(QPoint(rect.left, rect.top),
QPoint(rect.right - 1, rect.bottom - 1)); QPoint(rect.right - 1, rect.bottom - 1));
this->useNextBounds_.start(10);
} }
#endif #endif
return false; return false;

View file

@ -123,6 +123,8 @@ private:
#ifdef USEWINSDK #ifdef USEWINSDK
QRect initalBounds_; QRect initalBounds_;
QRect currentBounds_; QRect currentBounds_;
QRect nextBounds_;
QTimer useNextBounds_;
bool isNotMinimizedOrMaximized_{}; bool isNotMinimizedOrMaximized_{};
#endif #endif