|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2014 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter the data for a shelve operation. |
|
8 """ |
|
9 |
|
10 from PyQt6.QtCore import QDateTime |
|
11 from PyQt6.QtWidgets import QDialog |
|
12 |
|
13 from .Ui_HgShelveDataDialog import Ui_HgShelveDataDialog |
|
14 |
|
15 |
|
16 class HgShelveDataDialog(QDialog, Ui_HgShelveDataDialog): |
|
17 """ |
|
18 Class implementing a dialog to enter the data for a shelve operation. |
|
19 """ |
|
20 |
|
21 def __init__(self, version, parent=None): |
|
22 """ |
|
23 Constructor |
|
24 |
|
25 @param version Mercurial version |
|
26 @type tuple of three int |
|
27 @param parent reference to the parent widget |
|
28 @type QWidget |
|
29 """ |
|
30 super().__init__(parent) |
|
31 self.setupUi(self) |
|
32 |
|
33 self.__initialDateTime = QDateTime.currentDateTime() |
|
34 self.dateTimeEdit.setDateTime(self.__initialDateTime) |
|
35 |
|
36 if version < (5, 0, 0): |
|
37 self.keepCheckBox.setChecked(False) |
|
38 self.keepCheckBox.hide() |
|
39 |
|
40 msh = self.minimumSizeHint() |
|
41 self.resize(max(self.width(), msh.width()), msh.height()) |
|
42 |
|
43 def getData(self): |
|
44 """ |
|
45 Public method to get the user data. |
|
46 |
|
47 @return tuple containing the name, date, message, a flag indicating |
|
48 to add/remove new/missing files and a flag indicating to keep the |
|
49 shelved changes in the working directory |
|
50 @rtype tuple of (str, QDateTime, str, bool, bool) |
|
51 """ |
|
52 dateTime = ( |
|
53 self.dateTimeEdit.dateTime() |
|
54 if self.dateTimeEdit.dateTime() != self.__initialDateTime |
|
55 else QDateTime() |
|
56 ) |
|
57 return ( |
|
58 self.nameEdit.text().replace(" ", "_"), |
|
59 dateTime, |
|
60 self.messageEdit.text(), |
|
61 self.addRemoveCheckBox.isChecked(), |
|
62 self.keepCheckBox.isChecked(), |
|
63 ) |