1
0
mirror of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git synced 2025-04-01 02:42:39 +08:00

change setGeometry to setWindowState to set window maximized or

normalized
This commit is contained in:
helywin 2019-09-15 21:28:01 +08:00
parent d495abe3b5
commit 5b1313ff6b

View File

@ -68,7 +68,6 @@ struct FloatingDockContainerPrivate
#ifdef Q_OS_LINUX
QWidget* MouseEventHandler = nullptr;
CFloatingWidgetTitleBar* TitleBar = nullptr;
QRect LastGeometry;
#endif
/**
@ -250,7 +249,6 @@ CFloatingDockContainer::CFloatingDockContainer(CDockManager *DockManager) :
QDockWidget::setFloating(true);
QDockWidget::setFeatures(QDockWidget::AllDockWidgetFeatures);
setTitleBarWidget(d->TitleBar);
d->LastGeometry = geometry();
connect(d->TitleBar, SIGNAL(closeRequested()), SLOT(close()));
connect(d->TitleBar, &CFloatingWidgetTitleBar::maximizeRequested,
this, &CFloatingDockContainer::onMaximizeRequest);
@ -324,6 +322,7 @@ void CFloatingDockContainer::changeEvent(QEvent *event)
//============================================================================
void CFloatingDockContainer::moveEvent(QMoveEvent *event)
{
// todo: add normalize code when maximized window is dragged
QWidget::moveEvent(event);
switch (d->DraggingState)
{
@ -658,15 +657,14 @@ void CFloatingDockContainer::onMaximizeRequest()
}
ADS_PRINT("CFloatingDockContainer::onMaximizeRequest() current screen: " + currentScreen->name());
// get current windows state, if it is maximized and moved or not
if (geometry().size() == currentScreen->availableGeometry().size())
if (windowState() == Qt::WindowMaximized)
{
setGeometry(d->LastGeometry);
setWindowState(Qt::WindowNoState);
d->TitleBar->setMaximizedIcon(false);
}
else
{
d->LastGeometry = geometry();
setGeometry(currentScreen->availableGeometry());
setWindowState(Qt::WindowMaximized);
d->TitleBar->setMaximizedIcon(true);
}
}