eric6/Network/IRC/IrcServerEditDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

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

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

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

from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QDialog, QDialogButtonBox

from .Ui_IrcServerEditDialog import Ui_IrcServerEditDialog


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(IrcServerEditDialog, self).__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()
        
        msh = self.minimumSizeHint()
        self.resize(max(self.width(), msh.width()), msh.height())
    
    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)
        """
        from .IrcNetworkManager import 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