Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Switch main Options dialog to vertical tabs
- Icon-only mode enabled by fully moving splitter to left
  • Loading branch information
dakcarto committed Jan 6, 2013
1 parent 5cd7dc5 commit eb9af3e
Show file tree
Hide file tree
Showing 3 changed files with 3,173 additions and 3,033 deletions.
36 changes: 29 additions & 7 deletions src/app/qgsoptions.cpp
Expand Up @@ -703,23 +703,45 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
mOverlayAlgorithmComboBox->setCurrentIndex( 0 );
} //default is central point

// restore window and widget geometry/state
restoreGeometry( settings.value( "/Windows/Options/geometry" ).toByteArray() );
mOptionsSplitter->restoreState( settings.value( "/Windows/Options/splitState" ).toByteArray() );

int currentIndx = settings.value( "/Windows/Options/row" ).toInt();
mOptionsListWidget->setCurrentRow( currentIndx );
mOptionsStackedWidget->setCurrentIndex( currentIndx );

// load gdal driver list only when gdal tab is first opened
mLoadedGdalDriverList = false;

// tabWidget->setCurrentIndex( settings.value( "/Windows/Options/row" ).toInt() );
int currentTab = settings.value( "/Windows/Options/row" ).toInt();
tabWidget->setCurrentIndex( currentTab );
on_tabWidget_currentChanged( currentTab );
// update option section frame state
on_mOptionsListWidget_currentRowChanged( currentIndx );
}

//! Destructor
QgsOptions::~QgsOptions()
{
QSettings settings;
settings.setValue( "/Windows/Options/geometry", saveGeometry() );
settings.setValue( "/Windows/Options/row", tabWidget->currentIndex() );
settings.setValue( "/Windows/Options/splitState", mOptionsSplitter->saveState() );
settings.setValue( "/Windows/Options/row", mOptionsListWidget->currentRow() );
}

void QgsOptions::showEvent( QShowEvent * e )
{
Q_UNUSED( e );
on_mOptionsSplitter_splitterMoved( 0, 0 );
}

void QgsOptions::on_mOptionsSplitter_splitterMoved( int pos, int index )
{
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 );
mOptionsListWidget->setWordWrap( !iconOnly );
}

void QgsOptions::on_cbxProjectDefaultNew_toggled( bool checked )
Expand Down Expand Up @@ -1479,10 +1501,10 @@ void QgsOptions::on_mClearCache_clicked()
#endif
}

void QgsOptions::on_tabWidget_currentChanged( int theTab )
void QgsOptions::on_mOptionsListWidget_currentRowChanged( int theIndx )
{
// load gdal driver list when gdal tab is first opened
if ( theTab == 1 && ! mLoadedGdalDriverList )
if ( theIndx == 2 && ! mLoadedGdalDriverList )
{
loadGdalDriverList();
}
Expand Down
14 changes: 11 additions & 3 deletions src/app/qgsoptions.h
Expand Up @@ -51,6 +51,10 @@ 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 @@ -189,10 +193,10 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
*/
void on_pbnExportScales_clicked();

/** Auto slot executed when the active page in the main widget stack is changed
* @note added in 2.0
/** Auto slot executed when the active item in the option section list widget is changed
* @note added in 1.9
*/
void on_tabWidget_currentChanged( int theTab );
void on_mOptionsListWidget_currentRowChanged( int theIndx );

/* Load the list of drivers available in GDAL
* @note added in 2.0
Expand All @@ -216,6 +220,10 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
* @note added in QGIS 1.9
*/
void addCustomEnvVarRow( QString varName, QString varVal, QString varApply = QString() );

protected:
void showEvent( QShowEvent * e );

};

#endif // #ifndef QGSOPTIONS_H

0 comments on commit eb9af3e

Please sign in to comment.