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

This commit is contained in:
kh1
2010-09-21 17:00:41 +02:00
parent 718433d27e
commit 55fe83c291
5 changed files with 60 additions and 5 deletions

View File

@@ -137,6 +137,11 @@ QWidget *GeneralSettingsPage::createPage(QWidget *parent)
<< ' ' << m_ui.bookmarkGroupBox->title(); << ' ' << m_ui.bookmarkGroupBox->title();
m_searchKeywords.remove(QLatin1Char('&')); m_searchKeywords.remove(QLatin1Char('&'));
} }
m_returnOnClose = manager->customValue(QLatin1String("ReturnOnClose"),
false).toBool();
m_ui.m_returnOnClose->setChecked(m_returnOnClose);
return widget; return widget;
} }
@@ -195,6 +200,13 @@ void GeneralSettingsPage::apply()
emit contextHelpOptionChanged(); 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() void GeneralSettingsPage::setCurrentPage()

View File

@@ -59,6 +59,7 @@ public:
signals: signals:
void fontChanged(); void fontChanged();
void startOptionChanged(); void startOptionChanged();
void returnOnCloseChanged();
void contextHelpOptionChanged(); void contextHelpOptionChanged();
private slots: private slots:
@@ -81,6 +82,8 @@ private:
QString m_homePage; QString m_homePage;
int m_contextOption; int m_contextOption;
bool m_returnOnClose;
QString m_searchKeywords; QString m_searchKeywords;
Ui::GeneralSettingsPage m_ui; Ui::GeneralSettingsPage m_ui;
}; };

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>498</width> <width>491</width>
<height>304</height> <height>360</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -356,6 +356,25 @@
</layout> </layout>
</widget> </widget>
</item> </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> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">

View File

@@ -164,6 +164,8 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
SLOT(fontChanged())); SLOT(fontChanged()));
connect(m_generalSettingsPage, SIGNAL(contextHelpOptionChanged()), this, connect(m_generalSettingsPage, SIGNAL(contextHelpOptionChanged()), this,
SLOT(contextHelpOptionChanged())); SLOT(contextHelpOptionChanged()));
connect(m_generalSettingsPage, SIGNAL(returnOnCloseChanged()), this,
SLOT(updateCloseButton()));
connect(Core::HelpManager::instance(), SIGNAL(helpRequested(QUrl)), this, connect(Core::HelpManager::instance(), SIGNAL(helpRequested(QUrl)), this,
SLOT(handleHelpRequest(QUrl))); SLOT(handleHelpRequest(QUrl)));
@@ -670,7 +672,11 @@ void HelpPlugin::updateSideBarSource(const QUrl &newUrl)
void HelpPlugin::updateCloseButton() 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() void HelpPlugin::fontChanged()

View File

@@ -45,6 +45,10 @@
#include <QtHelp/QHelpEngine> #include <QtHelp/QHelpEngine>
#include <coreplugin/coreconstants.h>
#include <coreplugin/helpmanager.h>
#include <coreplugin/modemanager.h>
using namespace Help::Internal; using namespace Help::Internal;
OpenPagesManager *OpenPagesManager::m_instance = 0; OpenPagesManager *OpenPagesManager::m_instance = 0;
@@ -226,11 +230,22 @@ void OpenPagesManager::closeCurrentPage()
{ {
if (!m_openPagesWidget) if (!m_openPagesWidget)
return; return;
QModelIndexList indexes = m_openPagesWidget->selectionModel()->selectedRows(); QModelIndexList indexes = m_openPagesWidget->selectionModel()->selectedRows();
if (indexes.isEmpty()) if (indexes.isEmpty())
return; 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) void OpenPagesManager::closePage(const QModelIndex &index)