@@ -738,31 +738,39 @@ void QgsOptions::showEvent( QShowEvent * e )
738
738
updateVerticalTabs ();
739
739
}
740
740
741
- void QgsOptions::resizeEvent ( QResizeEvent * e )
741
+ void QgsOptions::paintEvent ( QPaintEvent * e )
742
742
{
743
743
Q_UNUSED ( e );
744
- if ( mOptionsListWidget ->isVisible () )
745
- updateVerticalTabs ();
744
+ QTimer::singleShot ( 0 , this , SLOT ( updateVerticalTabs () ) );
746
745
}
747
746
748
747
void QgsOptions::updateVerticalTabs ()
749
748
{
750
749
// auto-resize splitter for vert scrollbar without covering icons in icon-only mode
751
750
// TODO: mOptionsListWidget has fixed 32px wide icons for now, allow user-defined
751
+ // Note: called on splitter resize and dialog paint event, so only update when necessary
752
752
int iconWidth = mOptionsListWidget ->iconSize ().width ();
753
753
int snapToIconWidth = iconWidth + 32 ;
754
+
754
755
QList<int > splitSizes = mOptionsSplitter ->sizes ();
755
756
bool iconOnly = splitSizes.at ( 0 ) <= snapToIconWidth;
756
757
757
758
int newWidth = mOptionsListWidget ->verticalScrollBar ()->isVisible () ? iconWidth + 26 : iconWidth + 12 ;
758
- mOptionsListWidget ->setMinimumWidth ( newWidth );
759
- if ( iconOnly )
759
+ bool diffWidth = mOptionsListWidget ->minimumWidth () != newWidth;
760
+
761
+ if ( diffWidth )
762
+ mOptionsListWidget ->setMinimumWidth ( newWidth );
763
+
764
+ if ( iconOnly && ( diffWidth || mOptionsListWidget ->width () != newWidth ) )
760
765
{
761
766
splitSizes[1 ] = splitSizes.at ( 1 ) - ( splitSizes.at ( 0 ) - newWidth );
762
767
splitSizes[0 ] = newWidth;
763
768
mOptionsSplitter ->setSizes ( splitSizes );
764
769
}
765
- mOptionsListWidget ->setWordWrap ( !iconOnly );
770
+ if ( mOptionsListWidget ->wordWrap () && iconOnly )
771
+ mOptionsListWidget ->setWordWrap ( false );
772
+ if ( !mOptionsListWidget ->wordWrap () && !iconOnly )
773
+ mOptionsListWidget ->setWordWrap ( true );
766
774
}
767
775
768
776
void QgsOptions::on_cbxProjectDefaultNew_toggled ( bool checked )
0 commit comments