|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2014 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter the data for an unshelve operation. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.QtWidgets import QDialog |
|
13 |
|
14 from .Ui_HgUnshelveDataDialog import Ui_HgUnshelveDataDialog |
|
15 |
|
16 |
|
17 class HgUnshelveDataDialog(QDialog, Ui_HgUnshelveDataDialog): |
|
18 """ |
|
19 Class implementing a dialog to enter the data for an unshelve operation. |
|
20 """ |
|
21 def __init__(self, shelveNames, shelveName="", parent=None): |
|
22 """ |
|
23 Constructor |
|
24 |
|
25 @param shelveNames list of available shelves (list of string) |
|
26 @param shelveName name of the shelve to restore (string) |
|
27 @param parent reference to the parent widget (QWidget) |
|
28 """ |
|
29 super(HgUnshelveDataDialog, self).__init__(parent) |
|
30 self.setupUi(self) |
|
31 |
|
32 self.nameComboBox.addItem("") |
|
33 self.nameComboBox.addItems(sorted(shelveNames)) |
|
34 |
|
35 if shelveName and shelveName in shelveNames: |
|
36 self.nameComboBox.setCurrentIndex( |
|
37 self.nameComboBox.findText(shelveName)) |
|
38 |
|
39 msh = self.minimumSizeHint() |
|
40 self.resize(max(self.width(), msh.width()), msh.height()) |
|
41 |
|
42 def getData(self): |
|
43 """ |
|
44 Public method to get the user data. |
|
45 |
|
46 @return tuple containing the name (string) and a flag indicating |
|
47 to keep the shelved change (boolean) |
|
48 """ |
|
49 return ( |
|
50 self.nameComboBox.currentText().replace(" ", "_"), |
|
51 self.keepCheckBox.isChecked() |
|
52 ) |