mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
Merge pull request #4956 from jgrocha/profilemenu
Fix #16970 (related to PR#4184)
This commit is contained in:
commit
34ef954edc
@ -2298,13 +2298,34 @@ void QgisApp::refreshProfileMenu()
|
|||||||
QString activeName = profile->name();
|
QString activeName = profile->name();
|
||||||
mConfigMenu->setTitle( tr( "&User Profiles" ) );
|
mConfigMenu->setTitle( tr( "&User Profiles" ) );
|
||||||
|
|
||||||
mConfigMenu->addAction( new QgsMenuHeaderWidgetAction( tr( "Active Profile" ), mConfigMenu ) );
|
QActionGroup *profileGroup = new QActionGroup( this );
|
||||||
|
profileGroup->setExclusive( true );
|
||||||
|
|
||||||
mConfigMenu->addAction( new QgsMenuHeaderWidgetAction( tr( "Profiles" ), mConfigMenu ) );
|
Q_FOREACH ( const QString &name, userProfileManager()->allProfiles() )
|
||||||
QAction *profileSection = mConfigMenu->actions().at( 1 );
|
{
|
||||||
|
profile = userProfileManager()->profileForName( name );
|
||||||
|
// Qt 5.5 has no parent default as nullptr
|
||||||
|
QAction *action = new QAction( profile->icon(), profile->alias(), nullptr );
|
||||||
|
action->setToolTip( profile->folder() );
|
||||||
|
action->setCheckable( true );
|
||||||
|
profileGroup->addAction( action );
|
||||||
|
mConfigMenu->addAction( action );
|
||||||
|
delete profile;
|
||||||
|
|
||||||
mConfigMenu->addAction( new QgsMenuHeaderWidgetAction( tr( "Config" ), mConfigMenu ) );
|
if ( name == activeName )
|
||||||
QAction *configSection = mConfigMenu->actions().at( 2 );
|
{
|
||||||
|
action->setChecked( true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
connect( action, &QAction::triggered, this, [this, name]()
|
||||||
|
{
|
||||||
|
userProfileManager()->loadUserProfile( name );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mConfigMenu->addSeparator( );
|
||||||
|
|
||||||
QAction *openProfileFolderAction = mConfigMenu->addAction( tr( "Open active profile folder" ) );
|
QAction *openProfileFolderAction = mConfigMenu->addAction( tr( "Open active profile folder" ) );
|
||||||
connect( openProfileFolderAction, &QAction::triggered, this, [this]()
|
connect( openProfileFolderAction, &QAction::triggered, this, [this]()
|
||||||
@ -2314,33 +2335,6 @@ void QgisApp::refreshProfileMenu()
|
|||||||
|
|
||||||
QAction *newProfileAction = mConfigMenu->addAction( tr( "New profile" ) );
|
QAction *newProfileAction = mConfigMenu->addAction( tr( "New profile" ) );
|
||||||
connect( newProfileAction, &QAction::triggered, this, &QgisApp::newProfile );
|
connect( newProfileAction, &QAction::triggered, this, &QgisApp::newProfile );
|
||||||
|
|
||||||
Q_FOREACH ( const QString &name, userProfileManager()->allProfiles() )
|
|
||||||
{
|
|
||||||
profile = userProfileManager()->profileForName( name );
|
|
||||||
// Qt 5.5 has no parent default as nullptr
|
|
||||||
QAction *action = new QAction( profile->icon(), profile->alias(), nullptr );
|
|
||||||
action->setToolTip( profile->folder() );
|
|
||||||
delete profile;
|
|
||||||
|
|
||||||
if ( name == activeName )
|
|
||||||
{
|
|
||||||
mConfigMenu->insertAction( profileSection, action );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mConfigMenu->insertAction( configSection, action );
|
|
||||||
}
|
|
||||||
connect( action, &QAction::triggered, this, [this, name]()
|
|
||||||
{
|
|
||||||
userProfileManager()->loadUserProfile( name );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( userProfileManager()->allProfiles().count() == 1 )
|
|
||||||
{
|
|
||||||
profileSection->setVisible( false );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgisApp::createProfileMenu()
|
void QgisApp::createProfileMenu()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user