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