mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Apply suggestions from review
This commit is contained in:
parent
a905b1a994
commit
99f453344d
@ -29,13 +29,6 @@ A user profile is all settings and anything that used to be found in .qgis3 in t
|
||||
%End
|
||||
public:
|
||||
|
||||
enum UserProfileSelectionPolicy
|
||||
{
|
||||
LastProfile,
|
||||
DefaultProfile,
|
||||
AskUser,
|
||||
};
|
||||
|
||||
QgsUserProfileManager( const QString &rootLocation = QString(), QObject *parent = 0 );
|
||||
%Docstring
|
||||
User profile manager used to manage user profiles for the instance of QGIS.
|
||||
@ -152,57 +145,25 @@ Set the default profile name from the current active profile.
|
||||
|
||||
QString lastProfileName() const;
|
||||
%Docstring
|
||||
Returns the name of the lastly closed profile. Empty if its the first time QGIS has been run.
|
||||
Returns the name of the most recently closed profile. Empty if its the first time QGIS has been run.
|
||||
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
|
||||
UserProfileSelectionPolicy userProfileSelectionPolicy() const;
|
||||
Qgis::UserProfileSelectionPolicy userProfileSelectionPolicy() const;
|
||||
%Docstring
|
||||
Returns the user profile selection policy.
|
||||
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
void setUserProfileSelectionPolicy( UserProfileSelectionPolicy policy );
|
||||
void setUserProfileSelectionPolicy( Qgis::UserProfileSelectionPolicy policy );
|
||||
%Docstring
|
||||
Sets the user profile selection policy.
|
||||
|
||||
:param policy: The policy to use when selecting a user profile.
|
||||
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
int profileSelectorIconSize() const;
|
||||
%Docstring
|
||||
Returns the icon size for the profile selector.
|
||||
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
void setProfileSelectorIconSize( int size );
|
||||
%Docstring
|
||||
Sets the icon size for the profile selector.
|
||||
|
||||
:param size: The size of the icon in pixels.
|
||||
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
bool profileSelectorProfileCreationAllowed() const;
|
||||
%Docstring
|
||||
Returns whether the profile selector should allow the creation of new profiles.
|
||||
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
void setProfileSelectorProfileCreationAllowed( bool allow );
|
||||
%Docstring
|
||||
Sets whether the profile selector should allow the creation of new profiles.
|
||||
|
||||
:param allow: ``True`` if new profiles should be allowed.
|
||||
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
|
||||
@ -1032,7 +1032,7 @@ int main( int argc, char *argv[] )
|
||||
switch ( manager.userProfileSelectionPolicy() )
|
||||
{
|
||||
// Use the last closed profile (default behavior prior to QGIS 3.32)
|
||||
case QgsUserProfileManager::UserProfileSelectionPolicy::LastProfile:
|
||||
case Qgis::UserProfileSelectionPolicy::LastProfile:
|
||||
profileName = manager.lastProfileName();
|
||||
// If last used profile no longer exists, use the default profile
|
||||
if ( !manager.profileExists( profileName ) )
|
||||
@ -1042,7 +1042,7 @@ int main( int argc, char *argv[] )
|
||||
break;
|
||||
|
||||
// Ask the user to select a profile (if more than one exists)
|
||||
case QgsUserProfileManager::UserProfileSelectionPolicy::AskUser:
|
||||
case Qgis::UserProfileSelectionPolicy::AskUser:
|
||||
{
|
||||
if ( manager.allProfiles().size() == 1 )
|
||||
{
|
||||
@ -1063,8 +1063,7 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
|
||||
// Use the default profile
|
||||
case QgsUserProfileManager::UserProfileSelectionPolicy::DefaultProfile:
|
||||
default:
|
||||
case Qgis::UserProfileSelectionPolicy::DefaultProfile:
|
||||
profileName = manager.defaultProfileName();
|
||||
break;
|
||||
}
|
||||
@ -1077,8 +1076,6 @@ int main( int argc, char *argv[] )
|
||||
profileName = profile->name();
|
||||
delete profile;
|
||||
|
||||
|
||||
|
||||
{
|
||||
// The profile is selected, we can now set up the translation file for QGIS.
|
||||
QString myUserTranslation = QgsApplication::settingsLocaleUserLocale->value();
|
||||
|
||||
@ -29,7 +29,7 @@ QgsUserProfileOptionsWidget::QgsUserProfileOptionsWidget( QWidget *parent )
|
||||
{
|
||||
setupUi( this );
|
||||
|
||||
auto manager = QgisApp::instance()->userProfileManager();
|
||||
QgsUserProfileManager *manager = QgisApp::instance()->userProfileManager();
|
||||
|
||||
// Disable combobox if default profile is not selected
|
||||
mDefaultProfileComboBox->setEnabled( false );
|
||||
@ -40,17 +40,12 @@ QgsUserProfileOptionsWidget::QgsUserProfileOptionsWidget( QWidget *parent )
|
||||
connect( mAskUser, &QRadioButton::toggled, mProfileSelectorGroupBox, &QGroupBox::setEnabled );
|
||||
|
||||
// Connect icon size and allow profile creation
|
||||
mIconSize->setCurrentText( QString::number( manager->profileSelectorIconSize() ) );
|
||||
mAllowProfileCreation->setChecked( manager->profileSelectorProfileCreationAllowed() );
|
||||
mIconSize->setCurrentText( QString::number( QSettings().value( QStringLiteral( "/selector/iconSize" ), 24 ).toInt() ) );
|
||||
connect( mIconSize, &QComboBox::currentTextChanged, this, []( const QString & text )
|
||||
{
|
||||
auto manager = QgisApp::instance()->userProfileManager();
|
||||
manager->setProfileSelectorIconSize( text.toInt() );
|
||||
} );
|
||||
connect( mAllowProfileCreation, &QCheckBox::toggled, this, []( bool checked )
|
||||
{
|
||||
auto manager = QgisApp::instance()->userProfileManager();
|
||||
manager->setProfileSelectorProfileCreationAllowed( checked );
|
||||
QSettings settings;
|
||||
settings.setValue( QStringLiteral( "/selector/iconSize" ), text.toInt() );
|
||||
settings.sync();
|
||||
} );
|
||||
|
||||
// Connect change icon button
|
||||
@ -58,22 +53,22 @@ QgsUserProfileOptionsWidget::QgsUserProfileOptionsWidget( QWidget *parent )
|
||||
connect( mResetIconButton, &QToolButton::clicked, this, &QgsUserProfileOptionsWidget::onResetIconClicked );
|
||||
|
||||
// Init radio buttons
|
||||
if ( manager->userProfileSelectionPolicy() == QgsUserProfileManager::UserProfileSelectionPolicy::LastProfile )
|
||||
if ( manager->userProfileSelectionPolicy() == Qgis::UserProfileSelectionPolicy::LastProfile )
|
||||
{
|
||||
mLastProfile->setChecked( true );
|
||||
}
|
||||
else if ( manager->userProfileSelectionPolicy() == QgsUserProfileManager::UserProfileSelectionPolicy::AskUser )
|
||||
else if ( manager->userProfileSelectionPolicy() == Qgis::UserProfileSelectionPolicy::AskUser )
|
||||
{
|
||||
mAskUser->setChecked( true );
|
||||
}
|
||||
else if ( manager->userProfileSelectionPolicy() == QgsUserProfileManager::UserProfileSelectionPolicy::DefaultProfile )
|
||||
else if ( manager->userProfileSelectionPolicy() == Qgis::UserProfileSelectionPolicy::DefaultProfile )
|
||||
{
|
||||
mDefaultProfile->setChecked( true );
|
||||
}
|
||||
|
||||
// Fill combobox with profiles
|
||||
mDefaultProfileComboBox->clear();
|
||||
for ( auto profile : manager->allProfiles() )
|
||||
for ( const QString &profile : manager->allProfiles() )
|
||||
{
|
||||
QIcon icon = manager->profileForName( profile )->icon();
|
||||
mDefaultProfileComboBox->addItem( icon, profile );
|
||||
@ -87,26 +82,26 @@ QgsUserProfileOptionsWidget::QgsUserProfileOptionsWidget( QWidget *parent )
|
||||
|
||||
void QgsUserProfileOptionsWidget::apply()
|
||||
{
|
||||
auto manager = QgisApp::instance()->userProfileManager();
|
||||
QgsUserProfileManager *manager = QgisApp::instance()->userProfileManager();
|
||||
if ( mLastProfile->isChecked() )
|
||||
{
|
||||
manager->setUserProfileSelectionPolicy( QgsUserProfileManager::UserProfileSelectionPolicy::LastProfile );
|
||||
manager->setUserProfileSelectionPolicy( Qgis::UserProfileSelectionPolicy::LastProfile );
|
||||
}
|
||||
else if ( mAskUser->isChecked() )
|
||||
{
|
||||
manager->setUserProfileSelectionPolicy( QgsUserProfileManager::UserProfileSelectionPolicy::AskUser );
|
||||
manager->setUserProfileSelectionPolicy( Qgis::UserProfileSelectionPolicy::AskUser );
|
||||
}
|
||||
else if ( mDefaultProfile->isChecked() )
|
||||
{
|
||||
manager->setUserProfileSelectionPolicy( QgsUserProfileManager::UserProfileSelectionPolicy::DefaultProfile );
|
||||
manager->setUserProfileSelectionPolicy( Qgis::UserProfileSelectionPolicy::DefaultProfile );
|
||||
manager->setDefaultProfileName( mDefaultProfileComboBox->currentText() );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsUserProfileOptionsWidget::onChangeIconClicked()
|
||||
{
|
||||
auto activeProfile = QgisApp::instance()->userProfileManager()->userProfile();
|
||||
const QString iconPath = QFileDialog::getOpenFileName( this, tr( "Select icon" ), "", tr( "Images (*.png *.jpg *.jpeg *.gif *.bmp *.svg)" ) );
|
||||
const QgsUserProfile *activeProfile = QgisApp::instance()->userProfileManager()->userProfile();
|
||||
const QString iconPath = QFileDialog::getOpenFileName( this, tr( "Select Icon" ), "", tr( "Images (*.png *.jpg *.jpeg *.gif *.bmp *.svg)" ) );
|
||||
if ( !iconPath.isEmpty() )
|
||||
{
|
||||
// Remove existing icon files
|
||||
@ -129,7 +124,7 @@ void QgsUserProfileOptionsWidget::onChangeIconClicked()
|
||||
|
||||
void QgsUserProfileOptionsWidget::onResetIconClicked()
|
||||
{
|
||||
auto activeProfile = QgisApp::instance()->userProfileManager()->userProfile();
|
||||
const QgsUserProfile *activeProfile = QgisApp::instance()->userProfileManager()->userProfile();
|
||||
// Remove existing icon files
|
||||
QDir dir( activeProfile->folder(), "icon.*", QDir::Name, QDir::Files );
|
||||
for ( const QString &file : dir.entryList() )
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include <QListWidgetItem>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
|
||||
#include "qgsapplication.h"
|
||||
#include "qgsuserprofilemanager.h"
|
||||
@ -34,16 +35,11 @@ QgsUserProfileSelectionDialog::QgsUserProfileSelectionDialog( QgsUserProfileMana
|
||||
connect( mProfileListWidget, &QListWidget::itemDoubleClicked, this, &QgsUserProfileSelectionDialog::accept );
|
||||
|
||||
// Add a new profile on button click
|
||||
if ( mManager->profileSelectorProfileCreationAllowed() )
|
||||
{
|
||||
connect( mAddProfileButton, &QPushButton::clicked, this, &QgsUserProfileSelectionDialog::onAddProfile );
|
||||
}
|
||||
else
|
||||
{
|
||||
mAddProfileButton->hide();
|
||||
}
|
||||
connect( mAddProfileButton, &QPushButton::clicked, this, &QgsUserProfileSelectionDialog::onAddProfile );
|
||||
|
||||
mProfileListWidget->setIconSize( QSize( mManager->profileSelectorIconSize(), mManager->profileSelectorIconSize() ) );
|
||||
QSettings settings;
|
||||
int iconSize = settings.value( QStringLiteral( "/selector/iconSize" ), 24 ).toInt();
|
||||
mProfileListWidget->setIconSize( QSize( iconSize, iconSize ) );
|
||||
|
||||
// Fill the list of profiles
|
||||
mProfileListWidget->clear(); // Clear bogus profiles in the Ui form
|
||||
@ -82,7 +78,7 @@ void QgsUserProfileSelectionDialog::onAddProfile()
|
||||
dlg.setConflictingNameWarning( tr( "A profile with this name already exists" ) );
|
||||
dlg.setOverwriteEnabled( false );
|
||||
dlg.setHintString( tr( "New profile name" ) );
|
||||
dlg.setWindowTitle( tr( "New profile name" ) );
|
||||
dlg.setWindowTitle( tr( "New Profile Name" ) );
|
||||
|
||||
// Prevent from entering slashes and backslashes
|
||||
dlg.setRegularExpression( "[^/\\\\]+" );
|
||||
|
||||
@ -15672,7 +15672,7 @@ void QgisApp::newProfile()
|
||||
dlg.setConflictingNameWarning( tr( "A profile with this name already exists" ) );
|
||||
dlg.setOverwriteEnabled( false );
|
||||
dlg.setHintString( tr( "New profile name" ) );
|
||||
dlg.setWindowTitle( tr( "New profile name" ) );
|
||||
dlg.setWindowTitle( tr( "New Profile Name" ) );
|
||||
|
||||
// Prevent from entering slashes and backslashes
|
||||
dlg.setRegularExpression( "[^/\\\\]+" );
|
||||
|
||||
@ -3415,6 +3415,19 @@ class CORE_EXPORT Qgis
|
||||
Q_DECLARE_FLAGS( DatabaseProviderConnectionCapabilities2, DatabaseProviderConnectionCapability2 )
|
||||
Q_FLAG( DatabaseProviderConnectionCapabilities2 )
|
||||
|
||||
/**
|
||||
* User profile selection policy.
|
||||
*
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
enum class UserProfileSelectionPolicy : int
|
||||
{
|
||||
LastProfile, //!< Open the last closed profile (only mode supported prior to QGIS 3.32)
|
||||
DefaultProfile, //!< Open a specific profile
|
||||
AskUser, //!< Let the user choose which profile to open
|
||||
};
|
||||
Q_ENUM( UserProfileSelectionPolicy )
|
||||
|
||||
/**
|
||||
* Identify search radius in mm
|
||||
* \since QGIS 2.3
|
||||
|
||||
@ -128,41 +128,17 @@ void QgsUserProfileManager::updateLastProfileName( )
|
||||
mSettings->sync();
|
||||
}
|
||||
|
||||
QgsUserProfileManager::UserProfileSelectionPolicy QgsUserProfileManager::userProfileSelectionPolicy() const
|
||||
Qgis::UserProfileSelectionPolicy QgsUserProfileManager::userProfileSelectionPolicy() const
|
||||
{
|
||||
return static_cast< UserProfileSelectionPolicy >( mSettings->value( QStringLiteral( "/core/selectionPolicy" ), 0 ).toInt() );
|
||||
return static_cast< Qgis::UserProfileSelectionPolicy >( mSettings->value( QStringLiteral( "/core/selectionPolicy" ), 0 ).toInt() );
|
||||
}
|
||||
|
||||
void QgsUserProfileManager::setUserProfileSelectionPolicy( QgsUserProfileManager::UserProfileSelectionPolicy policy )
|
||||
void QgsUserProfileManager::setUserProfileSelectionPolicy( Qgis::UserProfileSelectionPolicy policy )
|
||||
{
|
||||
mSettings->setValue( QStringLiteral( "/core/selectionPolicy" ), static_cast< int >( policy ) );
|
||||
mSettings->sync();
|
||||
}
|
||||
|
||||
int QgsUserProfileManager::profileSelectorIconSize() const
|
||||
{
|
||||
return mSettings->value( QStringLiteral( "/selector/iconSize" ), 24 ).toInt();
|
||||
}
|
||||
|
||||
void QgsUserProfileManager::setProfileSelectorIconSize( int size )
|
||||
{
|
||||
mSettings->setValue( QStringLiteral( "/selector/iconSize" ), size );
|
||||
mSettings->sync();
|
||||
}
|
||||
|
||||
bool QgsUserProfileManager::profileSelectorProfileCreationAllowed() const
|
||||
{
|
||||
return mSettings->value( QStringLiteral( "/selector/allowCreation" ), true ).toBool();
|
||||
}
|
||||
|
||||
void QgsUserProfileManager::setProfileSelectorProfileCreationAllowed( bool allow )
|
||||
{
|
||||
mSettings->setValue( QStringLiteral( "/selector/allowCreation" ), allow );
|
||||
mSettings->sync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
QStringList QgsUserProfileManager::allProfiles() const
|
||||
{
|
||||
return QDir( mRootProfilePath ).entryList( QDir::Dirs | QDir::NoDotAndDotDot );
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include <QFileSystemWatcher>
|
||||
|
||||
|
||||
#include "qgis.h"
|
||||
#include "qgis_sip.h"
|
||||
#include "qgis_core.h"
|
||||
#include "qgserror.h"
|
||||
@ -44,18 +45,6 @@ class CORE_EXPORT QgsUserProfileManager : public QObject
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* User profile selection policy.
|
||||
*
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
enum UserProfileSelectionPolicy
|
||||
{
|
||||
LastProfile = 0, //!< Open the last closed profile (only mode supported prior to QGIS 3.32)
|
||||
DefaultProfile, //!< Open a specific profile
|
||||
AskUser, //!< Let the user choose which profile to open
|
||||
};
|
||||
|
||||
/**
|
||||
* User profile manager used to manage user profiles for the instance of QGIS.
|
||||
*/
|
||||
@ -155,7 +144,7 @@ class CORE_EXPORT QgsUserProfileManager : public QObject
|
||||
void setDefaultFromActive();
|
||||
|
||||
/**
|
||||
* Returns the name of the lastly closed profile. Empty if its the first time QGIS has been run.
|
||||
* Returns the name of the most recently closed profile. Empty if its the first time QGIS has been run.
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
QString lastProfileName() const;
|
||||
@ -167,43 +156,17 @@ class CORE_EXPORT QgsUserProfileManager : public QObject
|
||||
void updateLastProfileName() SIP_SKIP;
|
||||
|
||||
/**
|
||||
* Returns the user profile selection policy.
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
UserProfileSelectionPolicy userProfileSelectionPolicy() const;
|
||||
|
||||
/**
|
||||
* Sets the user profile selection policy.
|
||||
* \param policy The policy to use when selecting a user profile.
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
void setUserProfileSelectionPolicy( UserProfileSelectionPolicy policy );
|
||||
|
||||
/**
|
||||
* Returns the icon size for the profile selector.
|
||||
* Returns the user profile selection policy.
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
int profileSelectorIconSize() const;
|
||||
Qgis::UserProfileSelectionPolicy userProfileSelectionPolicy() const;
|
||||
|
||||
/**
|
||||
* Sets the icon size for the profile selector.
|
||||
* \param size The size of the icon in pixels.
|
||||
* Sets the user profile selection policy.
|
||||
* \param policy The policy to use when selecting a user profile.
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
void setProfileSelectorIconSize( int size );
|
||||
|
||||
/**
|
||||
* Returns whether the profile selector should allow the creation of new profiles.
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
bool profileSelectorProfileCreationAllowed() const;
|
||||
|
||||
/**
|
||||
* Sets whether the profile selector should allow the creation of new profiles.
|
||||
* \param allow TRUE if new profiles should be allowed.
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
void setProfileSelectorProfileCreationAllowed( bool allow );
|
||||
void setUserProfileSelectionPolicy( Qgis::UserProfileSelectionPolicy policy );
|
||||
|
||||
/**
|
||||
* Returns the profile found for a given name.
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
<item>
|
||||
<widget class="QGroupBox" name="mProfilePolicyGroupBox">
|
||||
<property name="title">
|
||||
<string>Which profile should be used when QGIS starts ?</string>
|
||||
<string>Startup Profile</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="5" column="0" colspan="2">
|
||||
@ -79,21 +79,14 @@
|
||||
<string>Profile Selector</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="mAllowProfileCreation">
|
||||
<property name="text">
|
||||
<string>Let user create a new profile when starting QGIS</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="mIconSizeLabel">
|
||||
<property name="text">
|
||||
<string>Icon size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="mIconSize">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
@ -212,7 +205,6 @@
|
||||
<tabstop>mDefaultProfileComboBox</tabstop>
|
||||
<tabstop>mAskUser</tabstop>
|
||||
<tabstop>mChangeIconButton</tabstop>
|
||||
<tabstop>mAllowProfileCreation</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../../images/images.qrc"/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user