]>
jfr.im git - irc/weechat/qweechat.git/blob - src/qweechat/connection.py
2 # -*- coding: utf-8 -*-
4 # connection.py - connection window
6 # Copyright (C) 2011-2014 Sébastien Helleu <flashcode@flashtux.org>
8 # This file is part of QWeeChat, a Qt remote GUI for WeeChat.
10 # QWeeChat is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # QWeeChat is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with QWeeChat. If not, see <http://www.gnu.org/licenses/>.
25 QtGui
= qt_compat
.import_module('QtGui')
28 class ConnectionDialog(QtGui
.QDialog
):
29 """Connection window."""
31 def __init__(self
, values
, *args
):
32 QtGui
.QDialog
.__init
__(*(self
,) + args
)
36 grid
= QtGui
.QGridLayout()
40 for y
, field
in enumerate(('server', 'port', 'password', 'lines')):
41 grid
.addWidget(QtGui
.QLabel(field
.capitalize()), y
, 0)
42 lineEdit
= QtGui
.QLineEdit()
43 lineEdit
.setFixedWidth(200)
44 if field
== 'password':
45 lineEdit
.setEchoMode(QtGui
.QLineEdit
.Password
)
47 validator
= QtGui
.QIntValidator(0, 2147483647, self
)
48 lineEdit
.setValidator(validator
)
49 lineEdit
.setFixedWidth(80)
50 lineEdit
.insert(self
.values
[field
])
51 grid
.addWidget(lineEdit
, y
, 1)
52 self
.fields
[field
] = lineEdit
54 ssl
= QtGui
.QCheckBox('SSL')
55 ssl
.setChecked(self
.values
['ssl'] == 'on')
56 grid
.addWidget(ssl
, y
, 2)
57 self
.fields
['ssl'] = ssl
59 self
.dialog_buttons
= QtGui
.QDialogButtonBox()
60 self
.dialog_buttons
.setStandardButtons(QtGui
.QDialogButtonBox
.Ok | QtGui
.QDialogButtonBox
.Cancel
)
61 self
.dialog_buttons
.rejected
.connect(self
.close
)
63 grid
.addWidget(self
.dialog_buttons
, 4, 0, 1, 2)