Showing with 38 additions and 11 deletions.
  1. +15 −7 src/app/qgsoptions.cpp
  2. +1 −1 src/app/qgsoptions.h
  3. +22 −3 src/ui/qgsoptionsbase.ui
22 changes: 15 additions & 7 deletions src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
addCustomEnvVarRow( varStrName, varStrValue, varStrApply );
}
QFontMetrics fmCustomVar( mCustomVariablesTable->horizontalHeader()->font() );
int fmCustomVarH = fmCustomVar.height() + 2;
int fmCustomVarH = fmCustomVar.height() + 8;
mCustomVariablesTable->horizontalHeader()->setFixedHeight( fmCustomVarH );

mCustomVariablesTable->setColumnWidth( 0, 120 );
Expand Down Expand Up @@ -738,31 +738,39 @@ void QgsOptions::showEvent( QShowEvent * e )
updateVerticalTabs();
}

void QgsOptions::resizeEvent( QResizeEvent * e )
void QgsOptions::paintEvent( QPaintEvent * e )
{
Q_UNUSED( e );
if ( mOptionsListWidget->isVisible() )
updateVerticalTabs();
QTimer::singleShot( 0, this, SLOT( updateVerticalTabs() ) );
}

void QgsOptions::updateVerticalTabs()
{
// auto-resize splitter for vert scrollbar without covering icons in icon-only mode
// TODO: mOptionsListWidget has fixed 32px wide icons for now, allow user-defined
// Note: called on splitter resize and dialog paint event, so only update when necessary
int iconWidth = mOptionsListWidget->iconSize().width();
int snapToIconWidth = iconWidth + 32;

QList<int> splitSizes = mOptionsSplitter->sizes();
bool iconOnly = splitSizes.at( 0 ) <= snapToIconWidth;

int newWidth = mOptionsListWidget->verticalScrollBar()->isVisible() ? iconWidth + 26 : iconWidth + 12;
mOptionsListWidget->setMinimumWidth( newWidth );
if ( iconOnly )
bool diffWidth = mOptionsListWidget->minimumWidth() != newWidth;

if ( diffWidth )
mOptionsListWidget->setMinimumWidth( newWidth );

if ( iconOnly && ( diffWidth || mOptionsListWidget->width() != newWidth ) )
{
splitSizes[1] = splitSizes.at( 1 ) - ( splitSizes.at( 0 ) - newWidth );
splitSizes[0] = newWidth;
mOptionsSplitter->setSizes( splitSizes );
}
mOptionsListWidget->setWordWrap( !iconOnly );
if ( mOptionsListWidget->wordWrap() && iconOnly )
mOptionsListWidget->setWordWrap( false );
if ( !mOptionsListWidget->wordWrap() && !iconOnly )
mOptionsListWidget->setWordWrap( true );
}

void QgsOptions::on_cbxProjectDefaultNew_toggled( bool checked )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase

protected:
void showEvent( QShowEvent * e );
void resizeEvent( QResizeEvent * e );
void paintEvent( QPaintEvent * e );
};

#endif // #ifndef QGSOPTIONS_H
25 changes: 22 additions & 3 deletions src/ui/qgsoptionsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1106,8 +1106,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>695</width>
<height>537</height>
<width>704</width>
<height>624</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_22">
Expand All @@ -1131,6 +1131,9 @@
<height>120</height>
</size>
</property>
<property name="editTriggers">
<set>QAbstractItemView::AllEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
Expand Down Expand Up @@ -1212,6 +1215,15 @@
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QTableWidget" name="mCurrentVariablesTable">
<property name="minimumSize">
<size>
<width>0</width>
<height>120</height>
</size>
</property>
<property name="editTriggers">
<set>QAbstractItemView::AllEditTriggers</set>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
Expand Down Expand Up @@ -1325,7 +1337,14 @@
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QListWidget" name="mListPluginPaths"/>
<widget class="QListWidget" name="mListPluginPaths">
<property name="minimumSize">
<size>
<width>0</width>
<height>120</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
Expand Down