eric7/HelpViewer/HelpBookmarkPropertiesDialog.py

Tue, 04 Jan 2022 17:13:35 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 04 Jan 2022 17:13:35 +0100
branch
eric7
changeset 8900
9c153ce17d74
child 8902
ba9b8c6e4928
permissions
-rw-r--r--

Help Viewer
- added bookmarks to the internal help viewer

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

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

"""
Module implementing a dialog to edit the bookmark properties.
"""

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

from .Ui_HelpBookmarkPropertiesDialog import Ui_HelpBookmarkPropertiesDialog


class HelpBookmarkPropertiesDialog(QDialog, Ui_HelpBookmarkPropertiesDialog):
    """
    Class implementing a dialog to edit the bookmark properties.
    """
    def __init__(self, title="", url="", parent=None):
        """
        Constructor
        
        @param title title for the bookmark (defaults to "")
        @type str (optional)
        @param url URL for the bookmark (defaults to "")
        @type str (optional)
        @param parent reference to the parent widget (defaults to None)
        @type QWidget (optional)
        """
        super().__init__(parent)
        self.setupUi(self)
        
        self.titleEdit.textChanged.connect(self.__updateOkButton)
        self.urlEdit.textChanged.connect(self.__updateOkButton)
        
        self.titleEdit.setText(title)
        self.urlEdit.setText(url)
        
        msh = self.minimumSizeHint()
        self.resize(max(self.width(), msh.width()), msh.height())
    
    @pyqtSlot()
    def __updateOkButton(self):
        """
        Private method to set the enabled state of the OK button.
        """
        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
            bool(self.titleEdit.text().strip()) and
            bool(self.urlEdit.text().strip())
        )
    
    def getData(self):
        """
        Public method to retrieve the entered data
        
        @return tuple containing the title and URL for the bookmark
        @rtype tuple of (str, str)
        """
        return (
            self.titleEdit.text().strip(),
            self.urlEdit.text().strip(),
        )

eric ide

mercurial