mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 06:38:13 -05:00
#14104 Fix property dialogs opening collapsed on multi-monitor setups
The export property dialogs that rely solely on sizeHint() could open collapsed when shown on a screen whose DPI differs from the screen they were built on. Recompute the layout on first show, after the dialog is associated with its destination screen, by calling adjustSize() in showEvent when no stored size is restored. Also give RiuPropertyViewTabWidget a minimum size floor so the inner scroll area's artificially small minimum width cannot collapse the dialog.
This commit is contained in:
1 parent
1989f93440
commit
5dae9a0a19
2 files changed
+39
-16
No files matched your search
@@ -105,7 +105,9 @@ QSize RiuPropertyViewTabWidget::minimumSizeHint() const
|
||||
maxSizeHint = maxSizeHint.expandedTo( pageSize );
|
||||
}
|
||||
|
||||
return maxSizeHint;
|
||||
// The inner scroll area reports an artificially small minimum width, which lets some window
|
||||
// managers open the dialog collapsed (issue #14104). Provide a sensible floor.
|
||||
return maxSizeHint.expandedTo( QSize( 300, 150 ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -141,16 +143,27 @@ QDialogButtonBox* RiuPropertyViewTabWidget::dialogButtonBox()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPropertyViewTabWidget::showEvent( QShowEvent* event )
|
||||
{
|
||||
// Restore the stored size on first show. Doing this here rather than in the constructor ensures
|
||||
// the geometry is applied reliably for a modal dialog and is not overridden by the initial sizing.
|
||||
// When no size is stored, the size is left to sizeHint()/minimumSizeHint().
|
||||
if ( RiaPreferencesSystem::current()->isFeatureEnabled( "remember-dialog-size" ) && !m_geometryRestored )
|
||||
// Let the base class perform its initial sizing first, so the dialog is associated with the
|
||||
// screen it actually opens on before we adjust its size.
|
||||
QDialog::showEvent( event );
|
||||
|
||||
if ( !m_geometryRestored )
|
||||
{
|
||||
m_geometryRestored = true;
|
||||
restoreDialogGeometry();
|
||||
}
|
||||
|
||||
QDialog::showEvent( event );
|
||||
// Restore the stored size on first show. Doing this here rather than in the constructor
|
||||
// ensures the size is applied reliably for a modal dialog and is not overridden by the
|
||||
// initial sizing.
|
||||
const bool restored = RiaPreferencesSystem::current()->isFeatureEnabled( "remember-dialog-size" ) && restoreDialogGeometry();
|
||||
if ( !restored )
|
||||
{
|
||||
// No stored size: the dialog was laid out while associated with the screen it was built
|
||||
// on, which on a multi-monitor setup can have a different DPI than the screen it ends up
|
||||
// on. Recompute the layout for the current screen so the dialog is not shown collapsed
|
||||
// (issue #14104). sizeHint()/minimumSizeHint() provide the floor.
|
||||
adjustSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -152,17 +152,27 @@ void PdmUiPropertyViewDialog::setupUi()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiPropertyViewDialog::showEvent( QShowEvent* event )
|
||||
{
|
||||
// Restore a previously stored size on first show. Restoring here rather than in the constructor
|
||||
// ensures the geometry is applied reliably for a modal dialog and is not overridden by the initial
|
||||
// sizing (see issue #14104). When no size is stored, the size is left to sizeHint()/minimumSizeHint()
|
||||
// and any explicit resize() done by the caller, so the default appearance is preserved.
|
||||
if ( sm_geometryPersistenceEnabled && !m_geometryRestored )
|
||||
// Let the base class perform its initial sizing first, so the dialog is associated with the
|
||||
// screen it actually opens on before we adjust its size.
|
||||
QDialog::showEvent( event );
|
||||
|
||||
if ( !m_geometryRestored )
|
||||
{
|
||||
m_geometryRestored = true;
|
||||
restoreDialogGeometry();
|
||||
}
|
||||
|
||||
QDialog::showEvent( event );
|
||||
// Restore a previously stored size on first show. Doing this here rather than in the
|
||||
// constructor ensures the size is applied reliably for a modal dialog and is not overridden
|
||||
// by the initial sizing (see issue #14104).
|
||||
const bool restored = sm_geometryPersistenceEnabled && restoreDialogGeometry();
|
||||
if ( !restored )
|
||||
{
|
||||
// No stored size: the dialog was laid out while associated with the screen it was built
|
||||
// on, which on a multi-monitor setup can have a different DPI than the screen it ends up
|
||||
// on. Recompute the layout for the current screen so the dialog is not shown collapsed
|
||||
// (issue #14104). sizeHint()/minimumSizeHint() provide the floor.
|
||||
adjustSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user