]> jfr.im git - irc/weechat/qweechat.git/blob - qweechat/connection.py
Remove python shebangs
[irc/weechat/qweechat.git] / qweechat / connection.py
1 # -*- coding: utf-8 -*-
2 #
3 # connection.py - connection window
4 #
5 # Copyright (C) 2011-2014 Sébastien Helleu <flashcode@flashtux.org>
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
23 import qt_compat
24 QtGui = qt_compat.import_module('QtGui')
25
26
27 class ConnectionDialog(QtGui.QDialog):
28 """Connection window."""
29
30 def __init__(self, values, *args):
31 QtGui.QDialog.__init__(*(self,) + args)
32 self.values = values
33 self.setModal(True)
34
35 grid = QtGui.QGridLayout()
36 grid.setSpacing(10)
37
38 self.fields = {}
39 for y, field in enumerate(('server', 'port', 'password', 'lines')):
40 grid.addWidget(QtGui.QLabel(field.capitalize()), y, 0)
41 lineEdit = QtGui.QLineEdit()
42 lineEdit.setFixedWidth(200)
43 if field == 'password':
44 lineEdit.setEchoMode(QtGui.QLineEdit.Password)
45 if field == 'lines':
46 validator = QtGui.QIntValidator(0, 2147483647, self)
47 lineEdit.setValidator(validator)
48 lineEdit.setFixedWidth(80)
49 lineEdit.insert(self.values[field])
50 grid.addWidget(lineEdit, y, 1)
51 self.fields[field] = lineEdit
52 if field == 'port':
53 ssl = QtGui.QCheckBox('SSL')
54 ssl.setChecked(self.values['ssl'] == 'on')
55 grid.addWidget(ssl, y, 2)
56 self.fields['ssl'] = ssl
57
58 self.dialog_buttons = QtGui.QDialogButtonBox()
59 self.dialog_buttons.setStandardButtons(
60 QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
61 self.dialog_buttons.rejected.connect(self.close)
62
63 grid.addWidget(self.dialog_buttons, 4, 0, 1, 2)
64 self.setLayout(grid)
65 self.show()