Commit 55fe83c2 authored by kh1's avatar kh1
Browse files

Make it possible to return editor mode if the last help page was closed.

parent 718433d2
......@@ -137,6 +137,11 @@ QWidget *GeneralSettingsPage::createPage(QWidget *parent)
<< ' ' << m_ui.bookmarkGroupBox->title();
m_searchKeywords.remove(QLatin1Char('&'));
}
m_returnOnClose = manager->customValue(QLatin1String("ReturnOnClose"),
false).toBool();
m_ui.m_returnOnClose->setChecked(m_returnOnClose);
return widget;
}
......@@ -195,6 +200,13 @@ void GeneralSettingsPage::apply()
emit contextHelpOptionChanged();
}
const bool close = m_ui.m_returnOnClose->isChecked();
if (m_returnOnClose != close) {
m_returnOnClose = close;
manager->setCustomValue(QLatin1String("ReturnOnClose"), close);
emit returnOnCloseChanged();
}
}
void GeneralSettingsPage::setCurrentPage()
......
......@@ -59,6 +59,7 @@ public:
signals:
void fontChanged();
void startOptionChanged();
void returnOnCloseChanged();
void contextHelpOptionChanged();
private slots:
......@@ -81,6 +82,8 @@ private:
QString m_homePage;
int m_contextOption;
bool m_returnOnClose;
QString m_searchKeywords;
Ui::GeneralSettingsPage m_ui;
};
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>498</width>
<height>304</height>
<width>491</width>
<height>360</height>
</rect>
</property>
<property name="windowTitle">
......@@ -356,6 +356,25 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="behaviourGroupBox">
<property name="title">
<string>Behaviour</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="m_returnOnClose">
<property name="toolTip">
<string>Switch to editor context after last help page is closed.</string>
</property>
<property name="text">
<string>Return to editor on close last page</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
......
......@@ -164,6 +164,8 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
SLOT(fontChanged()));
connect(m_generalSettingsPage, SIGNAL(contextHelpOptionChanged()), this,
SLOT(contextHelpOptionChanged()));
connect(m_generalSettingsPage, SIGNAL(returnOnCloseChanged()), this,
SLOT(updateCloseButton()));
connect(Core::HelpManager::instance(), SIGNAL(helpRequested(QUrl)), this,
SLOT(handleHelpRequest(QUrl)));
......@@ -670,7 +672,11 @@ void HelpPlugin::updateSideBarSource(const QUrl &newUrl)
void HelpPlugin::updateCloseButton()
{
m_closeButton->setEnabled(OpenPagesManager::instance().pageCount() > 1);
Core::HelpManager *manager = Core::HelpManager::instance();
const bool closeOnReturn = manager->customValue(QLatin1String("ReturnOnClose"),
false).toBool();
m_closeButton->setEnabled((OpenPagesManager::instance().pageCount() > 1)
| closeOnReturn);
}
void HelpPlugin::fontChanged()
......
......@@ -45,6 +45,10 @@
#include <QtHelp/QHelpEngine>
#include <coreplugin/coreconstants.h>
#include <coreplugin/helpmanager.h>
#include <coreplugin/modemanager.h>
using namespace Help::Internal;
OpenPagesManager *OpenPagesManager::m_instance = 0;
......@@ -226,11 +230,22 @@ void OpenPagesManager::closeCurrentPage()
{
if (!m_openPagesWidget)
return;
QModelIndexList indexes = m_openPagesWidget->selectionModel()->selectedRows();
if (indexes.isEmpty())
return;
Q_ASSERT(indexes.count() == 1);
removePage(indexes.first().row());
Core::HelpManager *manager = Core::HelpManager::instance();
const bool closeOnReturn = manager->customValue(QLatin1String("ReturnOnClose"),
false).toBool();
if (m_model->rowCount() == 1 && closeOnReturn) {
Core::ModeManager *modeManager = Core::ModeManager::instance();
modeManager->activateMode(Core::Constants::MODE_EDIT);
} else {
Q_ASSERT(indexes.count() == 1);
removePage(indexes.first().row());
}
}
void OpenPagesManager::closePage(const QModelIndex &index)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment