Skip to content
Permalink
Browse files

Merge pull request #4956 from jgrocha/profilemenu

Fix #16970 (related to PR#4184)
  • Loading branch information
elpaso committed Aug 4, 2017
2 parents 21653c0 + 511521f commit 34ef954edcc29d8b7bfabc80f1a6c5a38c69b0ae
Showing with 19 additions and 25 deletions.
  1. +19 −25 src/app/qgisapp.cpp
@@ -2298,49 +2298,43 @@ void QgisApp::refreshProfileMenu()
QString activeName = profile->name();
mConfigMenu->setTitle( tr( "&User Profiles" ) );

mConfigMenu->addAction( new QgsMenuHeaderWidgetAction( tr( "Active Profile" ), mConfigMenu ) );

mConfigMenu->addAction( new QgsMenuHeaderWidgetAction( tr( "Profiles" ), mConfigMenu ) );
QAction *profileSection = mConfigMenu->actions().at( 1 );

mConfigMenu->addAction( new QgsMenuHeaderWidgetAction( tr( "Config" ), mConfigMenu ) );
QAction *configSection = mConfigMenu->actions().at( 2 );

QAction *openProfileFolderAction = mConfigMenu->addAction( tr( "Open active profile folder" ) );
connect( openProfileFolderAction, &QAction::triggered, this, [this]()
{
QDesktopServices::openUrl( QUrl::fromLocalFile( userProfileManager()->userProfile()->folder() ) );
} );

QAction *newProfileAction = mConfigMenu->addAction( tr( "New profile" ) );
connect( newProfileAction, &QAction::triggered, this, &QgisApp::newProfile );
QActionGroup *profileGroup = new QActionGroup( this );
profileGroup->setExclusive( true );

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() );
action->setCheckable( true );
profileGroup->addAction( action );
mConfigMenu->addAction( action );
delete profile;

if ( name == activeName )
{
mConfigMenu->insertAction( profileSection, action );
action->setChecked( true );
}
else
{
mConfigMenu->insertAction( configSection, action );
connect( action, &QAction::triggered, this, [this, name]()
{
userProfileManager()->loadUserProfile( name );
} );
}
connect( action, &QAction::triggered, this, [this, name]()
{
userProfileManager()->loadUserProfile( name );
} );
}

if ( userProfileManager()->allProfiles().count() == 1 )
mConfigMenu->addSeparator( );

QAction *openProfileFolderAction = mConfigMenu->addAction( tr( "Open active profile folder" ) );
connect( openProfileFolderAction, &QAction::triggered, this, [this]()
{
profileSection->setVisible( false );
}
QDesktopServices::openUrl( QUrl::fromLocalFile( userProfileManager()->userProfile()->folder() ) );
} );

QAction *newProfileAction = mConfigMenu->addAction( tr( "New profile" ) );
connect( newProfileAction, &QAction::triggered, this, &QgisApp::newProfile );
}

void QgisApp::createProfileMenu()

0 comments on commit 34ef954

Please sign in to comment.
You can’t perform that action at this time.