forked from qt-creator/qt-creator
Help: Remove the now duplicate side bar code for central widget
By adding the open pages widget to the shared help widget for the mode widget. Change-Id: Ib2d63134d1e17356a285ad048529c50e151a2354 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -97,7 +97,6 @@
|
|||||||
using namespace Help::Internal;
|
using namespace Help::Internal;
|
||||||
|
|
||||||
static const char kExternalWindowStateKey[] = "Help/ExternalWindowState";
|
static const char kExternalWindowStateKey[] = "Help/ExternalWindowState";
|
||||||
static const char kHelpModeSideBarKey[] = "Help/ModeSideBar";
|
|
||||||
|
|
||||||
#define IMAGEPATH ":/help/images/"
|
#define IMAGEPATH ":/help/images/"
|
||||||
|
|
||||||
@@ -107,7 +106,6 @@ HelpPlugin::HelpPlugin()
|
|||||||
: m_mode(0),
|
: m_mode(0),
|
||||||
m_centralWidget(0),
|
m_centralWidget(0),
|
||||||
m_rightPaneSideBarWidget(0),
|
m_rightPaneSideBarWidget(0),
|
||||||
m_sideBar(0),
|
|
||||||
m_setupNeeded(true),
|
m_setupNeeded(true),
|
||||||
m_helpManager(0),
|
m_helpManager(0),
|
||||||
m_openPagesManager(0)
|
m_openPagesManager(0)
|
||||||
@@ -116,10 +114,7 @@ HelpPlugin::HelpPlugin()
|
|||||||
|
|
||||||
HelpPlugin::~HelpPlugin()
|
HelpPlugin::~HelpPlugin()
|
||||||
{
|
{
|
||||||
delete m_centralWidget;
|
|
||||||
delete m_openPagesManager;
|
delete m_openPagesManager;
|
||||||
delete m_rightPaneSideBarWidget;
|
|
||||||
|
|
||||||
delete m_helpManager;
|
delete m_helpManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +171,6 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
connect(HelpManager::instance(), SIGNAL(setupFinished()), this,
|
connect(HelpManager::instance(), SIGNAL(setupFinished()), this,
|
||||||
SLOT(unregisterOldQtCreatorDocumentation()));
|
SLOT(unregisterOldQtCreatorDocumentation()));
|
||||||
|
|
||||||
m_splitter = new MiniSplitter;
|
|
||||||
Command *cmd;
|
Command *cmd;
|
||||||
QAction *action;
|
QAction *action;
|
||||||
|
|
||||||
@@ -227,8 +221,6 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
SLOT(gotoNextPage()));
|
SLOT(gotoNextPage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_splitter->addWidget(m_centralWidget);
|
|
||||||
|
|
||||||
HelpIndexFilter *helpIndexFilter = new HelpIndexFilter();
|
HelpIndexFilter *helpIndexFilter = new HelpIndexFilter();
|
||||||
addAutoReleasedObject(helpIndexFilter);
|
addAutoReleasedObject(helpIndexFilter);
|
||||||
connect(helpIndexFilter, SIGNAL(linkActivated(QUrl)), this,
|
connect(helpIndexFilter, SIGNAL(linkActivated(QUrl)), this,
|
||||||
@@ -244,7 +236,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
this, SLOT(modeChanged(Core::IMode*,Core::IMode*)));
|
this, SLOT(modeChanged(Core::IMode*,Core::IMode*)));
|
||||||
|
|
||||||
m_mode = new HelpMode;
|
m_mode = new HelpMode;
|
||||||
m_mode->setWidget(m_splitter);
|
m_mode->setWidget(m_centralWidget);
|
||||||
addAutoReleasedObject(m_mode);
|
addAutoReleasedObject(m_mode);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -260,9 +252,12 @@ void HelpPlugin::extensionsInitialized()
|
|||||||
|
|
||||||
ExtensionSystem::IPlugin::ShutdownFlag HelpPlugin::aboutToShutdown()
|
ExtensionSystem::IPlugin::ShutdownFlag HelpPlugin::aboutToShutdown()
|
||||||
{
|
{
|
||||||
if (m_sideBar)
|
if (m_externalWindow)
|
||||||
m_sideBar->saveSettings(ICore::settings(), QLatin1String(kHelpModeSideBarKey));
|
delete m_externalWindow.data();
|
||||||
|
if (m_centralWidget)
|
||||||
|
delete m_centralWidget;
|
||||||
|
if (m_rightPaneSideBarWidget)
|
||||||
|
delete m_rightPaneSideBarWidget;
|
||||||
return SynchronousShutdown;
|
return SynchronousShutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,97 +277,6 @@ void HelpPlugin::unregisterOldQtCreatorDocumentation()
|
|||||||
HelpManager::unregisterDocumentation(documentationToUnregister);
|
HelpManager::unregisterDocumentation(documentationToUnregister);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpPlugin::setupUi()
|
|
||||||
{
|
|
||||||
// side bar widgets and shortcuts
|
|
||||||
Context modecontext(Constants::C_MODE_HELP);
|
|
||||||
|
|
||||||
IndexWindow *indexWindow = new IndexWindow();
|
|
||||||
indexWindow->setWindowTitle(tr(Constants::SB_INDEX));
|
|
||||||
auto indexItem = new SideBarItem(indexWindow, QLatin1String(Constants::HELP_INDEX));
|
|
||||||
|
|
||||||
connect(indexWindow, &IndexWindow::linkActivated,
|
|
||||||
m_centralWidget, &HelpWidget::open);
|
|
||||||
connect(indexWindow, &IndexWindow::linksActivated,
|
|
||||||
m_centralWidget, &HelpWidget::showTopicChooser);
|
|
||||||
|
|
||||||
QMap<QString, Command*> shortcutMap;
|
|
||||||
QAction *action = new QAction(tr("Activate Help Index View"), m_splitter);
|
|
||||||
Command *cmd = ActionManager::registerAction(action, Constants::HELP_INDEX, modecontext);
|
|
||||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+I") : tr("Ctrl+Shift+I")));
|
|
||||||
connect(action, SIGNAL(triggered()), this, SLOT(activateIndex()));
|
|
||||||
shortcutMap.insert(QLatin1String(Constants::HELP_INDEX), cmd);
|
|
||||||
|
|
||||||
ContentWindow *contentWindow = new ContentWindow();
|
|
||||||
contentWindow->setWindowTitle(tr(Constants::SB_CONTENTS));
|
|
||||||
auto contentItem = new SideBarItem(contentWindow, QLatin1String(Constants::HELP_CONTENTS));
|
|
||||||
connect(contentWindow, &ContentWindow::linkActivated, m_centralWidget, &HelpWidget::open);
|
|
||||||
|
|
||||||
action = new QAction(tr("Activate Help Contents View"), m_splitter);
|
|
||||||
cmd = ActionManager::registerAction(action, Constants::HELP_CONTENTS, modecontext);
|
|
||||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+Shift+C") : tr("Ctrl+Shift+C")));
|
|
||||||
connect(action, SIGNAL(triggered()), this, SLOT(activateContents()));
|
|
||||||
shortcutMap.insert(QLatin1String(Constants::HELP_CONTENTS), cmd);
|
|
||||||
|
|
||||||
auto searchItem = new SearchSideBarItem;
|
|
||||||
connect(searchItem, &SearchSideBarItem::linkActivated,
|
|
||||||
m_centralWidget, &HelpWidget::openFromSearch);
|
|
||||||
|
|
||||||
action = new QAction(tr("Activate Help Search View"), m_splitter);
|
|
||||||
cmd = ActionManager::registerAction(action, Constants::HELP_SEARCH, modecontext);
|
|
||||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+/") : tr("Ctrl+Shift+/")));
|
|
||||||
connect(action, SIGNAL(triggered()), this, SLOT(activateSearch()));
|
|
||||||
shortcutMap.insert(searchItem->id(), cmd);
|
|
||||||
|
|
||||||
BookmarkManager *manager = &LocalHelpManager::bookmarkManager();
|
|
||||||
BookmarkWidget *bookmarkWidget = new BookmarkWidget(manager);
|
|
||||||
bookmarkWidget->setWindowTitle(tr(Constants::SB_BOOKMARKS));
|
|
||||||
auto bookmarkItem = new SideBarItem(bookmarkWidget, QLatin1String(Constants::HELP_BOOKMARKS));
|
|
||||||
connect(bookmarkWidget, SIGNAL(linkActivated(QUrl)), m_centralWidget,
|
|
||||||
SLOT(setSource(QUrl)));
|
|
||||||
connect(bookmarkWidget, SIGNAL(createPage(QUrl,bool)), &OpenPagesManager::instance(),
|
|
||||||
SLOT(createPage(QUrl,bool)));
|
|
||||||
|
|
||||||
action = new QAction(tr("Activate Help Bookmarks View"), m_splitter);
|
|
||||||
cmd = ActionManager::registerAction(action, Constants::HELP_BOOKMARKS, modecontext);
|
|
||||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+B") : tr("Ctrl+Shift+B")));
|
|
||||||
connect(action, SIGNAL(triggered()), this, SLOT(activateBookmarks()));
|
|
||||||
shortcutMap.insert(QLatin1String(Constants::HELP_BOOKMARKS), cmd);
|
|
||||||
|
|
||||||
QWidget *openPagesWidget = OpenPagesManager::instance().openPagesWidget();
|
|
||||||
openPagesWidget->setWindowTitle(tr(Constants::SB_OPENPAGES));
|
|
||||||
auto openPagesItem = new SideBarItem(openPagesWidget, QLatin1String(Constants::HELP_OPENPAGES));
|
|
||||||
|
|
||||||
action = new QAction(tr("Activate Open Help Pages View"), m_splitter);
|
|
||||||
cmd = ActionManager::registerAction(action, Constants::HELP_OPENPAGES, modecontext);
|
|
||||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+O") : tr("Ctrl+Shift+O")));
|
|
||||||
connect(action, SIGNAL(triggered()), this, SLOT(activateOpenPages()));
|
|
||||||
shortcutMap.insert(QLatin1String(Constants::HELP_OPENPAGES), cmd);
|
|
||||||
|
|
||||||
QList<SideBarItem*> itemList;
|
|
||||||
itemList << contentItem << indexItem << searchItem << bookmarkItem
|
|
||||||
<< openPagesItem;
|
|
||||||
m_sideBar = new SideBar(itemList, QList<SideBarItem*>()
|
|
||||||
<< contentItem << openPagesItem);
|
|
||||||
m_sideBar->setCloseWhenEmpty(true);
|
|
||||||
m_sideBar->setShortcutMap(shortcutMap);
|
|
||||||
connect(m_sideBar, SIGNAL(sideBarClosed()), this, SLOT(onSideBarVisibilityChanged()));
|
|
||||||
|
|
||||||
m_splitter->setOpaqueResize(false);
|
|
||||||
m_splitter->insertWidget(0, m_sideBar);
|
|
||||||
m_splitter->setStretchFactor(0, 0);
|
|
||||||
m_splitter->setStretchFactor(1, 1);
|
|
||||||
m_sideBar->readSettings(ICore::settings(), QLatin1String(kHelpModeSideBarKey));
|
|
||||||
m_splitter->setSizes(QList<int>() << m_sideBar->size().width() << 300);
|
|
||||||
|
|
||||||
m_toggleSideBarAction = new QAction(QIcon(QLatin1String(Core::Constants::ICON_TOGGLE_SIDEBAR)),
|
|
||||||
tr(Core::Constants::TR_SHOW_SIDEBAR), this);
|
|
||||||
m_toggleSideBarAction->setCheckable(true);
|
|
||||||
m_toggleSideBarAction->setChecked(m_sideBar->isVisibleTo(m_splitter));
|
|
||||||
connect(m_toggleSideBarAction, SIGNAL(triggered(bool)), this, SLOT(setSideBarVisible(bool)));
|
|
||||||
cmd = ActionManager::registerAction(m_toggleSideBarAction, Core::Constants::TOGGLE_SIDEBAR, modecontext);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpPlugin::resetFilter()
|
void HelpPlugin::resetFilter()
|
||||||
{
|
{
|
||||||
const QString &filterInternal = QString::fromLatin1("Qt Creator %1.%2.%3")
|
const QString &filterInternal = QString::fromLatin1("Qt Creator %1.%2.%3")
|
||||||
@@ -515,14 +419,6 @@ void HelpPlugin::slotHideRightPane()
|
|||||||
RightPaneWidget::instance()->setShown(false);
|
RightPaneWidget::instance()->setShown(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpPlugin::setSideBarVisible(bool visible)
|
|
||||||
{
|
|
||||||
if (visible == m_sideBar->isVisible())
|
|
||||||
return;
|
|
||||||
m_sideBar->setVisible(visible);
|
|
||||||
onSideBarVisibilityChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpPlugin::modeChanged(IMode *mode, IMode *old)
|
void HelpPlugin::modeChanged(IMode *mode, IMode *old)
|
||||||
{
|
{
|
||||||
Q_UNUSED(old)
|
Q_UNUSED(old)
|
||||||
@@ -688,31 +584,13 @@ void HelpPlugin::showContextHelp()
|
|||||||
void HelpPlugin::activateIndex()
|
void HelpPlugin::activateIndex()
|
||||||
{
|
{
|
||||||
activateHelpMode();
|
activateHelpMode();
|
||||||
m_sideBar->activateItem(QLatin1String(Constants::HELP_INDEX));
|
m_centralWidget->activateSideBarItem(QLatin1String(Constants::HELP_INDEX));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpPlugin::activateContents()
|
void HelpPlugin::activateContents()
|
||||||
{
|
{
|
||||||
activateHelpMode();
|
activateHelpMode();
|
||||||
m_sideBar->activateItem(QLatin1String(Constants::HELP_CONTENTS));
|
m_centralWidget->activateSideBarItem(QLatin1String(Constants::HELP_CONTENTS));
|
||||||
}
|
|
||||||
|
|
||||||
void HelpPlugin::activateSearch()
|
|
||||||
{
|
|
||||||
activateHelpMode();
|
|
||||||
m_sideBar->activateItem(QLatin1String(Constants::HELP_SEARCH));
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpPlugin::activateOpenPages()
|
|
||||||
{
|
|
||||||
activateHelpMode();
|
|
||||||
m_sideBar->activateItem(QLatin1String(Constants::HELP_OPENPAGES));
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpPlugin::activateBookmarks()
|
|
||||||
{
|
|
||||||
activateHelpMode();
|
|
||||||
m_sideBar->activateItem(QLatin1String(Constants::HELP_BOOKMARKS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpPlugin::highlightSearchTermsInContextHelp()
|
void HelpPlugin::highlightSearchTermsInContextHelp()
|
||||||
@@ -762,20 +640,11 @@ void HelpPlugin::slotReportBug()
|
|||||||
QDesktopServices::openUrl(QUrl(QLatin1String("https://bugreports.qt-project.org")));
|
QDesktopServices::openUrl(QUrl(QLatin1String("https://bugreports.qt-project.org")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpPlugin::onSideBarVisibilityChanged()
|
|
||||||
{
|
|
||||||
bool visible = m_sideBar->isVisibleTo(m_splitter);
|
|
||||||
m_toggleSideBarAction->setChecked(visible);
|
|
||||||
m_toggleSideBarAction->setToolTip(visible ? tr(Core::Constants::TR_HIDE_SIDEBAR)
|
|
||||||
: tr(Core::Constants::TR_SHOW_SIDEBAR));
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpPlugin::doSetupIfNeeded()
|
void HelpPlugin::doSetupIfNeeded()
|
||||||
{
|
{
|
||||||
m_helpManager->setupGuiHelpEngine();
|
m_helpManager->setupGuiHelpEngine();
|
||||||
if (m_setupNeeded) {
|
if (m_setupNeeded) {
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
setupUi();
|
|
||||||
resetFilter();
|
resetFilter();
|
||||||
m_setupNeeded = false;
|
m_setupNeeded = false;
|
||||||
OpenPagesManager::instance().setupInitialPages();
|
OpenPagesManager::instance().setupInitialPages();
|
||||||
|
|||||||
@@ -92,14 +92,10 @@ private slots:
|
|||||||
void showContextHelp();
|
void showContextHelp();
|
||||||
void activateIndex();
|
void activateIndex();
|
||||||
void activateContents();
|
void activateContents();
|
||||||
void activateSearch();
|
|
||||||
void activateOpenPages();
|
|
||||||
void activateBookmarks();
|
|
||||||
|
|
||||||
void saveExternalWindowSettings();
|
void saveExternalWindowSettings();
|
||||||
void switchToHelpMode(const QUrl &source);
|
void switchToHelpMode(const QUrl &source);
|
||||||
void slotHideRightPane();
|
void slotHideRightPane();
|
||||||
void setSideBarVisible(bool visible);
|
|
||||||
|
|
||||||
void updateSideBarSource();
|
void updateSideBarSource();
|
||||||
void updateSideBarSource(const QUrl &newUrl);
|
void updateSideBarSource(const QUrl &newUrl);
|
||||||
@@ -114,10 +110,7 @@ private slots:
|
|||||||
void slotOpenSupportPage();
|
void slotOpenSupportPage();
|
||||||
void slotReportBug();
|
void slotReportBug();
|
||||||
|
|
||||||
void onSideBarVisibilityChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupUi();
|
|
||||||
void resetFilter();
|
void resetFilter();
|
||||||
void activateHelpMode();
|
void activateHelpMode();
|
||||||
bool canShowHelpSideBySide() const;
|
bool canShowHelpSideBySide() const;
|
||||||
@@ -140,19 +133,14 @@ private:
|
|||||||
GeneralSettingsPage *m_generalSettingsPage;
|
GeneralSettingsPage *m_generalSettingsPage;
|
||||||
SearchTaskHandler *m_searchTaskHandler;
|
SearchTaskHandler *m_searchTaskHandler;
|
||||||
|
|
||||||
Core::SideBar *m_sideBar;
|
|
||||||
|
|
||||||
bool m_setupNeeded;
|
bool m_setupNeeded;
|
||||||
LocalHelpManager *m_helpManager;
|
LocalHelpManager *m_helpManager;
|
||||||
OpenPagesManager *m_openPagesManager;
|
OpenPagesManager *m_openPagesManager;
|
||||||
Core::MiniSplitter *m_splitter;
|
|
||||||
|
|
||||||
QString m_contextHelpHighlightId;
|
QString m_contextHelpHighlightId;
|
||||||
|
|
||||||
QPointer<HelpWidget> m_externalWindow;
|
QPointer<HelpWidget> m_externalWindow;
|
||||||
QRect m_externalWindowState;
|
QRect m_externalWindowState;
|
||||||
|
|
||||||
QAction *m_toggleSideBarAction;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -63,7 +63,8 @@
|
|||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
static const char kSideBarSettingsKey[] = "Help/WindowSideBar";
|
static const char kWindowSideBarSettingsKey[] = "Help/WindowSideBar";
|
||||||
|
static const char kModeSideBarSettingsKey[] = "Help/ModeSideBar";
|
||||||
|
|
||||||
namespace Help {
|
namespace Help {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -80,7 +81,11 @@ HelpWidget::HelpWidget(const Core::Context &context, WidgetStyle style, QWidget
|
|||||||
m_resetScale(0),
|
m_resetScale(0),
|
||||||
m_printer(0),
|
m_printer(0),
|
||||||
m_sideBar(0),
|
m_sideBar(0),
|
||||||
m_indexAction(0)
|
m_contentsAction(0),
|
||||||
|
m_indexAction(0),
|
||||||
|
m_bookmarkAction(0),
|
||||||
|
m_searchAction(0),
|
||||||
|
m_openPagesAction(0)
|
||||||
{
|
{
|
||||||
m_viewerStack = new QStackedWidget;
|
m_viewerStack = new QStackedWidget;
|
||||||
|
|
||||||
@@ -123,7 +128,8 @@ HelpWidget::HelpWidget(const Core::Context &context, WidgetStyle style, QWidget
|
|||||||
Core::Context(Core::Id("Help.Window.").withSuffix(++windowId)));
|
Core::Context(Core::Id("Help.Window.").withSuffix(++windowId)));
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
setAttribute(Qt::WA_QuitOnClose, false); // don't prevent Qt Creator from closing
|
setAttribute(Qt::WA_QuitOnClose, false); // don't prevent Qt Creator from closing
|
||||||
|
}
|
||||||
|
if (style != SideBarWidget) {
|
||||||
m_toggleSideBarAction = new QAction(QIcon(QLatin1String(Core::Constants::ICON_TOGGLE_SIDEBAR)),
|
m_toggleSideBarAction = new QAction(QIcon(QLatin1String(Core::Constants::ICON_TOGGLE_SIDEBAR)),
|
||||||
tr(Core::Constants::TR_SHOW_SIDEBAR), toolBar);
|
tr(Core::Constants::TR_SHOW_SIDEBAR), toolBar);
|
||||||
m_toggleSideBarAction->setCheckable(true);
|
m_toggleSideBarAction->setCheckable(true);
|
||||||
@@ -136,12 +142,14 @@ HelpWidget::HelpWidget(const Core::Context &context, WidgetStyle style, QWidget
|
|||||||
: tr(Core::Constants::TR_SHOW_SIDEBAR));
|
: tr(Core::Constants::TR_SHOW_SIDEBAR));
|
||||||
});
|
});
|
||||||
addSideBar();
|
addSideBar();
|
||||||
|
m_toggleSideBarAction->setChecked(m_sideBar->isVisibleTo(this));
|
||||||
connect(m_toggleSideBarAction, &QAction::triggered, m_sideBar, &Core::SideBar::setVisible);
|
connect(m_toggleSideBarAction, &QAction::triggered, m_sideBar, &Core::SideBar::setVisible);
|
||||||
connect(m_sideBar, &Core::SideBar::sideBarClosed, m_toggleSideBarAction, [this]() {
|
connect(m_sideBar, &Core::SideBar::sideBarClosed, m_toggleSideBarAction, [this]() {
|
||||||
m_toggleSideBarAction->setChecked(false);
|
m_toggleSideBarAction->setChecked(false);
|
||||||
});
|
});
|
||||||
layout->addWidget(Core::Command::toolButtonWithAppendedShortcut(m_toggleSideBarAction, cmd));
|
|
||||||
}
|
}
|
||||||
|
if (style == ExternalWindow)
|
||||||
|
layout->addWidget(Core::Command::toolButtonWithAppendedShortcut(m_toggleSideBarAction, cmd));
|
||||||
|
|
||||||
if (style != ModeWidget) {
|
if (style != ModeWidget) {
|
||||||
m_switchToHelp = new QAction(tr("Go to Help Mode"), toolBar);
|
m_switchToHelp = new QAction(tr("Go to Help Mode"), toolBar);
|
||||||
@@ -258,11 +266,13 @@ HelpWidget::HelpWidget(const Core::Context &context, WidgetStyle style, QWidget
|
|||||||
HelpWidget::~HelpWidget()
|
HelpWidget::~HelpWidget()
|
||||||
{
|
{
|
||||||
if (m_sideBar) {
|
if (m_sideBar) {
|
||||||
m_sideBar->saveSettings(Core::ICore::settings(), QLatin1String(kSideBarSettingsKey));
|
m_sideBar->saveSettings(Core::ICore::settings(), sideBarSettingsKey());
|
||||||
Core::ActionManager::unregisterAction(m_contentsAction, Constants::HELP_CONTENTS);
|
Core::ActionManager::unregisterAction(m_contentsAction, Constants::HELP_CONTENTS);
|
||||||
Core::ActionManager::unregisterAction(m_indexAction, Constants::HELP_INDEX);
|
Core::ActionManager::unregisterAction(m_indexAction, Constants::HELP_INDEX);
|
||||||
Core::ActionManager::unregisterAction(m_bookmarkAction, Constants::HELP_BOOKMARKS);
|
Core::ActionManager::unregisterAction(m_bookmarkAction, Constants::HELP_BOOKMARKS);
|
||||||
Core::ActionManager::unregisterAction(m_searchAction, Constants::HELP_SEARCH);
|
Core::ActionManager::unregisterAction(m_searchAction, Constants::HELP_SEARCH);
|
||||||
|
if (m_openPagesAction)
|
||||||
|
Core::ActionManager::unregisterAction(m_openPagesAction, Constants::HELP_OPENPAGES);
|
||||||
}
|
}
|
||||||
Core::ICore::removeContextObject(m_context);
|
Core::ICore::removeContextObject(m_context);
|
||||||
Core::ActionManager::unregisterAction(m_copy, Core::Constants::COPY);
|
Core::ActionManager::unregisterAction(m_copy, Core::Constants::COPY);
|
||||||
@@ -287,14 +297,15 @@ void HelpWidget::addSideBar()
|
|||||||
{
|
{
|
||||||
QMap<QString, Core::Command *> shortcutMap;
|
QMap<QString, Core::Command *> shortcutMap;
|
||||||
Core::Command *cmd;
|
Core::Command *cmd;
|
||||||
|
bool supportsNewPages = (m_style == ModeWidget);
|
||||||
|
|
||||||
auto contentWindow = new ContentWindow;
|
auto contentWindow = new ContentWindow;
|
||||||
auto contentItem = new Core::SideBarItem(contentWindow, QLatin1String(Constants::HELP_CONTENTS));
|
auto contentItem = new Core::SideBarItem(contentWindow, QLatin1String(Constants::HELP_CONTENTS));
|
||||||
contentWindow->setOpenInNewPageActionVisible(false);
|
contentWindow->setOpenInNewPageActionVisible(supportsNewPages);
|
||||||
contentWindow->setWindowTitle(tr(Constants::SB_CONTENTS));
|
contentWindow->setWindowTitle(tr(Constants::SB_CONTENTS));
|
||||||
connect(contentWindow, &ContentWindow::linkActivated,
|
connect(contentWindow, &ContentWindow::linkActivated,
|
||||||
this, &HelpWidget::open);
|
this, &HelpWidget::open);
|
||||||
m_contentsAction = new QAction(tr("Activate Help Contents View"), this);
|
m_contentsAction = new QAction(tr(Constants::SB_CONTENTS), this);
|
||||||
cmd = Core::ActionManager::registerAction(m_contentsAction, Constants::HELP_CONTENTS, m_context->context());
|
cmd = Core::ActionManager::registerAction(m_contentsAction, Constants::HELP_CONTENTS, m_context->context());
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Shift+C")
|
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Shift+C")
|
||||||
: tr("Ctrl+Shift+C")));
|
: tr("Ctrl+Shift+C")));
|
||||||
@@ -302,13 +313,13 @@ void HelpWidget::addSideBar()
|
|||||||
|
|
||||||
auto indexWindow = new IndexWindow();
|
auto indexWindow = new IndexWindow();
|
||||||
auto indexItem = new Core::SideBarItem(indexWindow, QLatin1String(Constants::HELP_INDEX));
|
auto indexItem = new Core::SideBarItem(indexWindow, QLatin1String(Constants::HELP_INDEX));
|
||||||
indexWindow->setOpenInNewPageActionVisible(false);
|
indexWindow->setOpenInNewPageActionVisible(supportsNewPages);
|
||||||
indexWindow->setWindowTitle(tr(Constants::SB_INDEX));
|
indexWindow->setWindowTitle(tr(Constants::SB_INDEX));
|
||||||
connect(indexWindow, &IndexWindow::linkActivated,
|
connect(indexWindow, &IndexWindow::linkActivated,
|
||||||
this, &HelpWidget::open);
|
this, &HelpWidget::open);
|
||||||
connect(indexWindow, &IndexWindow::linksActivated,
|
connect(indexWindow, &IndexWindow::linksActivated,
|
||||||
this, &HelpWidget::showTopicChooser);
|
this, &HelpWidget::showTopicChooser);
|
||||||
m_indexAction = new QAction(tr("Activate Help Index View"), this);
|
m_indexAction = new QAction(tr(Constants::SB_INDEX), this);
|
||||||
cmd = Core::ActionManager::registerAction(m_indexAction, Constants::HELP_INDEX, m_context->context());
|
cmd = Core::ActionManager::registerAction(m_indexAction, Constants::HELP_INDEX, m_context->context());
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+I")
|
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+I")
|
||||||
: tr("Ctrl+Shift+I")));
|
: tr("Ctrl+Shift+I")));
|
||||||
@@ -316,7 +327,7 @@ void HelpWidget::addSideBar()
|
|||||||
|
|
||||||
auto bookmarkWidget = new BookmarkWidget(&LocalHelpManager::bookmarkManager());
|
auto bookmarkWidget = new BookmarkWidget(&LocalHelpManager::bookmarkManager());
|
||||||
bookmarkWidget->setWindowTitle(tr(Constants::SB_BOOKMARKS));
|
bookmarkWidget->setWindowTitle(tr(Constants::SB_BOOKMARKS));
|
||||||
bookmarkWidget->setOpenInNewPageActionVisible(false);
|
bookmarkWidget->setOpenInNewPageActionVisible(supportsNewPages);
|
||||||
auto bookmarkItem = new Core::SideBarItem(bookmarkWidget,
|
auto bookmarkItem = new Core::SideBarItem(bookmarkWidget,
|
||||||
QLatin1String(Constants::HELP_BOOKMARKS));
|
QLatin1String(Constants::HELP_BOOKMARKS));
|
||||||
connect(bookmarkWidget, &BookmarkWidget::linkActivated, this, &HelpWidget::setSource);
|
connect(bookmarkWidget, &BookmarkWidget::linkActivated, this, &HelpWidget::setSource);
|
||||||
@@ -336,10 +347,27 @@ void HelpWidget::addSideBar()
|
|||||||
: tr("Ctrl+Shift+/")));
|
: tr("Ctrl+Shift+/")));
|
||||||
shortcutMap.insert(QLatin1String(Constants::HELP_SEARCH), cmd);
|
shortcutMap.insert(QLatin1String(Constants::HELP_SEARCH), cmd);
|
||||||
|
|
||||||
|
Core::SideBarItem *openPagesItem = 0;
|
||||||
|
if (m_style == ModeWidget) {
|
||||||
|
QWidget *openPagesWidget = OpenPagesManager::instance().openPagesWidget();
|
||||||
|
openPagesWidget->setWindowTitle(tr(Constants::SB_OPENPAGES));
|
||||||
|
openPagesItem = new Core::SideBarItem(openPagesWidget,
|
||||||
|
QLatin1String(Constants::HELP_OPENPAGES));
|
||||||
|
m_openPagesAction = new QAction(tr("Activate Open Help Pages View"), this);
|
||||||
|
cmd = Core::ActionManager::registerAction(m_openPagesAction, Constants::HELP_OPENPAGES,
|
||||||
|
m_context->context());
|
||||||
|
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+O")
|
||||||
|
: tr("Ctrl+Shift+O")));
|
||||||
|
shortcutMap.insert(QLatin1String(Constants::HELP_OPENPAGES), cmd);
|
||||||
|
}
|
||||||
|
|
||||||
QList<Core::SideBarItem *> itemList;
|
QList<Core::SideBarItem *> itemList;
|
||||||
itemList << contentItem << indexItem << bookmarkItem << searchItem;
|
itemList << contentItem << indexItem << bookmarkItem << searchItem;
|
||||||
|
if (openPagesItem)
|
||||||
|
itemList << openPagesItem;
|
||||||
m_sideBar = new Core::SideBar(itemList,
|
m_sideBar = new Core::SideBar(itemList,
|
||||||
QList<Core::SideBarItem *>() << contentItem << indexItem);
|
QList<Core::SideBarItem *>() << contentItem
|
||||||
|
<< (openPagesItem ? openPagesItem : indexItem));
|
||||||
m_sideBar->setShortcutMap(shortcutMap);
|
m_sideBar->setShortcutMap(shortcutMap);
|
||||||
m_sideBar->setCloseWhenEmpty(true);
|
m_sideBar->setCloseWhenEmpty(true);
|
||||||
m_sideBarSplitter->insertWidget(0, m_sideBar);
|
m_sideBarSplitter->insertWidget(0, m_sideBar);
|
||||||
@@ -347,9 +375,8 @@ void HelpWidget::addSideBar()
|
|||||||
m_sideBarSplitter->setStretchFactor(1, 1);
|
m_sideBarSplitter->setStretchFactor(1, 1);
|
||||||
m_sideBar->setVisible(false);
|
m_sideBar->setVisible(false);
|
||||||
m_sideBar->resize(250, size().height());
|
m_sideBar->resize(250, size().height());
|
||||||
m_sideBar->readSettings(Core::ICore::settings(), QLatin1String(kSideBarSettingsKey));
|
m_sideBar->readSettings(Core::ICore::settings(), sideBarSettingsKey());
|
||||||
m_sideBarSplitter->setSizes(QList<int>() << m_sideBar->size().width() << 300);
|
m_sideBarSplitter->setSizes(QList<int>() << m_sideBar->size().width() << 300);
|
||||||
m_toggleSideBarAction->setChecked(m_sideBar->isVisibleTo(this));
|
|
||||||
|
|
||||||
connect(m_indexAction, &QAction::triggered, m_sideBar, [this]() {
|
connect(m_indexAction, &QAction::triggered, m_sideBar, [this]() {
|
||||||
m_sideBar->activateItem(QLatin1String(Constants::HELP_INDEX));
|
m_sideBar->activateItem(QLatin1String(Constants::HELP_INDEX));
|
||||||
@@ -360,6 +387,25 @@ void HelpWidget::addSideBar()
|
|||||||
connect(m_searchAction, &QAction::triggered, m_sideBar, [this]() {
|
connect(m_searchAction, &QAction::triggered, m_sideBar, [this]() {
|
||||||
m_sideBar->activateItem(QLatin1String(Constants::HELP_SEARCH));
|
m_sideBar->activateItem(QLatin1String(Constants::HELP_SEARCH));
|
||||||
});
|
});
|
||||||
|
if (m_openPagesAction) {
|
||||||
|
connect(m_openPagesAction, &QAction::triggered, m_sideBar, [this]() {
|
||||||
|
m_sideBar->activateItem(QLatin1String(Constants::HELP_OPENPAGES));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString HelpWidget::sideBarSettingsKey() const
|
||||||
|
{
|
||||||
|
switch (m_style) {
|
||||||
|
case ModeWidget:
|
||||||
|
return QLatin1String(kModeSideBarSettingsKey);
|
||||||
|
case ExternalWindow:
|
||||||
|
return QLatin1String(kWindowSideBarSettingsKey);
|
||||||
|
case SideBarWidget:
|
||||||
|
QTC_CHECK(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
HelpViewer *HelpWidget::currentViewer() const
|
HelpViewer *HelpWidget::currentViewer() const
|
||||||
@@ -459,6 +505,12 @@ void HelpWidget::showTopicChooser(const QMap<QString, QUrl> &links,
|
|||||||
open(tc.link(), newPage);
|
open(tc.link(), newPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HelpWidget::activateSideBarItem(const QString &id)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(m_sideBar, return);
|
||||||
|
m_sideBar->activateItem(id);
|
||||||
|
}
|
||||||
|
|
||||||
void HelpWidget::setSource(const QUrl &url)
|
void HelpWidget::setSource(const QUrl &url)
|
||||||
{
|
{
|
||||||
HelpViewer* viewer = currentViewer();
|
HelpViewer* viewer = currentViewer();
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ public:
|
|||||||
void openFromSearch(const QUrl &url, bool newPage = false);
|
void openFromSearch(const QUrl &url, bool newPage = false);
|
||||||
void showTopicChooser(const QMap<QString, QUrl> &links, const QString &key,
|
void showTopicChooser(const QMap<QString, QUrl> &links, const QString &key,
|
||||||
bool newPage = false);
|
bool newPage = false);
|
||||||
|
void activateSideBarItem(const QString &id);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setSource(const QUrl &url);
|
void setSource(const QUrl &url);
|
||||||
@@ -117,6 +118,7 @@ private:
|
|||||||
void print(HelpViewer *viewer);
|
void print(HelpViewer *viewer);
|
||||||
void highlightSearchTerms();
|
void highlightSearchTerms();
|
||||||
void addSideBar();
|
void addSideBar();
|
||||||
|
QString sideBarSettingsKey() const;
|
||||||
|
|
||||||
Core::IContext *m_context;
|
Core::IContext *m_context;
|
||||||
WidgetStyle m_style;
|
WidgetStyle m_style;
|
||||||
@@ -145,6 +147,7 @@ private:
|
|||||||
QAction *m_indexAction;
|
QAction *m_indexAction;
|
||||||
QAction *m_bookmarkAction;
|
QAction *m_bookmarkAction;
|
||||||
QAction *m_searchAction;
|
QAction *m_searchAction;
|
||||||
|
QAction *m_openPagesAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user