Skip to content

Commit

Permalink
fixed minimized and maximized size not saving on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
fourtf committed Sep 8, 2019
1 parent 9404859 commit 9d2665a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lib/appbase/widgets/BaseWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags)
// QTimer::this->scaleChangedEvent(this->getScale());

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)
Expand Down Expand Up @@ -809,15 +815,18 @@ bool BaseWindow::handleSIZE(MSG *msg)
{
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;
::GetWindowRect(msg->hwnd, &rect);
this->currentBounds_ =
QRect(QPoint(rect.left, rect.top),
QPoint(rect.right - 1, rect.bottom - 1));
}
this->useNextBounds_.stop();
}
}
return false;
Expand All @@ -833,8 +842,10 @@ bool BaseWindow::handleMOVE(MSG *msg)
{
RECT rect;
::GetWindowRect(msg->hwnd, &rect);
this->currentBounds_ = QRect(QPoint(rect.left, rect.top),
QPoint(rect.right - 1, rect.bottom - 1));
this->nextBounds_ = QRect(QPoint(rect.left, rect.top),
QPoint(rect.right - 1, rect.bottom - 1));

this->useNextBounds_.start(10);
}
#endif
return false;
Expand Down
2 changes: 2 additions & 0 deletions lib/appbase/widgets/BaseWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class BaseWindow : public BaseWidget
#ifdef USEWINSDK
QRect initalBounds_;
QRect currentBounds_;
QRect nextBounds_;
QTimer useNextBounds_;
bool isNotMinimizedOrMaximized_{};
#endif

Expand Down

0 comments on commit 9d2665a

Please sign in to comment.