Skip to content

Commit eb9af3e

Browse files
committed
Switch main Options dialog to vertical tabs
- Icon-only mode enabled by fully moving splitter to left
1 parent 5cd7dc5 commit eb9af3e

File tree

3 files changed

+3173
-3033
lines changed

3 files changed

+3173
-3033
lines changed

src/app/qgsoptions.cpp

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -703,23 +703,45 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
703703
mOverlayAlgorithmComboBox->setCurrentIndex( 0 );
704704
} //default is central point
705705

706+
// restore window and widget geometry/state
706707
restoreGeometry( settings.value( "/Windows/Options/geometry" ).toByteArray() );
708+
mOptionsSplitter->restoreState( settings.value( "/Windows/Options/splitState" ).toByteArray() );
709+
710+
int currentIndx = settings.value( "/Windows/Options/row" ).toInt();
711+
mOptionsListWidget->setCurrentRow( currentIndx );
712+
mOptionsStackedWidget->setCurrentIndex( currentIndx );
707713

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

711-
// tabWidget->setCurrentIndex( settings.value( "/Windows/Options/row" ).toInt() );
712-
int currentTab = settings.value( "/Windows/Options/row" ).toInt();
713-
tabWidget->setCurrentIndex( currentTab );
714-
on_tabWidget_currentChanged( currentTab );
717+
// update option section frame state
718+
on_mOptionsListWidget_currentRowChanged( currentIndx );
715719
}
716720

717721
//! Destructor
718722
QgsOptions::~QgsOptions()
719723
{
720724
QSettings settings;
721725
settings.setValue( "/Windows/Options/geometry", saveGeometry() );
722-
settings.setValue( "/Windows/Options/row", tabWidget->currentIndex() );
726+
settings.setValue( "/Windows/Options/splitState", mOptionsSplitter->saveState() );
727+
settings.setValue( "/Windows/Options/row", mOptionsListWidget->currentRow() );
728+
}
729+
730+
void QgsOptions::showEvent( QShowEvent * e )
731+
{
732+
Q_UNUSED( e );
733+
on_mOptionsSplitter_splitterMoved( 0, 0 );
734+
}
735+
736+
void QgsOptions::on_mOptionsSplitter_splitterMoved( int pos, int index )
737+
{
738+
Q_UNUSED( pos );
739+
Q_UNUSED( index );
740+
// when list widget is collapsed, show vert scrollbar to hide text, making view icon-only, like a toolbar
741+
// mOptionsListWidget has 32px wide icons with minimum width for widget at 58
742+
bool iconOnly = mOptionsListWidget->width() <= 60;
743+
mOptionsListWidget->setVerticalScrollBarPolicy( iconOnly ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAsNeeded );
744+
mOptionsListWidget->setWordWrap( !iconOnly );
723745
}
724746

725747
void QgsOptions::on_cbxProjectDefaultNew_toggled( bool checked )
@@ -1479,10 +1501,10 @@ void QgsOptions::on_mClearCache_clicked()
14791501
#endif
14801502
}
14811503

1482-
void QgsOptions::on_tabWidget_currentChanged( int theTab )
1504+
void QgsOptions::on_mOptionsListWidget_currentRowChanged( int theIndx )
14831505
{
14841506
// load gdal driver list when gdal tab is first opened
1485-
if ( theTab == 1 && ! mLoadedGdalDriverList )
1507+
if ( theIndx == 2 && ! mLoadedGdalDriverList )
14861508
{
14871509
loadGdalDriverList();
14881510
}

src/app/qgsoptions.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
5151
QString theme();
5252

5353
public slots:
54+
/** Slot to update whether list widget has a scrollbar
55+
* @note added in QGIS 1.9
56+
*/
57+
void on_mOptionsSplitter_splitterMoved( int pos, int index );
5458
void on_cbxProjectDefaultNew_toggled( bool checked );
5559
void on_pbnProjectDefaultSetCurrent_clicked();
5660
void on_pbnProjectDefaultReset_clicked();
@@ -189,10 +193,10 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
189193
*/
190194
void on_pbnExportScales_clicked();
191195

192-
/** Auto slot executed when the active page in the main widget stack is changed
193-
* @note added in 2.0
196+
/** Auto slot executed when the active item in the option section list widget is changed
197+
* @note added in 1.9
194198
*/
195-
void on_tabWidget_currentChanged( int theTab );
199+
void on_mOptionsListWidget_currentRowChanged( int theIndx );
196200

197201
/* Load the list of drivers available in GDAL
198202
* @note added in 2.0
@@ -216,6 +220,10 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
216220
* @note added in QGIS 1.9
217221
*/
218222
void addCustomEnvVarRow( QString varName, QString varVal, QString varApply = QString() );
223+
224+
protected:
225+
void showEvent( QShowEvent * e );
226+
219227
};
220228

221229
#endif // #ifndef QGSOPTIONS_H

0 commit comments

Comments
 (0)