Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update Options dialog vertical tabs
- Icon-only mode now only shows vert. scrollbar as needed
- Icon-only mode is snapped to when splitter is near icons
- Splitter is adjusted for vert. scrollbar width, keeping it from covering icon-only mode icons
- Remove size grip for dialog
  • Loading branch information
dakcarto committed Jan 7, 2013
1 parent 73dc9b1 commit 4ff5b29
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
35 changes: 27 additions & 8 deletions src/app/qgsoptions.cpp
Expand Up @@ -41,6 +41,7 @@
#include <QLocale>
#include <QProcess>
#include <QToolBar>
#include <QScrollBar>
#include <QSize>
#include <QStyleFactory>
#include <QMessageBox>
Expand Down Expand Up @@ -69,6 +70,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
{
setupUi( this );

connect( mOptionsSplitter, SIGNAL( splitterMoved( int, int ) ), this, SLOT( updateVerticalTabs() ) );

connect( cmbTheme, SIGNAL( activated( const QString& ) ), this, SLOT( themeChanged( const QString& ) ) );
connect( cmbTheme, SIGNAL( highlighted( const QString& ) ), this, SLOT( themeChanged( const QString& ) ) );
connect( cmbTheme, SIGNAL( textChanged( const QString& ) ), this, SLOT( themeChanged( const QString& ) ) );
Expand Down Expand Up @@ -730,17 +733,33 @@ QgsOptions::~QgsOptions()
void QgsOptions::showEvent( QShowEvent * e )
{
Q_UNUSED( e );
on_mOptionsSplitter_splitterMoved( 0, 0 );
updateVerticalTabs();
}

void QgsOptions::resizeEvent( QResizeEvent * e )
{
Q_UNUSED( e );
if ( mOptionsListWidget->isVisible() )
updateVerticalTabs();
}

void QgsOptions::on_mOptionsSplitter_splitterMoved( int pos, int index )
void QgsOptions::updateVerticalTabs()
{
Q_UNUSED( pos );
Q_UNUSED( index );
// when list widget is collapsed, show vert scrollbar to hide text, making view icon-only, like a toolbar
// mOptionsListWidget has 32px wide icons with minimum width for widget at 58
bool iconOnly = mOptionsListWidget->width() <= 60;
mOptionsListWidget->setVerticalScrollBarPolicy( iconOnly ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAsNeeded );
// 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
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 )
{
splitSizes[1] = splitSizes.at( 1 ) - ( splitSizes.at( 0 ) - newWidth );
splitSizes[0] = newWidth;
mOptionsSplitter->setSizes( splitSizes );
}
mOptionsListWidget->setWordWrap( !iconOnly );
}

Expand Down
11 changes: 6 additions & 5 deletions src/app/qgsoptions.h
Expand Up @@ -51,10 +51,6 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
QString theme();

public slots:
/** Slot to update whether list widget has a scrollbar
* @note added in QGIS 1.9
*/
void on_mOptionsSplitter_splitterMoved( int pos, int index );
void on_cbxProjectDefaultNew_toggled( bool checked );
void on_pbnProjectDefaultSetCurrent_clicked();
void on_pbnProjectDefaultReset_clicked();
Expand Down Expand Up @@ -198,6 +194,11 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
*/
void on_mOptionsListWidget_currentRowChanged( int theIndx );

/** Slot to update widget of vertical tabs
* @note added in QGIS 1.9
*/
void updateVerticalTabs();

/* Load the list of drivers available in GDAL
* @note added in 2.0
*/
Expand All @@ -223,7 +224,7 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase

protected:
void showEvent( QShowEvent * e );

void resizeEvent( QResizeEvent * e );
};

#endif // #ifndef QGSOPTIONS_H
7 changes: 1 addition & 6 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -19,9 +19,6 @@
<property name="windowTitle">
<string>Options</string>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<property name="modal">
<bool>true</bool>
</property>
Expand Down Expand Up @@ -222,14 +219,12 @@
<widget class="QLabel" name="mOptionsTitleLabel">
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">font-weight:bold;
font-size: 14px;</string>
<string notr="true">font-weight:bold;</string>
</property>
<property name="text">
<string>General</string>
Expand Down

0 comments on commit 4ff5b29

Please sign in to comment.