Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify authentication step during process of adding plugin repository #60350

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions python/pyplugin_installer/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def addRepository(self):
reposName = reposName + "(2)"
# add to settings
settings.setValue(reposName + "/url", reposURL)
settings.setValue(reposName + "/authcfg", dlg.editAuthCfg.text().strip())
settings.setValue(reposName + "/authcfg", dlg.configId().strip())
settings.setValue(
reposName + "/enabled", bool(dlg.checkBoxEnabled.checkState())
)
Expand All @@ -622,7 +622,7 @@ def editRepository(self, reposName):
dlg = QgsPluginInstallerRepositoryDialog(iface.mainWindow())
dlg.editName.setText(reposName)
dlg.editURL.setText(repositories.all()[reposName]["url"])
dlg.editAuthCfg.setText(repositories.all()[reposName]["authcfg"])
dlg.editAuthCfgWgt.setConfigId(repositories.all()[reposName]["authcfg"])
dlg.editParams.setText(repositories.urlParams())
dlg.checkBoxEnabled.setCheckState(
checkState[repositories.all()[reposName]["enabled"]]
Expand Down Expand Up @@ -658,10 +658,10 @@ def editRepository(self, reposName):
if newName in repositories.all() and newName != reposName:
newName = newName + "(2)"
settings.setValue(newName + "/url", dlg.editURL.text().strip())
settings.setValue(newName + "/authcfg", dlg.editAuthCfg.text().strip())
settings.setValue(newName + "/authcfg", dlg.configId().strip())
settings.setValue(newName + "/enabled", bool(dlg.checkBoxEnabled.checkState()))
if dlg.editAuthCfg.text().strip() != repositories.all()[reposName]["authcfg"]:
repositories.all()[reposName]["authcfg"] = dlg.editAuthCfg.text().strip()
if dlg.editAuthCfgWgt.configId().strip() != repositories.all()[reposName]["authcfg"]:
repositories.all()[reposName]["authcfg"] = dlg.editAuthCfgWgt.configId().strip()
if (
dlg.editURL.text().strip() == repositories.all()[reposName]["url"]
and dlg.checkBoxEnabled.checkState()
Expand Down
224 changes: 97 additions & 127 deletions python/pyplugin_installer/qgsplugininstallerrepositorybase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,16 @@
<string/>
</property>
<layout class="QGridLayout">
<item row="5" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="editURL">
<property name="toolTip">
<string>Enter the repository URL, beginning with &quot;http://&quot; or &quot;file:///&quot;</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>351</width>
<height>23</height>
</size>
<property name="whatsThis">
<string>Enter the repository URL, beginning with &quot;http://&quot; or &quot;file:///&quot;</string>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>URL</string>
</property>
<property name="buddy">
<cstring>editURL</cstring>
<string/>
</property>
</widget>
</item>
Expand All @@ -63,49 +50,93 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="editName">
<property name="toolTip">
<string>Enter a name for the repository</string>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="whatsThis">
<string>Enter a name for the repository</string>
<property name="text">
<string>Name</string>
</property>
<property name="buddy">
<cstring>editName</cstring>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="editParams">
<item row="4" column="1" colspan="2">
<widget class="QgsAuthConfigSelect" name="editAuthCfgWgt" native="true"/>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="checkBoxEnabled">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Enable or disable the repository (disabled repositories will be omitted)</string>
</property>
<property name="whatsThis">
<string>Enable or disable the repository (disabled repositories will be omitted)</string>
</property>
<property name="text">
<string>?qgis=</string>
<string/>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="9" column="0" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<item row="5" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>351</width>
<height>23</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="editName">
<property name="toolTip">
<string>Enter a name for the repository</string>
</property>
<property name="whatsThis">
<string>Enter a name for the repository</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Parameters</string>
</property>
<property name="buddy">
<cstring>editParams</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Name</string>
<string>URL</string>
</property>
<property name="buddy">
<cstring>editName</cstring>
<cstring>editURL</cstring>
</property>
</widget>
</item>
Expand Down Expand Up @@ -159,7 +190,6 @@
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
Expand All @@ -171,51 +201,20 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Parameters</string>
</property>
<property name="buddy">
<cstring>editParams</cstring>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="checkBoxEnabled">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Enable or disable the repository (disabled repositories will be omitted)</string>
</property>
<property name="whatsThis">
<string>Enable or disable the repository (disabled repositories will be omitted)</string>
</property>
<item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>false</bool>
<string>Authentication</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="editURL">
<property name="toolTip">
<string>Enter the repository URL, beginning with &quot;http://&quot; or &quot;file:///&quot;</string>
</property>
<property name="whatsThis">
<string>Enter the repository URL, beginning with &quot;http://&quot; or &quot;file:///&quot;</string>
<item row="9" column="0" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="text">
<string/>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
Expand All @@ -232,55 +231,26 @@
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="editParams">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Authentication</string>
<string>?qgis=</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<layout class="QHBoxLayout" name="layoutAuthCfg">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QLineEdit" name="editAuthCfg">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnClearAuthCfg">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
</size>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnEditAuthCfg">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
</size>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsAuthConfigSelect</class>
<extends>QWidget</extends>
<header>qgsauthconfigselect.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>editName</tabstop>
<tabstop>editURL</tabstop>
Expand Down
22 changes: 2 additions & 20 deletions python/pyplugin_installer/qgsplugininstallerrepositorydialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,12 @@ def __init__(self, parent=None):
self.editURL.setText("http://")
self.editName.textChanged.connect(self.textChanged)
self.editURL.textChanged.connect(self.textChanged)
self.btnClearAuthCfg.clicked.connect(self.editAuthCfg.clear)
self.btnEditAuthCfg.clicked.connect(self.editAuthCfgId)
self.textChanged(None)

# ----------------------------------------- #
def textChanged(self, string):
enable = len(self.editName.text()) > 0 and len(self.editURL.text()) > 0
self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable)

def editAuthCfgId(self):
dlg = QDialog(self)
dlg.setWindowModality(Qt.WindowModality.WindowModal)
layout = QVBoxLayout()
selector = QgsAuthConfigSelect(self)
if self.editAuthCfg.text():
selector.setConfigId(self.editAuthCfg.text())
layout.addWidget(selector)
buttonBox = QDialogButtonBox(
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Close
)
buttonBox.accepted.connect(dlg.accept)
buttonBox.rejected.connect(dlg.reject)
layout.addWidget(buttonBox)
dlg.setLayout(layout)
if dlg.exec():
self.editAuthCfg.setText(selector.configId())
del dlg
def configId(self):
return self.editAuthCfgWgt.configId()
Loading