2011-12-06 20:27:09 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
2013-02-04 09:29:51 +00:00
|
|
|
# connection.py - connection window
|
|
|
|
#
|
2014-02-07 10:33:46 +00:00
|
|
|
# Copyright (C) 2011-2014 Sébastien Helleu <flashcode@flashtux.org>
|
2011-12-06 20:27:09 +00:00
|
|
|
#
|
|
|
|
# This file is part of QWeeChat, a Qt remote GUI for WeeChat.
|
|
|
|
#
|
|
|
|
# QWeeChat is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# QWeeChat is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with QWeeChat. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
import qt_compat
|
|
|
|
QtGui = qt_compat.import_module('QtGui')
|
|
|
|
|
|
|
|
|
|
|
|
class ConnectionDialog(QtGui.QDialog):
|
2014-02-07 12:03:15 +00:00
|
|
|
"""Connection window."""
|
2011-12-06 20:27:09 +00:00
|
|
|
|
|
|
|
def __init__(self, values, *args):
|
2011-12-24 10:57:43 +00:00
|
|
|
QtGui.QDialog.__init__(*(self,) + args)
|
2011-12-06 20:27:09 +00:00
|
|
|
self.values = values
|
|
|
|
self.setModal(True)
|
|
|
|
|
|
|
|
grid = QtGui.QGridLayout()
|
|
|
|
grid.setSpacing(10)
|
|
|
|
|
|
|
|
self.fields = {}
|
2014-02-07 12:03:15 +00:00
|
|
|
for y, field in enumerate(('server', 'port', 'password', 'lines')):
|
2011-12-06 20:27:09 +00:00
|
|
|
grid.addWidget(QtGui.QLabel(field.capitalize()), y, 0)
|
|
|
|
lineEdit = QtGui.QLineEdit()
|
2012-07-27 15:56:55 +00:00
|
|
|
lineEdit.setFixedWidth(200)
|
2011-12-06 20:27:09 +00:00
|
|
|
if field == 'password':
|
|
|
|
lineEdit.setEchoMode(QtGui.QLineEdit.Password)
|
2014-02-07 12:03:15 +00:00
|
|
|
if field == 'lines':
|
|
|
|
validator = QtGui.QIntValidator(0, 2147483647, self)
|
|
|
|
lineEdit.setValidator(validator)
|
|
|
|
lineEdit.setFixedWidth(80)
|
2011-12-06 20:27:09 +00:00
|
|
|
lineEdit.insert(self.values[field])
|
|
|
|
grid.addWidget(lineEdit, y, 1)
|
|
|
|
self.fields[field] = lineEdit
|
2012-07-27 15:56:55 +00:00
|
|
|
if field == 'port':
|
|
|
|
ssl = QtGui.QCheckBox('SSL')
|
|
|
|
ssl.setChecked(self.values['ssl'] == 'on')
|
|
|
|
grid.addWidget(ssl, y, 2)
|
|
|
|
self.fields['ssl'] = ssl
|
2011-12-06 20:27:09 +00:00
|
|
|
|
|
|
|
self.dialog_buttons = QtGui.QDialogButtonBox()
|
2014-05-08 15:40:31 +00:00
|
|
|
self.dialog_buttons.setStandardButtons(
|
|
|
|
QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
|
2011-12-06 20:27:09 +00:00
|
|
|
self.dialog_buttons.rejected.connect(self.close)
|
|
|
|
|
2014-02-07 12:03:15 +00:00
|
|
|
grid.addWidget(self.dialog_buttons, 4, 0, 1, 2)
|
2011-12-06 20:27:09 +00:00
|
|
|
self.setLayout(grid)
|
|
|
|
self.show()
|