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); 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> template <typename T>
IFloatingWidget* createFloatingWidget(T* Widget, bool OpaqueUndocking) IFloatingWidget* createFloatingWidget(T* Widget, bool OpaqueUndocking)
{ {
@ -200,7 +213,7 @@ void DockWidgetTabPrivate::createLayout()
CloseButton->setObjectName("tabCloseButton"); CloseButton->setObjectName("tabCloseButton");
internal::setButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton, TabCloseIcon); internal::setButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton, TabCloseIcon);
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
_this->onDockWidgetFeaturesChanged(); updateCloseButtonSizePolicy();
internal::setToolTip(CloseButton, QObject::tr("Close Tab")); internal::setToolTip(CloseButton, QObject::tr("Close Tab"));
_this->connect(CloseButton, SIGNAL(clicked()), SIGNAL(closeRequested())); _this->connect(CloseButton, SIGNAL(clicked()), SIGNAL(closeRequested()));
@ -656,11 +669,7 @@ bool CDockWidgetTab::event(QEvent *e)
//============================================================================ //============================================================================
void CDockWidgetTab::onDockWidgetFeaturesChanged() void CDockWidgetTab::onDockWidgetFeaturesChanged()
{ {
auto Features = d->DockWidget->features(); d->updateCloseButtonSizePolicy();
auto SizePolicy = d->CloseButton->sizePolicy();
SizePolicy.setRetainSizeWhenHidden(Features.testFlag(CDockWidget::DockWidgetClosable)
&& d->testConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden));
d->CloseButton->setSizePolicy(SizePolicy);
d->updateCloseButtonVisibility(isActiveTab()); d->updateCloseButtonVisibility(isActiveTab());
} }