From 74cf70deafab891ff79c45b3199708457e892f33 Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Fri, 24 Sep 2010 09:07:08 +0200
Subject: [PATCH] fakevim: add an option to pass Control + <x> directly to
 Creator core

Original code by dcarr.
---
 src/plugins/fakevim/fakevimactions.cpp |  7 +++++++
 src/plugins/fakevim/fakevimactions.h   |  1 +
 src/plugins/fakevim/fakevimhandler.cpp |  3 ++-
 src/plugins/fakevim/fakevimoptions.ui  | 12 +++++++++++-
 src/plugins/fakevim/fakevimplugin.cpp  |  3 +++
 5 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/plugins/fakevim/fakevimactions.cpp b/src/plugins/fakevim/fakevimactions.cpp
index a17fbe146c1..6637a171cf6 100644
--- a/src/plugins/fakevim/fakevimactions.cpp
+++ b/src/plugins/fakevim/fakevimactions.cpp
@@ -217,6 +217,13 @@ FakeVimSettings *theFakeVimSettings()
     item->setCheckable(true);
     instance->insertItem(ConfigShowMarks, item, _("showmarks"), _("sm"));
 
+    item = new SavedAction(instance);
+    item->setDefaultValue(false);
+    item->setValue(false);
+    item->setSettingsKey(group, _("PassControlKey"));
+    item->setCheckable(true);
+    instance->insertItem(ConfigPassControlKey, item, _("passcontrolkey"), _("pck"));
+
     return instance;
 }
 
diff --git a/src/plugins/fakevim/fakevimactions.h b/src/plugins/fakevim/fakevimactions.h
index 3ff9c5c587b..3b3a78bce60 100644
--- a/src/plugins/fakevim/fakevimactions.h
+++ b/src/plugins/fakevim/fakevimactions.h
@@ -66,6 +66,7 @@ enum FakeVimSettingsCode
 
     // other actions
     ConfigShowMarks,
+    ConfigPassControlKey
 };
 
 class FakeVimSettings : public QObject
diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index b431a33a234..1e83636f04b 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -1027,8 +1027,9 @@ bool FakeVimHandler::Private::wantsOverride(QKeyEvent *ev)
         return true;
     }
 
-    // We are interested in overriding  most Ctrl key combinations
+    // We are interested in overriding most Ctrl key combinations
     if (mods == Qt::ControlModifier
+            && !config(ConfigPassControlKey).toBool()
             && ((key >= Key_A && key <= Key_Z && key != Key_K)
                 || key == Key_BracketLeft || key == Key_BracketRight)) {
         // Ctrl-K is special as it is the Core's default notion of Locator
diff --git a/src/plugins/fakevim/fakevimoptions.ui b/src/plugins/fakevim/fakevimoptions.ui
index 992455cd75a..2445c6eb52b 100644
--- a/src/plugins/fakevim/fakevimoptions.ui
+++ b/src/plugins/fakevim/fakevimoptions.ui
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>472</width>
-    <height>420</height>
+    <height>421</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout_2">
@@ -80,6 +80,16 @@
         </property>
        </widget>
       </item>
+      <item row="3" column="2">
+       <widget class="QCheckBox" name="checkBoxPassControlKey">
+        <property name="toolTip">
+         <string>Checking this box passes key sequences like Ctrl-S to the Creator core instead of interpreting them in FakeVim. This gives easier access to Creator core functionality at the price of losing some features of FakeVim.</string>
+        </property>
+        <property name="text">
+         <string>Pass control key</string>
+        </property>
+       </widget>
+      </item>
       <item row="4" column="0" colspan="2">
        <widget class="QCheckBox" name="checkBoxHlSearch">
         <property name="text">
diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp
index 34631c52793..f377d465391 100644
--- a/src/plugins/fakevim/fakevimplugin.cpp
+++ b/src/plugins/fakevim/fakevimplugin.cpp
@@ -183,6 +183,8 @@ QWidget *FakeVimOptionPage::createPage(QWidget *parent)
     m_group.insert(theFakeVimSetting(ConfigIsKeyword),
         m_ui.lineEditIsKeyword);
 
+    m_group.insert(theFakeVimSetting(ConfigPassControlKey),
+        m_ui.checkBoxPassControlKey);
     m_group.insert(theFakeVimSetting(ConfigAutoIndent),
         m_ui.checkBoxAutoIndent);
     m_group.insert(theFakeVimSetting(ConfigSmartIndent),
@@ -204,6 +206,7 @@ QWidget *FakeVimOptionPage::createPage(QWidget *parent)
             << ' ' << m_ui.checkBoxExpandTab->text()
             << ' ' << m_ui.checkBoxShowMarks->text()
             << ' ' << m_ui.checkBoxSmartIndent->text()
+            << ' ' << m_ui.checkBoxPassControlKey->text()
             << ' ' << m_ui.checkBoxHlSearch->text()
             << ' ' << m_ui.checkBoxIncSearch->text()
             << ' ' << m_ui.checkBoxSmartTab->text()
-- 
GitLab