SelectionEncloser/ConfigurationPage/SelectionEncloserEditDialog.py

Tue, 01 Jun 2021 18:45:45 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 01 Jun 2021 18:45:45 +0200
branch
eric7
changeset 51
318d7ebbdce2
parent 45
896b66ba45f0
child 52
d2119f1dd5b3
permissions
-rw-r--r--

Ported the plug-in to PyQt6 for eric7.

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

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

"""
Module implementing a dialog to edit an enclosing menu entry.
"""

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

from .Ui_SelectionEncloserEditDialog import Ui_SelectionEncloserEditDialog


class SelectionEncloserEditDialog(QDialog, Ui_SelectionEncloserEditDialog):
    """
    Class implementing a dialog to edit an enclosing menu entry.
    """
    def __init__(self, title="", string="", parent=None):
        """
        Constructor
        
        @param title menu entry title
        @type str
        @param string enclosing string or string format expression
        @type str
        @param parent reference to the parent widget
        @type QWidget
        """
        super().__init__(parent)
        self.setupUi(self)
        
        self.titleEdit.setText(title)
        self.stringEdit.setText(string)
        
        msh = self.minimumSizeHint()
        self.resize(max(self.size().width(), msh.width()), msh.height())
        
        self.__updateOkButton()
    
    def __updateOkButton(self):
        """
        Private slot to set the status of the OK button.
        """
        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
            bool(self.titleEdit.text()) and bool(self.stringEdit.text()))
    
    @pyqtSlot(str)
    def on_titleEdit_textChanged(self, txt):
        """
        Private slot to react on changes of the title.
        
        @param txt title text
        @type str
        """
        self.__updateOkButton()
    
    @pyqtSlot(str)
    def on_stringEdit_textChanged(self, txt):
        """
        Private slot to react on changes of the string.
        
        @param txt enclosing string
        @type str
        """
        self.__updateOkButton()
    
    def getData(self):
        """
        Public method to get the dialog data.
        
        @return tuple with menu entry title and enclosing string or string
            format expression
        @rtype tuple of (str, str)
        """
        return self.titleEdit.text(), self.stringEdit.text()

eric ide

mercurial