29
29
30
30
31
31
QgsOptionsDialogBase::QgsOptionsDialogBase ( QString settingsKey, QWidget* parent, Qt::WFlags fl )
32
- : QDialog( parent, fl ), mOptsKey( settingsKey ), mInit( false )
32
+ : QDialog( parent, fl )
33
+ , mOptsKey( settingsKey )
34
+ , mInit( false )
35
+ , mDialogTitle( " " )
33
36
{
34
37
}
35
38
@@ -46,6 +49,10 @@ QgsOptionsDialogBase::~QgsOptionsDialogBase()
46
49
47
50
void QgsOptionsDialogBase::initOptionsBase ( bool restoreUi )
48
51
{
52
+ // save original dialog title so it can be used to be concatenated
53
+ // with category title in icon-only mode
54
+ mDialogTitle = windowTitle ();
55
+
49
56
// don't add to dialog margins
50
57
// redefine now, or those in inherited .ui file will be added
51
58
if ( layout () )
@@ -68,7 +75,10 @@ void QgsOptionsDialogBase::initOptionsBase( bool restoreUi )
68
75
69
76
QSettings settings;
70
77
int size = settings.value ( " /IconSize" , 24 ).toInt ();
71
- mOptListWidget ->setIconSize ( QSize ( size, size ) );
78
+ // buffer size to match displayed icon size in toolbars, and expected geometry restore
79
+ // newWidth (above) may need adjusted if you adjust iconBuffer here
80
+ int iconBuffer = 4 ;
81
+ mOptListWidget ->setIconSize ( QSize ( size + iconBuffer, size + iconBuffer ) );
72
82
mOptListWidget ->setFrameStyle ( QFrame::NoFrame );
73
83
74
84
optionsFrame->layout ()->setContentsMargins ( 0 , 3 , 3 , 3 );
@@ -109,6 +119,9 @@ void QgsOptionsDialogBase::restoreOptionsBaseUi()
109
119
return ;
110
120
}
111
121
122
+ // re-save original dialog title in case it was changed after dialog initialization
123
+ mDialogTitle = windowTitle ();
124
+
112
125
QSettings settings;
113
126
restoreGeometry ( settings.value ( QString ( " /Windows/%1/geometry" ).arg ( mOptsKey ) ).toByteArray () );
114
127
// mOptListWidget width is fixed to take up less space in QtDesigner
@@ -148,6 +161,7 @@ void QgsOptionsDialogBase::showEvent( QShowEvent* e )
148
161
if ( mInit )
149
162
{
150
163
updateOptionsListVerticalTabs ();
164
+ optionsStackedWidget_CurrentChanged ( mOptListWidget ->currentRow () );
151
165
}
152
166
else
153
167
{
@@ -179,23 +193,25 @@ void QgsOptionsDialogBase::updateOptionsListVerticalTabs()
179
193
int snapToIconWidth = iconWidth + 32 ;
180
194
181
195
QList<int > splitSizes = mOptSplitter ->sizes ();
182
- bool iconOnly = ( splitSizes.at ( 0 ) <= snapToIconWidth );
196
+ mIconOnly = ( splitSizes.at ( 0 ) <= snapToIconWidth );
183
197
184
- int newWidth = mOptListWidget ->verticalScrollBar ()->isVisible () ? iconWidth + 26 : iconWidth + 12 ;
198
+ // iconBuffer (above) may need adjusted if you adjust iconWidth here
199
+ int newWidth = mOptListWidget ->verticalScrollBar ()->isVisible () ? iconWidth + 22 : iconWidth + 9 ;
185
200
bool diffWidth = mOptListWidget ->minimumWidth () != newWidth;
186
201
187
202
if ( diffWidth )
188
203
mOptListWidget ->setMinimumWidth ( newWidth );
189
204
190
- if ( iconOnly && ( diffWidth || mOptListWidget ->width () != newWidth ) )
205
+ if ( mIconOnly && ( diffWidth || mOptListWidget ->width () != newWidth ) )
191
206
{
192
207
splitSizes[1 ] = splitSizes.at ( 1 ) - ( splitSizes.at ( 0 ) - newWidth );
193
208
splitSizes[0 ] = newWidth;
194
209
mOptSplitter ->setSizes ( splitSizes );
195
210
}
196
- if ( mOptListWidget ->wordWrap () && iconOnly )
211
+
212
+ if ( mOptListWidget ->wordWrap () && mIconOnly )
197
213
mOptListWidget ->setWordWrap ( false );
198
- if ( !mOptListWidget ->wordWrap () && !iconOnly )
214
+ if ( !mOptListWidget ->wordWrap () && !mIconOnly )
199
215
mOptListWidget ->setWordWrap ( true );
200
216
}
201
217
@@ -204,6 +220,16 @@ void QgsOptionsDialogBase::optionsStackedWidget_CurrentChanged( int indx )
204
220
mOptListWidget ->blockSignals ( true );
205
221
mOptListWidget ->setCurrentRow ( indx );
206
222
mOptListWidget ->blockSignals ( false );
223
+
224
+ QListWidgetItem *curitem = mOptListWidget ->currentItem ();
225
+ if ( curitem )
226
+ {
227
+ setWindowTitle ( QString ( " %1 - %2" ).arg ( mDialogTitle ).arg ( curitem->text () ) );
228
+ }
229
+ else
230
+ {
231
+ setWindowTitle ( mDialogTitle );
232
+ }
207
233
}
208
234
209
235
void QgsOptionsDialogBase::optionsStackedWidget_WidgetRemoved ( int indx )
0 commit comments