Extended the user configuration dialog.

Tue, 21 Mar 2017 19:34:33 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 21 Mar 2017 19:34:33 +0100
changeset 5641
3ced21e990eb
parent 5640
2e046f1818ed
child 5642
6d0728526b36

Extended the user configuration dialog.

Plugins/VcsPlugins/vcsMercurial/HgUserConfigDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/HgUserConfigHostMinimumProtocolDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/HgUserConfigHostMinimumProtocolDialog.ui file | annotate | diff | comparison | revisions
changelog file | annotate | diff | comparison | revisions
eric6.e4p file | annotate | diff | comparison | revisions
--- a/Plugins/VcsPlugins/vcsMercurial/HgUserConfigDialog.py	Mon Mar 20 19:31:22 2017 +0100
+++ b/Plugins/VcsPlugins/vcsMercurial/HgUserConfigDialog.py	Tue Mar 21 19:34:33 2017 +0100
@@ -23,6 +23,8 @@
 from .HgUtilities import getConfigPath
 from .HgUserConfigHostFingerprintDialog import \
     HgUserConfigHostFingerprintDialog
+from .HgUserConfigHostMinimumProtocolDialog import \
+    HgUserConfigHostMinimumProtocolDialog
 
 from .Ui_HgUserConfigDialog import Ui_HgUserConfigDialog
 
@@ -457,9 +459,11 @@
         self.proxyBypassEdit.clear()
         
         self.fingerprintsList.clear()
+        self.__finalizeFingerprintsColumns()
         self.__updateFingerprintsButtons()
         
         self.protocolsList.clear()
+        self.__finalizeProtocolsColumns()
         self.__updateProtocolsButtons()
     
     #######################################################################
@@ -535,6 +539,7 @@
                 self.fingerprintsList.takeTopLevelItem(
                     self.fingerprintsList.indexOfTopLevelItem(itm))
                 del itm
+                self.__finalizeFingerprintsColumns()
     
     @pyqtSlot()
     def on_fpEditButton_clicked(self):
@@ -614,26 +619,58 @@
     @pyqtSlot()
     def on_protocolAddButton_clicked(self):
         """
-        Slot documentation goes here.
+        Private slot to add a minimum protocol entry.
         """
-        # TODO: not implemented yet
-        raise NotImplementedError
+        dlg = HgUserConfigHostMinimumProtocolDialog(self.__minimumProtocols,
+                                                    self)
+        if dlg.exec_() == QDialog.Accepted:
+            host, protocol = dlg.getData()
+            itm = QTreeWidgetItem(self.protocolsList, [
+                host,
+                self.__minimumProtocols[protocol]
+            ])
+            itm.setData(1, Qt.UserRole, protocol)
+            self.__finalizeProtocolsColumns()
+            self.protocolsList.setCurrentItem(itm)
+            self.protocolsList.scrollToItem(itm)
     
     @pyqtSlot()
     def on_protocolDeleteButton_clicked(self):
         """
-        Slot documentation goes here.
+        Private slot to delete the current minimum protocol item.
         """
-        # TODO: not implemented yet
-        raise NotImplementedError
+        itm = self.protocolsList.currentItem()
+        if itm is not None:
+            host = itm.text(0)
+            yes = E5MessageBox.yesNo(
+                self,
+                self.tr("Delete Host Minimum Protocol"),
+                self.tr("""<p>Shall the minimum protocol entry for host"""
+                        """ <b>{0}</b> really be deleted?</p>""").format(host))
+            if yes:
+                self.protocolsList.takeTopLevelItem(
+                    self.protocolsList.indexOfTopLevelItem(itm))
+                del itm
+                self.__finalizeProtocolsColumns()
     
     @pyqtSlot()
     def on_protocolEditButton_clicked(self):
         """
-        Slot documentation goes here.
+        Private slot to edit the current minimum protocol item.
         """
-        # TODO: not implemented yet
-        raise NotImplementedError
+        itm = self.protocolsList.currentItem()
+        if itm is not None:
+            host = itm.text(0)
+            protocol = itm.data(1, Qt.UserRole)
+            dlg = HgUserConfigHostMinimumProtocolDialog(
+                self.__minimumProtocols, self, host, protocol)
+            if dlg.exec_() == QDialog.Accepted:
+                host, protocol = dlg.getData()
+                itm.setText(0, host)
+                itm.setText(1, self.__minimumProtocols[protocol])
+                itm.setData(1, Qt.UserRole, protocol)
+                self.__finalizeProtocolsColumns()
+                self.protocolsList.scrollToItem(itm)
     
     def __finalizeProtocolsColumns(self):
         """
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/VcsPlugins/vcsMercurial/HgUserConfigHostMinimumProtocolDialog.py	Tue Mar 21 19:34:33 2017 +0100
@@ -0,0 +1,98 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2016 - 2017 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing a dialog to enter the minimum protocol for a host.
+"""
+
+from __future__ import unicode_literals
+
+from PyQt5.QtCore import pyqtSlot
+from PyQt5.QtWidgets import QDialog, QDialogButtonBox
+
+from .Ui_HgUserConfigHostMinimumProtocolDialog import \
+    Ui_HgUserConfigHostMinimumProtocolDialog
+
+
+class HgUserConfigHostMinimumProtocolDialog(
+        QDialog, Ui_HgUserConfigHostMinimumProtocolDialog):
+    """
+    Class implementing a dialog to enter the minimum protocol for a host.
+    """
+    def __init__(self, allowedProtocols, parent=None, host="", protocol=""):
+        """
+        Constructor
+        
+        @param allowedProtocols dictionary containing the allowed protocols
+            with the value as key and the display string as value
+        @type dict
+        @param parent reference to the parent widget
+        @type QWidget
+        @param host host name
+        @type str
+        @param protocol name of the minimum protocol for the host
+        @type str
+        """
+        super(HgUserConfigHostMinimumProtocolDialog, self).__init__(parent)
+        self.setupUi(self)
+        
+        self.minimumProtocolComboBox.addItem("", "")
+        for minimumProtocol in sorted(allowedProtocols.keys()):
+            self.minimumProtocolComboBox.addItem(
+                allowedProtocols[minimumProtocol], minimumProtocol)
+        
+        self.hostEdit.setText(host)
+        index = self.minimumProtocolComboBox.findData(protocol)
+        if index == -1:
+            index = 0
+        self.minimumProtocolComboBox.setCurrentIndex(index)
+        
+        msh = self.minimumSizeHint()
+        self.resize(max(self.width(), msh.width()), msh.height())
+        
+        self.__updateOkButton()
+    
+    def __updateOkButton(self):
+        """
+        Private method to update the status of the Ok button.
+        """
+        enabled = (
+            bool(self.hostEdit.text()) and
+            self.minimumProtocolComboBox.currentIndex() > 0
+        )
+        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)
+    
+    @pyqtSlot(str)
+    def on_hostEdit_textChanged(self, txt):
+        """
+        Private slot to handle changes of the host edit.
+        
+        @param txt current text
+        @type str
+        """
+        self.__updateOkButton()
+    
+    @pyqtSlot(int)
+    def on_minimumProtocolComboBox_currentIndexChanged(self, index):
+        """
+        Private slot to handle the selection of a minimum protocol.
+        
+        @param index index of the selected entry
+        @type int
+        """
+        self.__updateOkButton()
+    
+    def getData(self):
+        """
+        Public method to retrieve the data.
+        
+        @return tuple containig the host name and the minimum protocol
+        @rtype tuple of two str
+        """
+        return (
+            self.hostEdit.text().strip(),
+            self.minimumProtocolComboBox.itemData(
+                self.minimumProtocolComboBox.currentIndex())
+        )
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/VcsPlugins/vcsMercurial/HgUserConfigHostMinimumProtocolDialog.ui	Tue Mar 21 19:34:33 2017 +0100
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>HgUserConfigHostMinimumProtocolDialog</class>
+ <widget class="QDialog" name="HgUserConfigHostMinimumProtocolDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>450</width>
+    <height>95</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Minimum Protocol</string>
+  </property>
+  <property name="sizeGripEnabled">
+   <bool>true</bool>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Host:</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1">
+    <widget class="E5ClearableLineEdit" name="hostEdit">
+     <property name="toolTip">
+      <string>Enter the host name</string>
+     </property>
+     <property name="placeholderText">
+      <string>Enter Hostname</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0">
+    <widget class="QLabel" name="hashLabel">
+     <property name="text">
+      <string>Minimum Protocol:</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1">
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QComboBox" name="minimumProtocolComboBox">
+       <property name="currentText">
+        <string notr="true"/>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>178</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item row="2" column="0" colspan="2">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>E5ClearableLineEdit</class>
+   <extends>QLineEdit</extends>
+   <header>E5Gui/E5LineEdit.h</header>
+  </customwidget>
+ </customwidgets>
+ <tabstops>
+  <tabstop>hostEdit</tabstop>
+  <tabstop>minimumProtocolComboBox</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>HgUserConfigHostMinimumProtocolDialog</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>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>HgUserConfigHostMinimumProtocolDialog</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>
--- a/changelog	Mon Mar 20 19:31:22 2017 +0100
+++ b/changelog	Tue Mar 21 19:34:33 2017 +0100
@@ -7,6 +7,8 @@
      and generators to the code style checker
   -- added capability to place line flags (e.g. __IGNORE...) on the line
      following the one to be ignored
+- Mercurial Interface
+  -- extended the user configuration dialog
 
 Version 17.03.1:
 - bug fixes
--- a/eric6.e4p	Mon Mar 20 19:31:22 2017 +0100
+++ b/eric6.e4p	Tue Mar 21 19:34:33 2017 +0100
@@ -575,6 +575,7 @@
     <Source>Plugins/VcsPlugins/vcsMercurial/HgTagDialog.py</Source>
     <Source>Plugins/VcsPlugins/vcsMercurial/HgUserConfigDialog.py</Source>
     <Source>Plugins/VcsPlugins/vcsMercurial/HgUserConfigHostFingerprintDialog.py</Source>
+    <Source>Plugins/VcsPlugins/vcsMercurial/HgUserConfigHostMinimumProtocolDialog.py</Source>
     <Source>Plugins/VcsPlugins/vcsMercurial/HgUtilities.py</Source>
     <Source>Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditCommitEditor.py</Source>
     <Source>Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditConfigDialog.py</Source>
@@ -1657,6 +1658,7 @@
     <Form>Plugins/VcsPlugins/vcsMercurial/HgTagDialog.ui</Form>
     <Form>Plugins/VcsPlugins/vcsMercurial/HgUserConfigDialog.ui</Form>
     <Form>Plugins/VcsPlugins/vcsMercurial/HgUserConfigHostFingerprintDialog.ui</Form>
+    <Form>Plugins/VcsPlugins/vcsMercurial/HgUserConfigHostMinimumProtocolDialog.ui</Form>
     <Form>Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditCommitEditor.ui</Form>
     <Form>Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditConfigDialog.ui</Form>
     <Form>Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditPlanEditor.ui</Form>
@@ -1956,14 +1958,14 @@
   <Interfaces/>
   <Others>
     <Other>.hgignore</Other>
-    <Other>APIs/Python/zope-2.10.7.api</Other>
-    <Other>APIs/Python/zope-2.11.2.api</Other>
-    <Other>APIs/Python/zope-3.3.1.api</Other>
     <Other>APIs/Python3/PyQt4.bas</Other>
     <Other>APIs/Python3/PyQt5.bas</Other>
     <Other>APIs/Python3/QScintilla2.bas</Other>
     <Other>APIs/Python3/eric6.api</Other>
     <Other>APIs/Python3/eric6.bas</Other>
+    <Other>APIs/Python/zope-2.10.7.api</Other>
+    <Other>APIs/Python/zope-2.11.2.api</Other>
+    <Other>APIs/Python/zope-3.3.1.api</Other>
     <Other>APIs/QSS/qss.api</Other>
     <Other>APIs/Ruby/Ruby-1.8.7.api</Other>
     <Other>APIs/Ruby/Ruby-1.8.7.bas</Other>

eric ide

mercurial