Skip to content
Snippets Groups Projects
Commit c859a721 authored by kh1's avatar kh1
Browse files

Some cleanup, no intended functional change.

parent 23b4fab5
No related branches found
No related tags found
No related merge requests found
...@@ -144,12 +144,12 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error) ...@@ -144,12 +144,12 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
QList<int> modecontext; QList<int> modecontext;
modecontext << m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_MODE_HELP); modecontext << m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_MODE_HELP);
QString locale = qApp->property("qtc_locale").toString(); const QString &locale = qApp->property("qtc_locale").toString();
if (!locale.isEmpty()) { if (!locale.isEmpty()) {
QTranslator *qtr = new QTranslator(this); QTranslator *qtr = new QTranslator(this);
QTranslator *qhelptr = new QTranslator(this); QTranslator *qhelptr = new QTranslator(this);
const QString &creatorTrPath = const QString &creatorTrPath = Core::ICore::instance()->resourcePath()
Core::ICore::instance()->resourcePath() + QLatin1String("/translations"); + QLatin1String("/translations");
const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
const QString &trFile = QLatin1String("assistant_") + locale; const QString &trFile = QLatin1String("assistant_") + locale;
const QString &helpTrFile = QLatin1String("qt_help_") + locale; const QString &helpTrFile = QLatin1String("qt_help_") + locale;
...@@ -802,43 +802,47 @@ void HelpPlugin::updateViewerComboBoxIndex(int index) ...@@ -802,43 +802,47 @@ void HelpPlugin::updateViewerComboBoxIndex(int index)
HelpViewer* HelpPlugin::viewerForContextMode() HelpViewer* HelpPlugin::viewerForContextMode()
{ {
HelpViewer *viewer = 0; using namespace Core;
bool showSideBySide = false;
Core::RightPanePlaceHolder* placeHolder = Core::RightPanePlaceHolder::current();
Core::IEditor *editor = Core::EditorManager::instance()->currentEditor();
switch (m_helpEngine->customValue(QLatin1String("ContextHelpOption"), 0).toInt()) bool showSideBySide = false;
{ RightPanePlaceHolder *placeHolder = RightPanePlaceHolder::current();
case 0: // side by side if possible switch (m_helpEngine->customValue(QLatin1String("ContextHelpOption"), 0).toInt()) {
{ case 0: {
if ((!placeHolder || !placeHolder->isVisible()) && editor) { // side by side if possible
if (!editor->widget() && editor->widget()->isVisible() && editor->widget()->width() < 800 ) if (IEditor *editor = EditorManager::instance()->currentEditor()) {
break; if (!placeHolder || !placeHolder->isVisible()) {
if (!editor->widget() && editor->widget()->isVisible()
&& editor->widget()->width() < 800) {
break;
}
}
} }
} } // fall through
// fall through case 1: {
case 1: // side by side // side by side
showSideBySide = true; showSideBySide = true;
break; } break;
default: // help mode
break; default: // help mode
break;
} }
HelpViewer *viewer = m_centralWidget->currentHelpViewer();
if (placeHolder && showSideBySide) { if (placeHolder && showSideBySide) {
Core::RightPaneWidget::instance()->setShown(true); RightPaneWidget::instance()->setShown(true);
viewer = m_helpViewerForSideBar; viewer = m_helpViewerForSideBar;
} else { } else {
if (!m_centralWidget->currentHelpViewer()) if (!viewer)
activateHelpMode(); activateHelpMode();
viewer = m_centralWidget->currentHelpViewer();
} }
return viewer; return viewer;
} }
void HelpPlugin::activateContext() void HelpPlugin::activateContext()
{ {
Core::RightPanePlaceHolder* placeHolder = Core::RightPanePlaceHolder::current(); using namespace Core;
RightPanePlaceHolder* placeHolder = RightPanePlaceHolder::current();
if (placeHolder && m_helpViewerForSideBar->hasFocus()) { if (placeHolder && m_helpViewerForSideBar->hasFocus()) {
switchToHelpMode(); switchToHelpMode();
return; return;
...@@ -849,7 +853,7 @@ void HelpPlugin::activateContext() ...@@ -849,7 +853,7 @@ void HelpPlugin::activateContext()
QMap<QString, QUrl> links; QMap<QString, QUrl> links;
// Find out what to show // Find out what to show
if (Core::IContext *context = m_core->currentContextObject()) { if (IContext *context = m_core->currentContextObject()) {
if (!m_contextHelpEngine) { if (!m_contextHelpEngine) {
m_contextHelpEngine = m_contextHelpEngine =
new QHelpEngineCore(m_helpEngine->collectionFile(), this); new QHelpEngineCore(m_helpEngine->collectionFile(), this);
...@@ -861,9 +865,7 @@ void HelpPlugin::activateContext() ...@@ -861,9 +865,7 @@ void HelpPlugin::activateContext()
links = m_contextHelpEngine->linksForIdentifier(id); links = m_contextHelpEngine->linksForIdentifier(id);
} }
HelpViewer* viewer = viewerForContextMode(); if (HelpViewer* viewer = viewerForContextMode()) {
if (viewer) {
if (links.isEmpty()) { if (links.isEmpty()) {
// No link found or no context object // No link found or no context object
viewer->setHtml(tr("<html><head><title>No Documentation</title>" viewer->setHtml(tr("<html><head><title>No Documentation</title>"
...@@ -871,7 +873,7 @@ void HelpPlugin::activateContext() ...@@ -871,7 +873,7 @@ void HelpPlugin::activateContext()
"available.</center></body></html>").arg(id)); "available.</center></body></html>").arg(id));
viewer->setSource(QUrl()); viewer->setSource(QUrl());
} else { } else {
QUrl source = *links.begin(); const QUrl &source = *links.begin();
if (viewer->source() != source) if (viewer->source() != source)
viewer->setSource(source); viewer->setSource(source);
viewer->setFocus(); viewer->setFocus();
...@@ -891,8 +893,9 @@ void HelpPlugin::activateContents() ...@@ -891,8 +893,9 @@ void HelpPlugin::activateContents()
{ {
activateHelpMode(); activateHelpMode();
m_sideBar->activateItem(m_contentItem); m_sideBar->activateItem(m_contentItem);
openHelpPage(QString::fromLatin1("qthelp://com.nokia.qtcreator.%1%2%3/doc/index.html") openHelpPage(QString::fromLatin1("qthelp://com.nokia.qtcreator.%1%2%3/doc/"
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE)); "index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)
.arg(IDE_VERSION_RELEASE));
} }
void HelpPlugin::activateSearch() void HelpPlugin::activateSearch()
...@@ -997,22 +1000,26 @@ void HelpPlugin::openHelpPage(const QString& url) ...@@ -997,22 +1000,26 @@ void HelpPlugin::openHelpPage(const QString& url)
// local help not installed, resort to external web help // local help not installed, resort to external web help
QString urlPrefix; QString urlPrefix;
if (url.startsWith(QLatin1String("qthelp://com.nokia.qtcreator"))) { if (url.startsWith(QLatin1String("qthelp://com.nokia.qtcreator"))) {
urlPrefix = QString::fromLatin1("http://doc.trolltech.com/qtcreator-%1.%2/") urlPrefix = QString::fromLatin1("http://doc.trolltech.com/qtcreator"
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR); "-%1.%2/").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR);
} else { } else {
urlPrefix = QLatin1String("http://doc.trolltech.com/latest/"); urlPrefix = QLatin1String("http://doc.trolltech.com/latest/");
} }
QDesktopServices::openUrl(urlPrefix + url.mid(url.lastIndexOf('/') + 1)); QDesktopServices::openUrl(urlPrefix + url.mid(url
.lastIndexOf(QLatin1Char('/')) + 1));
} }
} }
void HelpPlugin::openContextHelpPage(const QString &url) void HelpPlugin::openContextHelpPage(const QString &url)
{ {
using namespace Core::Constants;
Core::ModeManager *modeManager = Core::ICore::instance()->modeManager(); Core::ModeManager *modeManager = Core::ICore::instance()->modeManager();
if (modeManager->currentMode() == modeManager->mode(Core::Constants::MODE_WELCOME)) if (modeManager->currentMode() == modeManager->mode(MODE_WELCOME))
modeManager->activateMode(Core::Constants::MODE_EDIT); modeManager->activateMode(MODE_EDIT);
HelpViewer* viewer = viewerForContextMode();
viewer->setSource(QUrl(url)); if (HelpViewer* viewer = viewerForContextMode())
viewer->setSource(QUrl(url));
} }
Q_EXPORT_PLUGIN(HelpPlugin) Q_EXPORT_PLUGIN(HelpPlugin)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment