|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2014 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Git command dialog. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtCore import pyqtSlot |
|
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
|
12 |
|
13 from .Ui_GitCommandDialog import Ui_GitCommandDialog |
|
14 |
|
15 import Utilities |
|
16 |
|
17 |
|
18 class GitCommandDialog(QDialog, Ui_GitCommandDialog): |
|
19 """ |
|
20 Class implementing the Git command dialog. |
|
21 |
|
22 It implements a dialog that is used to enter an |
|
23 arbitrary Git command. It asks the user to enter |
|
24 the commandline parameters. |
|
25 """ |
|
26 def __init__(self, argvList, ppath, parent=None): |
|
27 """ |
|
28 Constructor |
|
29 |
|
30 @param argvList history list of commandline arguments (list of strings) |
|
31 @param ppath pathname of the project directory (string) |
|
32 @param parent parent widget of this dialog (QWidget) |
|
33 """ |
|
34 super().__init__(parent) |
|
35 self.setupUi(self) |
|
36 |
|
37 self.okButton = self.buttonBox.button( |
|
38 QDialogButtonBox.StandardButton.Ok) |
|
39 self.okButton.setEnabled(False) |
|
40 |
|
41 self.commandCombo.clear() |
|
42 self.commandCombo.addItems(argvList) |
|
43 if len(argvList) > 0: |
|
44 self.commandCombo.setCurrentIndex(0) |
|
45 self.projectDirLabel.setText(ppath) |
|
46 |
|
47 # modify some what's this help texts |
|
48 t = self.commandCombo.whatsThis() |
|
49 if t: |
|
50 t += Utilities.getPercentReplacementHelp() |
|
51 self.commandCombo.setWhatsThis(t) |
|
52 |
|
53 msh = self.minimumSizeHint() |
|
54 self.resize(max(self.width(), msh.width()), msh.height()) |
|
55 |
|
56 @pyqtSlot(str) |
|
57 def on_commandCombo_editTextChanged(self, text): |
|
58 """ |
|
59 Private method used to enable/disable the OK-button. |
|
60 |
|
61 @param text ignored |
|
62 """ |
|
63 self.okButton.setDisabled(self.commandCombo.currentText() == "") |
|
64 |
|
65 def getData(self): |
|
66 """ |
|
67 Public method to retrieve the data entered into this dialog. |
|
68 |
|
69 @return commandline parameters (string) |
|
70 """ |
|
71 return self.commandCombo.currentText() |