mirror of https://github.com/JakubMelka/PDF4QT.git
Issue #25: Bad dialog size
This commit is contained in:
parent
0219139cf9
commit
72ad433467
|
@ -83,6 +83,18 @@ void PDFTextToSpeech::setDocument(const pdf::PDFModifiedDocument& document)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PDFTextToSpeech::updateVoices()
|
||||||
|
{
|
||||||
|
QVector<QVoice> voices = m_textToSpeech->availableVoices();
|
||||||
|
m_speechVoiceComboBox->setUpdatesEnabled(false);
|
||||||
|
m_speechVoiceComboBox->clear();
|
||||||
|
for (const QVoice& voice : voices)
|
||||||
|
{
|
||||||
|
m_speechVoiceComboBox->addItem(QString("%1 (%2, %3)").arg(voice.name(), QVoice::genderName(voice.gender()), QVoice::ageName(voice.age())), voice.name());
|
||||||
|
}
|
||||||
|
m_speechVoiceComboBox->setUpdatesEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
void PDFTextToSpeech::setSettings(const PDFViewerSettings* viewerSettings)
|
void PDFTextToSpeech::setSettings(const PDFViewerSettings* viewerSettings)
|
||||||
{
|
{
|
||||||
Q_ASSERT(viewerSettings);
|
Q_ASSERT(viewerSettings);
|
||||||
|
@ -103,6 +115,7 @@ void PDFTextToSpeech::setSettings(const PDFViewerSettings* viewerSettings)
|
||||||
if (!settings.m_speechEngine.isEmpty())
|
if (!settings.m_speechEngine.isEmpty())
|
||||||
{
|
{
|
||||||
m_textToSpeech = new QTextToSpeech(settings.m_speechEngine, this);
|
m_textToSpeech = new QTextToSpeech(settings.m_speechEngine, this);
|
||||||
|
m_textToSpeech->setLocale(QLocale(settings.m_speechLocale));
|
||||||
connect(m_textToSpeech, &QTextToSpeech::stateChanged, this, &PDFTextToSpeech::updatePlay);
|
connect(m_textToSpeech, &QTextToSpeech::stateChanged, this, &PDFTextToSpeech::updatePlay);
|
||||||
m_state = m_document ? Ready : NoDocument;
|
m_state = m_document ? Ready : NoDocument;
|
||||||
|
|
||||||
|
@ -115,14 +128,7 @@ void PDFTextToSpeech::setSettings(const PDFViewerSettings* viewerSettings)
|
||||||
}
|
}
|
||||||
m_speechLocaleComboBox->setUpdatesEnabled(true);
|
m_speechLocaleComboBox->setUpdatesEnabled(true);
|
||||||
|
|
||||||
QVector<QVoice> voices = m_textToSpeech->availableVoices();
|
updateVoices();
|
||||||
m_speechVoiceComboBox->setUpdatesEnabled(false);
|
|
||||||
m_speechVoiceComboBox->clear();
|
|
||||||
for (const QVoice& voice : voices)
|
|
||||||
{
|
|
||||||
m_speechVoiceComboBox->addItem(QString("%1 (%2, %3)").arg(voice.name(), QVoice::genderName(voice.gender()), QVoice::ageName(voice.age())), voice.name());
|
|
||||||
}
|
|
||||||
m_speechVoiceComboBox->setUpdatesEnabled(true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -340,6 +346,12 @@ void PDFTextToSpeech::onLocaleChanged()
|
||||||
if (m_textToSpeech)
|
if (m_textToSpeech)
|
||||||
{
|
{
|
||||||
m_textToSpeech->setLocale(QLocale(m_speechLocaleComboBox->currentData().toString()));
|
m_textToSpeech->setLocale(QLocale(m_speechLocaleComboBox->currentData().toString()));
|
||||||
|
updateVoices();
|
||||||
|
|
||||||
|
if (m_speechVoiceComboBox->currentIndex() == -1)
|
||||||
|
{
|
||||||
|
m_speechVoiceComboBox->setCurrentIndex(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,7 @@ private:
|
||||||
void onStopClicked();
|
void onStopClicked();
|
||||||
|
|
||||||
void updatePlay();
|
void updatePlay();
|
||||||
|
void updateVoices();
|
||||||
void updateToNextPage(pdf::PDFInteger pageIndex);
|
void updateToNextPage(pdf::PDFInteger pageIndex);
|
||||||
|
|
||||||
QTextToSpeech* m_textToSpeech;
|
QTextToSpeech* m_textToSpeech;
|
||||||
|
|
|
@ -264,7 +264,7 @@ PDFViewerSettings::Settings::Settings() :
|
||||||
m_allowLaunchURI(true),
|
m_allowLaunchURI(true),
|
||||||
m_allowDeveloperMode(false),
|
m_allowDeveloperMode(false),
|
||||||
m_multithreadingStrategy(pdf::PDFExecutionPolicy::Strategy::AlwaysMultithreaded),
|
m_multithreadingStrategy(pdf::PDFExecutionPolicy::Strategy::AlwaysMultithreaded),
|
||||||
m_compiledPageCacheLimit(128 * 1024),
|
m_compiledPageCacheLimit(512 * 1024),
|
||||||
m_thumbnailsCacheLimit(PIXMAP_CACHE_LIMIT),
|
m_thumbnailsCacheLimit(PIXMAP_CACHE_LIMIT),
|
||||||
m_fontCacheLimit(pdf::DEFAULT_FONT_CACHE_LIMIT),
|
m_fontCacheLimit(pdf::DEFAULT_FONT_CACHE_LIMIT),
|
||||||
m_instancedFontCacheLimit(pdf::DEFAULT_REALIZED_FONT_CACHE_LIMIT),
|
m_instancedFontCacheLimit(pdf::DEFAULT_REALIZED_FONT_CACHE_LIMIT),
|
||||||
|
|
|
@ -189,16 +189,16 @@ PDFViewerSettingsDialog::PDFViewerSettingsDialog(const PDFViewerSettings::Settin
|
||||||
connect(ui->trustedCertificateStoreTableWidget, &QTableWidget::itemSelectionChanged, this, &PDFViewerSettingsDialog::updateTrustedCertificatesTableActions);
|
connect(ui->trustedCertificateStoreTableWidget, &QTableWidget::itemSelectionChanged, this, &PDFViewerSettingsDialog::updateTrustedCertificatesTableActions);
|
||||||
connect(ui->pluginsTableWidget, &QTableWidget::itemSelectionChanged, this, &PDFViewerSettingsDialog::updatePluginInformation);
|
connect(ui->pluginsTableWidget, &QTableWidget::itemSelectionChanged, this, &PDFViewerSettingsDialog::updatePluginInformation);
|
||||||
|
|
||||||
setMinimumSize(pdf::PDFWidgetUtils::scaleDPI(this, QSize(1000, 700)));
|
setMinimumSize(pdf::PDFWidgetUtils::scaleDPI(this, QSize(1000, 800)));
|
||||||
pdf::PDFWidgetUtils::style(this);
|
pdf::PDFWidgetUtils::style(this);
|
||||||
|
|
||||||
ui->optionsPagesWidget->setCurrentRow(0);
|
ui->optionsPagesWidget->setCurrentRow(0);
|
||||||
adjustSize();
|
|
||||||
loadData();
|
loadData();
|
||||||
loadActionShortcutsTable();
|
loadActionShortcutsTable();
|
||||||
loadPluginsTable();
|
loadPluginsTable();
|
||||||
updateTrustedCertificatesTable();
|
updateTrustedCertificatesTable();
|
||||||
updateTrustedCertificatesTableActions();
|
updateTrustedCertificatesTableActions();
|
||||||
|
resize(sizeHint());
|
||||||
}
|
}
|
||||||
|
|
||||||
PDFViewerSettingsDialog::~PDFViewerSettingsDialog()
|
PDFViewerSettingsDialog::~PDFViewerSettingsDialog()
|
||||||
|
@ -387,8 +387,7 @@ void PDFViewerSettingsDialog::loadData()
|
||||||
|
|
||||||
// Text-to-speech
|
// Text-to-speech
|
||||||
ui->speechEnginesComboBox->setCurrentIndex(ui->speechEnginesComboBox->findData(m_settings.m_speechEngine));
|
ui->speechEnginesComboBox->setCurrentIndex(ui->speechEnginesComboBox->findData(m_settings.m_speechEngine));
|
||||||
QString speechEngine = ui->speechEnginesComboBox->currentData().toString();
|
setSpeechEngine(m_settings.m_speechEngine, m_settings.m_speechLocale);
|
||||||
setSpeechEngine(speechEngine);
|
|
||||||
ui->speechLocaleComboBox->setCurrentIndex(ui->speechLocaleComboBox->findData(m_settings.m_speechLocale));
|
ui->speechLocaleComboBox->setCurrentIndex(ui->speechLocaleComboBox->findData(m_settings.m_speechLocale));
|
||||||
ui->speechVoiceComboBox->setCurrentIndex(ui->speechVoiceComboBox->findData(m_settings.m_speechVoice));
|
ui->speechVoiceComboBox->setCurrentIndex(ui->speechVoiceComboBox->findData(m_settings.m_speechVoice));
|
||||||
ui->speechRateEdit->setValue(m_settings.m_speechRate);
|
ui->speechRateEdit->setValue(m_settings.m_speechRate);
|
||||||
|
@ -795,15 +794,19 @@ void PDFViewerSettingsDialog::updatePluginInformation()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PDFViewerSettingsDialog::setSpeechEngine(const QString& engine)
|
void PDFViewerSettingsDialog::setSpeechEngine(const QString& engine, const QString& locale)
|
||||||
{
|
{
|
||||||
if (m_currentSpeechEngine == engine)
|
if (m_currentSpeechEngine == engine && m_currentSpeechLocale == locale)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentSpeechEngine = engine;
|
|
||||||
QTextToSpeech textToSpeech(engine, nullptr);
|
QTextToSpeech textToSpeech(engine, nullptr);
|
||||||
|
textToSpeech.setLocale(QLocale(locale));
|
||||||
|
|
||||||
|
if (m_currentSpeechEngine != engine)
|
||||||
|
{
|
||||||
|
m_currentSpeechEngine = engine;
|
||||||
|
|
||||||
QVector<QLocale> locales = textToSpeech.availableLocales();
|
QVector<QLocale> locales = textToSpeech.availableLocales();
|
||||||
ui->speechLocaleComboBox->setUpdatesEnabled(false);
|
ui->speechLocaleComboBox->setUpdatesEnabled(false);
|
||||||
|
@ -813,6 +816,9 @@ void PDFViewerSettingsDialog::setSpeechEngine(const QString& engine)
|
||||||
ui->speechLocaleComboBox->addItem(QString("%1 (%2)").arg(locale.nativeLanguageName(), locale.nativeCountryName()), locale.name());
|
ui->speechLocaleComboBox->addItem(QString("%1 (%2)").arg(locale.nativeLanguageName(), locale.nativeCountryName()), locale.name());
|
||||||
}
|
}
|
||||||
ui->speechLocaleComboBox->setUpdatesEnabled(true);
|
ui->speechLocaleComboBox->setUpdatesEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_currentSpeechLocale = locale;
|
||||||
|
|
||||||
QVector<QVoice> voices = textToSpeech.availableVoices();
|
QVector<QVoice> voices = textToSpeech.availableVoices();
|
||||||
ui->speechVoiceComboBox->setUpdatesEnabled(false);
|
ui->speechVoiceComboBox->setUpdatesEnabled(false);
|
||||||
|
|
|
@ -107,7 +107,7 @@ private:
|
||||||
void savePluginsTable();
|
void savePluginsTable();
|
||||||
void updatePluginInformation();
|
void updatePluginInformation();
|
||||||
|
|
||||||
void setSpeechEngine(const QString& engine);
|
void setSpeechEngine(const QString& engine, const QString& locale);
|
||||||
|
|
||||||
/// Returns true, if dialog can be closed. If not, then message is displayed
|
/// Returns true, if dialog can be closed. If not, then message is displayed
|
||||||
/// and false is returned.
|
/// and false is returned.
|
||||||
|
@ -121,6 +121,7 @@ private:
|
||||||
bool m_isLoadingData;
|
bool m_isLoadingData;
|
||||||
QStringList m_textToSpeechEngines;
|
QStringList m_textToSpeechEngines;
|
||||||
QString m_currentSpeechEngine;
|
QString m_currentSpeechEngine;
|
||||||
|
QString m_currentSpeechLocale;
|
||||||
pdf::PDFCertificateStore m_certificateStore;
|
pdf::PDFCertificateStore m_certificateStore;
|
||||||
QStringList m_enabledPlugins;
|
QStringList m_enabledPlugins;
|
||||||
pdf::PDFPluginInfos m_plugins;
|
pdf::PDFPluginInfos m_plugins;
|
||||||
|
|
Loading…
Reference in New Issue