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