summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@theqtcompany.com>2015-04-02 16:49:04 +0200
committerEike Ziller <eike.ziller@theqtcompany.com>2015-04-24 08:32:38 +0000
commit5e0f0268aeff37489ea3563b3e527109b54a5753 (patch)
treeb941aaf5a65a96f043c985246050ce828d0c4314 /src
parent94af581dd850881a520d48e2dfe57096cc18262d (diff)
downloadqt-creator-5e0f0268aeff37489ea3563b3e527109b54a5753.tar.gz
Help: Do not save settings in help database
Using the help database is not necessary, does not follow our style, and is less reliable (with all the setupEngine mess). Change-Id: Icb7f63a6b349458011e1b068bdf0954b78d3281f Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/help/centralwidget.cpp17
-rw-r--r--src/plugins/help/generalsettingspage.cpp33
-rw-r--r--src/plugins/help/generalsettingspage.h1
-rw-r--r--src/plugins/help/helpconstants.h8
-rw-r--r--src/plugins/help/helpplugin.cpp44
-rw-r--r--src/plugins/help/helpplugin.h4
-rw-r--r--src/plugins/help/helpwidget.cpp13
-rw-r--r--src/plugins/help/helpwidget.h2
-rw-r--r--src/plugins/help/localhelpmanager.cpp152
-rw-r--r--src/plugins/help/localhelpmanager.h32
-rw-r--r--src/plugins/help/openpagesmanager.cpp27
-rw-r--r--src/shared/help/bookmarkmanager.cpp18
12 files changed, 225 insertions, 126 deletions
diff --git a/src/plugins/help/centralwidget.cpp b/src/plugins/help/centralwidget.cpp
index 9849a3f18a..32941d7f44 100644
--- a/src/plugins/help/centralwidget.cpp
+++ b/src/plugins/help/centralwidget.cpp
@@ -35,8 +35,6 @@
#include <utils/qtcassert.h>
-#include <QHelpEngine>
-
using namespace Help::Internal;
CentralWidget *gStaticCentralWidget = 0;
@@ -53,21 +51,20 @@ CentralWidget::CentralWidget(const Core::Context &context, QWidget *parent)
CentralWidget::~CentralWidget()
{
// TODO: this shouldn't be done here
- QString zoomFactors;
- QString currentPages;
+ QList<float> zoomFactors;
+ QStringList currentPages;
for (int i = 0; i < viewerCount(); ++i) {
const HelpViewer * const viewer = viewerAt(i);
const QUrl &source = viewer->source();
if (source.isValid()) {
- currentPages += source.toString() + QLatin1Char('|');
- zoomFactors += QString::number(viewer->scale()) + QLatin1Char('|');
+ currentPages.append(source.toString());
+ zoomFactors.append(viewer->scale());
}
}
- QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
- engine->setCustomValue(QLatin1String("LastShownPages"), currentPages);
- engine->setCustomValue(QLatin1String("LastShownPagesZoom"), zoomFactors);
- engine->setCustomValue(QLatin1String("LastTabPage"), currentIndex());
+ LocalHelpManager::setLastShownPages(currentPages);
+ LocalHelpManager::setLastShownPagesZoom(zoomFactors);
+ LocalHelpManager::setLastSelectedTab(currentIndex());
}
CentralWidget *CentralWidget::instance()
diff --git a/src/plugins/help/generalsettingspage.cpp b/src/plugins/help/generalsettingspage.cpp
index e216b93da8..aff6c70415 100644
--- a/src/plugins/help/generalsettingspage.cpp
+++ b/src/plugins/help/generalsettingspage.cpp
@@ -61,12 +61,6 @@ using namespace Help::Internal;
GeneralSettingsPage::GeneralSettingsPage()
: m_ui(0)
{
- m_font = qApp->font();
- // TODO remove QT_NO_WEBKIT
-#if !defined(QT_NO_WEBKIT)
- QWebSettings* webSettings = QWebSettings::globalSettings();
- m_font.setPointSize(webSettings->fontSize(QWebSettings::DefaultFontSize));
-#endif
setId("A.General settings");
setDisplayName(tr("General"));
setCategory(Help::Constants::HELP_CATEGORY);
@@ -83,9 +77,7 @@ QWidget *GeneralSettingsPage::widget()
m_ui->sizeComboBox->setEditable(false);
m_ui->styleComboBox->setEditable(false);
- QVariant fontSetting = LocalHelpManager::engineFontSettings();
- if (fontSetting.isValid())
- m_font = fontSetting.value<QFont>();
+ m_font = LocalHelpManager::fallbackFont();
updateFontSize();
updateFontStyle();
@@ -94,12 +86,10 @@ QWidget *GeneralSettingsPage::widget()
m_homePage = LocalHelpManager::homePage();
m_ui->homePageLineEdit->setText(m_homePage);
- m_startOption = HelpManager::customValue(QLatin1String("StartOption"),
- Help::Constants::ShowLastPages).toInt();
+ m_startOption = LocalHelpManager::startOption();
m_ui->helpStartComboBox->setCurrentIndex(m_startOption);
- m_contextOption = HelpManager::customValue(QLatin1String("ContextHelpOption"),
- HelpManager::SideBySideIfPossible).toInt();
+ m_contextOption = LocalHelpManager::contextHelpOption();
m_ui->contextHelpComboBox->setCurrentIndex(m_contextOption);
connect(m_ui->currentPageButton, &QPushButton::clicked,
@@ -119,8 +109,7 @@ QWidget *GeneralSettingsPage::widget()
connect(m_ui->exportButton, &QPushButton::clicked,
this, &GeneralSettingsPage::exportBookmarks);
- m_returnOnClose = HelpManager::customValue(QLatin1String("ReturnOnClose"),
- false).toBool();
+ m_returnOnClose = LocalHelpManager::returnOnClose();
m_ui->m_returnOnClose->setChecked(m_returnOnClose);
}
return m_widget;
@@ -158,7 +147,7 @@ void GeneralSettingsPage::apply()
if (newFont != m_font) {
m_font = newFont;
- HelpManager::setCustomValue(Constants::FontKey, newFont);
+ LocalHelpManager::setFallbackFont(newFont);
emit fontChanged();
}
@@ -174,25 +163,19 @@ void GeneralSettingsPage::apply()
const int startOption = m_ui->helpStartComboBox->currentIndex();
if (m_startOption != startOption) {
m_startOption = startOption;
- HelpManager::setCustomValue(QLatin1String("StartOption"), startOption);
+ LocalHelpManager::setStartOption((LocalHelpManager::StartOption)m_startOption);
}
const int helpOption = m_ui->contextHelpComboBox->currentIndex();
if (m_contextOption != helpOption) {
m_contextOption = helpOption;
- HelpManager::setCustomValue(QLatin1String("ContextHelpOption"), helpOption);
-
- QSettings *settings = ICore::settings();
- settings->beginGroup(QLatin1String(Help::Constants::ID_MODE_HELP));
- settings->setValue(QLatin1String("ContextHelpOption"), helpOption);
- settings->endGroup();
+ LocalHelpManager::setContextHelpOption((HelpManager::HelpViewerLocation)m_contextOption);
}
const bool close = m_ui->m_returnOnClose->isChecked();
if (m_returnOnClose != close) {
m_returnOnClose = close;
- HelpManager::setCustomValue(QLatin1String("ReturnOnClose"), close);
- emit returnOnCloseChanged();
+ LocalHelpManager::setReturnOnClose(m_returnOnClose);
}
}
diff --git a/src/plugins/help/generalsettingspage.h b/src/plugins/help/generalsettingspage.h
index 5cdcb9141e..f592aff639 100644
--- a/src/plugins/help/generalsettingspage.h
+++ b/src/plugins/help/generalsettingspage.h
@@ -54,7 +54,6 @@ public:
signals:
void fontChanged();
- void returnOnCloseChanged();
private slots:
void setCurrentPage();
diff --git a/src/plugins/help/helpconstants.h b/src/plugins/help/helpconstants.h
index 6165a21952..6485bed43a 100644
--- a/src/plugins/help/helpconstants.h
+++ b/src/plugins/help/helpconstants.h
@@ -37,18 +37,10 @@
namespace Help {
namespace Constants {
-enum {
- ShowHomePage = 0,
- ShowBlankPage = 1,
- ShowLastPages = 2
-};
-
static const QLatin1String ListSeparator("|");
-static const QLatin1String DefaultZoomFactor("0.0");
static const QLatin1String AboutBlank("about:blank");
static const QLatin1String WeAddedFilterKey("UnfilteredFilterInserted");
static const QLatin1String PreviousFilterNameKey("UnfilteredFilterName");
-static const QLatin1String FontKey("font");
const int P_MODE_HELP = 70;
const char ID_MODE_HELP [] = "Help";
diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp
index d03a2dfe1e..626f49debd 100644
--- a/src/plugins/help/helpplugin.cpp
+++ b/src/plugins/help/helpplugin.cpp
@@ -146,7 +146,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
m_openPagesManager = new OpenPagesManager(this);
addAutoReleasedObject(m_docSettingsPage = new DocSettingsPage());
addAutoReleasedObject(m_filterSettingsPage = new FilterSettingsPage());
- addAutoReleasedObject(m_generalSettingsPage = new GeneralSettingsPage());
+ addAutoReleasedObject(new GeneralSettingsPage());
addAutoReleasedObject(m_searchTaskHandler = new SearchTaskHandler);
m_centralWidget = new CentralWidget(modecontext);
@@ -155,10 +155,8 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
connect(m_centralWidget, &CentralWidget::closeButtonClicked,
&OpenPagesManager::instance(), &OpenPagesManager::closeCurrentPage);
- connect(m_generalSettingsPage, SIGNAL(fontChanged()), this,
- SLOT(fontChanged()));
- connect(m_generalSettingsPage, SIGNAL(returnOnCloseChanged()), m_centralWidget,
- SLOT(updateCloseButton()));
+ connect(LocalHelpManager::instance(), &LocalHelpManager::returnOnCloseChanged,
+ m_centralWidget, &CentralWidget::updateCloseButton);
connect(HelpManager::instance(), SIGNAL(helpRequested(QUrl,Core::HelpManager::HelpViewerLocation)),
this, SLOT(handleHelpRequest(QUrl,Core::HelpManager::HelpViewerLocation)));
connect(m_searchTaskHandler, SIGNAL(search(QUrl)), this,
@@ -390,9 +388,9 @@ HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
HelpViewer *viewer = factory();
// initialize font
- QVariant fontSetting = LocalHelpManager::engineFontSettings();
- if (fontSetting.isValid())
- viewer->setViewerFont(fontSetting.value<QFont>());
+ viewer->setViewerFont(LocalHelpManager::fallbackFont());
+ connect(LocalHelpManager::instance(), &LocalHelpManager::fallbackFontChanged,
+ viewer, &HelpViewer::setViewerFont);
// initialize zoom
viewer->setScale(zoom);
@@ -460,24 +458,11 @@ void HelpPlugin::updateSideBarSource(const QUrl &newUrl)
}
}
-void HelpPlugin::fontChanged()
-{
- if (!m_rightPaneSideBarWidget)
- createRightPaneContextViewer();
-
- QVariant fontSetting = LocalHelpManager::engineFontSettings();
- QFont font = fontSetting.isValid() ? fontSetting.value<QFont>()
- : m_rightPaneSideBarWidget->currentViewer()->viewerFont();
-
- m_rightPaneSideBarWidget->setViewerFont(font);
- m_centralWidget->setViewerFont(font);
-}
-
void HelpPlugin::setupHelpEngineIfNeeded()
{
LocalHelpManager::setEngineNeedsUpdate();
if (ModeManager::currentMode() == m_mode
- || contextHelpOption() == HelpManager::ExternalHelpAlways)
+ || LocalHelpManager::contextHelpOption() == HelpManager::ExternalHelpAlways)
LocalHelpManager::setupGuiHelpEngine();
}
@@ -528,7 +513,7 @@ HelpViewer *HelpPlugin::viewerForHelpViewerLocation(HelpManager::HelpViewerLocat
HelpViewer *HelpPlugin::viewerForContextHelp()
{
- return viewerForHelpViewerLocation(contextHelpOption());
+ return viewerForHelpViewerLocation(LocalHelpManager::contextHelpOption());
}
static QUrl findBestLink(const QMap<QString, QUrl> &links, QString *highlightId)
@@ -671,16 +656,3 @@ void HelpPlugin::doSetupIfNeeded()
LocalHelpManager::bookmarkManager().setupBookmarkModels();
}
}
-
-HelpManager::HelpViewerLocation HelpPlugin::contextHelpOption() const
-{
- QSettings *settings = ICore::settings();
- const QString key = QLatin1String(Help::Constants::ID_MODE_HELP) + QLatin1String("/ContextHelpOption");
- if (settings->contains(key))
- return HelpManager::HelpViewerLocation(
- settings->value(key, HelpManager::SideBySideIfPossible).toInt());
-
- const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
- return HelpManager::HelpViewerLocation(engine.customValue(QLatin1String("ContextHelpOption"),
- HelpManager::SideBySideIfPossible).toInt());
-}
diff --git a/src/plugins/help/helpplugin.h b/src/plugins/help/helpplugin.h
index 0540c5ad53..ed3325643c 100644
--- a/src/plugins/help/helpplugin.h
+++ b/src/plugins/help/helpplugin.h
@@ -99,8 +99,6 @@ private slots:
void updateSideBarSource();
void updateSideBarSource(const QUrl &newUrl);
- void fontChanged();
-
void setupHelpEngineIfNeeded();
void highlightSearchTermsInContextHelp();
@@ -120,7 +118,6 @@ private:
HelpViewer *externalHelpViewer();
void doSetupIfNeeded();
- Core::HelpManager::HelpViewerLocation contextHelpOption() const;
private:
HelpMode *m_mode;
@@ -129,7 +126,6 @@ private:
DocSettingsPage *m_docSettingsPage;
FilterSettingsPage *m_filterSettingsPage;
- GeneralSettingsPage *m_generalSettingsPage;
SearchTaskHandler *m_searchTaskHandler;
bool m_setupNeeded;
diff --git a/src/plugins/help/helpwidget.cpp b/src/plugins/help/helpwidget.cpp
index 69d07e4b21..ced702260f 100644
--- a/src/plugins/help/helpwidget.cpp
+++ b/src/plugins/help/helpwidget.cpp
@@ -47,7 +47,6 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
#include <coreplugin/findplaceholder.h>
-#include <coreplugin/helpmanager.h>
#include <coreplugin/minisplitter.h>
#include <coreplugin/sidebar.h>
#include <texteditor/texteditorconstants.h>
@@ -474,15 +473,6 @@ void HelpWidget::removeViewerAt(int index)
updateCloseButton();
}
-void HelpWidget::setViewerFont(const QFont &font)
-{
- for (int i = 0; i < m_viewerStack->count(); ++i) {
- HelpViewer *viewer = qobject_cast<HelpViewer *>(m_viewerStack->widget(i));
- QTC_ASSERT(viewer, continue);
- viewer->setFont(font);
- }
-}
-
int HelpWidget::viewerCount() const
{
return m_viewerStack->count();
@@ -576,8 +566,7 @@ void HelpWidget::helpModeButtonClicked()
void HelpWidget::updateCloseButton()
{
if (m_style == ModeWidget) {
- const bool closeOnReturn = Core::HelpManager::customValue(QLatin1String("ReturnOnClose"),
- false).toBool();
+ const bool closeOnReturn = LocalHelpManager::returnOnClose();
m_closeAction->setEnabled(closeOnReturn || m_viewerStack->count() > 1);
}
}
diff --git a/src/plugins/help/helpwidget.h b/src/plugins/help/helpwidget.h
index 2bee28b2f0..6ff34ee42b 100644
--- a/src/plugins/help/helpwidget.h
+++ b/src/plugins/help/helpwidget.h
@@ -74,8 +74,6 @@ public:
void addViewer(HelpViewer *viewer);
void removeViewerAt(int index);
- void setViewerFont(const QFont &font);
-
// so central widget can save the state
int viewerCount() const;
HelpViewer *viewerAt(int index) const;
diff --git a/src/plugins/help/localhelpmanager.cpp b/src/plugins/help/localhelpmanager.cpp
index 96508149e7..606f5029ae 100644
--- a/src/plugins/help/localhelpmanager.cpp
+++ b/src/plugins/help/localhelpmanager.cpp
@@ -36,7 +36,7 @@
#include <app/app_version.h>
#include <coreplugin/icore.h>
-#include <coreplugin/helpmanager.h>
+#include <utils/algorithm.h>
#include <utils/qtcassert.h>
#include <QMutexLocker>
@@ -60,7 +60,27 @@ QStandardItemModel *LocalHelpManager::m_filterModel = 0;
QString LocalHelpManager::m_currentFilter = QString();
int LocalHelpManager::m_currentFilterIndex = -1;
-static char kHelpHomePageKey[] = "Help/HomePage";
+static const char kHelpHomePageKey[] = "Help/HomePage";
+static const char kFontKey[] = "Help/Font";
+static const char kStartOptionKey[] = "Help/StartOption";
+static const char kContextHelpOptionKey[] = "Help/ContextHelpOption";
+static const char kReturnOnCloseKey[] = "Help/ReturnOnClose";
+static const char kLastShownPagesKey[] = "Help/LastShownPages";
+static const char kLastShownPagesZoomKey[] = "Help/LastShownPagesZoom";
+static const char kLastSelectedTabKey[] = "Help/LastSelectedTab";
+
+// TODO remove some time after Qt Creator 3.5
+static QVariant getSettingWithFallback(const QString &settingsKey,
+ const QString &fallbackSettingsKey,
+ const QVariant &fallbackSettingsValue)
+{
+ QSettings *settings = Core::ICore::settings();
+ if (settings->contains(settingsKey))
+ return settings->value(settingsKey);
+ // read from help engine for old settings
+ // TODO remove some time after Qt Creator 3.5
+ return LocalHelpManager::helpEngine().customValue(fallbackSettingsKey, fallbackSettingsValue);
+}
LocalHelpManager::LocalHelpManager(QObject *parent)
: QObject(parent)
@@ -106,6 +126,129 @@ void LocalHelpManager::setHomePage(const QString &page)
Core::ICore::settings()->setValue(QLatin1String(kHelpHomePageKey), page);
}
+QFont LocalHelpManager::fallbackFont()
+{
+ const QVariant value = getSettingWithFallback(QLatin1String(kFontKey),
+ QLatin1String("font"), QVariant());
+ return value.value<QFont>();
+}
+
+void LocalHelpManager::setFallbackFont(const QFont &font)
+{
+ Core::ICore::settings()->setValue(QLatin1String(kFontKey), font);
+ emit m_instance->fallbackFontChanged(font);
+}
+
+LocalHelpManager::StartOption LocalHelpManager::startOption()
+{
+ const QVariant value = getSettingWithFallback(QLatin1String(kStartOptionKey),
+ QLatin1String("StartOption"), ShowLastPages);
+ bool ok;
+ int optionValue = value.toInt(&ok);
+ if (!ok)
+ optionValue = ShowLastPages;
+ switch (optionValue) {
+ case ShowHomePage:
+ return ShowHomePage;
+ case ShowBlankPage:
+ return ShowBlankPage;
+ case ShowLastPages:
+ return ShowLastPages;
+ default:
+ break;
+ }
+ return ShowLastPages;
+}
+
+void LocalHelpManager::setStartOption(LocalHelpManager::StartOption option)
+{
+ Core::ICore::settings()->setValue(QLatin1String(kStartOptionKey), option);
+}
+
+Core::HelpManager::HelpViewerLocation LocalHelpManager::contextHelpOption()
+{
+ const QVariant value = getSettingWithFallback(QLatin1String(kContextHelpOptionKey),
+ QLatin1String("ContextHelpOption"),
+ Core::HelpManager::SideBySideIfPossible);
+ bool ok;
+ int optionValue = value.toInt(&ok);
+ if (!ok)
+ optionValue = Core::HelpManager::SideBySideIfPossible;
+ switch (optionValue) {
+ case Core::HelpManager::SideBySideIfPossible:
+ return Core::HelpManager::SideBySideIfPossible;
+ case Core::HelpManager::SideBySideAlways:
+ return Core::HelpManager::SideBySideAlways;
+ case Core::HelpManager::HelpModeAlways:
+ return Core::HelpManager::HelpModeAlways;
+ case Core::HelpManager::ExternalHelpAlways:
+ return Core::HelpManager::ExternalHelpAlways;
+ default:
+ break;
+ }
+ return Core::HelpManager::SideBySideIfPossible;
+}
+
+void LocalHelpManager::setContextHelpOption(Core::HelpManager::HelpViewerLocation location)
+{
+ Core::ICore::settings()->setValue(QLatin1String(kContextHelpOptionKey), location);
+}
+
+bool LocalHelpManager::returnOnClose()
+{
+ const QVariant value = getSettingWithFallback(QLatin1String(kReturnOnCloseKey),
+ QLatin1String("ReturnOnClose"), false);
+ return value.toBool();
+}
+
+void LocalHelpManager::setReturnOnClose(bool returnOnClose)
+{
+ Core::ICore::settings()->setValue(QLatin1String(kReturnOnCloseKey), returnOnClose);
+ emit m_instance->returnOnCloseChanged();
+}
+
+QStringList LocalHelpManager::lastShownPages()
+{
+ const QVariant value = getSettingWithFallback(QLatin1String(kLastShownPagesKey),
+ QLatin1String("LastShownPages"), QVariant());
+ return value.toString().split(Constants::ListSeparator, QString::SkipEmptyParts);
+}
+
+void LocalHelpManager::setLastShownPages(const QStringList &pages)
+{
+ Core::ICore::settings()->setValue(QLatin1String(kLastShownPagesKey),
+ pages.join(Constants::ListSeparator));
+}
+
+QList<float> LocalHelpManager::lastShownPagesZoom()
+{
+ const QVariant value = getSettingWithFallback(QLatin1String(kLastShownPagesZoomKey),
+ QLatin1String("LastShownPagesZoom"), QVariant());
+ const QStringList stringValues = value.toString().split(Constants::ListSeparator,
+ QString::SkipEmptyParts);
+ return Utils::transform(stringValues, [](const QString &str) { return str.toFloat(); });
+}
+
+void LocalHelpManager::setLastShownPagesZoom(const QList<float> &zoom)
+{
+ const QStringList stringValues = Utils::transform(zoom,
+ [](float z) { return QString::number(z); });
+ Core::ICore::settings()->setValue(QLatin1String(kLastShownPagesZoomKey),
+ stringValues.join(Constants::ListSeparator));
+}
+
+int LocalHelpManager::lastSelectedTab()
+{
+ const QVariant value = getSettingWithFallback(QLatin1String(kLastSelectedTabKey),
+ QLatin1String("LastTabPage"), 0);
+ return value.toInt();
+}
+
+void LocalHelpManager::setLastSelectedTab(int index)
+{
+ Core::ICore::settings()->setValue(QLatin1String(kLastSelectedTabKey), index);
+}
+
void LocalHelpManager::setupGuiHelpEngine()
{
if (m_needsCollectionFile) {
@@ -146,11 +289,6 @@ BookmarkManager& LocalHelpManager::bookmarkManager()
return *m_bookmarkManager;
}
-QVariant LocalHelpManager::engineFontSettings()
-{
- return helpEngine().customValue(Constants::FontKey, QVariant());
-}
-
/*!
* Checks if the string does contain a scheme, and if that scheme is a "sensible" scheme for
* opening in a internal or external browser (qthelp, about, file, http, https).
diff --git a/src/plugins/help/localhelpmanager.h b/src/plugins/help/localhelpmanager.h
index 0fe6676057..91f482691c 100644
--- a/src/plugins/help/localhelpmanager.h
+++ b/src/plugins/help/localhelpmanager.h
@@ -31,6 +31,8 @@
#ifndef LOCALHELPMANAGER_H
#define LOCALHELPMANAGER_H
+#include <coreplugin/helpmanager.h>
+
#include <QMetaType>
#include <QMutex>
#include <QObject>
@@ -55,6 +57,12 @@ public:
QString mimeType;
};
+ enum StartOption {
+ ShowHomePage = 0,
+ ShowBlankPage = 1,
+ ShowLastPages = 2,
+ };
+
LocalHelpManager(QObject *parent = 0);
~LocalHelpManager();
@@ -64,13 +72,33 @@ public:
static QString homePage();
static void setHomePage(const QString &page);
+ static QFont fallbackFont();
+ static void setFallbackFont(const QFont &font);
+
+ static StartOption startOption();
+ static void setStartOption(StartOption option);
+
+ static Core::HelpManager::HelpViewerLocation contextHelpOption();
+ static void setContextHelpOption(Core::HelpManager::HelpViewerLocation location);
+
+ static bool returnOnClose();
+ static void setReturnOnClose(bool returnOnClose);
+
+ static QStringList lastShownPages();
+ static void setLastShownPages(const QStringList &pages);
+
+ static QList<float> lastShownPagesZoom();
+ static void setLastShownPagesZoom(const QList<float> &zoom);
+
+ static int lastSelectedTab();
+ static void setLastSelectedTab(int index);
+
static void setupGuiHelpEngine();
static void setEngineNeedsUpdate();
static QHelpEngine& helpEngine();
static BookmarkManager& bookmarkManager();
- static QVariant engineFontSettings();
static bool isValidUrl(const QString &link);
static QByteArray loadErrorMessage(const QUrl &url, const QString &errorString);
@@ -84,6 +112,8 @@ public:
signals:
void filterIndexChanged(int index);
+ void fallbackFontChanged(const QFont &font);
+ void returnOnCloseChanged();
private:
static bool m_guiNeedsSetup;
diff --git a/src/plugins/help/openpagesmanager.cpp b/src/plugins/help/openpagesmanager.cpp
index 4b994a13d1..a1f0be1a92 100644
--- a/src/plugins/help/openpagesmanager.cpp
+++ b/src/plugins/help/openpagesmanager.cpp
@@ -46,7 +46,6 @@
#include <QHelpEngine>
#include <coreplugin/coreconstants.h>
-#include <coreplugin/helpmanager.h>
#include <coreplugin/modemanager.h>
using namespace Core;
@@ -127,37 +126,34 @@ QStringList splitString(const QVariant &value)
void OpenPagesManager::setupInitialPages()
{
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
- const int option = engine.customValue(QLatin1String("StartOption"),
- Help::Constants::ShowLastPages).toInt();
+ const LocalHelpManager::StartOption option = LocalHelpManager::startOption();
QString homePage = LocalHelpManager::homePage();
int initialPage = 0;
switch (option) {
- case Help::Constants::ShowHomePage: {
+ case LocalHelpManager::ShowHomePage: {
m_model->addPage(homePage);
} break;
- case Help::Constants::ShowBlankPage: {
+ case LocalHelpManager::ShowBlankPage: {
m_model->addPage(QUrl(Help::Constants::AboutBlank));
} break;
- case Help::Constants::ShowLastPages: {
- const QStringList &lastShownPageList = splitString(engine
- .customValue(QLatin1String("LastShownPages")));
+ case LocalHelpManager::ShowLastPages: {
+ const QStringList &lastShownPageList = LocalHelpManager::lastShownPages();
const int pageCount = lastShownPageList.count();
if (pageCount > 0) {
- QStringList zoomFactors = splitString(engine
- .customValue(QLatin1String("LastShownPagesZoom")));
+ QList<float> zoomFactors = LocalHelpManager::lastShownPagesZoom();
while (zoomFactors.count() < pageCount)
- zoomFactors.append(Help::Constants::DefaultZoomFactor);
+ zoomFactors.append(0.);
- initialPage = engine.customValue(QLatin1String("LastTabPage"), 0).toInt();
+ initialPage = LocalHelpManager::lastSelectedTab();
for (int curPage = 0; curPage < pageCount; ++curPage) {
const QString &curFile = lastShownPageList.at(curPage);
if (engine.findFile(curFile).isValid()
|| curFile == Help::Constants::AboutBlank) {
- m_model->addPage(curFile, zoomFactors.at(curPage).toFloat());
+ m_model->addPage(curFile, zoomFactors.at(curPage));
} else if (curPage <= initialPage && initialPage > 0) {
--initialPage;
}
@@ -228,10 +224,9 @@ void OpenPagesManager::closeCurrentPage()
if (indexes.isEmpty())
return;
- const bool closeOnReturn = HelpManager::customValue(QLatin1String("ReturnOnClose"),
- false).toBool();
+ const bool returnOnClose = LocalHelpManager::returnOnClose();
- if (m_model->rowCount() == 1 && closeOnReturn) {
+ if (m_model->rowCount() == 1 && returnOnClose) {
ModeManager::activateMode(Core::Constants::MODE_EDIT);
} else {
Q_ASSERT(indexes.count() == 1);
diff --git a/src/shared/help/bookmarkmanager.cpp b/src/shared/help/bookmarkmanager.cpp
index 68225ae132..361ee4e947 100644
--- a/src/shared/help/bookmarkmanager.cpp
+++ b/src/shared/help/bookmarkmanager.cpp
@@ -32,6 +32,8 @@
#include <localhelpmanager.h>
+#include <coreplugin/icore.h>
+
#include <utils/fancylineedit.h>
#include <utils/styledbar.h>
@@ -56,6 +58,8 @@
using namespace Help::Internal;
+static const char kBookmarksKey[] = "Help/Bookmarks";
+
BookmarkDialog::BookmarkDialog(BookmarkManager *manager, const QString &title,
const QString &url, QWidget *parent)
: QDialog(parent)
@@ -605,8 +609,7 @@ void BookmarkManager::saveBookmarks()
QDataStream stream(&bookmarks, QIODevice::WriteOnly);
readBookmarksRecursive(treeModel->invisibleRootItem(), stream, 0);
- (&LocalHelpManager::helpEngine())->setCustomValue(QLatin1String("Bookmarks"),
- bookmarks);
+ Core::ICore::settings()->setValue(QLatin1String(kBookmarksKey), bookmarks);
}
QStringList BookmarkManager::bookmarkFolders() const
@@ -723,8 +726,15 @@ void BookmarkManager::setupBookmarkModels()
QList<int> lastDepths;
QList<QStandardItem*> parents;
- QByteArray ba = LocalHelpManager::helpEngine()
- .customValue(QLatin1String("Bookmarks")).toByteArray();
+ QByteArray ba;
+ QSettings *settings = Core::ICore::settings();
+ if (settings->contains(QLatin1String(kBookmarksKey))) {
+ ba = settings->value(QLatin1String(kBookmarksKey)).toByteArray();
+ } else {
+ // read old settings from help engine
+ // TODO remove some time after Qt Creator 3.5
+ ba = LocalHelpManager::helpEngine().customValue(QLatin1String("Bookmarks")).toByteArray();
+ }
QDataStream stream(ba);
while (!stream.atEnd()) {
stream >> depth >> name >> type >> expanded;