15 |
15 |
16 class IrcChannelEditDialog(QDialog, Ui_IrcChannelEditDialog): |
16 class IrcChannelEditDialog(QDialog, Ui_IrcChannelEditDialog): |
17 """ |
17 """ |
18 Class implementing a dialog to edit channel data. |
18 Class implementing a dialog to edit channel data. |
19 """ |
19 """ |
|
20 |
20 def __init__(self, name, key, autoJoin, edit, parent=None): |
21 def __init__(self, name, key, autoJoin, edit, parent=None): |
21 """ |
22 """ |
22 Constructor |
23 Constructor |
23 |
24 |
24 @param name channel name (string) |
25 @param name channel name (string) |
25 @param key channel key (string) |
26 @param key channel key (string) |
26 @param autoJoin flag indicating, that the channel should |
27 @param autoJoin flag indicating, that the channel should |
27 be joined automatically (boolean) |
28 be joined automatically (boolean) |
28 @param edit flag indicating an edit of an existing |
29 @param edit flag indicating an edit of an existing |
29 channel (boolean) |
30 channel (boolean) |
30 @param parent reference to the parent widget (QWidget) |
31 @param parent reference to the parent widget (QWidget) |
31 """ |
32 """ |
32 super().__init__(parent) |
33 super().__init__(parent) |
33 self.setupUi(self) |
34 self.setupUi(self) |
34 |
35 |
35 self.nameEdit.setText(name) |
36 self.nameEdit.setText(name) |
36 self.keyEdit.setText(key) |
37 self.keyEdit.setText(key) |
37 self.autoJoinCheckBox.setChecked(autoJoin) |
38 self.autoJoinCheckBox.setChecked(autoJoin) |
38 |
39 |
39 self.nameEdit.setReadOnly(edit) |
40 self.nameEdit.setReadOnly(edit) |
40 |
41 |
41 self.buttonBox.button( |
42 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(name != "") |
42 QDialogButtonBox.StandardButton.Ok).setEnabled(name != "") |
43 |
43 |
|
44 msh = self.minimumSizeHint() |
44 msh = self.minimumSizeHint() |
45 self.resize(max(self.width(), msh.width()), msh.height()) |
45 self.resize(max(self.width(), msh.width()), msh.height()) |
46 |
46 |
47 @pyqtSlot(str) |
47 @pyqtSlot(str) |
48 def on_nameEdit_textChanged(self, txt): |
48 def on_nameEdit_textChanged(self, txt): |
49 """ |
49 """ |
50 Private slot to handle changes of the given name. |
50 Private slot to handle changes of the given name. |
51 |
51 |
52 @param txt text of the edit (string) |
52 @param txt text of the edit (string) |
53 """ |
53 """ |
54 self.buttonBox.button( |
54 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(txt != "") |
55 QDialogButtonBox.StandardButton.Ok).setEnabled(txt != "") |
55 |
56 |
|
57 def getData(self): |
56 def getData(self): |
58 """ |
57 """ |
59 Public method to get the channel data. |
58 Public method to get the channel data. |
60 |
59 |
61 @return tuple giving the channel name, channel key and a flag |
60 @return tuple giving the channel name, channel key and a flag |
62 indicating, that the channel should be joined automatically |
61 indicating, that the channel should be joined automatically |
63 (string, string, boolean) |
62 (string, string, boolean) |
64 """ |
63 """ |
65 return (self.nameEdit.text(), |
64 return ( |
66 self.keyEdit.text(), |
65 self.nameEdit.text(), |
67 self.autoJoinCheckBox.isChecked()) |
66 self.keyEdit.text(), |
|
67 self.autoJoinCheckBox.isChecked(), |
|
68 ) |