Skip to content
Permalink
Browse files

[auth] Added support for "Store" checkboxes

  • Loading branch information
elpaso committed Oct 2, 2017
1 parent 7ee03a6 commit dfdf2ceeaca7cda3288eb2b8d091586a62bbf8b2
@@ -88,11 +88,17 @@ class QgsAuthSettingsWidget : QWidget
param configId the authentication configuration id
%End

int currentTabIndex( ) const;
void setDataprovider( const QString &dataprovider );
%Docstring
currentTabIndex, mainly useful for unit tests
:return: active tab index
:rtype: int
setDataprovider set the data provider key for filtering compatible authentication configurations
\param dataprovider data provider key
%End

const QString dataprovider( ) const;
%Docstring
dataprovider
:return: the data provider key used to filter compatible authentication configurations
:rtype: str
%End

bool btnConvertToEncryptedIsEnabled( ) const;
@@ -102,6 +108,51 @@ class QgsAuthSettingsWidget : QWidget
:rtype: bool
%End

void showStoreCheckboxes( bool enabled );
%Docstring
showStoreCheckboxes show the "Store" checkboxes for basic auth.
Some connection configurations allow the user to enter credentials
for testing the connection without storing them in the project.
"Store" checkboxes are disabled by default.
\param enabled
%End

void setStoreUsername( bool checked );
%Docstring
setStoreUsername check the "Store" checkbox for the username
\param checked
.. seealso:: showStoreCheckboxes
%End

void setStorePassword( bool checked );
%Docstring
updateStorePasswordcheck the "Store" checkbox for the password
\param checked
.. seealso:: showStoreCheckboxes
%End

bool storePasswordIsChecked( ) const;
%Docstring
storePassword
:return: true if "Store" checkbox for the password is checked
:rtype: bool
%End

bool storeUsernameIsChecked( ) const;
%Docstring
storeUsername
:return: true if "Store" checkbox for the username is checked
:rtype: bool
%End


bool configurationTabIsSelected( );
%Docstring
configurationTabIsSelected
:return: true if the configuration tab is the currently selected tab
:rtype: bool
%End

public slots:

bool convertToEncrypted( );
@@ -25,6 +25,7 @@ QgsAuthSettingsWidget::QgsAuthSettingsWidget( QWidget *parent,
const QString &password,
const QString &dataprovider )
: QWidget( parent )
, mDataprovider( dataprovider )
{
setupUi( this );
txtPassword->setText( password );
@@ -40,6 +41,8 @@ QgsAuthSettingsWidget::QgsAuthSettingsWidget( QWidget *parent,
connect( btnConvertToEncrypted, &QPushButton::clicked, this, &QgsAuthSettingsWidget::convertToEncrypted );
connect( txtUserName, &QLineEdit::textChanged, this, &QgsAuthSettingsWidget::userNameTextChanged );
connect( txtPassword, &QLineEdit::textChanged, this, &QgsAuthSettingsWidget::passwordTextChanged );
// Hide store password and username by default
showStoreCheckboxes( false );
updateSelectedTab();
updateConvertBtnState();
}
@@ -82,21 +85,66 @@ void QgsAuthSettingsWidget::setConfigId( const QString &configId )
updateSelectedTab();
}

const QString QgsAuthSettingsWidget::configId() const
void QgsAuthSettingsWidget::setDataprovider( const QString &dataprovider )
{
return mAuthConfigSelect->configId();
mDataprovider = dataprovider;
mAuthConfigSelect->setDataProviderKey( dataprovider );
}

const QString QgsAuthSettingsWidget::dataprovider() const
{
return mDataprovider;
}

int QgsAuthSettingsWidget::currentTabIndex() const
const QString QgsAuthSettingsWidget::configId() const
{
return tabAuth->currentIndex( );
return mAuthConfigSelect->configId();
}

bool QgsAuthSettingsWidget::btnConvertToEncryptedIsEnabled() const
{
return btnConvertToEncrypted->isEnabled( );
}

void QgsAuthSettingsWidget::showStoreCheckboxes( bool enabled )
{
if ( enabled )
{
cbStorePassword->show();
cbStoreUsername->show();
}
else
{
cbStorePassword->hide();
cbStoreUsername->hide();
}
}

void QgsAuthSettingsWidget::setStoreUsername( bool checked )
{
cbStoreUsername->setChecked( checked );
}

void QgsAuthSettingsWidget::setStorePassword( bool checked )
{
cbStorePassword->setChecked( checked );
}

bool QgsAuthSettingsWidget::storePasswordIsChecked() const
{
return cbStorePassword->isChecked( );
}

bool QgsAuthSettingsWidget::storeUsernameIsChecked() const
{
return cbStoreUsername->isChecked( );
}

bool QgsAuthSettingsWidget::configurationTabIsSelected()
{
return tabAuth->currentIndex( ) == tabAuth->indexOf( tabConfigurations );
}

bool QgsAuthSettingsWidget::convertToEncrypted( )
{
tabAuth->setCurrentIndex( tabAuth->indexOf( tabConfigurations ) );
@@ -99,17 +99,65 @@ class GUI_EXPORT QgsAuthSettingsWidget : public QWidget, private Ui::QgsAuthSett
void setConfigId( const QString &configId );

/**
* \brief currentTabIndex, mainly useful for unit tests
* \return active tab index
* \brief setDataprovider set the data provider key for filtering compatible authentication configurations
* \param dataprovider data provider key
*/
int currentTabIndex( ) const;
void setDataprovider( const QString &dataprovider );

/**
* \brief dataprovider
* \return the data provider key used to filter compatible authentication configurations
*/
const QString dataprovider( ) const;

/**
* \brief convertButtonEnabled, mainly useful for unit tests
* \return true if the convert button is enabled
*/
bool btnConvertToEncryptedIsEnabled( ) const;

/**
* \brief showStoreCheckboxes show the "Store" checkboxes for basic auth.
* Some connection configurations allow the user to enter credentials
* for testing the connection without storing them in the project.
* "Store" checkboxes are disabled by default.
* \param enabled
*/
void showStoreCheckboxes( bool enabled );

/**
* \brief setStoreUsername check the "Store" checkbox for the username
* \param checked
* \see showStoreCheckboxes
*/
void setStoreUsername( bool checked );

/**
* \brief updateStorePasswordcheck the "Store" checkbox for the password
* \param checked
* \see showStoreCheckboxes
*/
void setStorePassword( bool checked );

/**
* \brief storePassword
* \return true if "Store" checkbox for the password is checked
*/
bool storePasswordIsChecked( ) const;

/**
* \brief storeUsername
* \return true if "Store" checkbox for the username is checked
*/
bool storeUsernameIsChecked( ) const;


/**
* \brief configurationTabIsSelected
* \return true if the configuration tab is the currently selected tab
*/
bool configurationTabIsSelected( );

public slots:

/**
@@ -137,6 +185,9 @@ class GUI_EXPORT QgsAuthSettingsWidget : public QWidget, private Ui::QgsAuthSett

private:

// Mainly for tests
QString mDataprovider;

void updateConvertBtnState( );

void updateSelectedTab( );
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<width>405</width>
<height>264</height>
</rect>
</property>
@@ -89,16 +89,6 @@
<string>Basic</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="lblWarning">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600; color:#ff0000;&quot;&gt;Warning: credentials are stored unencrypted (in clear text) in the project file!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
@@ -142,7 +132,44 @@
<item row="1" column="1">
<widget class="QLineEdit" name="txtUserName"/>
</item>
<item row="0" column="0" colspan="2">
<item row="1" column="2">
<widget class="QCheckBox" name="cbStoreUsername">
<property name="text">
<string>Store</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="cbStorePassword">
<property name="text">
<string>Store</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QPushButton" name="btnConvertToEncrypted">
<property name="text">
<string>Convert to configuration</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QLabel" name="lblWarning">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600; color:#ff0000;&quot;&gt;Warning: credentials are stored unencrypted (in clear text) in the project file!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="lblBasic">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@@ -161,13 +188,6 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QPushButton" name="btnConvertToEncrypted">
<property name="text">
<string>Convert to configuration</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
@@ -186,6 +206,15 @@
<header>qgsauthconfigselect.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabAuth</tabstop>
<tabstop>mAuthConfigSelect</tabstop>
<tabstop>txtUserName</tabstop>
<tabstop>cbStoreUsername</tabstop>
<tabstop>txtPassword</tabstop>
<tabstop>cbStorePassword</tabstop>
<tabstop>btnConvertToEncrypted</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

0 comments on commit dfdf2ce

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