]>
Commit | Line | Data |
---|---|---|
7dcf23b1 SH |
1 | #!/usr/bin/python |
2 | # -*- coding: utf-8 -*- | |
3 | # | |
4 | # Copyright (C) 2011 Sebastien Helleu <flashcode@flashtux.org> | |
5 | # | |
6 | # This file is part of QWeeChat, a Qt remote GUI for WeeChat. | |
7 | # | |
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. | |
12 | # | |
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. | |
17 | # | |
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/>. | |
20 | # | |
21 | ||
22 | # | |
23 | # Connection window. | |
24 | # | |
25 | ||
26 | import qt_compat | |
27 | QtGui = qt_compat.import_module('QtGui') | |
28 | ||
29 | ||
30 | class ConnectionDialog(QtGui.QDialog): | |
31 | """Connection window with server/port/password fields.""" | |
32 | ||
33 | def __init__(self, values, *args): | |
34 | apply(QtGui.QDialog.__init__, (self,) + args) | |
35 | self.values = values | |
36 | self.setModal(True) | |
37 | ||
38 | grid = QtGui.QGridLayout() | |
39 | grid.setSpacing(10) | |
40 | ||
41 | self.fields = {} | |
42 | for y, field in enumerate(('server', 'port', 'password')): | |
43 | grid.addWidget(QtGui.QLabel(field.capitalize()), y, 0) | |
44 | lineEdit = QtGui.QLineEdit() | |
45 | if field == 'password': | |
46 | lineEdit.setEchoMode(QtGui.QLineEdit.Password) | |
47 | lineEdit.insert(self.values[field]) | |
48 | grid.addWidget(lineEdit, y, 1) | |
49 | self.fields[field] = lineEdit | |
50 | ||
51 | self.dialog_buttons = QtGui.QDialogButtonBox() | |
52 | self.dialog_buttons.setStandardButtons(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel) | |
53 | self.dialog_buttons.rejected.connect(self.close) | |
54 | ||
55 | grid.addWidget(self.dialog_buttons, 3, 0, 1, 2) | |
56 | self.setLayout(grid) | |
57 | self.show() |