forked from qt-creator/qt-creator
Help: Save home page in Qt Creator settings instead of help collection
And do not save the default page anywhere at all. This simplifies the logic, and makes the setting independent of help engine initialization. Change-Id: I264903229e274a0bf25c18b33734d36432aa525f Task-number: QTCREATORBUG-13198 Reviewed-by: Robert Loehning <robert.loehning@digia.com> Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -91,12 +91,7 @@ QWidget *GeneralSettingsPage::widget()
|
|||||||
updateFontStyle();
|
updateFontStyle();
|
||||||
updateFontFamily();
|
updateFontFamily();
|
||||||
|
|
||||||
m_homePage = HelpManager::customValue(QLatin1String("HomePage"), QString())
|
m_homePage = LocalHelpManager::homePage();
|
||||||
.toString();
|
|
||||||
if (m_homePage.isEmpty()) {
|
|
||||||
m_homePage = HelpManager::customValue(QLatin1String("DefaultHomePage"),
|
|
||||||
Help::Constants::AboutBlank).toString();
|
|
||||||
}
|
|
||||||
m_ui->homePageLineEdit->setText(m_homePage);
|
m_ui->homePageLineEdit->setText(m_homePage);
|
||||||
|
|
||||||
m_startOption = HelpManager::customValue(QLatin1String("StartOption"),
|
m_startOption = HelpManager::customValue(QLatin1String("StartOption"),
|
||||||
@@ -168,7 +163,7 @@ void GeneralSettingsPage::apply()
|
|||||||
m_ui->homePageLineEdit->setText(homePage);
|
m_ui->homePageLineEdit->setText(homePage);
|
||||||
if (m_homePage != homePage) {
|
if (m_homePage != homePage) {
|
||||||
m_homePage = homePage;
|
m_homePage = homePage;
|
||||||
HelpManager::setCustomValue(QLatin1String("HomePage"), homePage);
|
LocalHelpManager::setHomePage(homePage);
|
||||||
}
|
}
|
||||||
|
|
||||||
const int startOption = m_ui->helpStartComboBox->currentIndex();
|
const int startOption = m_ui->helpStartComboBox->currentIndex();
|
||||||
@@ -210,8 +205,7 @@ void GeneralSettingsPage::setBlankPage()
|
|||||||
|
|
||||||
void GeneralSettingsPage::setDefaultPage()
|
void GeneralSettingsPage::setDefaultPage()
|
||||||
{
|
{
|
||||||
m_ui->homePageLineEdit->setText(
|
m_ui->homePageLineEdit->setText(LocalHelpManager::defaultHomePage());
|
||||||
HelpManager::customValue(QLatin1String("DefaultHomePage"), QString()).toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralSettingsPage::importBookmarks()
|
void GeneralSettingsPage::importBookmarks()
|
||||||
|
@@ -144,16 +144,7 @@ bool HelpViewer::launchWithExternalApp(const QUrl &url)
|
|||||||
|
|
||||||
void HelpViewer::home()
|
void HelpViewer::home()
|
||||||
{
|
{
|
||||||
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
|
setSource(LocalHelpManager::homePage());
|
||||||
QString homepage = engine.customValue(QLatin1String("HomePage"),
|
|
||||||
QLatin1String("")).toString();
|
|
||||||
|
|
||||||
if (homepage.isEmpty()) {
|
|
||||||
homepage = engine.customValue(QLatin1String("DefaultHomePage"),
|
|
||||||
Help::Constants::AboutBlank).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
setSource(homepage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpViewer::slotLoadStarted()
|
void HelpViewer::slotLoadStarted()
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include "helpviewer.h"
|
#include "helpviewer.h"
|
||||||
|
|
||||||
#include <app/app_version.h>
|
#include <app/app_version.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/helpmanager.h>
|
#include <coreplugin/helpmanager.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -56,6 +57,8 @@ 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";
|
||||||
|
|
||||||
LocalHelpManager::LocalHelpManager(QObject *parent)
|
LocalHelpManager::LocalHelpManager(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_guiNeedsSetup(true)
|
, m_guiNeedsSetup(true)
|
||||||
@@ -83,6 +86,25 @@ LocalHelpManager *LocalHelpManager::instance()
|
|||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString LocalHelpManager::defaultHomePage()
|
||||||
|
{
|
||||||
|
static const QString url = QString::fromLatin1("qthelp://org.qt-project.qtcreator."
|
||||||
|
"%1%2%3/doc/index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)
|
||||||
|
.arg(IDE_VERSION_RELEASE);
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString LocalHelpManager::homePage()
|
||||||
|
{
|
||||||
|
return Core::ICore::settings()->value(QLatin1String(kHelpHomePageKey),
|
||||||
|
defaultHomePage()).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalHelpManager::setHomePage(const QString &page)
|
||||||
|
{
|
||||||
|
Core::ICore::settings()->setValue(QLatin1String(kHelpHomePageKey), page);
|
||||||
|
}
|
||||||
|
|
||||||
void LocalHelpManager::setupGuiHelpEngine()
|
void LocalHelpManager::setupGuiHelpEngine()
|
||||||
{
|
{
|
||||||
if (m_needsCollectionFile) {
|
if (m_needsCollectionFile) {
|
||||||
@@ -120,10 +142,6 @@ BookmarkManager& LocalHelpManager::bookmarkManager()
|
|||||||
if (!m_bookmarkManager) {
|
if (!m_bookmarkManager) {
|
||||||
m_bookmarkManager = new BookmarkManager;
|
m_bookmarkManager = new BookmarkManager;
|
||||||
m_bookmarkManager->setupBookmarkModels();
|
m_bookmarkManager->setupBookmarkModels();
|
||||||
const QString &url = QString::fromLatin1("qthelp://org.qt-project.qtcreator."
|
|
||||||
"%1%2%3/doc/index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)
|
|
||||||
.arg(IDE_VERSION_RELEASE);
|
|
||||||
helpEngine().setCustomValue(QLatin1String("DefaultHomePage"), url);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return *m_bookmarkManager;
|
return *m_bookmarkManager;
|
||||||
|
@@ -60,6 +60,10 @@ public:
|
|||||||
|
|
||||||
static LocalHelpManager *instance();
|
static LocalHelpManager *instance();
|
||||||
|
|
||||||
|
static QString defaultHomePage();
|
||||||
|
static QString homePage();
|
||||||
|
static void setHomePage(const QString &page);
|
||||||
|
|
||||||
void setupGuiHelpEngine();
|
void setupGuiHelpEngine();
|
||||||
void setEngineNeedsUpdate();
|
void setEngineNeedsUpdate();
|
||||||
|
|
||||||
|
@@ -129,14 +129,12 @@ void OpenPagesManager::setupInitialPages()
|
|||||||
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
|
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
|
||||||
const int option = engine.customValue(QLatin1String("StartOption"),
|
const int option = engine.customValue(QLatin1String("StartOption"),
|
||||||
Help::Constants::ShowLastPages).toInt();
|
Help::Constants::ShowLastPages).toInt();
|
||||||
QString homePage = engine.customValue(QLatin1String("DefaultHomePage"),
|
QString homePage = LocalHelpManager::homePage();
|
||||||
Help::Constants::AboutBlank).toString();
|
|
||||||
|
|
||||||
int initialPage = 0;
|
int initialPage = 0;
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case Help::Constants::ShowHomePage: {
|
case Help::Constants::ShowHomePage: {
|
||||||
m_model->addPage(engine.customValue(QLatin1String("HomePage"),
|
m_model->addPage(homePage);
|
||||||
homePage).toString());
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Help::Constants::ShowBlankPage: {
|
case Help::Constants::ShowBlankPage: {
|
||||||
|
Reference in New Issue
Block a user