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