src/eric7/QtHelpInterface/QtHelpDocumentationConfigurationDialog.py

branch
eric7
changeset 9686
2eee7a645cba
parent 9653
e67609152c5e
child 10439
21c28b0f9e41
equal deleted inserted replaced
9685:b43e04854aba 9686:2eee7a645cba
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2021 - 2023 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to manage the QtHelp documentation database.
8 """
9
10 from PyQt6.QtCore import pyqtSlot
11 from PyQt6.QtWidgets import QAbstractButton, QDialog, QDialogButtonBox
12
13 from .QtHelpDocumentationSettings import QtHelpDocumentationSettings
14 from .Ui_QtHelpDocumentationConfigurationDialog import (
15 Ui_QtHelpDocumentationConfigurationDialog,
16 )
17
18
19 class QtHelpDocumentationConfigurationDialog(
20 QDialog, Ui_QtHelpDocumentationConfigurationDialog
21 ):
22 """
23 Class implementing a dialog to manage the QtHelp documentation database.
24 """
25
26 def __init__(self, engine, parent=None):
27 """
28 Constructor
29
30 @param engine reference to the Qt help engine
31 @type QHelpEngineCore
32 @param parent reference to the parent widget (defaults to None)
33 @type QWidget (optional)
34 """
35 super().__init__(parent)
36 self.setupUi(self)
37
38 self.__engine = engine
39
40 self.__settings = QtHelpDocumentationSettings.readSettings(self.__engine)
41
42 self.documentationSettingsWidget.documentationSettingsChanged.connect(
43 self.__documentationSettingsChanged
44 )
45 self.documentationSettingsWidget.setDocumentationSettings(self.__settings)
46
47 self.filterSettingsWidget.setAvailableComponents(self.__settings.components())
48 self.filterSettingsWidget.setAvailableVersions(self.__settings.versions())
49 self.filterSettingsWidget.readSettings(self.__engine.filterEngine())
50
51 @pyqtSlot(QtHelpDocumentationSettings)
52 def __documentationSettingsChanged(self, settings):
53 """
54 Private slot to handle a change of the QtHelp documentation
55 configuration.
56
57 @param settings reference to the documentation settings object
58 @type QtHelpDocumentationSettings
59 """
60 self.__settings = settings
61
62 self.filterSettingsWidget.setAvailableComponents(self.__settings.components())
63 self.filterSettingsWidget.setAvailableVersions(self.__settings.versions())
64
65 @pyqtSlot(QAbstractButton)
66 def on_buttonBox_clicked(self, button):
67 """
68 Private slot called by a button of the button box clicked.
69
70 @param button button that was clicked
71 @type QAbstractButton
72 """
73 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Apply):
74 self.__applyConfiguration()
75
76 self.__settings = QtHelpDocumentationSettings.readSettings(self.__engine)
77
78 self.filterSettingsWidget.setAvailableComponents(
79 self.__settings.components()
80 )
81 self.filterSettingsWidget.setAvailableVersions(self.__settings.versions())
82 self.filterSettingsWidget.readSettings(self.__engine.filterEngine())
83 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Ok):
84 self.__applyConfiguration()
85 self.accept()
86
87 def __applyConfiguration(self):
88 """
89 Private method to apply the current QtHelp documentation configuration.
90 """
91 changed = QtHelpDocumentationSettings.applySettings(
92 self.__engine, self.__settings
93 )
94 changed |= self.filterSettingsWidget.applySettings(self.__engine.filterEngine())
95
96 if changed:
97 # In order to update the filter combobox and index widget according
98 # to the new filter configuration.
99 self.__engine.setupData()

eric ide

mercurial