From 771fdc5b13f1b13c82eeaf513696b2e564326b80 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 19 Aug 2019 13:18:44 +0200 Subject: Fix applying font and option settings Move the code which applies changes to applyChanges() method. Fixes: QTBUG-77399 Change-Id: Ic4436ce65e246c518a6fcdfe119df772a0585468 Reviewed-by: Friedemann Kleint --- src/assistant/assistant/mainwindow.cpp | 2 +- src/assistant/assistant/preferencesdialog.cpp | 55 ++++++++++++--------------- src/assistant/assistant/preferencesdialog.h | 4 +- 3 files changed, 26 insertions(+), 35 deletions(-) (limited to 'src/assistant') diff --git a/src/assistant/assistant/mainwindow.cpp b/src/assistant/assistant/mainwindow.cpp index 2b9c87bbf..fc5fe5b3f 100644 --- a/src/assistant/assistant/mainwindow.cpp +++ b/src/assistant/assistant/mainwindow.cpp @@ -842,7 +842,7 @@ void MainWindow::showPreferences() m_centralWidget, &CentralWidget::updateBrowserFont); connect(&dia, &PreferencesDialog::updateUserInterface, m_centralWidget, &CentralWidget::updateUserInterface); - dia.showDialog(); + dia.exec(); } void MainWindow::syncContents() diff --git a/src/assistant/assistant/preferencesdialog.cpp b/src/assistant/assistant/preferencesdialog.cpp index 7955e08df..67f91326c 100644 --- a/src/assistant/assistant/preferencesdialog.cpp +++ b/src/assistant/assistant/preferencesdialog.cpp @@ -142,31 +142,6 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) setFont(helpEngine.appFont()); } -PreferencesDialog::~PreferencesDialog() -{ - if (m_appFontChanged) { - helpEngine.setAppFont(m_appFontPanel->selectedFont()); - helpEngine.setUseAppFont(m_appFontPanel->isChecked()); - helpEngine.setAppWritingSystem(m_appFontPanel->writingSystem()); - emit updateApplicationFont(); - } - - if (m_browserFontChanged) { - helpEngine.setBrowserFont(m_browserFontPanel->selectedFont()); - helpEngine.setUseBrowserFont(m_browserFontPanel->isChecked()); - helpEngine.setBrowserWritingSystem(m_browserFontPanel->writingSystem()); - emit updateBrowserFont(); - } - - QString homePage = m_ui.homePageLineEdit->text(); - if (homePage.isEmpty()) - homePage = QLatin1String("help"); - helpEngine.setHomePage(homePage); - - int option = m_ui.helpStartComboBox->currentIndex(); - helpEngine.setStartOption(option); -} - FilterSetup PreferencesDialog::readOriginalSetup() const { FilterSetup filterSetup; @@ -195,12 +170,6 @@ FilterSetup PreferencesDialog::readOriginalSetup() const return filterSetup; } -void PreferencesDialog::showDialog() -{ - if (exec() != Accepted) - m_appFontChanged = m_browserFontChanged = false; -} - void PreferencesDialog::updateFilterPage() { if (m_hideFiltersTab) @@ -563,6 +532,30 @@ void PreferencesDialog::applyChanges() helpEngine.setShowTabs(m_ui.showTabs->isChecked()); if (m_showTabs != m_ui.showTabs->isChecked()) emit updateUserInterface(); + + if (m_appFontChanged) { + helpEngine.setAppFont(m_appFontPanel->selectedFont()); + helpEngine.setUseAppFont(m_appFontPanel->isChecked()); + helpEngine.setAppWritingSystem(m_appFontPanel->writingSystem()); + emit updateApplicationFont(); + m_appFontChanged = false; + } + + if (m_browserFontChanged) { + helpEngine.setBrowserFont(m_browserFontPanel->selectedFont()); + helpEngine.setUseBrowserFont(m_browserFontPanel->isChecked()); + helpEngine.setBrowserWritingSystem(m_browserFontPanel->writingSystem()); + emit updateBrowserFont(); + m_browserFontChanged = false; + } + + QString homePage = m_ui.homePageLineEdit->text(); + if (homePage.isEmpty()) + homePage = QLatin1String("help"); + helpEngine.setHomePage(homePage); + + const int option = m_ui.helpStartComboBox->currentIndex(); + helpEngine.setStartOption(option); } void PreferencesDialog::updateFontSettingsPage() diff --git a/src/assistant/assistant/preferencesdialog.h b/src/assistant/assistant/preferencesdialog.h index 89c30c568..1ff39e326 100644 --- a/src/assistant/assistant/preferencesdialog.h +++ b/src/assistant/assistant/preferencesdialog.h @@ -29,6 +29,7 @@ #ifndef PREFERENCESDIALOG_H #define PREFERENCESDIALOG_H +#include #include #include #include "ui_preferencesdialog.h" @@ -60,9 +61,6 @@ class PreferencesDialog : public QDialog public: PreferencesDialog(QWidget *parent = nullptr); - ~PreferencesDialog() override; - - void showDialog(); private slots: void filterSelected(QListWidgetItem *item); -- cgit v1.2.3