Fixed issue #251 - Window momentarily flashes as floating widget

This commit is contained in:
Uwe Kindler 2020-09-02 09:04:59 +02:00
parent 175b48569f
commit 65058d3a48

View File

@ -146,6 +146,19 @@ struct DockWidgetTabPrivate
CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton);
}
/**
* Update the size policy of the close button depending on the
* RetainTabSizeWhenCloseButtonHidden feature
*/
void updateCloseButtonSizePolicy()
{
auto Features = DockWidget->features();
auto SizePolicy = CloseButton->sizePolicy();
SizePolicy.setRetainSizeWhenHidden(Features.testFlag(CDockWidget::DockWidgetClosable)
&& testConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden));
CloseButton->setSizePolicy(SizePolicy);
}
template <typename T>
IFloatingWidget* createFloatingWidget(T* Widget, bool OpaqueUndocking)
{
@ -200,7 +213,7 @@ void DockWidgetTabPrivate::createLayout()
CloseButton->setObjectName("tabCloseButton");
internal::setButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton, TabCloseIcon);
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
_this->onDockWidgetFeaturesChanged();
updateCloseButtonSizePolicy();
internal::setToolTip(CloseButton, QObject::tr("Close Tab"));
_this->connect(CloseButton, SIGNAL(clicked()), SIGNAL(closeRequested()));
@ -656,11 +669,7 @@ bool CDockWidgetTab::event(QEvent *e)
//============================================================================
void CDockWidgetTab::onDockWidgetFeaturesChanged()
{
auto Features = d->DockWidget->features();
auto SizePolicy = d->CloseButton->sizePolicy();
SizePolicy.setRetainSizeWhenHidden(Features.testFlag(CDockWidget::DockWidgetClosable)
&& d->testConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden));
d->CloseButton->setSizePolicy(SizePolicy);
d->updateCloseButtonSizePolicy();
d->updateCloseButtonVisibility(isActiveTab());
}