src/eric7/WebBrowser/QtHelp/QtHelpDocumentationConfigurationDialog.py

Thu, 07 Jul 2022 11:23:56 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 07 Jul 2022 11:23:56 +0200
branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
eric7/WebBrowser/QtHelp/QtHelpDocumentationConfigurationDialog.py@54e42bc2437a
child 9221
bf71ee032bb4
permissions
-rw-r--r--

Reorganized the project structure to use the source layout in order to support up-to-date build systems with "pyproject.toml".

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

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

"""
Module implementing a dialog to manage the QtHelp documentation database.
"""

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

from .Ui_QtHelpDocumentationConfigurationDialog import (
    Ui_QtHelpDocumentationConfigurationDialog
)

from .QtHelpDocumentationSettings import QtHelpDocumentationSettings


class QtHelpDocumentationConfigurationDialog(
    QDialog, Ui_QtHelpDocumentationConfigurationDialog
):
    """
    Class implementing a dialog to manage the QtHelp documentation database.
    """
    def __init__(self, engine, parent=None):
        """
        Constructor
        
        @param engine reference to the Qt help engine
        @type QHelpEngineCore
        @param parent reference to the parent widget (defaults to None)
        @type QWidget (optional)
        """
        super().__init__(parent)
        self.setupUi(self)
        
        self.__engine = engine
        
        self.__settings = QtHelpDocumentationSettings.readSettings(
            self.__engine)
        
        self.documentationSettingsWidget.documentationSettingsChanged.connect(
            self.__documentationSettingsChanged)
        self.documentationSettingsWidget.setDocumentationSettings(
            self.__settings)
        
        self.filterSettingsWidget.setAvailableComponents(
            self.__settings.components())
        self.filterSettingsWidget.setAvailableVersions(
            self.__settings.versions())
        self.filterSettingsWidget.readSettings(self.__engine.filterEngine())
    
    @pyqtSlot(QtHelpDocumentationSettings)
    def __documentationSettingsChanged(self, settings):
        """
        Private slot to handle a change of the QtHelp documentation
        configuration.
        
        @param settings reference to the documentation settings object
        @type QtHelpDocumentationSettings
        """
        self.__settings = settings
        
        self.filterSettingsWidget.setAvailableComponents(
            self.__settings.components())
        self.filterSettingsWidget.setAvailableVersions(
            self.__settings.versions())
    
    @pyqtSlot(QAbstractButton)
    def on_buttonBox_clicked(self, button):
        """
        Private slot called by a button of the button box clicked.
        
        @param button button that was clicked
        @type QAbstractButton
        """
        if button == self.buttonBox.button(
                QDialogButtonBox.StandardButton.Apply):
            self.__applyConfiguration()
            
            self.__settings = QtHelpDocumentationSettings.readSettings(
                self.__engine)
            
            self.filterSettingsWidget.setAvailableComponents(
                self.__settings.components())
            self.filterSettingsWidget.setAvailableVersions(
                self.__settings.versions())
            self.filterSettingsWidget.readSettings(
                self.__engine.filterEngine())
        elif button == self.buttonBox.button(
                QDialogButtonBox.StandardButton.Ok):
            self.__applyConfiguration()
            self.accept()
    
    def __applyConfiguration(self):
        """
        Private method to apply the current QtHelp documentation configuration.
        """
        changed = QtHelpDocumentationSettings.applySettings(
            self.__engine, self.__settings)
        changed |= self.filterSettingsWidget.applySettings(
            self.__engine.filterEngine())
        
        if changed:
            # In order to update the filter combobox and index widget according
            # to the new filter configuration.
            self.__engine.setupData()

eric ide

mercurial