@@ -56,15 +56,21 @@ QgsVectorLayerLoadStyleDialog::QgsVectorLayerLoadStyleDialog( QgsVectorLayer *la
56
56
connect ( mStyleTypeComboBox , qgis::overload<int >::of ( &QComboBox::currentIndexChanged ), this , [ = ]( int )
57
57
{
58
58
QgsVectorLayerProperties::StyleType type = currentStyleType ();
59
- mFromFileWidget ->setVisible ( type != QgsVectorLayerProperties::DB );
60
- mFromDbWidget ->setVisible ( type == QgsVectorLayerProperties::DB );
61
- mDeleteButton ->setVisible ( type == QgsVectorLayerProperties::DB && mLayer ->dataProvider ()->isDeleteStyleFromDatabaseSupported () );
62
- mStyleCategoriesListView ->setEnabled ( currentStyleType () != QgsVectorLayerProperties::SLD );
59
+ mFromFileWidget ->setVisible ( type != QgsVectorLayerProperties::StyleType:: DB );
60
+ mFromDbWidget ->setVisible ( type == QgsVectorLayerProperties::StyleType:: DB );
61
+ mDeleteButton ->setVisible ( type == QgsVectorLayerProperties::StyleType:: DB && mLayer ->dataProvider ()->isDeleteStyleFromDatabaseSupported () );
62
+ mStyleCategoriesListView ->setEnabled ( currentStyleType () != QgsVectorLayerProperties::StyleType:: SLD );
63
63
updateLoadButtonState ();
64
64
} );
65
65
mStyleTypeComboBox ->addItem ( tr ( " from file" ), QgsVectorLayerProperties::QML ); // QML is used as entry, but works for SLD too, see currentStyleType()
66
66
if ( mLayer ->dataProvider ()->isSaveAndLoadStyleToDatabaseSupported () )
67
- mStyleTypeComboBox ->addItem ( tr ( " from database (%1)" ).arg ( providerName ), QgsVectorLayerProperties::DB );
67
+ {
68
+ mStyleTypeComboBox ->addItem ( tr ( " from database (%1)" ).arg ( providerName ), QgsVectorLayerProperties::StyleType::DB );
69
+ if ( settings.value ( QStringLiteral ( " style/lastLoadStyleTypeSelection" ) ) == QgsVectorLayerProperties::StyleType::DB )
70
+ {
71
+ mStyleTypeComboBox ->setCurrentIndex ( mStyleTypeComboBox ->findData ( QgsVectorLayerProperties::StyleType::DB ) );
72
+ }
73
+ }
68
74
69
75
// fill style categories
70
76
mModel = new QgsMapLayerStyleCategoriesModel ( this );
@@ -105,6 +111,11 @@ QgsVectorLayerLoadStyleDialog::QgsVectorLayerLoadStyleDialog( QgsVectorLayer *la
105
111
connect ( mButtonBox , &QDialogButtonBox::helpRequested, this , &QgsVectorLayerLoadStyleDialog::showHelp );
106
112
connect ( mLoadButton , &QPushButton::clicked, this , &QDialog::accept );
107
113
connect ( mDeleteButton , &QPushButton::clicked, this , &QgsVectorLayerLoadStyleDialog::deleteStyleFromDB );
114
+ connect ( this , &QgsVectorLayerLoadStyleDialog::rejected, [ = ]
115
+ {
116
+ QgsSettings ().setValue ( QStringLiteral ( " style/lastLoadStyleTypeSelection" ), currentStyleType () );
117
+ } );
118
+
108
119
setTabOrder ( mRelatedTable , mOthersTable );
109
120
110
121
restoreGeometry ( settings.value ( QStringLiteral ( " Windows/vectorLayerLoadStyle/geometry" ) ).toByteArray () );
@@ -113,8 +124,7 @@ QgsVectorLayerLoadStyleDialog::QgsVectorLayerLoadStyleDialog( QgsVectorLayer *la
113
124
114
125
QgsVectorLayerLoadStyleDialog::~QgsVectorLayerLoadStyleDialog ()
115
126
{
116
- QgsSettings settings;
117
- settings.setValue ( QStringLiteral ( " Windows/vectorLayerLoadStyle/geometry" ), saveGeometry () );
127
+ QgsSettings ().setValue ( QStringLiteral ( " Windows/vectorLayerLoadStyle/geometry" ), saveGeometry () );
118
128
}
119
129
120
130
QgsMapLayer::StyleCategories QgsVectorLayerLoadStyleDialog::styleCategories () const
@@ -246,7 +256,9 @@ void QgsVectorLayerLoadStyleDialog::selectionChanged( QTableWidget *styleTable )
246
256
247
257
void QgsVectorLayerLoadStyleDialog::accept ()
248
258
{
249
- QgsSettings ().setFlagValue ( QStringLiteral ( " style/lastStyleCategories" ), styleCategories () );
259
+ QgsSettings settings;
260
+ settings.setFlagValue ( QStringLiteral ( " style/lastStyleCategories" ), styleCategories () );
261
+ settings.setValue ( QStringLiteral ( " style/lastLoadStyleTypeSelection" ), currentStyleType () );
250
262
QDialog::accept ();
251
263
}
252
264
@@ -274,7 +286,7 @@ void QgsVectorLayerLoadStyleDialog::deleteStyleFromDB()
274
286
mRelatedTable ->setRowCount ( 0 );
275
287
mOthersTable ->setRowCount ( 0 );
276
288
277
- // Fill UI widgets again from DB. Other users might have change the styles meanwhile.
289
+ // Fill UI widgets again from DB. Other users might have changed the styles meanwhile.
278
290
QString errorMsg;
279
291
QStringList ids, names, descriptions;
280
292
// get the list of styles in the db
0 commit comments