ExtensionIrc/IrcChannelEditDialog.py

changeset 2
5b635dc8895f
equal deleted inserted replaced
1:60cb9d784005 2:5b635dc8895f
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2012 - 2025 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
21 def __init__(self, name, key, autoJoin, edit, parent=None):
22 """
23 Constructor
24
25 @param name channel name
26 @type str
27 @param key channel key
28 @type str
29 @param autoJoin flag indicating, that the channel should
30 be joined automatically
31 @type bool
32 @param edit flag indicating an edit of an existing
33 channel
34 @type bool
35 @param parent reference to the parent widget
36 @type QWidget
37 """
38 super().__init__(parent)
39 self.setupUi(self)
40
41 self.nameEdit.setText(name)
42 self.keyEdit.setText(key)
43 self.autoJoinCheckBox.setChecked(autoJoin)
44
45 self.nameEdit.setReadOnly(edit)
46
47 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(name != "")
48
49 msh = self.minimumSizeHint()
50 self.resize(max(self.width(), msh.width()), msh.height())
51
52 @pyqtSlot(str)
53 def on_nameEdit_textChanged(self, txt):
54 """
55 Private slot to handle changes of the given name.
56
57 @param txt text of the edit
58 @type str
59 """
60 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(txt != "")
61
62 def getData(self):
63 """
64 Public method to get the channel data.
65
66 @return tuple giving the channel name, channel key and a flag
67 indicating, that the channel should be joined automatically
68 @rtype tuple of (str, str, bool)
69 """
70 return (
71 self.nameEdit.text(),
72 self.keyEdit.text(),
73 self.autoJoinCheckBox.isChecked(),
74 )

eric ide

mercurial