Network/IRC/IrcServerEditDialog.py

Wed, 01 Jan 2014 14:40:41 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 01 Jan 2014 14:40:41 +0100
branch
5_3_x
changeset 3163
9f50365a0870
parent 2302
f29e9405c851
permissions
-rw-r--r--

Updated copyright for 2014.

# -*- coding: utf-8 -*-

# Copyright (c) 2012 - 2014 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog for editing the IRC server configuration.
"""

from PyQt4.QtCore import pyqtSlot
from PyQt4.QtGui import QDialog, QDialogButtonBox

from .Ui_IrcServerEditDialog import Ui_IrcServerEditDialog

from .IrcNetworkManager import IrcServer


class IrcServerEditDialog(QDialog, Ui_IrcServerEditDialog):
    """
    Class implementing a dialog for editing the IRC server configuration.
    """
    def __init__(self, server, parent=None):
        """
        Constructor
        
        @param server reference to the IRC server object (IrcServer)
        @param parent reference to the parent widget (QWidget)
        """
        super().__init__(parent)
        self.setupUi(self)
        
        self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok)
        
        if server:
            self.serverEdit.setText(server.getName())
            self.portSpinBox.setValue(server.getPort())
            self.passwordEdit.setText(server.getPassword())
            self.sslCheckBox.setChecked(server.useSSL())
        
        self.__updateOkButton()
    
    def __updateOkButton(self):
        """
        Private method to update the OK button state.
        """
        self.__okButton.setEnabled(self.serverEdit.text() != "")
    
    @pyqtSlot(str)
    def on_serverEdit_textChanged(self, name):
        """
        Private slot handling changes of the server name.
        
        @param name current name of the server (string)
        """
        self.__updateOkButton()
    
    def getServer(self):
        """
        Public method to create a server object from the data entered into
        the dialog.
        
        @return server object (IrcServer)
        """
        server = IrcServer(self.serverEdit.text())
        server.setPort(self.portSpinBox.value())
        server.setPassword(self.passwordEdit.text())
        server.setUseSSL(self.sslCheckBox.isChecked())
        
        return server

eric ide

mercurial