eric6/Network/IRC/IrcChannelEditDialog.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2012 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to edit channel data.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import pyqtSlot
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
14
15 from .Ui_IrcChannelEditDialog import Ui_IrcChannelEditDialog
16
17
18 class IrcChannelEditDialog(QDialog, Ui_IrcChannelEditDialog):
19 """
20 Class implementing a dialog to edit channel data.
21 """
22 def __init__(self, name, key, autoJoin, edit, parent=None):
23 """
24 Constructor
25
26 @param name channel name (string)
27 @param key channel key (string)
28 @param autoJoin flag indicating, that the channel should
29 be joined automatically (boolean)
30 @param edit flag indicating an edit of an existing
31 channel (boolean)
32 @param parent reference to the parent widget (QWidget)
33 """
34 super(IrcChannelEditDialog, self).__init__(parent)
35 self.setupUi(self)
36
37 self.nameEdit.setText(name)
38 self.keyEdit.setText(key)
39 self.autoJoinCheckBox.setChecked(autoJoin)
40
41 self.nameEdit.setReadOnly(edit)
42
43 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(name != "")
44
45 msh = self.minimumSizeHint()
46 self.resize(max(self.width(), msh.width()), msh.height())
47
48 @pyqtSlot(str)
49 def on_nameEdit_textChanged(self, txt):
50 """
51 Private slot to handle changes of the given name.
52
53 @param txt text of the edit (string)
54 """
55 self.buttonBox.button(QDialogButtonBox.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())

eric ide

mercurial