customize context help. The three modes are:

- show side-by-side if possible
 - always show side-by-side
 - always show full help

The default is "show side-by-side if possible". It's currently considered
possible if the editor is at least 800 pixels wide.
This commit is contained in:
mae
2009-07-14 13:20:26 +02:00
parent ca97bce8de
commit 35be3a3b02
3 changed files with 91 additions and 20 deletions

View File

@@ -110,6 +110,10 @@ QWidget *GeneralSettingsPage::createPage(QWidget *parent)
int index = m_helpEngine->customValue(QLatin1String("StartOption"), 2).toInt(); int index = m_helpEngine->customValue(QLatin1String("StartOption"), 2).toInt();
m_ui.helpStartComboBox->setCurrentIndex(index); m_ui.helpStartComboBox->setCurrentIndex(index);
index = m_helpEngine->customValue(QLatin1String("ContextHelpOption"), 0).toInt();
m_ui.contextHelpComboBox->setCurrentIndex(index);
connect(m_ui.currentPageButton, SIGNAL(clicked()), this, SLOT(setCurrentPage())); connect(m_ui.currentPageButton, SIGNAL(clicked()), this, SLOT(setCurrentPage()));
connect(m_ui.blankPageButton, SIGNAL(clicked()), this, SLOT(setBlankPage())); connect(m_ui.blankPageButton, SIGNAL(clicked()), this, SLOT(setBlankPage()));
@@ -165,6 +169,9 @@ void GeneralSettingsPage::apply()
int startOption = m_ui.helpStartComboBox->currentIndex(); int startOption = m_ui.helpStartComboBox->currentIndex();
m_helpEngine->setCustomValue(QLatin1String("StartOption"), startOption); m_helpEngine->setCustomValue(QLatin1String("StartOption"), startOption);
int contextHelpOption = m_ui.contextHelpComboBox->currentIndex();
m_helpEngine->setCustomValue(QLatin1String("ContextHelpOption"), contextHelpOption);
} }
void GeneralSettingsPage::finish() void GeneralSettingsPage::finish()

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>447</width> <width>593</width>
<height>300</height> <height>371</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -140,8 +140,59 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QGridLayout" name="gridLayout">
<item> <item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>On context help:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="contextHelpComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Show side-by-side if possible</string>
</property>
</item>
<item>
<property name="text">
<string>Always show side-by-side</string>
</property>
</item>
<item>
<property name="text">
<string>Always start full help</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@@ -154,7 +205,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="1">
<widget class="QComboBox" name="helpStartComboBox"> <widget class="QComboBox" name="helpStartComboBox">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@@ -179,19 +230,6 @@
</item> </item>
</widget> </widget>
</item> </item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@@ -53,6 +53,7 @@
#include <coreplugin/rightpane.h> #include <coreplugin/rightpane.h>
#include <coreplugin/sidebar.h> #include <coreplugin/sidebar.h>
#include <coreplugin/welcomemode.h> #include <coreplugin/welcomemode.h>
#include <coreplugin/editormanager/editormanager.h>
#include <texteditor/texteditorconstants.h> #include <texteditor/texteditorconstants.h>
@@ -732,12 +733,35 @@ void HelpPlugin::activateContext()
} }
HelpViewer *viewer = 0; HelpViewer *viewer = 0;
if (placeHolder && !Core::RightPaneWidget::instance()->hasFocus()) {
bool showSideBySide = false;
switch (m_helpEngine->customValue(QLatin1String("ContextHelpOption"), 0).toInt())
{
case 0: // side by side if possible
{
if (Core::IEditor *editor = Core::EditorManager::instance()->currentEditor()) {
if (editor->widget() && editor->widget()->isVisible() && editor->widget()->width() < 800 )
break;
}
}
// fall through
case 1: // side by side
showSideBySide = true;
break;
default: // help mode
break;
}
if (placeHolder && showSideBySide && !Core::RightPaneWidget::instance()->hasFocus()) {
Core::RightPaneWidget::instance()->setShown(true); Core::RightPaneWidget::instance()->setShown(true);
viewer = m_helpViewerForSideBar; viewer = m_helpViewerForSideBar;
} else { } else {
if (!m_centralWidget->currentHelpViewer())
activateHelpMode();
viewer = m_centralWidget->currentHelpViewer(); viewer = m_centralWidget->currentHelpViewer();
activateHelpMode();
} }
if (viewer) { if (viewer) {
@@ -753,6 +777,8 @@ void HelpPlugin::activateContext()
viewer->setSource(source); viewer->setSource(source);
viewer->setFocus(); viewer->setFocus();
} }
if (viewer != m_helpViewerForSideBar)
activateHelpMode();
} }
} }