@@ -2298,49 +2298,43 @@ void QgisApp::refreshProfileMenu()
2298
2298
QString activeName = profile->name ();
2299
2299
mConfigMenu ->setTitle ( tr ( " &User Profiles" ) );
2300
2300
2301
- mConfigMenu ->addAction ( new QgsMenuHeaderWidgetAction ( tr ( " Active Profile" ), mConfigMenu ) );
2302
-
2303
- mConfigMenu ->addAction ( new QgsMenuHeaderWidgetAction ( tr ( " Profiles" ), mConfigMenu ) );
2304
- QAction *profileSection = mConfigMenu ->actions ().at ( 1 );
2305
-
2306
- mConfigMenu ->addAction ( new QgsMenuHeaderWidgetAction ( tr ( " Config" ), mConfigMenu ) );
2307
- QAction *configSection = mConfigMenu ->actions ().at ( 2 );
2308
-
2309
- QAction *openProfileFolderAction = mConfigMenu ->addAction ( tr ( " Open active profile folder" ) );
2310
- connect ( openProfileFolderAction, &QAction::triggered, this , [this ]()
2311
- {
2312
- QDesktopServices::openUrl ( QUrl::fromLocalFile ( userProfileManager ()->userProfile ()->folder () ) );
2313
- } );
2314
-
2315
- QAction *newProfileAction = mConfigMenu ->addAction ( tr ( " New profile" ) );
2316
- connect ( newProfileAction, &QAction::triggered, this , &QgisApp::newProfile );
2301
+ QActionGroup *profileGroup = new QActionGroup ( this );
2302
+ profileGroup->setExclusive ( true );
2317
2303
2318
2304
Q_FOREACH ( const QString &name, userProfileManager ()->allProfiles () )
2319
2305
{
2320
2306
profile = userProfileManager ()->profileForName ( name );
2321
2307
// Qt 5.5 has no parent default as nullptr
2322
2308
QAction *action = new QAction ( profile->icon (), profile->alias (), nullptr );
2323
2309
action->setToolTip ( profile->folder () );
2310
+ action->setCheckable ( true );
2311
+ profileGroup->addAction ( action );
2312
+ mConfigMenu ->addAction ( action );
2324
2313
delete profile;
2325
2314
2326
2315
if ( name == activeName )
2327
2316
{
2328
- mConfigMenu -> insertAction ( profileSection, action );
2317
+ action-> setChecked ( true );
2329
2318
}
2330
2319
else
2331
2320
{
2332
- mConfigMenu ->insertAction ( configSection, action );
2321
+ connect ( action, &QAction::triggered, this , [this , name]()
2322
+ {
2323
+ userProfileManager ()->loadUserProfile ( name );
2324
+ } );
2333
2325
}
2334
- connect ( action, &QAction::triggered, this , [this , name]()
2335
- {
2336
- userProfileManager ()->loadUserProfile ( name );
2337
- } );
2338
2326
}
2339
2327
2340
- if ( userProfileManager ()->allProfiles ().count () == 1 )
2328
+ mConfigMenu ->addSeparator ( );
2329
+
2330
+ QAction *openProfileFolderAction = mConfigMenu ->addAction ( tr ( " Open active profile folder" ) );
2331
+ connect ( openProfileFolderAction, &QAction::triggered, this , [this ]()
2341
2332
{
2342
- profileSection->setVisible ( false );
2343
- }
2333
+ QDesktopServices::openUrl ( QUrl::fromLocalFile ( userProfileManager ()->userProfile ()->folder () ) );
2334
+ } );
2335
+
2336
+ QAction *newProfileAction = mConfigMenu ->addAction ( tr ( " New profile" ) );
2337
+ connect ( newProfileAction, &QAction::triggered, this , &QgisApp::newProfile );
2344
2338
}
2345
2339
2346
2340
void QgisApp::createProfileMenu ()
0 commit comments