forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -35,8 +35,6 @@
|
|||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QHelpEngine>
|
|
||||||
|
|
||||||
using namespace Help::Internal;
|
using namespace Help::Internal;
|
||||||
|
|
||||||
CentralWidget *gStaticCentralWidget = 0;
|
CentralWidget *gStaticCentralWidget = 0;
|
||||||
@@ -53,21 +51,20 @@ CentralWidget::CentralWidget(const Core::Context &context, QWidget *parent)
|
|||||||
CentralWidget::~CentralWidget()
|
CentralWidget::~CentralWidget()
|
||||||
{
|
{
|
||||||
// TODO: this shouldn't be done here
|
// TODO: this shouldn't be done here
|
||||||
QString zoomFactors;
|
QList<float> zoomFactors;
|
||||||
QString currentPages;
|
QStringList currentPages;
|
||||||
for (int i = 0; i < viewerCount(); ++i) {
|
for (int i = 0; i < viewerCount(); ++i) {
|
||||||
const HelpViewer * const viewer = viewerAt(i);
|
const HelpViewer * const viewer = viewerAt(i);
|
||||||
const QUrl &source = viewer->source();
|
const QUrl &source = viewer->source();
|
||||||
if (source.isValid()) {
|
if (source.isValid()) {
|
||||||
currentPages += source.toString() + QLatin1Char('|');
|
currentPages.append(source.toString());
|
||||||
zoomFactors += QString::number(viewer->scale()) + QLatin1Char('|');
|
zoomFactors.append(viewer->scale());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
|
LocalHelpManager::setLastShownPages(currentPages);
|
||||||
engine->setCustomValue(QLatin1String("LastShownPages"), currentPages);
|
LocalHelpManager::setLastShownPagesZoom(zoomFactors);
|
||||||
engine->setCustomValue(QLatin1String("LastShownPagesZoom"), zoomFactors);
|
LocalHelpManager::setLastSelectedTab(currentIndex());
|
||||||
engine->setCustomValue(QLatin1String("LastTabPage"), currentIndex());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CentralWidget *CentralWidget::instance()
|
CentralWidget *CentralWidget::instance()
|
||||||
|
@@ -61,12 +61,6 @@ using namespace Help::Internal;
|
|||||||
GeneralSettingsPage::GeneralSettingsPage()
|
GeneralSettingsPage::GeneralSettingsPage()
|
||||||
: m_ui(0)
|
: 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");
|
setId("A.General settings");
|
||||||
setDisplayName(tr("General"));
|
setDisplayName(tr("General"));
|
||||||
setCategory(Help::Constants::HELP_CATEGORY);
|
setCategory(Help::Constants::HELP_CATEGORY);
|
||||||
@@ -83,9 +77,7 @@ QWidget *GeneralSettingsPage::widget()
|
|||||||
m_ui->sizeComboBox->setEditable(false);
|
m_ui->sizeComboBox->setEditable(false);
|
||||||
m_ui->styleComboBox->setEditable(false);
|
m_ui->styleComboBox->setEditable(false);
|
||||||
|
|
||||||
QVariant fontSetting = LocalHelpManager::engineFontSettings();
|
m_font = LocalHelpManager::fallbackFont();
|
||||||
if (fontSetting.isValid())
|
|
||||||
m_font = fontSetting.value<QFont>();
|
|
||||||
|
|
||||||
updateFontSize();
|
updateFontSize();
|
||||||
updateFontStyle();
|
updateFontStyle();
|
||||||
@@ -94,12 +86,10 @@ QWidget *GeneralSettingsPage::widget()
|
|||||||
m_homePage = LocalHelpManager::homePage();
|
m_homePage = LocalHelpManager::homePage();
|
||||||
m_ui->homePageLineEdit->setText(m_homePage);
|
m_ui->homePageLineEdit->setText(m_homePage);
|
||||||
|
|
||||||
m_startOption = HelpManager::customValue(QLatin1String("StartOption"),
|
m_startOption = LocalHelpManager::startOption();
|
||||||
Help::Constants::ShowLastPages).toInt();
|
|
||||||
m_ui->helpStartComboBox->setCurrentIndex(m_startOption);
|
m_ui->helpStartComboBox->setCurrentIndex(m_startOption);
|
||||||
|
|
||||||
m_contextOption = HelpManager::customValue(QLatin1String("ContextHelpOption"),
|
m_contextOption = LocalHelpManager::contextHelpOption();
|
||||||
HelpManager::SideBySideIfPossible).toInt();
|
|
||||||
m_ui->contextHelpComboBox->setCurrentIndex(m_contextOption);
|
m_ui->contextHelpComboBox->setCurrentIndex(m_contextOption);
|
||||||
|
|
||||||
connect(m_ui->currentPageButton, &QPushButton::clicked,
|
connect(m_ui->currentPageButton, &QPushButton::clicked,
|
||||||
@@ -119,8 +109,7 @@ QWidget *GeneralSettingsPage::widget()
|
|||||||
connect(m_ui->exportButton, &QPushButton::clicked,
|
connect(m_ui->exportButton, &QPushButton::clicked,
|
||||||
this, &GeneralSettingsPage::exportBookmarks);
|
this, &GeneralSettingsPage::exportBookmarks);
|
||||||
|
|
||||||
m_returnOnClose = HelpManager::customValue(QLatin1String("ReturnOnClose"),
|
m_returnOnClose = LocalHelpManager::returnOnClose();
|
||||||
false).toBool();
|
|
||||||
m_ui->m_returnOnClose->setChecked(m_returnOnClose);
|
m_ui->m_returnOnClose->setChecked(m_returnOnClose);
|
||||||
}
|
}
|
||||||
return m_widget;
|
return m_widget;
|
||||||
@@ -158,7 +147,7 @@ void GeneralSettingsPage::apply()
|
|||||||
|
|
||||||
if (newFont != m_font) {
|
if (newFont != m_font) {
|
||||||
m_font = newFont;
|
m_font = newFont;
|
||||||
HelpManager::setCustomValue(Constants::FontKey, newFont);
|
LocalHelpManager::setFallbackFont(newFont);
|
||||||
emit fontChanged();
|
emit fontChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,25 +163,19 @@ void GeneralSettingsPage::apply()
|
|||||||
const int startOption = m_ui->helpStartComboBox->currentIndex();
|
const int startOption = m_ui->helpStartComboBox->currentIndex();
|
||||||
if (m_startOption != startOption) {
|
if (m_startOption != startOption) {
|
||||||
m_startOption = startOption;
|
m_startOption = startOption;
|
||||||
HelpManager::setCustomValue(QLatin1String("StartOption"), startOption);
|
LocalHelpManager::setStartOption((LocalHelpManager::StartOption)m_startOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
const int helpOption = m_ui->contextHelpComboBox->currentIndex();
|
const int helpOption = m_ui->contextHelpComboBox->currentIndex();
|
||||||
if (m_contextOption != helpOption) {
|
if (m_contextOption != helpOption) {
|
||||||
m_contextOption = helpOption;
|
m_contextOption = helpOption;
|
||||||
HelpManager::setCustomValue(QLatin1String("ContextHelpOption"), helpOption);
|
LocalHelpManager::setContextHelpOption((HelpManager::HelpViewerLocation)m_contextOption);
|
||||||
|
|
||||||
QSettings *settings = ICore::settings();
|
|
||||||
settings->beginGroup(QLatin1String(Help::Constants::ID_MODE_HELP));
|
|
||||||
settings->setValue(QLatin1String("ContextHelpOption"), helpOption);
|
|
||||||
settings->endGroup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool close = m_ui->m_returnOnClose->isChecked();
|
const bool close = m_ui->m_returnOnClose->isChecked();
|
||||||
if (m_returnOnClose != close) {
|
if (m_returnOnClose != close) {
|
||||||
m_returnOnClose = close;
|
m_returnOnClose = close;
|
||||||
HelpManager::setCustomValue(QLatin1String("ReturnOnClose"), close);
|
LocalHelpManager::setReturnOnClose(m_returnOnClose);
|
||||||
emit returnOnCloseChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -54,7 +54,6 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void fontChanged();
|
void fontChanged();
|
||||||
void returnOnCloseChanged();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setCurrentPage();
|
void setCurrentPage();
|
||||||
|
@@ -37,18 +37,10 @@
|
|||||||
namespace Help {
|
namespace Help {
|
||||||
namespace Constants {
|
namespace Constants {
|
||||||
|
|
||||||
enum {
|
|
||||||
ShowHomePage = 0,
|
|
||||||
ShowBlankPage = 1,
|
|
||||||
ShowLastPages = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
static const QLatin1String ListSeparator("|");
|
static const QLatin1String ListSeparator("|");
|
||||||
static const QLatin1String DefaultZoomFactor("0.0");
|
|
||||||
static const QLatin1String AboutBlank("about:blank");
|
static const QLatin1String AboutBlank("about:blank");
|
||||||
static const QLatin1String WeAddedFilterKey("UnfilteredFilterInserted");
|
static const QLatin1String WeAddedFilterKey("UnfilteredFilterInserted");
|
||||||
static const QLatin1String PreviousFilterNameKey("UnfilteredFilterName");
|
static const QLatin1String PreviousFilterNameKey("UnfilteredFilterName");
|
||||||
static const QLatin1String FontKey("font");
|
|
||||||
|
|
||||||
const int P_MODE_HELP = 70;
|
const int P_MODE_HELP = 70;
|
||||||
const char ID_MODE_HELP [] = "Help";
|
const char ID_MODE_HELP [] = "Help";
|
||||||
|
@@ -146,7 +146,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
m_openPagesManager = new OpenPagesManager(this);
|
m_openPagesManager = new OpenPagesManager(this);
|
||||||
addAutoReleasedObject(m_docSettingsPage = new DocSettingsPage());
|
addAutoReleasedObject(m_docSettingsPage = new DocSettingsPage());
|
||||||
addAutoReleasedObject(m_filterSettingsPage = new FilterSettingsPage());
|
addAutoReleasedObject(m_filterSettingsPage = new FilterSettingsPage());
|
||||||
addAutoReleasedObject(m_generalSettingsPage = new GeneralSettingsPage());
|
addAutoReleasedObject(new GeneralSettingsPage());
|
||||||
addAutoReleasedObject(m_searchTaskHandler = new SearchTaskHandler);
|
addAutoReleasedObject(m_searchTaskHandler = new SearchTaskHandler);
|
||||||
|
|
||||||
m_centralWidget = new CentralWidget(modecontext);
|
m_centralWidget = new CentralWidget(modecontext);
|
||||||
@@ -155,10 +155,8 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
connect(m_centralWidget, &CentralWidget::closeButtonClicked,
|
connect(m_centralWidget, &CentralWidget::closeButtonClicked,
|
||||||
&OpenPagesManager::instance(), &OpenPagesManager::closeCurrentPage);
|
&OpenPagesManager::instance(), &OpenPagesManager::closeCurrentPage);
|
||||||
|
|
||||||
connect(m_generalSettingsPage, SIGNAL(fontChanged()), this,
|
connect(LocalHelpManager::instance(), &LocalHelpManager::returnOnCloseChanged,
|
||||||
SLOT(fontChanged()));
|
m_centralWidget, &CentralWidget::updateCloseButton);
|
||||||
connect(m_generalSettingsPage, SIGNAL(returnOnCloseChanged()), m_centralWidget,
|
|
||||||
SLOT(updateCloseButton()));
|
|
||||||
connect(HelpManager::instance(), SIGNAL(helpRequested(QUrl,Core::HelpManager::HelpViewerLocation)),
|
connect(HelpManager::instance(), SIGNAL(helpRequested(QUrl,Core::HelpManager::HelpViewerLocation)),
|
||||||
this, SLOT(handleHelpRequest(QUrl,Core::HelpManager::HelpViewerLocation)));
|
this, SLOT(handleHelpRequest(QUrl,Core::HelpManager::HelpViewerLocation)));
|
||||||
connect(m_searchTaskHandler, SIGNAL(search(QUrl)), this,
|
connect(m_searchTaskHandler, SIGNAL(search(QUrl)), this,
|
||||||
@@ -390,9 +388,9 @@ HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
|
|||||||
HelpViewer *viewer = factory();
|
HelpViewer *viewer = factory();
|
||||||
|
|
||||||
// initialize font
|
// initialize font
|
||||||
QVariant fontSetting = LocalHelpManager::engineFontSettings();
|
viewer->setViewerFont(LocalHelpManager::fallbackFont());
|
||||||
if (fontSetting.isValid())
|
connect(LocalHelpManager::instance(), &LocalHelpManager::fallbackFontChanged,
|
||||||
viewer->setViewerFont(fontSetting.value<QFont>());
|
viewer, &HelpViewer::setViewerFont);
|
||||||
|
|
||||||
// initialize zoom
|
// initialize zoom
|
||||||
viewer->setScale(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()
|
void HelpPlugin::setupHelpEngineIfNeeded()
|
||||||
{
|
{
|
||||||
LocalHelpManager::setEngineNeedsUpdate();
|
LocalHelpManager::setEngineNeedsUpdate();
|
||||||
if (ModeManager::currentMode() == m_mode
|
if (ModeManager::currentMode() == m_mode
|
||||||
|| contextHelpOption() == HelpManager::ExternalHelpAlways)
|
|| LocalHelpManager::contextHelpOption() == HelpManager::ExternalHelpAlways)
|
||||||
LocalHelpManager::setupGuiHelpEngine();
|
LocalHelpManager::setupGuiHelpEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,7 +513,7 @@ HelpViewer *HelpPlugin::viewerForHelpViewerLocation(HelpManager::HelpViewerLocat
|
|||||||
|
|
||||||
HelpViewer *HelpPlugin::viewerForContextHelp()
|
HelpViewer *HelpPlugin::viewerForContextHelp()
|
||||||
{
|
{
|
||||||
return viewerForHelpViewerLocation(contextHelpOption());
|
return viewerForHelpViewerLocation(LocalHelpManager::contextHelpOption());
|
||||||
}
|
}
|
||||||
|
|
||||||
static QUrl findBestLink(const QMap<QString, QUrl> &links, QString *highlightId)
|
static QUrl findBestLink(const QMap<QString, QUrl> &links, QString *highlightId)
|
||||||
@@ -671,16 +656,3 @@ void HelpPlugin::doSetupIfNeeded()
|
|||||||
LocalHelpManager::bookmarkManager().setupBookmarkModels();
|
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());
|
|
||||||
}
|
|
||||||
|
@@ -99,8 +99,6 @@ private slots:
|
|||||||
void updateSideBarSource();
|
void updateSideBarSource();
|
||||||
void updateSideBarSource(const QUrl &newUrl);
|
void updateSideBarSource(const QUrl &newUrl);
|
||||||
|
|
||||||
void fontChanged();
|
|
||||||
|
|
||||||
void setupHelpEngineIfNeeded();
|
void setupHelpEngineIfNeeded();
|
||||||
|
|
||||||
void highlightSearchTermsInContextHelp();
|
void highlightSearchTermsInContextHelp();
|
||||||
@@ -120,7 +118,6 @@ private:
|
|||||||
HelpViewer *externalHelpViewer();
|
HelpViewer *externalHelpViewer();
|
||||||
|
|
||||||
void doSetupIfNeeded();
|
void doSetupIfNeeded();
|
||||||
Core::HelpManager::HelpViewerLocation contextHelpOption() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HelpMode *m_mode;
|
HelpMode *m_mode;
|
||||||
@@ -129,7 +126,6 @@ private:
|
|||||||
|
|
||||||
DocSettingsPage *m_docSettingsPage;
|
DocSettingsPage *m_docSettingsPage;
|
||||||
FilterSettingsPage *m_filterSettingsPage;
|
FilterSettingsPage *m_filterSettingsPage;
|
||||||
GeneralSettingsPage *m_generalSettingsPage;
|
|
||||||
SearchTaskHandler *m_searchTaskHandler;
|
SearchTaskHandler *m_searchTaskHandler;
|
||||||
|
|
||||||
bool m_setupNeeded;
|
bool m_setupNeeded;
|
||||||
|
@@ -47,7 +47,6 @@
|
|||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/findplaceholder.h>
|
#include <coreplugin/findplaceholder.h>
|
||||||
#include <coreplugin/helpmanager.h>
|
|
||||||
#include <coreplugin/minisplitter.h>
|
#include <coreplugin/minisplitter.h>
|
||||||
#include <coreplugin/sidebar.h>
|
#include <coreplugin/sidebar.h>
|
||||||
#include <texteditor/texteditorconstants.h>
|
#include <texteditor/texteditorconstants.h>
|
||||||
@@ -474,15 +473,6 @@ void HelpWidget::removeViewerAt(int index)
|
|||||||
updateCloseButton();
|
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
|
int HelpWidget::viewerCount() const
|
||||||
{
|
{
|
||||||
return m_viewerStack->count();
|
return m_viewerStack->count();
|
||||||
@@ -576,8 +566,7 @@ void HelpWidget::helpModeButtonClicked()
|
|||||||
void HelpWidget::updateCloseButton()
|
void HelpWidget::updateCloseButton()
|
||||||
{
|
{
|
||||||
if (m_style == ModeWidget) {
|
if (m_style == ModeWidget) {
|
||||||
const bool closeOnReturn = Core::HelpManager::customValue(QLatin1String("ReturnOnClose"),
|
const bool closeOnReturn = LocalHelpManager::returnOnClose();
|
||||||
false).toBool();
|
|
||||||
m_closeAction->setEnabled(closeOnReturn || m_viewerStack->count() > 1);
|
m_closeAction->setEnabled(closeOnReturn || m_viewerStack->count() > 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -74,8 +74,6 @@ public:
|
|||||||
void addViewer(HelpViewer *viewer);
|
void addViewer(HelpViewer *viewer);
|
||||||
void removeViewerAt(int index);
|
void removeViewerAt(int index);
|
||||||
|
|
||||||
void setViewerFont(const QFont &font);
|
|
||||||
|
|
||||||
// so central widget can save the state
|
// so central widget can save the state
|
||||||
int viewerCount() const;
|
int viewerCount() const;
|
||||||
HelpViewer *viewerAt(int index) const;
|
HelpViewer *viewerAt(int index) const;
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#include <app/app_version.h>
|
#include <app/app_version.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/helpmanager.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
@@ -60,7 +60,27 @@ QStandardItemModel *LocalHelpManager::m_filterModel = 0;
|
|||||||
QString LocalHelpManager::m_currentFilter = QString();
|
QString LocalHelpManager::m_currentFilter = QString();
|
||||||
int LocalHelpManager::m_currentFilterIndex = -1;
|
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)
|
LocalHelpManager::LocalHelpManager(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
@@ -106,6 +126,129 @@ void LocalHelpManager::setHomePage(const QString &page)
|
|||||||
Core::ICore::settings()->setValue(QLatin1String(kHelpHomePageKey), 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()
|
void LocalHelpManager::setupGuiHelpEngine()
|
||||||
{
|
{
|
||||||
if (m_needsCollectionFile) {
|
if (m_needsCollectionFile) {
|
||||||
@@ -146,11 +289,6 @@ BookmarkManager& LocalHelpManager::bookmarkManager()
|
|||||||
return *m_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
|
* 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).
|
* opening in a internal or external browser (qthelp, about, file, http, https).
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
#ifndef LOCALHELPMANAGER_H
|
#ifndef LOCALHELPMANAGER_H
|
||||||
#define LOCALHELPMANAGER_H
|
#define LOCALHELPMANAGER_H
|
||||||
|
|
||||||
|
#include <coreplugin/helpmanager.h>
|
||||||
|
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -55,6 +57,12 @@ public:
|
|||||||
QString mimeType;
|
QString mimeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum StartOption {
|
||||||
|
ShowHomePage = 0,
|
||||||
|
ShowBlankPage = 1,
|
||||||
|
ShowLastPages = 2,
|
||||||
|
};
|
||||||
|
|
||||||
LocalHelpManager(QObject *parent = 0);
|
LocalHelpManager(QObject *parent = 0);
|
||||||
~LocalHelpManager();
|
~LocalHelpManager();
|
||||||
|
|
||||||
@@ -64,13 +72,33 @@ public:
|
|||||||
static QString homePage();
|
static QString homePage();
|
||||||
static void setHomePage(const QString &page);
|
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 setupGuiHelpEngine();
|
||||||
static void setEngineNeedsUpdate();
|
static void setEngineNeedsUpdate();
|
||||||
|
|
||||||
static QHelpEngine& helpEngine();
|
static QHelpEngine& helpEngine();
|
||||||
static BookmarkManager& bookmarkManager();
|
static BookmarkManager& bookmarkManager();
|
||||||
|
|
||||||
static QVariant engineFontSettings();
|
|
||||||
static bool isValidUrl(const QString &link);
|
static bool isValidUrl(const QString &link);
|
||||||
|
|
||||||
static QByteArray loadErrorMessage(const QUrl &url, const QString &errorString);
|
static QByteArray loadErrorMessage(const QUrl &url, const QString &errorString);
|
||||||
@@ -84,6 +112,8 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void filterIndexChanged(int index);
|
void filterIndexChanged(int index);
|
||||||
|
void fallbackFontChanged(const QFont &font);
|
||||||
|
void returnOnCloseChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool m_guiNeedsSetup;
|
static bool m_guiNeedsSetup;
|
||||||
|
@@ -46,7 +46,6 @@
|
|||||||
#include <QHelpEngine>
|
#include <QHelpEngine>
|
||||||
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/helpmanager.h>
|
|
||||||
#include <coreplugin/modemanager.h>
|
#include <coreplugin/modemanager.h>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
@@ -127,37 +126,34 @@ QStringList splitString(const QVariant &value)
|
|||||||
void OpenPagesManager::setupInitialPages()
|
void OpenPagesManager::setupInitialPages()
|
||||||
{
|
{
|
||||||
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
|
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
|
||||||
const int option = engine.customValue(QLatin1String("StartOption"),
|
const LocalHelpManager::StartOption option = LocalHelpManager::startOption();
|
||||||
Help::Constants::ShowLastPages).toInt();
|
|
||||||
QString homePage = LocalHelpManager::homePage();
|
QString homePage = LocalHelpManager::homePage();
|
||||||
|
|
||||||
int initialPage = 0;
|
int initialPage = 0;
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case Help::Constants::ShowHomePage: {
|
case LocalHelpManager::ShowHomePage: {
|
||||||
m_model->addPage(homePage);
|
m_model->addPage(homePage);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Help::Constants::ShowBlankPage: {
|
case LocalHelpManager::ShowBlankPage: {
|
||||||
m_model->addPage(QUrl(Help::Constants::AboutBlank));
|
m_model->addPage(QUrl(Help::Constants::AboutBlank));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Help::Constants::ShowLastPages: {
|
case LocalHelpManager::ShowLastPages: {
|
||||||
const QStringList &lastShownPageList = splitString(engine
|
const QStringList &lastShownPageList = LocalHelpManager::lastShownPages();
|
||||||
.customValue(QLatin1String("LastShownPages")));
|
|
||||||
const int pageCount = lastShownPageList.count();
|
const int pageCount = lastShownPageList.count();
|
||||||
|
|
||||||
if (pageCount > 0) {
|
if (pageCount > 0) {
|
||||||
QStringList zoomFactors = splitString(engine
|
QList<float> zoomFactors = LocalHelpManager::lastShownPagesZoom();
|
||||||
.customValue(QLatin1String("LastShownPagesZoom")));
|
|
||||||
while (zoomFactors.count() < pageCount)
|
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) {
|
for (int curPage = 0; curPage < pageCount; ++curPage) {
|
||||||
const QString &curFile = lastShownPageList.at(curPage);
|
const QString &curFile = lastShownPageList.at(curPage);
|
||||||
if (engine.findFile(curFile).isValid()
|
if (engine.findFile(curFile).isValid()
|
||||||
|| curFile == Help::Constants::AboutBlank) {
|
|| 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) {
|
} else if (curPage <= initialPage && initialPage > 0) {
|
||||||
--initialPage;
|
--initialPage;
|
||||||
}
|
}
|
||||||
@@ -228,10 +224,9 @@ void OpenPagesManager::closeCurrentPage()
|
|||||||
if (indexes.isEmpty())
|
if (indexes.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const bool closeOnReturn = HelpManager::customValue(QLatin1String("ReturnOnClose"),
|
const bool returnOnClose = LocalHelpManager::returnOnClose();
|
||||||
false).toBool();
|
|
||||||
|
|
||||||
if (m_model->rowCount() == 1 && closeOnReturn) {
|
if (m_model->rowCount() == 1 && returnOnClose) {
|
||||||
ModeManager::activateMode(Core::Constants::MODE_EDIT);
|
ModeManager::activateMode(Core::Constants::MODE_EDIT);
|
||||||
} else {
|
} else {
|
||||||
Q_ASSERT(indexes.count() == 1);
|
Q_ASSERT(indexes.count() == 1);
|
||||||
|
@@ -32,6 +32,8 @@
|
|||||||
|
|
||||||
#include <localhelpmanager.h>
|
#include <localhelpmanager.h>
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <utils/fancylineedit.h>
|
#include <utils/fancylineedit.h>
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
|
|
||||||
@@ -56,6 +58,8 @@
|
|||||||
|
|
||||||
using namespace Help::Internal;
|
using namespace Help::Internal;
|
||||||
|
|
||||||
|
static const char kBookmarksKey[] = "Help/Bookmarks";
|
||||||
|
|
||||||
BookmarkDialog::BookmarkDialog(BookmarkManager *manager, const QString &title,
|
BookmarkDialog::BookmarkDialog(BookmarkManager *manager, const QString &title,
|
||||||
const QString &url, QWidget *parent)
|
const QString &url, QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
@@ -605,8 +609,7 @@ void BookmarkManager::saveBookmarks()
|
|||||||
QDataStream stream(&bookmarks, QIODevice::WriteOnly);
|
QDataStream stream(&bookmarks, QIODevice::WriteOnly);
|
||||||
|
|
||||||
readBookmarksRecursive(treeModel->invisibleRootItem(), stream, 0);
|
readBookmarksRecursive(treeModel->invisibleRootItem(), stream, 0);
|
||||||
(&LocalHelpManager::helpEngine())->setCustomValue(QLatin1String("Bookmarks"),
|
Core::ICore::settings()->setValue(QLatin1String(kBookmarksKey), bookmarks);
|
||||||
bookmarks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList BookmarkManager::bookmarkFolders() const
|
QStringList BookmarkManager::bookmarkFolders() const
|
||||||
@@ -723,8 +726,15 @@ void BookmarkManager::setupBookmarkModels()
|
|||||||
QList<int> lastDepths;
|
QList<int> lastDepths;
|
||||||
QList<QStandardItem*> parents;
|
QList<QStandardItem*> parents;
|
||||||
|
|
||||||
QByteArray ba = LocalHelpManager::helpEngine()
|
QByteArray ba;
|
||||||
.customValue(QLatin1String("Bookmarks")).toByteArray();
|
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);
|
QDataStream stream(ba);
|
||||||
while (!stream.atEnd()) {
|
while (!stream.atEnd()) {
|
||||||
stream >> depth >> name >> type >> expanded;
|
stream >> depth >> name >> type >> expanded;
|
||||||
|
Reference in New Issue
Block a user