Skip to content

Commit 34ef954

Browse files
authored
Merge pull request #4956 from jgrocha/profilemenu
Fix #16970 (related to PR#4184)
2 parents 21653c0 + 511521f commit 34ef954

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

src/app/qgisapp.cpp

+19-25
Original file line numberDiff line numberDiff line change
@@ -2298,49 +2298,43 @@ void QgisApp::refreshProfileMenu()
22982298
QString activeName = profile->name();
22992299
mConfigMenu->setTitle( tr( "&User Profiles" ) );
23002300

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 );
23172303

23182304
Q_FOREACH ( const QString &name, userProfileManager()->allProfiles() )
23192305
{
23202306
profile = userProfileManager()->profileForName( name );
23212307
// Qt 5.5 has no parent default as nullptr
23222308
QAction *action = new QAction( profile->icon(), profile->alias(), nullptr );
23232309
action->setToolTip( profile->folder() );
2310+
action->setCheckable( true );
2311+
profileGroup->addAction( action );
2312+
mConfigMenu->addAction( action );
23242313
delete profile;
23252314

23262315
if ( name == activeName )
23272316
{
2328-
mConfigMenu->insertAction( profileSection, action );
2317+
action->setChecked( true );
23292318
}
23302319
else
23312320
{
2332-
mConfigMenu->insertAction( configSection, action );
2321+
connect( action, &QAction::triggered, this, [this, name]()
2322+
{
2323+
userProfileManager()->loadUserProfile( name );
2324+
} );
23332325
}
2334-
connect( action, &QAction::triggered, this, [this, name]()
2335-
{
2336-
userProfileManager()->loadUserProfile( name );
2337-
} );
23382326
}
23392327

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]()
23412332
{
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 );
23442338
}
23452339

23462340
void QgisApp::createProfileMenu()

0 commit comments

Comments
 (0)