src/eric7/WebBrowser/QtHelp/QtHelpDocumentationConfigurationDialog.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2021 - 2022 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 QDialog, QDialogButtonBox, QAbstractButton
12
13 from .Ui_QtHelpDocumentationConfigurationDialog import (
14 Ui_QtHelpDocumentationConfigurationDialog
15 )
16
17 from .QtHelpDocumentationSettings import QtHelpDocumentationSettings
18
19
20 class QtHelpDocumentationConfigurationDialog(
21 QDialog, Ui_QtHelpDocumentationConfigurationDialog
22 ):
23 """
24 Class implementing a dialog to manage the QtHelp documentation database.
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(
41 self.__engine)
42
43 self.documentationSettingsWidget.documentationSettingsChanged.connect(
44 self.__documentationSettingsChanged)
45 self.documentationSettingsWidget.setDocumentationSettings(
46 self.__settings)
47
48 self.filterSettingsWidget.setAvailableComponents(
49 self.__settings.components())
50 self.filterSettingsWidget.setAvailableVersions(
51 self.__settings.versions())
52 self.filterSettingsWidget.readSettings(self.__engine.filterEngine())
53
54 @pyqtSlot(QtHelpDocumentationSettings)
55 def __documentationSettingsChanged(self, settings):
56 """
57 Private slot to handle a change of the QtHelp documentation
58 configuration.
59
60 @param settings reference to the documentation settings object
61 @type QtHelpDocumentationSettings
62 """
63 self.__settings = settings
64
65 self.filterSettingsWidget.setAvailableComponents(
66 self.__settings.components())
67 self.filterSettingsWidget.setAvailableVersions(
68 self.__settings.versions())
69
70 @pyqtSlot(QAbstractButton)
71 def on_buttonBox_clicked(self, button):
72 """
73 Private slot called by a button of the button box clicked.
74
75 @param button button that was clicked
76 @type QAbstractButton
77 """
78 if button == self.buttonBox.button(
79 QDialogButtonBox.StandardButton.Apply):
80 self.__applyConfiguration()
81
82 self.__settings = QtHelpDocumentationSettings.readSettings(
83 self.__engine)
84
85 self.filterSettingsWidget.setAvailableComponents(
86 self.__settings.components())
87 self.filterSettingsWidget.setAvailableVersions(
88 self.__settings.versions())
89 self.filterSettingsWidget.readSettings(
90 self.__engine.filterEngine())
91 elif button == self.buttonBox.button(
92 QDialogButtonBox.StandardButton.Ok):
93 self.__applyConfiguration()
94 self.accept()
95
96 def __applyConfiguration(self):
97 """
98 Private method to apply the current QtHelp documentation configuration.
99 """
100 changed = QtHelpDocumentationSettings.applySettings(
101 self.__engine, self.__settings)
102 changed |= self.filterSettingsWidget.applySettings(
103 self.__engine.filterEngine())
104
105 if changed:
106 # In order to update the filter combobox and index widget according
107 # to the new filter configuration.
108 self.__engine.setupData()

eric ide

mercurial