Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add User Settings dialog
- Loading branch information
1 parent
e1b6d8f
commit 7b5f745
Showing
6 changed files
with
264 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/*************************************************************************** | ||
qgsuserprofilesettingsdialog.cpp | ||
-------------------------------------- | ||
Date : February 2023 | ||
Copyright : (C) 2023 by Yoann Quenach de Quivillic | ||
Email : yoann dot quenach at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgisapp.h" | ||
#include "qgsuserprofilemanager.h" | ||
|
||
#include "qgsuserprofilesettingsdialog.h" | ||
|
||
|
||
QgsUserProfileSettingsDialog::QgsUserProfileSettingsDialog( QWidget *parent ) | ||
: QDialog( parent ) | ||
|
||
{ | ||
setupUi( this ); | ||
connect( mDefaultProfile, &QRadioButton::toggled, mDefaultProfileComboBox, &QComboBox::setEnabled ); | ||
connect( mButtonBox, &QDialogButtonBox::accepted, this, &QgsUserProfileSettingsDialog::apply ); | ||
|
||
// Init radio buttons | ||
auto manager = QgisApp::instance()->userProfileManager(); | ||
if ( manager->userProfileSelectionPolicy() == QgsUserProfileManager::UserProfileSelectionPolicy::LastProfile ) | ||
{ | ||
mLastProfile->setChecked( true ); | ||
} | ||
else if ( manager->userProfileSelectionPolicy() == QgsUserProfileManager::UserProfileSelectionPolicy::AskUser ) | ||
{ | ||
mAskUser->setChecked( true ); | ||
} | ||
else if ( manager->userProfileSelectionPolicy() == QgsUserProfileManager::UserProfileSelectionPolicy::DefaultProfile ) | ||
{ | ||
mDefaultProfile->setChecked( true ); | ||
} | ||
|
||
// Fill combobox with profiles | ||
mDefaultProfileComboBox->clear(); | ||
mDefaultProfileComboBox->addItems( manager->allProfiles() ); | ||
mDefaultProfileComboBox->setCurrentText( manager->defaultProfileName() ); | ||
|
||
} | ||
|
||
void QgsUserProfileSettingsDialog::apply() | ||
{ | ||
auto manager = QgisApp::instance()->userProfileManager(); | ||
if ( mLastProfile->isChecked() ) | ||
{ | ||
manager->setUserProfileSelectionPolicy( QgsUserProfileManager::UserProfileSelectionPolicy::LastProfile ); | ||
} | ||
else if ( mAskUser->isChecked() ) | ||
{ | ||
manager->setUserProfileSelectionPolicy( QgsUserProfileManager::UserProfileSelectionPolicy::AskUser ); | ||
} | ||
else if ( mDefaultProfile->isChecked() ) | ||
{ | ||
manager->setUserProfileSelectionPolicy( QgsUserProfileManager::UserProfileSelectionPolicy::DefaultProfile ); | ||
manager->setDefaultProfileName( mDefaultProfileComboBox->currentText() ); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/*************************************************************************** | ||
qgsuserprofilesettingsdialog.h | ||
-------------------------------------- | ||
Date : February 2023 | ||
Copyright : (C) 2023 by Yoann Quenach de Quivillic | ||
Email : yoann dot quenach at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSUSERPROFILESETTINGSDIALOG_H | ||
#define QGSUSERPROFILESETTINGSDIALOG_H | ||
|
||
#include <QDialog> | ||
#include "ui_qgsuserprofilesettingsdialog.h" | ||
|
||
/** | ||
* \class QgsUserProfileSettingsDialog | ||
* \brief A dialog displaying user profile policy settings (open last closed profile, open specific, let user choose) | ||
* \since QGIS 3.32 | ||
*/ | ||
class QgsUserProfileSettingsDialog : public QDialog, private Ui::QgsUserProfileSettingsDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
/** | ||
* Constructor for QgsUserProfileSettingsDialog. | ||
* \param parent parent widget | ||
*/ | ||
explicit QgsUserProfileSettingsDialog( QWidget *parent = nullptr ); | ||
virtual ~QgsUserProfileSettingsDialog() = default; | ||
|
||
public slots: | ||
|
||
/** | ||
* Apply changes | ||
*/ | ||
void apply(); | ||
|
||
|
||
}; | ||
|
||
#endif // QGSUSERPROFILESETTINGSDIALOG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>QgsUserProfileSettingsDialog</class> | ||
<widget class="QDialog" name="QgsUserProfileSettingsDialog"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>412</width> | ||
<height>226</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>User Profile Settings</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout_2"> | ||
<item> | ||
<widget class="QGroupBox" name="groupBox"> | ||
<property name="title"> | ||
<string>Which profile should be used when QGIS starts ?</string> | ||
</property> | ||
<layout class="QGridLayout" name="gridLayout"> | ||
<item row="2" column="0"> | ||
<widget class="QRadioButton" name="mDefaultProfile"> | ||
<property name="text"> | ||
<string>Always use profile</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="2" column="1"> | ||
<widget class="QComboBox" name="mDefaultProfileComboBox"/> | ||
</item> | ||
<item row="4" column="0" colspan="2"> | ||
<widget class="QLabel" name="label"> | ||
<property name="font"> | ||
<font> | ||
<pointsize>9</pointsize> | ||
<italic>true</italic> | ||
</font> | ||
</property> | ||
<property name="text"> | ||
<string>These settings do not apply if a profile was explicitely selected with the --profile command line argument</string> | ||
</property> | ||
<property name="textFormat"> | ||
<enum>Qt::PlainText</enum> | ||
</property> | ||
<property name="wordWrap"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="0"> | ||
<widget class="QRadioButton" name="mLastProfile"> | ||
<property name="text"> | ||
<string>Use last closed profile</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="3" column="0"> | ||
<spacer name="verticalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>20</width> | ||
<height>40</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item row="1" column="0" colspan="2"> | ||
<widget class="QRadioButton" name="mAskUser"> | ||
<property name="text"> | ||
<string>Let user choose profile at start up</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QDialogButtonBox" name="mButtonBox"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="standardButtons"> | ||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections> | ||
<connection> | ||
<sender>mButtonBox</sender> | ||
<signal>accepted()</signal> | ||
<receiver>QgsUserProfileSettingsDialog</receiver> | ||
<slot>accept()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>248</x> | ||
<y>254</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>157</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>mButtonBox</sender> | ||
<signal>rejected()</signal> | ||
<receiver>QgsUserProfileSettingsDialog</receiver> | ||
<slot>reject()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>316</x> | ||
<y>260</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>286</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
</connections> | ||
</ui> |