Plugins/VcsPlugins/vcsMercurial/HgUserConfigDialog.py

Sat, 22 Oct 2016 17:09:08 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 22 Oct 2016 17:09:08 +0200
changeset 5264
8bc23ecb4ea3
parent 5262
235d6a030128
child 5265
787d87769425
permissions
-rw-r--r--

Finished the refactoring of the Mercurial user config management code.

3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
4631
5c1a96925da4 Updated copyright for 2016.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
3 # Copyright (c) 2014 - 2016 Detlev Offenbach <detlev@die-offenbachs.de>
3806
743e085ba266 Added forgotten file header to the Mercurial user config dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
4 #
743e085ba266 Added forgotten file header to the Mercurial user config dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
5
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to enter some user data.
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3366
diff changeset
10 from __future__ import unicode_literals
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3366
diff changeset
11
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
12 import os
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
13
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
14 from PyQt5.QtCore import pyqtSlot, Qt, QEvent
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
15 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
17 from E5Gui.E5PathPicker import E5PathPickerModes
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
18 from E5Gui import E5MessageBox
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
19
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
20 import Globals
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
21 from Globals.E5ConfigParser import E5ConfigParser
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
22
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
23 from .HgUtilities import getConfigPath
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
24 from .HgUserConfigHostFingerprintDialog import \
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
25 HgUserConfigHostFingerprintDialog
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
26
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
27 from .Ui_HgUserConfigDialog import Ui_HgUserConfigDialog
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
29 import UI.PixmapCache
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
30
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
32 class HgUserConfigDialog(QDialog, Ui_HgUserConfigDialog):
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 Class implementing a dialog to enter some user data.
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 def __init__(self, version=(0, 0), parent=None):
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 Constructor
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
3246
4cd58a0d6c28 Some code style fixes and renaming of UtilitiesPython2.py2flakes to UtilitiesPython2.pyflakes to make it clear, that it is just a copy of the one in Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3231
diff changeset
40 @param version Mercurial version info (tuple of two integers)
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 @param parent reference to the parent widget (QWidget)
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 """
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
43 super(HgUserConfigDialog, self).__init__(parent)
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.setupUi(self)
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
46 self.lfUserCachePicker.setMode(E5PathPickerModes.DirectoryMode)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
47 if Globals.isLinuxPlatform():
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
48 self.lfUserCachePicker.setDefaultDirectory(os.path.expanduser(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
49 "~/.cache/largefiles"))
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
50 elif Globals.isMacPlatform():
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
51 self.lfUserCachePicker.setDefaultDirectory(os.path.expanduser(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
52 "~/Library/Caches/largefiles"))
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
53 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
54 self.lfUserCachePicker.setDefaultDirectory(os.path.expanduser(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
55 "~\\AppData\\Local\\largefiles"))
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
56
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
57 self.fpAddButton.setIcon(UI.PixmapCache.getIcon("plus.png"))
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
58 self.fpDeleteButton.setIcon(UI.PixmapCache.getIcon("minus.png"))
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
59 self.fpEditButton.setIcon(UI.PixmapCache.getIcon("edit.png"))
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
60
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
61 self.tabWidget.setCurrentIndex(0)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
62
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
63 self.__editor = None
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
65 self.__config = None
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
66 self.readUserConfig()
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
67
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
68 self.__updateFingerprintsButtons()
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
69
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
70 def writeUserConfig(self):
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
71 """
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
72 Public method to write the user configuration file.
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 """
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
74 if self.__config is None:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
75 self.__config = E5ConfigParser()
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
77 ###################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
78 ## ui section
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
79 ###################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
80 if "ui" not in self.__config:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
81 self.__config["ui"] = {}
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
82 self.__config["ui"]["username"] = "{0} <{1}>".format(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
83 self.userNameEdit.text(),
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
84 self.emailEdit.text(),
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
85 )
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
86 ###################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
87 ## extensions section
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
88 ###################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
89 if "extensions" not in self.__config:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
90 self.__config["extensions"] = {}
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 if self.fetchCheckBox.isChecked():
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
92 self.__config["extensions"]["fetch"] = ""
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
93 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
94 if "fetch" in self.__config["extensions"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
95 del self.__config["extensions"]["fetch"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
96 self.__config["extensions"]["#fetch"] = ""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
97
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 if self.gpgCheckBox.isChecked():
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
99 self.__config["extensions"]["gpg"] = ""
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
100 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
101 if "gpg" in self.__config["extensions"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
102 del self.__config["extensions"]["gpg"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
103 self.__config["extensions"]["#gpg"] = ""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
104
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 if self.purgeCheckBox.isChecked():
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
106 self.__config["extensions"]["purge"] = ""
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
107 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
108 if "purge" in self.__config["extensions"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
109 del self.__config["extensions"]["purge"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
110 self.__config["extensions"]["#purge"] = ""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
111
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 if self.queuesCheckBox.isChecked():
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
113 self.__config["extensions"]["mq"] = ""
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
114 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
115 if "mq" in self.__config["extensions"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
116 del self.__config["extensions"]["mq"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
117 self.__config["extensions"]["#mq"] = ""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
118
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 if self.rebaseCheckBox.isChecked():
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
120 self.__config["extensions"]["rebase"] = ""
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
121 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
122 if "rebase" in self.__config["extensions"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
123 del self.__config["extensions"]["rebase"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
124 self.__config["extensions"]["#rebase"] = ""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
125
3288
1a68ecb67c06 Started implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3246
diff changeset
126 if self.shelveCheckBox.isChecked():
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
127 self.__config["extensions"]["shelve"] = ""
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
128 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
129 if "shelve" in self.__config["extensions"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
130 del self.__config["extensions"]["shelve"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
131 self.__config["extensions"]["#shelve"] = ""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
132
3308
955abb40a903 Started implementing support for the Mercurial largefiles extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3288
diff changeset
133 if self.largefilesCheckBox.isChecked():
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
134 self.__config["extensions"]["largefiles"] = ""
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
135 ###############################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
136 ## largefiles section
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
137 ###############################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
138 if "largefiles" not in self.__config:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
139 self.__config["largefiles"] = {}
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
140 self.__config["largefiles"]["minsize"] = \
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
141 str(self.lfFileSizeSpinBox.value())
3308
955abb40a903 Started implementing support for the Mercurial largefiles extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3288
diff changeset
142 lfFilePatterns = self.lfFilePatternsEdit.text()
955abb40a903 Started implementing support for the Mercurial largefiles extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3288
diff changeset
143 if lfFilePatterns:
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
144 self.__config["largefiles"]["patterns"] = lfFilePatterns
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
145 elif "patterns" in self.__config["largefiles"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
146 del self.__config["largefiles"]["patterns"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
147 lfUserCache = self.lfUserCachePicker.text()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
148 if lfUserCache:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
149 self.__config["largefiles"]["usercache"] = lfUserCache
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
150 elif "usercache" in self.__config["largefiles"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
151 del self.__config["largefiles"]["usercache"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
152 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
153 if "largefiles" in self.__config["extensions"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
154 del self.__config["extensions"]["largefiles"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
155 self.__config["extensions"]["#largefiles"] = ""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
156 ###################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
157 ## http_proxy section
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
158 ###################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
159 if self.proxyHostEdit.text():
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
160 self.__config["http_proxy"] = {
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
161 "host": self.proxyHostEdit.text(),
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
162 "user": self.proxyUserEdit.text(),
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
163 "passwd": self.proxyPasswordEdit.text()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
164 }
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
165 if self.proxyBypassEdit.text():
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
166 self.__config["http_proxy"]["no"] = \
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
167 self.proxyBypassEdit.text()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
168 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
169 if "http_proxy" in self.__config:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
170 del self.__config["http_proxy"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
171 ###################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
172 ## hostfingerprints section
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
173 ###################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
174 if self.fingerprintsList.topLevelItemCount() > 0:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
175 self.__config["hostfingerprints"] = {}
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
176 for row in range(self.fingerprintsList.topLevelItemCount()):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
177 itm = self.fingerprintsList.topLevelItem(row)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
178 self.__config["hostfingerprints"][itm.text(0)] = itm.text(1)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
179 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
180 if "hostfingerprints" in self.__config:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
181 del self.__config["hostfingerprints"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
182 ###################################################################
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
183
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
184 cfgFile = getConfigPath()
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
185 with open(cfgFile, "w") as configFile:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
186 self.__config.write(configFile)
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
187
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
188 def readUserConfig(self):
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
189 """
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
190 Public method to read the user configuration file.
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
191 """
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
192 cfgFile = getConfigPath()
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
194 self.__config = E5ConfigParser()
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
195 if self.__config.read(cfgFile):
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
196 # step 1: extract user name and email
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
197 try:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
198 username = self.__config["ui"]["username"].strip()
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
199 if "<" in username and username.endswith(">"):
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
200 name, email = username[:-1].rsplit("<", 1)
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
201 else:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
202 name = username
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
203 email = ""
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
204 self.userNameEdit.setText(name.strip()),
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
205 self.emailEdit.setText(email.strip()),
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
206 except KeyError:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
207 pass
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
208
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
209 # step 2: extract extensions information
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
210 if "extensions" in self.__config:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
211 self.fetchCheckBox.setChecked(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
212 "fetch" in self.__config["extensions"])
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
213 self.gpgCheckBox.setChecked(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
214 "gpg" in self.__config["extensions"])
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
215 self.purgeCheckBox.setChecked(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
216 "purge" in self.__config["extensions"])
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
217 self.queuesCheckBox.setChecked(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
218 "mq" in self.__config["extensions"])
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
219 self.rebaseCheckBox.setChecked(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
220 "rebase" in self.__config["extensions"])
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
221 self.shelveCheckBox.setChecked(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
222 "shelve" in self.__config["extensions"])
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
223 self.largefilesCheckBox.setChecked(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
224 "largefiles" in self.__config["extensions"])
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
225
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
226 # step 3: extract large files information
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
227 if "largefiles" in self.__config:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
228 if "minsize" in self.__config["largefiles"]:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
229 self.lfFileSizeSpinBox.setValue(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
230 self.__config.getint("largefiles", "minsize"))
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
231 if "patterns" in self.__config["largefiles"]:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
232 self.lfFilePatternsEdit.setText(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
233 self.__config["largefiles"]["patterns"])
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
234 if "usercache" in self.__config["largefiles"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
235 self.lfUserCachePicker.setText(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
236 self.__config["largefiles"]["usercache"])
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
237
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
238 # step 4: extract http proxy information
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
239 if "http_proxy" in self.__config:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
240 if "host" in self.__config["http_proxy"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
241 self.proxyHostEdit.setText(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
242 self.__config["http_proxy"]["host"])
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
243 if "user" in self.__config["http_proxy"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
244 self.proxyUserEdit.setText(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
245 self.__config["http_proxy"]["user"])
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
246 if "passwd" in self.__config["http_proxy"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
247 self.proxyPasswordEdit.setText(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
248 self.__config["http_proxy"]["passwd"])
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
249 if "no" in self.__config["http_proxy"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
250 self.proxyBypassEdit.setText(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
251 self.__config["http_proxy"]["no"])
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
252
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
253 # step 5: extract host fingerprints
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
254 if "hostfingerprints" in self.__config:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
255 for host in self.__config["hostfingerprints"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
256 QTreeWidgetItem(self.fingerprintsList, [
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
257 host,
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
258 self.__config["hostfingerprints"][host]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
259 ])
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
260 self.__finalizeFingerprintsColumns()
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
261
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
262 @pyqtSlot()
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
263 def accept(self):
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
264 """
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
265 Public slot to accept the dialog.
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
266 """
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
267 self.writeUserConfig()
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
268
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
269 super(HgUserConfigDialog, self).accept()
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
270
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
271 def __clearDialog(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
272 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
273 Private method to clear the data of the dialog.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
274 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
275 self.userNameEdit.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
276 self.emailEdit.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
277
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
278 self.fetchCheckBox.setChecked(False)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
279 self.gpgCheckBox.setChecked(False)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
280 self.purgeCheckBox.setChecked(False)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
281 self.queuesCheckBox.setChecked(False)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
282 self.rebaseCheckBox.setChecked(False)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
283 self.shelveCheckBox.setChecked(False)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
284 self.largefilesCheckBox.setChecked(False)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
285 self.lfFileSizeSpinBox.setValue(10)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
286 self.lfFilePatternsEdit.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
287 self.lfUserCachePicker.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
288
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
289 self.proxyHostEdit.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
290 self.proxyUserEdit.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
291 self.proxyPasswordEdit.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
292 self.proxyBypassEdit.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
293
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
294 self.fingerprintsList.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
295 self.__updateFingerprintsButtons()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
296
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
297 #######################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
298 ## Methods and slots for the host fingerprint handling below
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
299 #######################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
300
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
301 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
302 def on_fingerprintsList_currentItemChanged(self, current, previous):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
303 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
304 Private slot handling a change of the current fingerprints item.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
305
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
306 @param current reference to the current item
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
307 @type QTreeWidgetItem
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
308 @param previous reference to the previous current item
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
309 @type QTreeWidgetItem
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
310 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
311 self.__updateFingerprintsButtons()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
312
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
313 @pyqtSlot()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
314 def on_fpAddButton_clicked(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
315 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
316 Private slot to add a fingerprints entry.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
317 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
318 dlg = HgUserConfigHostFingerprintDialog(self)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
319 if dlg.exec_() == QDialog.Accepted:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
320 host, fingerprint = dlg.getData()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
321 itm = QTreeWidgetItem(self.fingerprintsList, [host, fingerprint])
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
322 self.__finalizeFingerprintsColumns()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
323 self.fingerprintsList.setCurrentItem(itm)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
324 self.fingerprintsList.scrollToItem(itm)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
325
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
326 @pyqtSlot()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
327 def on_fpDeleteButton_clicked(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
328 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
329 Private slot to delete the current fingerprints item.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
330 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
331 itm = self.fingerprintsList.currentItem()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
332 if itm is not None:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
333 host = itm.text(0)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
334 yes = E5MessageBox.yesNo(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
335 self,
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
336 self.tr("Delete Host Fingerprint"),
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
337 self.tr("""<p>Shall the fingerprint for host <b>{0}</b>"""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
338 """ really be deleted?</p>""").format(host))
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
339 if yes:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
340 self.fingerprintsList.takeTopLevelItem(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
341 self.fingerprintsList.indexOfTopLevelItem(itm))
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
342 del itm
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
343
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
344 @pyqtSlot()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
345 def on_fpEditButton_clicked(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
346 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
347 Private slot to edit the current fingerprints item.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
348 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
349 itm = self.fingerprintsList.currentItem()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
350 if itm is not None:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
351 host = itm.text(0)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
352 fingerprint = itm.text(1)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
353 dlg = HgUserConfigHostFingerprintDialog(self, host, fingerprint)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
354 if dlg.exec_() == QDialog.Accepted:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
355 host, fingerprint = dlg.getData()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
356 itm.setText(0, host)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
357 itm.setText(1, fingerprint)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
358 self.__finalizeFingerprintsColumns()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
359 self.fingerprintsList.scrollToItem(itm)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
360
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
361 def __finalizeFingerprintsColumns(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
362 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
363 Private method to resize and sort the host fingerprints columns.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
364 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
365 for col in range(self.fingerprintsList.columnCount()):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
366 self.fingerprintsList.resizeColumnToContents(col)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
367 self.fingerprintsList.sortItems(0, Qt.AscendingOrder)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
368
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
369 def __updateFingerprintsButtons(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
370 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
371 Private slot to update the host fingerprints edit buttons.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
372 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
373 enable = self.fingerprintsList.currentItem() is not None
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
374 self.fpDeleteButton.setEnabled(enable)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
375 self.fpEditButton.setEnabled(enable)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
376
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
377 #######################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
378 ## Slot to edit the user configuration in an editor below
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
379 #######################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
380
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
381 @pyqtSlot()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
382 def on_editorButton_clicked(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
383 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
384 Private slot to open the user configuration file in a text editor.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
385 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
386 from QScintilla.MiniEditor import MiniEditor
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
387 cfgFile = getConfigPath()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
388
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
389 yes = E5MessageBox.yesNo(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
390 self,
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
391 self.tr("Edit User Configuration"),
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
392 self.tr("""You will loose all changes made in this dialog."""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
393 """ Shall the data be saved first?"""),
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
394 icon=E5MessageBox.Warning,
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
395 yesDefault=True)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
396 if yes:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
397 self.writeUserConfig()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
398
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
399 self.__editor = MiniEditor(cfgFile, "Properties", self)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
400 self.__editor.setWindowModality(Qt.WindowModal)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
401 self.__editor.installEventFilter(self)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
402 self.__editor.show()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
403
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
404 def eventFilter(self, watched, event):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
405 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
406 Public method called to filter the event queue.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
407
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
408 @param watched reference to the object being watched
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
409 @type QObject
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
410 @param event event to be handled
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
411 @type QEvent
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
412 @return flag indicating, if we handled the event
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
413 @rtype bool
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
414 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
415 if watched is self.__editor and event.type() == QEvent.Close:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
416 self.__editor.closeEvent(event)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
417 if event.isAccepted():
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
418 self.__clearDialog()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
419 self.readUserConfig()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
420 return True
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
421
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
422 return False

eric ide

mercurial