]> jfr.im git - irc/weechat/qweechat.git/blame - qweechat/connection.py
Update copyright dates
[irc/weechat/qweechat.git] / qweechat / connection.py
CommitLineData
7dcf23b1
SH
1# -*- coding: utf-8 -*-
2#
e836cfb0
SH
3# connection.py - connection window
4#
235ad369 5# Copyright (C) 2011-2020 Sébastien Helleu <flashcode@flashtux.org>
7dcf23b1
SH
6#
7# This file is part of QWeeChat, a Qt remote GUI for WeeChat.
8#
9# QWeeChat is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 3 of the License, or
12# (at your option) any later version.
13#
14# QWeeChat is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with QWeeChat. If not, see <http://www.gnu.org/licenses/>.
21#
22
7dcf23b1 23import qt_compat
356719e0 24
7dcf23b1
SH
25QtGui = qt_compat.import_module('QtGui')
26
27
28class ConnectionDialog(QtGui.QDialog):
46e5dee0 29 """Connection window."""
7dcf23b1
SH
30
31 def __init__(self, values, *args):
67ae3204 32 QtGui.QDialog.__init__(*(self,) + args)
7dcf23b1
SH
33 self.values = values
34 self.setModal(True)
35
36 grid = QtGui.QGridLayout()
37 grid.setSpacing(10)
38
39 self.fields = {}
42f2f7ee
SH
40 for line, field in enumerate(('server', 'port', 'password', 'lines')):
41 grid.addWidget(QtGui.QLabel(field.capitalize()), line, 0)
42 line_edit = QtGui.QLineEdit()
43 line_edit.setFixedWidth(200)
7dcf23b1 44 if field == 'password':
42f2f7ee 45 line_edit.setEchoMode(QtGui.QLineEdit.Password)
46e5dee0
SH
46 if field == 'lines':
47 validator = QtGui.QIntValidator(0, 2147483647, self)
42f2f7ee
SH
48 line_edit.setValidator(validator)
49 line_edit.setFixedWidth(80)
50 line_edit.insert(self.values[field])
51 grid.addWidget(line_edit, line, 1)
52 self.fields[field] = line_edit
77b25057
SH
53 if field == 'port':
54 ssl = QtGui.QCheckBox('SSL')
55 ssl.setChecked(self.values['ssl'] == 'on')
42f2f7ee 56 grid.addWidget(ssl, line, 2)
77b25057 57 self.fields['ssl'] = ssl
7dcf23b1
SH
58
59 self.dialog_buttons = QtGui.QDialogButtonBox()
77df9d06
SH
60 self.dialog_buttons.setStandardButtons(
61 QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
7dcf23b1
SH
62 self.dialog_buttons.rejected.connect(self.close)
63
46e5dee0 64 grid.addWidget(self.dialog_buttons, 4, 0, 1, 2)
7dcf23b1
SH
65 self.setLayout(grid)
66 self.show()