]>
Commit | Line | Data |
---|---|---|
7dcf23b1 SH |
1 | #!/usr/bin/python |
2 | # -*- coding: utf-8 -*- | |
3 | # | |
e836cfb0 SH |
4 | # connection.py - connection window |
5 | # | |
e17d5dc0 | 6 | # Copyright (C) 2011-2013 Sebastien Helleu <flashcode@flashtux.org> |
7dcf23b1 SH |
7 | # |
8 | # This file is part of QWeeChat, a Qt remote GUI for WeeChat. | |
9 | # | |
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. | |
14 | # | |
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. | |
19 | # | |
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/>. | |
22 | # | |
23 | ||
7dcf23b1 SH |
24 | import qt_compat |
25 | QtGui = qt_compat.import_module('QtGui') | |
26 | ||
27 | ||
28 | class ConnectionDialog(QtGui.QDialog): | |
29 | """Connection window with server/port/password fields.""" | |
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 = {} | |
40 | for y, field in enumerate(('server', 'port', 'password')): | |
41 | grid.addWidget(QtGui.QLabel(field.capitalize()), y, 0) | |
42 | lineEdit = QtGui.QLineEdit() | |
77b25057 | 43 | lineEdit.setFixedWidth(200) |
7dcf23b1 SH |
44 | if field == 'password': |
45 | lineEdit.setEchoMode(QtGui.QLineEdit.Password) | |
46 | lineEdit.insert(self.values[field]) | |
47 | grid.addWidget(lineEdit, y, 1) | |
48 | self.fields[field] = lineEdit | |
77b25057 SH |
49 | if field == 'port': |
50 | ssl = QtGui.QCheckBox('SSL') | |
51 | ssl.setChecked(self.values['ssl'] == 'on') | |
52 | grid.addWidget(ssl, y, 2) | |
53 | self.fields['ssl'] = ssl | |
7dcf23b1 SH |
54 | |
55 | self.dialog_buttons = QtGui.QDialogButtonBox() | |
56 | self.dialog_buttons.setStandardButtons(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel) | |
57 | self.dialog_buttons.rejected.connect(self.close) | |
58 | ||
59 | grid.addWidget(self.dialog_buttons, 3, 0, 1, 2) | |
60 | self.setLayout(grid) | |
61 | self.show() |