11#include <QtCore/QVersionNumber>
13#include <QtGui/QFontDatabase>
15#include <QtHelp/QHelpEngineCore>
16#include <QtHelp/QHelpFilterData>
17#include <QtHelp/QHelpFilterEngine>
18#include <QtHelp/QHelpFilterSettingsWidget>
24using namespace Qt::StringLiterals;
28 , m_appFontChanged(
false)
29 , m_browserFontChanged(
false)
36 connect(m_ui.buttonBox->button(QDialogButtonBox::Ok), &QAbstractButton::clicked,
37 this, &PreferencesDialog::okClicked);
38 connect(m_ui.buttonBox->button(QDialogButtonBox::Apply), &QAbstractButton::clicked,
39 this, &PreferencesDialog::applyClicked);
40 connect(m_ui.buttonBox->button(QDialogButtonBox::Cancel), &QAbstractButton::clicked,
41 this, &QDialog::reject);
43 m_docSettings = HelpDocSettings::readSettings(helpEngine.helpEngine());
46 m_ui.tabWidget->removeTab(m_ui.tabWidget->indexOf(m_ui.docsTab));
48 connect(m_ui.docSettingsWidget, &HelpDocSettingsWidget::docSettingsChanged,
this,
49 [
this](
const HelpDocSettings &settings) {
50 m_docSettings = settings;
54 m_ui.filterSettingsWidget->setAvailableComponents(m_docSettings.components());
55 m_ui.filterSettingsWidget->setAvailableVersions(m_docSettings.versions());
58 m_ui.docSettingsWidget->setDocSettings(m_docSettings);
61 if (m_hideFiltersTab) {
62 m_ui.tabWidget->removeTab(m_ui.tabWidget->indexOf(m_ui.filtersTab));
64 m_ui.filterSettingsWidget->setAvailableComponents(m_docSettings.components());
65 m_ui.filterSettingsWidget->setAvailableVersions(m_docSettings.versions());
66 m_ui.filterSettingsWidget->readSettings(helpEngine.filterEngine());
69 updateFontSettingsPage();
73 setFont(helpEngine.appFont());
86 m_docSettings = HelpDocSettings::readSettings(helpEngine.helpEngine());
89 m_ui.docSettingsWidget->setDocSettings(m_docSettings);
90 if (!m_hideFiltersTab) {
91 m_ui.filterSettingsWidget->setAvailableComponents(m_docSettings.components());
92 m_ui.filterSettingsWidget->setAvailableVersions(m_docSettings.versions());
93 m_ui.filterSettingsWidget->readSettings(helpEngine.filterEngine());
101 changed = HelpDocSettings::applySettings(helpEngine.helpEngine(), m_docSettings);
102 if (!m_hideFiltersTab)
103 changed = changed || m_ui.filterSettingsWidget->applySettings(helpEngine.filterEngine());
111 helpEngine.setShowTabs(m_ui.showTabs->isChecked());
112 if (m_showTabs != m_ui.showTabs->isChecked())
113 emit updateUserInterface();
115 if (m_appFontChanged) {
116 helpEngine.setAppFont(m_appFontPanel->selectedFont());
118 helpEngine.setAppWritingSystem(m_appFontPanel->writingSystem());
119 emit updateApplicationFont();
120 m_appFontChanged =
false;
123 if (m_browserFontChanged) {
124 helpEngine.setBrowserFont(m_browserFontPanel->selectedFont());
126 helpEngine.setBrowserWritingSystem(m_browserFontPanel->writingSystem());
127 emit updateBrowserFont();
128 m_browserFontChanged =
false;
131 QString homePage = m_ui.homePageLineEdit->text();
132 if (homePage.isEmpty())
133 homePage =
"help"_L1;
134 helpEngine.setHomePage(homePage);
136 const int option = m_ui.helpStartComboBox->currentIndex();
142 m_browserFontPanel =
new FontPanel(
this);
143 m_browserFontPanel->setCheckable(
true);
144 m_ui.stackedWidget_2->insertWidget(0, m_browserFontPanel);
146 m_appFontPanel =
new FontPanel(
this);
147 m_appFontPanel->setCheckable(
true);
148 m_ui.stackedWidget_2->insertWidget(1, m_appFontPanel);
150 m_ui.stackedWidget_2->setCurrentIndex(0);
152 const QString customSettings(tr(
"Use custom settings"));
153 m_appFontPanel->setTitle(customSettings);
155 QFont font = helpEngine.appFont();
156 m_appFontPanel->setSelectedFont(font);
158 QFontDatabase::WritingSystem system = helpEngine.appWritingSystem();
159 m_appFontPanel->setWritingSystem(system);
163 m_browserFontPanel->setTitle(customSettings);
165 font = helpEngine.browserFont();
166 m_browserFontPanel->setSelectedFont(font);
168 system = helpEngine.browserWritingSystem();
169 m_browserFontPanel->setWritingSystem(system);
173 connect(m_appFontPanel, &QGroupBox::toggled,
174 this, &PreferencesDialog::appFontSettingToggled);
175 connect(m_browserFontPanel, &QGroupBox::toggled,
176 this, &PreferencesDialog::browserFontSettingToggled);
178 const QList<QComboBox*> &appCombos = m_appFontPanel->findChildren<QComboBox*>();
179 for (QComboBox* box : appCombos) {
180 connect(box, &QComboBox::currentIndexChanged,
181 this, &PreferencesDialog::appFontSettingChanged);
184 const QList<QComboBox*> &browserCombos = m_browserFontPanel->findChildren<QComboBox*>();
185 for (QComboBox* box : browserCombos) {
186 connect(box, &QComboBox::currentIndexChanged,
187 this, &PreferencesDialog::browserFontSettingChanged);
194 m_appFontChanged =
true;
200 m_appFontChanged =
true;
206 m_browserFontChanged =
true;
212 m_browserFontChanged =
true;
217 m_ui.homePageLineEdit->setText(helpEngine.homePage());
220 m_ui.helpStartComboBox->setCurrentIndex(option);
223 m_ui.showTabs->setChecked(m_showTabs);
225 connect(m_ui.blankPageButton, &QAbstractButton::clicked,
226 this, &PreferencesDialog::setBlankPage);
227 connect(m_ui.currentPageButton, &QAbstractButton::clicked,
228 this, &PreferencesDialog::setCurrentPage);
229 connect(m_ui.defaultPageButton, &QAbstractButton::clicked,
230 this, &PreferencesDialog::setDefaultPage);
235 m_ui.homePageLineEdit->setText(
"about:blank"_L1);
240 QString homepage = CentralWidget::instance()->currentSource().toString();
241 if (homepage.isEmpty())
242 homepage =
"help"_L1;
244 m_ui.homePageLineEdit->setText(homepage);
249 m_ui.homePageLineEdit->setText(helpEngine.defaultHomePage());
void setStartOption(int option)
bool usesBrowserFont() const
static HelpEngineWrapper & instance()
void setUseBrowserFont(bool useBrowserFont)
bool documentationManagerEnabled() const
bool filterFunctionalityEnabled() const
void setUseAppFont(bool useAppFont)
Combined button and popup list for selecting options.