eric6/Plugins/VcsPlugins/vcsMercurial/GpgExtension/HgGpgSignaturesDialog.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7775
4a1db75550bd
child 7970
c4ee8a81584c
permissions
-rw-r--r--

Updated copyright for 2021.

1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7775
diff changeset
3 # Copyright (c) 2011 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog showing signed changesets.
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
11 import re
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
13 from PyQt5.QtCore import pyqtSlot, Qt, QCoreApplication
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
14 from PyQt5.QtWidgets import (
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
15 QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
16 )
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from .Ui_HgGpgSignaturesDialog import Ui_HgGpgSignaturesDialog
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 class HgGpgSignaturesDialog(QDialog, Ui_HgGpgSignaturesDialog):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Class implementing a dialog showing signed changesets.
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 def __init__(self, vcs, parent=None):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Constructor
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @param vcs reference to the vcs object
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @param parent reference to the parent widget (QWidget)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
32 super(HgGpgSignaturesDialog, self).__init__(parent)
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.setupUi(self)
4278
ccd1e13cb9bd Fixed issues where dialogs could not be minimized on some desktop environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4126
diff changeset
34 self.setWindowFlags(Qt.Window)
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.vcs = vcs
1249
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
40 self.__hgClient = vcs.getClient()
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
1260
9488a3aceb0e Added code to some Mercurial dialogs to improve user experience.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1256
diff changeset
42 self.show()
9488a3aceb0e Added code to some Mercurial dialogs to improve user experience.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1256
diff changeset
43 QCoreApplication.processEvents()
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 def closeEvent(self, e):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
47 Protected slot implementing a close event handler.
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 @param e close event (QCloseEvent)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
51 if self.__hgClient.isExecuting():
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
52 self.__hgClient.cancel()
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 e.accept()
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 def start(self, path):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 Public slot to start the list command.
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 @param path name of directory (string)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.errorGroup.hide()
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.intercept = False
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.activateWindow()
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.__path = path
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 dname, fname = self.vcs.splitPath(path)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 # find the root of the repo
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 repodir = dname
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 repodir = os.path.dirname(repodir)
1318
6fa303bd65d6 Fixed issues in various Mercurial files that could cause infinite loops on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1260
diff changeset
74 if os.path.splitdrive(repodir)[1] == os.sep:
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 return
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
3302
e92f0dd51979 Removed the Mercurial support for a command options dialog and added useable global options to the Mercurial config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
77 args = self.vcs.initCommand("sigs")
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
79 out, err = self.__hgClient.runcommand(args)
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
80 if err:
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
81 self.__showError(err)
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
82 if out:
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
83 for line in out.splitlines():
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
84 self.__processOutputLine(line)
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
85 if self.__hgClient.wasCanceled():
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
86 break
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
87 self.__finish()
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 def __finish(self):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 """
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
91 Private slot called when the process finished or the user pressed
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
92 the button.
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
97 self.buttonBox.button(QDialogButtonBox.Close).setFocus(
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
98 Qt.OtherFocusReason)
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 if self.signaturesList.topLevelItemCount() == 0:
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 # no patches present
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
102 self.__generateItem("", "", self.tr("no signatures found"))
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 self.__resizeColumns()
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 self.__resort()
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 def on_buttonBox_clicked(self, button):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 Private slot called by a button of the button box clicked.
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 @param button button that was clicked (QAbstractButton)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 if button == self.buttonBox.button(QDialogButtonBox.Close):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.close()
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
115 self.__hgClient.cancel()
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 def __resort(self):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 Private method to resort the tree.
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 """
3023
34ce20603bf7 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
121 self.signaturesList.sortItems(
34ce20603bf7 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
122 self.signaturesList.sortColumn(),
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 self.signaturesList.header().sortIndicatorOrder())
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 def __resizeColumns(self):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 Private method to resize the list columns.
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 """
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
129 self.signaturesList.header().resizeSections(
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
130 QHeaderView.ResizeToContents)
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 self.signaturesList.header().setStretchLastSection(True)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 def __generateItem(self, revision, changeset, signature):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 Private method to generate a patch item in the list of patches.
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 @param revision revision number (string)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 @param changeset changeset of the bookmark (string)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 @param signature signature of the changeset (string)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 if revision == "" and changeset == "":
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 QTreeWidgetItem(self.signaturesList, [signature])
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 else:
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 revString = "{0:>7}:{1}".format(revision, changeset)
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
145 topItems = self.signaturesList.findItems(
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
146 revString, Qt.MatchExactly)
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 if len(topItems) == 0:
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 # first signature for this changeset
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 topItm = QTreeWidgetItem(self.signaturesList, [
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 "{0:>7}:{1}".format(revision, changeset)])
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 topItm.setExpanded(True)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 font = topItm.font(0)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 font.setBold(True)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 topItm.setFont(0, font)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 else:
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 topItm = topItems[0]
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 QTreeWidgetItem(topItm, [signature])
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158
1249
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
159 def __processOutputLine(self, line):
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
160 """
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
161 Private method to process the lines of output.
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
162
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
163 @param line output line to be processed (string)
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
164 """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
165 li = line.split()
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
166 if li[-1][0] in "1234567890":
1249
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
167 # last element is a rev:changeset
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
168 rev, changeset = li[-1].split(":", 1)
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
169 del li[-1]
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
170 signature = " ".join(li)
1249
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
171 self.__generateItem(rev, changeset, signature)
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
1249
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
173 def __showError(self, out):
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
174 """
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
175 Private slot to show some error.
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
176
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
177 @param out error to be shown (string)
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
178 """
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
179 self.errorGroup.show()
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
180 self.errors.insertPlainText(out)
77f836a883c1 Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
181 self.errors.ensureCursorVisible()
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 @pyqtSlot()
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 def on_signaturesList_itemSelectionChanged(self):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 Private slot handling changes of the selection.
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 selectedItems = self.signaturesList.selectedItems()
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
189 if (
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
190 len(selectedItems) == 1 and
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
191 self.signaturesList.indexOfTopLevelItem(selectedItems[0]) != -1
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
192 ):
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 self.verifyButton.setEnabled(True)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 else:
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 self.verifyButton.setEnabled(False)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 @pyqtSlot()
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 def on_verifyButton_clicked(self):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 Private slot to verify the signatures of the selected revision.
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 """
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
202 rev = (
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
203 self.signaturesList.selectedItems()[0].text(0)
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
204 .split(":")[0].strip()
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
205 )
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
206 self.vcs.getExtensionObject("gpg").hgGpgVerifySignatures(
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
207 self.__path, rev)
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 @pyqtSlot(str)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 def on_categoryCombo_activated(self, txt):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 Private slot called, when a new filter category is selected.
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 @param txt text of the selected category (string)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 self.__filterSignatures()
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 @pyqtSlot(str)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 def on_rxEdit_textChanged(self, txt):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 Private slot called, when a filter expression is entered.
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 @param txt filter expression (string)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 self.__filterSignatures()
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 def __filterSignatures(self):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 Private method to filter the log entries.
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 """
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 searchRxText = self.rxEdit.text()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
232 filterTop = self.categoryCombo.currentText() == self.tr("Revision")
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 if filterTop and searchRxText.startswith("^"):
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
234 searchRx = re.compile(
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
235 r"^\s*{0}".format(searchRxText[1:]), re.IGNORECASE)
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 else:
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
237 searchRx = re.compile(searchRxText, re.IGNORECASE)
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 for topIndex in range(self.signaturesList.topLevelItemCount()):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 topLevelItem = self.signaturesList.topLevelItem(topIndex)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 if filterTop:
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
241 topLevelItem.setHidden(
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
242 searchRx.search(topLevelItem.text(0)) is None)
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 else:
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 visibleChildren = topLevelItem.childCount()
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 for childIndex in range(topLevelItem.childCount()):
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 childItem = topLevelItem.child(childIndex)
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
247 if searchRx.search(childItem.text(0)) is None:
1075
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 childItem.setHidden(True)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 visibleChildren -= 1
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 else:
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 childItem.setHidden(False)
75bfe8bd4243 Added support for the Mercurial gpg extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 topLevelItem.setHidden(visibleChildren == 0)

eric ide

mercurial