Skip to content

Commit 15de06d

Browse files
committedJan 16, 2013
Update Options dialog vertical tabs after paintEvent, instead of on resize
- Allows full updating of icon-only mode on OSes that emit only one resize event
1 parent 0dbb781 commit 15de06d

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed
 

‎src/app/qgsoptions.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -738,31 +738,39 @@ void QgsOptions::showEvent( QShowEvent * e )
738738
updateVerticalTabs();
739739
}
740740

741-
void QgsOptions::resizeEvent( QResizeEvent * e )
741+
void QgsOptions::paintEvent( QPaintEvent * e )
742742
{
743743
Q_UNUSED( e );
744-
if ( mOptionsListWidget->isVisible() )
745-
updateVerticalTabs();
744+
QTimer::singleShot( 0, this, SLOT( updateVerticalTabs() ) );
746745
}
747746

748747
void QgsOptions::updateVerticalTabs()
749748
{
750749
// auto-resize splitter for vert scrollbar without covering icons in icon-only mode
751750
// 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
752752
int iconWidth = mOptionsListWidget->iconSize().width();
753753
int snapToIconWidth = iconWidth + 32;
754+
754755
QList<int> splitSizes = mOptionsSplitter->sizes();
755756
bool iconOnly = splitSizes.at( 0 ) <= snapToIconWidth;
756757

757758
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 ) )
760765
{
761766
splitSizes[1] = splitSizes.at( 1 ) - ( splitSizes.at( 0 ) - newWidth );
762767
splitSizes[0] = newWidth;
763768
mOptionsSplitter->setSizes( splitSizes );
764769
}
765-
mOptionsListWidget->setWordWrap( !iconOnly );
770+
if ( mOptionsListWidget->wordWrap() && iconOnly )
771+
mOptionsListWidget->setWordWrap( false );
772+
if ( !mOptionsListWidget->wordWrap() && !iconOnly )
773+
mOptionsListWidget->setWordWrap( true );
766774
}
767775

768776
void QgsOptions::on_cbxProjectDefaultNew_toggled( bool checked )

‎src/app/qgsoptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
229229

230230
protected:
231231
void showEvent( QShowEvent * e );
232-
void resizeEvent( QResizeEvent * e );
232+
void paintEvent( QPaintEvent * e );
233233
};
234234

235235
#endif // #ifndef QGSOPTIONS_H

0 commit comments

Comments
 (0)
Please sign in to comment.