|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2012 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to edit channel data. |
|
8 """ |
|
9 |
|
10 from PyQt6.QtCore import pyqtSlot |
|
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
|
12 |
|
13 from .Ui_IrcChannelEditDialog import Ui_IrcChannelEditDialog |
|
14 |
|
15 |
|
16 class IrcChannelEditDialog(QDialog, Ui_IrcChannelEditDialog): |
|
17 """ |
|
18 Class implementing a dialog to edit channel data. |
|
19 """ |
|
20 def __init__(self, name, key, autoJoin, edit, parent=None): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param name channel name (string) |
|
25 @param key channel key (string) |
|
26 @param autoJoin flag indicating, that the channel should |
|
27 be joined automatically (boolean) |
|
28 @param edit flag indicating an edit of an existing |
|
29 channel (boolean) |
|
30 @param parent reference to the parent widget (QWidget) |
|
31 """ |
|
32 super().__init__(parent) |
|
33 self.setupUi(self) |
|
34 |
|
35 self.nameEdit.setText(name) |
|
36 self.keyEdit.setText(key) |
|
37 self.autoJoinCheckBox.setChecked(autoJoin) |
|
38 |
|
39 self.nameEdit.setReadOnly(edit) |
|
40 |
|
41 self.buttonBox.button( |
|
42 QDialogButtonBox.StandardButton.Ok).setEnabled(name != "") |
|
43 |
|
44 msh = self.minimumSizeHint() |
|
45 self.resize(max(self.width(), msh.width()), msh.height()) |
|
46 |
|
47 @pyqtSlot(str) |
|
48 def on_nameEdit_textChanged(self, txt): |
|
49 """ |
|
50 Private slot to handle changes of the given name. |
|
51 |
|
52 @param txt text of the edit (string) |
|
53 """ |
|
54 self.buttonBox.button( |
|
55 QDialogButtonBox.StandardButton.Ok).setEnabled(txt != "") |
|
56 |
|
57 def getData(self): |
|
58 """ |
|
59 Public method to get the channel data. |
|
60 |
|
61 @return tuple giving the channel name, channel key and a flag |
|
62 indicating, that the channel should be joined automatically |
|
63 (string, string, boolean) |
|
64 """ |
|
65 return (self.nameEdit.text(), |
|
66 self.keyEdit.text(), |
|
67 self.autoJoinCheckBox.isChecked()) |