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