From da84000313c1041add2714cbb9f50d19e6a376b5 Mon Sep 17 00:00:00 2001
From: kh1 <qt-info@nokia.com>
Date: Tue, 16 Nov 2010 14:16:48 +0100
Subject: [PATCH] Cannot reset font size for help when shown in side pane.

Task-number: QTCREATORBUG-2924
Reviewed-by: ck
---
 src/plugins/help/helpplugin.cpp | 60 ++++++++++++++++++++++++---------
 src/plugins/help/helpplugin.h   |  4 +++
 2 files changed, 48 insertions(+), 16 deletions(-)

diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp
index b51cb16f68a..07301309ef7 100644
--- a/src/plugins/help/helpplugin.cpp
+++ b/src/plugins/help/helpplugin.cpp
@@ -267,23 +267,18 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
         action = new QAction(tr("Increase Font Size"), this);
         cmd = am->registerAction(action, TextEditor::Constants::INCREASE_FONT_SIZE,
             modecontext);
-        cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl++")));
         connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(zoomIn()));
         advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
 
         action = new QAction(tr("Decrease Font Size"), this);
         cmd = am->registerAction(action, TextEditor::Constants::DECREASE_FONT_SIZE,
             modecontext);
-        cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+-")));
         connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(zoomOut()));
         advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
 
         action = new QAction(tr("Reset Font Size"), this);
         cmd = am->registerAction(action, TextEditor::Constants::RESET_FONT_SIZE,
             modecontext);
-#ifndef Q_WS_MAC
-        cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+0")));
-#endif
         connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(resetZoom()));
         advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
     }
@@ -305,14 +300,6 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
         windowMenu->addAction(ctrlShiftTab, Core::Constants::G_WINDOW_NAVIGATE);
         connect(action, SIGNAL(triggered()), &OpenPagesManager::instance(),
             SLOT(gotoNextPage()));
-
-#ifdef Q_WS_MAC
-        ctrlTab->setDefaultKeySequence(QKeySequence(tr("Alt+Tab")));
-        ctrlShiftTab->setDefaultKeySequence(QKeySequence(tr("Alt+Shift+Tab")));
-#else
-        ctrlTab->setDefaultKeySequence(QKeySequence(tr("Ctrl+Tab")));
-        ctrlShiftTab->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Tab")));
-#endif
     }
 
     Aggregation::Aggregate *agg = new Aggregation::Aggregate;
@@ -583,15 +570,16 @@ void HelpPlugin::createRightPaneContextViewer()
     Aggregation::Aggregate *agg = new Aggregation::Aggregate();
     agg->add(m_helpViewerForSideBar);
     agg->add(new HelpViewerFindSupport(m_helpViewerForSideBar));
+
+    Core::Context context(Constants::C_HELP_SIDEBAR);
     m_core->addContextObject(new Core::BaseContext(m_helpViewerForSideBar,
-        Core::Context(Constants::C_HELP_SIDEBAR), this));
+        context, this));
 
     QAction *copy = new QAction(this);
     Core::Command *cmd = m_core->actionManager()->registerAction(copy,
-        Core::Constants::COPY, Core::Context(Constants::C_HELP_SIDEBAR));
+        Core::Constants::COPY, context);
     copy->setText(cmd->action()->text());
     copy->setIcon(cmd->action()->icon());
-
     connect(copy, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(copy()));
 
     next->setEnabled(m_helpViewerForSideBar->isForwardAvailable());
@@ -604,11 +592,51 @@ void HelpPlugin::createRightPaneContextViewer()
     connect(m_helpViewerForSideBar, SIGNAL(backwardAvailable(bool)), back,
         SLOT(setEnabled(bool)));
 
+    Core::ActionManager *am = m_core->actionManager();
+    if (Core::ActionContainer *advancedMenu = am->actionContainer(M_EDIT_ADVANCED)) {
+        // reuse TextEditor constants to avoid a second pair of menu actions
+        QAction *action = new QAction(tr("Increase Font Size"), this);
+        cmd = am->registerAction(action, TextEditor::Constants::INCREASE_FONT_SIZE,
+            context);
+        connect(action, SIGNAL(triggered()), this, SLOT(scaleRightPaneUp()));
+        advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
+
+        action = new QAction(tr("Decrease Font Size"), this);
+        cmd = am->registerAction(action, TextEditor::Constants::DECREASE_FONT_SIZE,
+            context);
+        connect(action, SIGNAL(triggered()), this, SLOT(scaleRightPaneDown()));
+        advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
+
+        action = new QAction(tr("Reset Font Size"), this);
+        cmd = am->registerAction(action, TextEditor::Constants::RESET_FONT_SIZE,
+            context);
+        connect(action, SIGNAL(triggered()), this, SLOT(resetRightPaneScale()));
+        advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
+    }
+
     // force setup, as we might have never switched to full help mode
     // thus the help engine might still run without collection file setup
     m_helpManager->setupGuiHelpEngine();
 }
 
+void HelpPlugin::scaleRightPaneUp()
+{
+    if (m_helpViewerForSideBar)
+        m_helpViewerForSideBar->scaleUp();
+}
+
+void HelpPlugin::scaleRightPaneDown()
+{
+    if (m_helpViewerForSideBar)
+        m_helpViewerForSideBar->scaleDown();
+}
+
+void HelpPlugin::resetRightPaneScale()
+{
+    if (m_helpViewerForSideBar)
+        m_helpViewerForSideBar->resetScale();
+}
+
 void HelpPlugin::activateHelpMode()
 {
     if (contextHelpOption() != Help::Constants::ExternalHelpAlways)
diff --git a/src/plugins/help/helpplugin.h b/src/plugins/help/helpplugin.h
index 0d387691cab..ff63ecb3f44 100644
--- a/src/plugins/help/helpplugin.h
+++ b/src/plugins/help/helpplugin.h
@@ -115,6 +115,10 @@ private slots:
 
     void openFindToolBar();
 
+    void scaleRightPaneUp();
+    void scaleRightPaneDown();
+    void resetRightPaneScale();
+
 private:
     void setupUi();
     void resetFilter();
-- 
GitLab