|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2021 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 == QDialogButtonBox.StandardButton.Apply: |
|
79 self.__applyConfiguration() |
|
80 |
|
81 self.__settings = QtHelpDocumentationSettings.readSettings( |
|
82 self.__engine) |
|
83 |
|
84 self.filterSettingsWidget.setAvailableComponents( |
|
85 self.__settings.components()) |
|
86 self.filterSettingsWidget.setAvailableVersions( |
|
87 self.__settings.versions()) |
|
88 self.filterSettingsWidget.readSettings( |
|
89 self.__engine.filterEngine()) |
|
90 elif button == QDialogButtonBox.StandardButton.Ok: |
|
91 self.__applyConfiguration() |
|
92 self.accept() |
|
93 |
|
94 def __applyConfiguration(self): |
|
95 """ |
|
96 Private method to apply the current QtHelp documentation configuration. |
|
97 """ |
|
98 changed = QtHelpDocumentationSettings.applySettings( |
|
99 self.__engine, self.__settings) |
|
100 changed |= self.filterSettingsWidget.applySettings( |
|
101 self.__engine.filterEngine()) |
|
102 |
|
103 if changed: |
|
104 # In order to update the filter combobox and index widget according |
|
105 # to the new filter configuration. |
|
106 self.__engine.setupData() |