Skip to content

Commit 94027df

Browse files
committed
Merge pull request #1091 from 3nids/uioptionbase2
dialog base: separator and dialog title as argument to init/restore
2 parents db7cddf + f9c5ee0 commit 94027df

6 files changed

+53
-34
lines changed

src/app/pluginmanager/qgspluginmanager.cpp

+13-8
Original file line numberDiff line numberDiff line change
@@ -1346,18 +1346,23 @@ bool QgsPluginManager::hasInvalidPlugins( )
13461346

13471347
void QgsPluginManager::updateWindowTitle( )
13481348
{
1349-
QString newTitle = QString( "%1 - %2" ).arg( tr( "Plugins" ) ).arg( mOptionsListWidget->currentItem()->text() );
1350-
if ( mOptionsListWidget->currentRow() < mOptionsListWidget->count() - 1 )
1349+
QListWidgetItem *curitem = mOptListWidget->currentItem();
1350+
if ( curitem )
13511351
{
1352-
// if it's not the Settings tab, add the plugin count
1353-
newTitle += QString( " (%3)" ).arg( mModelProxy->countWithCurrentStatus() );
1352+
QString title = QString( "%1 | %2" ).arg( tr( "Plugins" ) ).arg( curitem->text() );
1353+
if ( mOptionsListWidget->currentRow() < mOptionsListWidget->count() - 1 )
1354+
{
1355+
// if it's not the Settings tab, add the plugin count
1356+
title += QString( " (%3)" ).arg( mModelProxy->countWithCurrentStatus() );
1357+
setWindowTitle( title );
1358+
}
1359+
}
1360+
else
1361+
{
1362+
setWindowTitle( mDialogTitle );
13541363
}
1355-
setWindowTitle( newTitle );
1356-
return;
13571364
}
13581365

1359-
1360-
13611366
void QgsPluginManager::showEvent( QShowEvent* e )
13621367
{
13631368
if ( mInit )

src/app/qgsabout.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ QgsAbout::QgsAbout( QWidget *parent )
3838
#endif
3939
{
4040
setupUi( this );
41-
initOptionsBase();
41+
QString title = QString( "%1 - %2 Bit" ).arg( windowTitle() ).arg( QSysInfo::WordSize );
42+
initOptionsBase( true, title );
4243
init();
4344
}
4445

@@ -50,8 +51,6 @@ void QgsAbout::init()
5051
{
5152
setPluginInfo();
5253

53-
setWindowTitle( QString( "%1 - %2 Bit" ).arg( windowTitle() ).arg( QSysInfo::WordSize ) );
54-
5554
// set the 60x60 icon pixmap
5655
QPixmap icon( QgsApplication::iconsPath() + "qgis-icon-60x60.png" );
5756
qgisIcon->setPixmap( icon );

src/app/qgsrasterlayerproperties.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
225225
.arg( pyramidSentence2 ).arg( pyramidSentence3 )
226226
.arg( pyramidSentence4 ).arg( pyramidSentence5 ) );
227227

228-
setWindowTitle( tr( "Layer Properties - %1" ).arg( lyr->name() ) );
229-
230228
tableTransparency->horizontalHeader()->setResizeMode( 0, QHeaderView::Stretch );
231229
tableTransparency->horizontalHeader()->setResizeMode( 1, QHeaderView::Stretch );
232230

@@ -402,7 +400,8 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
402400

403401
mResetColorRenderingBtn->setIcon( QgsApplication::getThemeIcon( "/mActionUndo.png" ) );
404402

405-
restoreOptionsBaseUi();
403+
QString title = QString( tr( "Layer Properties - %1" ) ).arg( lyr->name() );
404+
restoreOptionsBaseUi( title );
406405
} // QgsRasterLayerProperties ctor
407406

408407

src/app/qgsvectorlayerproperties.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
250250
);
251251
}
252252

253-
setWindowTitle( tr( "Layer Properties - %1" ).arg( layer->name() ) );
254-
255253
QSettings settings;
256254
// if dialog hasn't been opened/closed yet, default to Styles tab, which is used most often
257255
// this will be read by restoreOptionsBaseUi()
@@ -261,7 +259,8 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
261259
mOptStackedWidget->indexOf( mOptsPage_Style ) );
262260
}
263261

264-
restoreOptionsBaseUi();
262+
QString title = QString( tr( "Layer Properties - %1" ) ).arg( layer->name() );
263+
restoreOptionsBaseUi( title );
265264
} // QgsVectorLayerProperties ctor
266265

267266

src/gui/qgsoptionsdialogbase.cpp

+28-14
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,14 @@ QgsOptionsDialogBase::~QgsOptionsDialogBase()
4747
}
4848
}
4949

50-
void QgsOptionsDialogBase::initOptionsBase( bool restoreUi )
50+
void QgsOptionsDialogBase::initOptionsBase( bool restoreUi, QString title )
5151
{
52-
// save original dialog title so it can be used to be concatenated
52+
// save dialog title so it can be used to be concatenated
5353
// with category title in icon-only mode
54-
mDialogTitle = windowTitle();
54+
if ( title.isEmpty() )
55+
mDialogTitle = windowTitle();
56+
else
57+
mDialogTitle = title;
5558

5659
// don't add to dialog margins
5760
// redefine now, or those in inherited .ui file will be added
@@ -109,16 +112,22 @@ void QgsOptionsDialogBase::initOptionsBase( bool restoreUi )
109112
mInit = true;
110113

111114
if ( restoreUi )
112-
restoreOptionsBaseUi();
115+
restoreOptionsBaseUi( mDialogTitle );
113116
}
114117

115-
void QgsOptionsDialogBase::restoreOptionsBaseUi()
118+
void QgsOptionsDialogBase::restoreOptionsBaseUi( QString title )
116119
{
117120
if ( !mInit )
118121
{
119122
return;
120123
}
121124

125+
if ( !title.isEmpty() )
126+
{
127+
mDialogTitle = title;
128+
updateWindowTitle();
129+
}
130+
122131
// re-save original dialog title in case it was changed after dialog initialization
123132
mDialogTitle = windowTitle();
124133

@@ -179,6 +188,19 @@ void QgsOptionsDialogBase::paintEvent( QPaintEvent* e )
179188
QDialog::paintEvent( e );
180189
}
181190

191+
void QgsOptionsDialogBase::updateWindowTitle()
192+
{
193+
QListWidgetItem *curitem = mOptListWidget->currentItem();
194+
if ( curitem )
195+
{
196+
setWindowTitle( QString( "%1 | %2" ).arg( mDialogTitle ).arg( curitem->text() ) );
197+
}
198+
else
199+
{
200+
setWindowTitle( mDialogTitle );
201+
}
202+
}
203+
182204
void QgsOptionsDialogBase::updateOptionsListVerticalTabs()
183205
{
184206
if ( !mInit )
@@ -221,15 +243,7 @@ void QgsOptionsDialogBase::optionsStackedWidget_CurrentChanged( int indx )
221243
mOptListWidget->setCurrentRow( indx );
222244
mOptListWidget->blockSignals( false );
223245

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-
}
246+
updateWindowTitle();
233247
}
234248

235249
void QgsOptionsDialogBase::optionsStackedWidget_WidgetRemoved( int indx )

src/gui/qgsoptionsdialogbase.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ class GUI_EXPORT QgsOptionsDialogBase : public QDialog
5959

6060
/** Set up the base ui connections for vertical tabs.
6161
* @param restoreUi Whether to restore the base ui at this time.
62+
* @param title the window title
6263
*/
63-
void initOptionsBase( bool restoreUi = true );
64+
void initOptionsBase( bool restoreUi = true, QString title = QString() );
6465

6566
/** Restore the base ui.
6667
* Sometimes useful to do at end of subclass's constructor.
67-
* e.g. if setWindowTitle is used after initOptionsBase.
68+
* @param title the window title (it does not need to be defined if previously given to initOptionsBase();
6869
*/
69-
void restoreOptionsBaseUi();
70+
void restoreOptionsBaseUi( QString title = QString() );
7071

7172
/** determine if the options list is in icon only mode
7273
*/
@@ -82,6 +83,8 @@ class GUI_EXPORT QgsOptionsDialogBase : public QDialog
8283
void showEvent( QShowEvent* e );
8384
void paintEvent( QPaintEvent* e );
8485

86+
virtual void updateWindowTitle();
87+
8588
QString mOptsKey;
8689
bool mInit;
8790
QListWidget* mOptListWidget;

0 commit comments

Comments
 (0)