diff --git a/src/plugins/help/centralwidget.cpp b/src/plugins/help/centralwidget.cpp index 5c1b5acbe86a9a36852079107bc4505ca6b2e4b9..20ae95f0069e2399ddafcf94ef3d31fc8b1f2e82 100644 --- a/src/plugins/help/centralwidget.cpp +++ b/src/plugins/help/centralwidget.cpp @@ -239,18 +239,20 @@ void CentralWidget::setLastShownPages() QString()).toString(); const QStringList lastShownPageList = value.split(QLatin1Char('|'), QString::SkipEmptyParts); - const int pageCount = lastShownPageList.count(); - if (pageCount <= 0) { - QUrl url = helpEngine->findFile(QString::fromLatin1("qthelp://com." - "trolltech.qt.440/qdoc/index.html")); - if (!url.isValid()) { - url.setUrl(QString("qthelp://com.nokia.qtcreator.%1%2/doc/index.html"). - arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)); - url.setUrl(QString::fromLatin1("qthelp://com.nokia.qtcreator.%1%2/" - "doc/index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)); + + QString homePage = helpEngine->customValue(QLatin1String("DefaultHomePage"), + QLatin1String("about:blank")).toString(); + + int option = helpEngine->customValue(QLatin1String("StartOption"), 2).toInt(); + if (option == 0 || option == 1 || pageCount <= 0) { + if (option == 0) { + homePage = helpEngine->customValue(QLatin1String("HomePage"), + homePage).toString(); + } else if (option == 1) { + homePage = QLatin1String("about:blank"); } - setSource(url); + setSource(homePage); return; } diff --git a/src/plugins/help/generalsettingspage.cpp b/src/plugins/help/generalsettingspage.cpp index f5f168e8fd5f26d949793bb5910451abd4f45c15..5dbd91d9dbf158a84ecf6b1b07090423278dbd8c 100644 --- a/src/plugins/help/generalsettingspage.cpp +++ b/src/plugins/help/generalsettingspage.cpp @@ -29,7 +29,8 @@ #include "generalsettingspage.h" -#include <QtHelp/QHelpEngine> +#include "centralwidget.h" +#include "helpviewer.h" #if defined(QT_NO_WEBKIT) #include <QtGui/QApplication> @@ -37,11 +38,17 @@ #include <QtWebKit/QWebSettings> #endif +#include <QtHelp/QHelpEngine> + +#include <coreplugin/coreconstants.h> + using namespace Help::Internal; -GeneralSettingsPage::GeneralSettingsPage(QHelpEngine *helpEngine) +GeneralSettingsPage::GeneralSettingsPage(QHelpEngine *helpEngine, + CentralWidget *centralWidget) : m_currentPage(0) , m_helpEngine(helpEngine) + , m_centralWidget(centralWidget) { #if !defined(QT_NO_WEBKIT) QWebSettings* webSettings = QWebSettings::globalSettings(); @@ -87,6 +94,26 @@ QWidget *GeneralSettingsPage::createPage(QWidget *parent) updateFontStyle(); updateFontFamily(); + QString homePage = m_helpEngine->customValue(QLatin1String("HomePage"), + QString()).toString(); + + if (homePage.isEmpty()) { + homePage = m_helpEngine->customValue(QLatin1String("DefaultHomePage"), + QLatin1String("about:blank")).toString(); + } + m_ui.homePageLineEdit->setText(homePage); + + int index = m_helpEngine->customValue(QLatin1String("StartOption"), 2).toInt(); + m_ui.helpStartComboBox->setCurrentIndex(index); + + connect(m_ui.currentPageButton, SIGNAL(clicked()), this, SLOT(setCurrentPage())); + connect(m_ui.blankPageButton, SIGNAL(clicked()), this, SLOT(setBlankPage())); + connect(m_ui.defaultPageButton, SIGNAL(clicked()), this, SLOT(setDefaultPage())); + + HelpViewer *viewer = m_centralWidget->currentHelpViewer(); + if (viewer == 0) + m_ui.currentPageButton->setEnabled(false); + return m_currentPage; } @@ -121,6 +148,14 @@ void GeneralSettingsPage::apply() #else emit fontChanged(); #endif + + QString homePage = m_ui.homePageLineEdit->text(); + if (homePage.isEmpty()) + homePage = QLatin1String("about:blank"); + m_helpEngine->setCustomValue(QLatin1String("HomePage"), homePage); + + int startOption = m_ui.helpStartComboBox->currentIndex(); + m_helpEngine->setCustomValue(QLatin1String("StartOption"), startOption); } void GeneralSettingsPage::finish() @@ -128,6 +163,26 @@ void GeneralSettingsPage::finish() // Hmm, what to do here? } +void GeneralSettingsPage::setCurrentPage() +{ + HelpViewer *viewer = m_centralWidget->currentHelpViewer(); + if (viewer) + m_ui.homePageLineEdit->setText(viewer->source().toString()); +} + +void GeneralSettingsPage::setBlankPage() +{ + m_ui.homePageLineEdit->setText(QLatin1String("about:blank")); +} + +void GeneralSettingsPage::setDefaultPage() +{ + const QString &homePage = + m_helpEngine->customValue(QLatin1String("DefaultHomePage"), + QString()).toString(); + m_ui.homePageLineEdit->setText(homePage); +} + void GeneralSettingsPage::updateFontSize() { const QString &family = font.family(); diff --git a/src/plugins/help/generalsettingspage.h b/src/plugins/help/generalsettingspage.h index e42724b8c122c5d2ee7d7da031173c94dc9ea86f..aa4995257d0e9e34b533d51a5dd60691a61146fe 100644 --- a/src/plugins/help/generalsettingspage.h +++ b/src/plugins/help/generalsettingspage.h @@ -43,12 +43,14 @@ QT_FORWARD_DECLARE_CLASS(QHelpEngine) namespace Help { namespace Internal { +class CentralWidget; + class GeneralSettingsPage : public Core::IOptionsPage { Q_OBJECT public: - GeneralSettingsPage(QHelpEngine *helpEngine); + GeneralSettingsPage(QHelpEngine *helpEngine, CentralWidget *centralWidget); QString id() const; virtual QString trName() const; @@ -62,6 +64,11 @@ public: signals: void fontChanged(); +private slots: + void setCurrentPage(); + void setBlankPage(); + void setDefaultPage(); + private: void updateFontSize(); void updateFontStyle(); @@ -71,6 +78,7 @@ private: private: QWidget *m_currentPage; QHelpEngine *m_helpEngine; + CentralWidget *m_centralWidget; QFont font; QFontDatabase fontDatabase; diff --git a/src/plugins/help/generalsettingspage.ui b/src/plugins/help/generalsettingspage.ui index fa50fdc18f8a921833636833eef05c532d17fb1f..abf3a2336e357a7c47179c7ce2c92c056eb007d9 100644 --- a/src/plugins/help/generalsettingspage.ui +++ b/src/plugins/help/generalsettingspage.ui @@ -133,7 +133,7 @@ <item> <widget class="QGroupBox" name="groupBox_2"> <property name="enabled"> - <bool>false</bool> + <bool>true</bool> </property> <property name="title"> <string>Startup</string> @@ -155,7 +155,7 @@ </widget> </item> <item> - <widget class="QComboBox" name="comboBox"> + <widget class="QComboBox" name="helpStartComboBox"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> @@ -209,7 +209,7 @@ </layout> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> + <layout class="QHBoxLayout" name="horizontalLayout"> <item> <spacer name="horizontalSpacer"> <property name="orientation"> @@ -224,22 +224,25 @@ </spacer> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="currentPageButton"> - <property name="text"> - <string>Current Page</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="restoreDefaultHomePageButton"> - <property name="text"> - <string>Restore to default</string> - </property> - </widget> - </item> - </layout> + <widget class="QPushButton" name="currentPageButton"> + <property name="text"> + <string>Use &Current Page</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="blankPageButton"> + <property name="text"> + <string>Use &Blank Page</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="defaultPageButton"> + <property name="text"> + <string>Restore to Default</string> + </property> + </widget> </item> </layout> </item> diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index 8b31a468b7dac3223151d28e0ad5bbfb7682c186..482edff4ceab6b795e78783d4ed954ae81fe4bb8 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -188,10 +188,6 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error) connect(m_docSettingsPage, SIGNAL(dialogAccepted()), this, SLOT(checkForHelpChanges())); - GeneralSettingsPage *generalSettings = new GeneralSettingsPage(m_helpEngine); - addAutoReleasedObject(generalSettings); - connect(generalSettings, SIGNAL(fontChanged()), this, SLOT(fontChanged())); - m_contentWidget = new ContentWindow(m_helpEngine); m_contentWidget->setWindowTitle(tr("Contents")); m_indexWidget = new IndexWindow(m_helpEngine); @@ -421,6 +417,11 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error) advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT); } + GeneralSettingsPage *generalSettings = + new GeneralSettingsPage(m_helpEngine, m_centralWidget); + addAutoReleasedObject(generalSettings); + connect(generalSettings, SIGNAL(fontChanged()), this, SLOT(fontChanged())); + return true; } @@ -628,6 +629,14 @@ void HelpPlugin::extensionsInitialized() webSettings->setFontFamily(QWebSettings::StandardFont, font.family()); webSettings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize()); #endif + + QUrl url = m_helpEngine->findFile(QString::fromLatin1("qthelp://com." + "trolltech.qt.440/qdoc/index.html")); + if (!url.isValid()) { + url.setUrl(QString::fromLatin1("qthelp://com.nokia.qtcreator.%1%2/doc/" + "index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)); + } + m_helpEngine->setCustomValue(QLatin1String("DefaultHomePage"), url.toString()); } void HelpPlugin::shutdown() diff --git a/src/shared/help/helpviewer.cpp b/src/shared/help/helpviewer.cpp index 45caae8e53014395b87285b8963109d5d358f41f..5d0a43166d5fea5cfd74e2a50bd5a38e5ef4f889 100644 --- a/src/shared/help/helpviewer.cpp +++ b/src/shared/help/helpviewer.cpp @@ -295,8 +295,15 @@ int HelpViewer::zoom() const void HelpViewer::home() { - if (homeUrl.isValid()) - setSource(homeUrl); + QString homepage = helpEngine->customValue(QLatin1String("HomePage"), + QLatin1String("")).toString(); + + if (homepage.isEmpty()) { + homepage = helpEngine->customValue(QLatin1String("DefaultHomePage"), + QLatin1String("about:blank")).toString(); + } + + setSource(homepage); } void HelpViewer::wheelEvent(QWheelEvent *e) @@ -552,8 +559,15 @@ void HelpViewer::keyPressEvent(QKeyEvent *e) void HelpViewer::home() { - if (homeUrl.isValid()) - setSource(homeUrl); + QString homepage = helpEngine->customValue(QLatin1String("HomePage"), + QLatin1String("")).toString(); + + if (homepage.isEmpty()) { + homepage = helpEngine->customValue(QLatin1String("DefaultHomePage"), + QLatin1String("about:blank")).toString(); + } + + setSource(homepage); } void HelpViewer::wheelEvent(QWheelEvent *e)