Commit d01ff29492b805ed96c07371c4840def2b6e9c92

  • avatar
  • con <qtc-committer @no…a.com>
  • Fri Nov 20 15:03:22 GMT 2009
Make context help work also when switching user interface language.

Also avoids errors because of users messing with the "Unfiltered"
filter, which is used for e.g. context help.
The strategy now is to remove the "Unfiltered" filter from previous runs
(possibly in a different language), and re-register a fresh filter with
the name in the current language, and guaranteed to not filter out
anything.

Reviewed-by: kh1
(cherry picked from commit ad4c227ca45912b27383236d8b73b790e97acf8e)
src/plugins/help/helpplugin.cpp
(29 / 22)
  
418418 cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl++")));
419419 connect(a, SIGNAL(triggered()), m_centralWidget, SLOT(zoomIn()));
420420 advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
421
421
422422 a = new QAction(tr("Decrease Font Size"), this);
423423 cmd = am->registerAction(a, TextEditor::Constants::DECREASE_FONT_SIZE,
424424 modecontext);
572572 return;
573573 }
574574
575 bool needsSetup = false;
576575 bool assistantInternalDocRegistered = false;
577576 QStringList documentationToRemove;
578577 QStringList filtersToRemove;
600600 QHelpEngineCore hc(m_helpEngine->collectionFile());
601601 hc.setupData();
602602 foreach (const QString &ns, documentationToRemove) {
603 if (hc.unregisterDocumentation(ns))
604 needsSetup = true;
603 hc.unregisterDocumentation(ns);
605604 }
606605 foreach (const QString &filter, filtersToRemove) {
607 if (hc.removeCustomFilter(filter))
608 needsSetup = true;
606 hc.removeCustomFilter(filter);
609607 }
610608
611609 if (!assistantInternalDocRegistered) {
616616#endif
617617 if (!hc.registerDocumentation(qchFileName))
618618 qDebug() << qPrintable(hc.error());
619 needsSetup = true;
620619 }
621620
622621 }
623622
624 QLatin1String key("UnfilteredFilterInserted");
625 int i = m_helpEngine->customValue(key).toInt();
626 if (i != 1) {
627 {
628 QHelpEngineCore hc(m_helpEngine->collectionFile());
629 hc.setupData();
630 hc.addCustomFilter(tr("Unfiltered"), QStringList());
631 hc.setCustomValue(key, 1);
623 const QLatin1String weAddedFilterKey("UnfilteredFilterInserted");
624 const QLatin1String previousFilterNameKey("UnfilteredFilterName");
625 int i = m_helpEngine->customValue(weAddedFilterKey).toInt();
626 const QString filterName = tr("Unfiltered");
627 if (i == 1) { // we added a filter at some point
628 // remove previously added filter
629 QHelpEngineCore hc(m_helpEngine->collectionFile());
630 hc.setupData();
631 QString previousFilterName = hc.customValue(previousFilterNameKey).toString();
632 if (!previousFilterName.isEmpty()) { // we noted down the name of the previously added filter
633 hc.removeCustomFilter(previousFilterName);
632634 }
633 bool blocked = m_helpEngine->blockSignals(true);
634 m_helpEngine->setCurrentFilter(tr("Unfiltered"));
635 m_helpEngine->blockSignals(blocked);
636 needsSetup = true;
635 if (previousFilterName != filterName) { // potentially remove a filter with new name
636 hc.removeCustomFilter(filterName);
637 }
637638 }
639 {
640 QHelpEngineCore hc(m_helpEngine->collectionFile());
641 hc.setupData();
642 hc.addCustomFilter(filterName, QStringList());
643 hc.setCustomValue(weAddedFilterKey, 1);
644 hc.setCustomValue(previousFilterNameKey, filterName);
645 }
646 bool blocked = m_helpEngine->blockSignals(true);
647 m_helpEngine->setCurrentFilter(filterName);
648 m_helpEngine->blockSignals(blocked);
638649
639 if (needsSetup)
640 m_helpEngine->setupData();
650 m_helpEngine->setupData();
641651
642652 updateFilterComboBox();
643653 m_bookmarkManager->setupBookmarkModels();
659659
660660 font = qVariantValue<QFont>(m_helpEngine->customValue(QLatin1String("font"),
661661 font));
662
662
663663 webSettings->setFontFamily(QWebSettings::StandardFont, font.family());
664664 webSettings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
665665#endif

Comments

Add a new comment:

Login or create an account to post a comment

Add your comment