Branch: master

c7a9fafe 2014-04-19 09:19:49 Michele Calgaro
Added support for handling Meta key as Alt key in terminal emulation.
This relates to bug 1026.
M konsole/konsole/TEmuVt102.cpp
M konsole/konsole/TEmulation.cpp
M konsole/konsole/TEmulation.h
diff --git a/konsole/konsole/TEmuVt102.cpp b/konsole/konsole/TEmuVt102.cpp
index c460693..ebe090f 100644
--- a/konsole/konsole/TEmuVt102.cpp
+++ b/konsole/konsole/TEmuVt102.cpp
@@ -936,18 +936,21 @@
 
   // lookup in keyboard translation table ...
   int cmd = CMD_none; 
-  const char* txt; 
+  const char *txt; 
   int len;
   bool metaspecified;
-  if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine		, BITS_NewLine   ) + // OLD,
-                                     encodeMode(MODE_Ansi		, BITS_Ansi      ) + // OBSOLETE,
-                                     encodeMode(MODE_AppCuKeys		, BITS_AppCuKeys ) + // VT100 stuff
-                                     encodeMode(MODE_AppScreen		, BITS_AppScreen ) + // VT100 stuff
-                                     encodeStat(TQt::ControlButton	, BITS_Control   ) +
-                                     encodeStat(TQt::ShiftButton	, BITS_Shift     ) +
-                                     encodeStat(TQt::AltButton		, BITS_Alt       ),
-                          &cmd, &txt, &len, &metaspecified ))
-//printf("cmd: %d, %s, %d\n",cmd,txt,len);
+  int bits = encodeMode(MODE_NewLine		  , BITS_NewLine   ) + // OLD,
+             encodeMode(MODE_Ansi		      , BITS_Ansi      ) + // OBSOLETE,
+             encodeMode(MODE_AppCuKeys		, BITS_AppCuKeys ) + // VT100 stuff
+             encodeMode(MODE_AppScreen		, BITS_AppScreen ) + // VT100 stuff
+             encodeStat(TQt::ControlButton, BITS_Control   ) +
+             encodeStat(TQt::ShiftButton	, BITS_Shift     ) +
+             encodeStat(TQt::AltButton		, BITS_Alt       );
+  if (metaKeyMode)
+    bits += encodeStat(TQt::MetaButton , BITS_Alt);
+  bool transRes = keytrans->findEntry(ev->key(), bits, &cmd, &txt, &len, &metaspecified);
+//if (transRes)
+//  printf("cmd: %d, %s, %d\n",cmd,txt,len);
   if (connected)
   {
   switch(cmd) // ... and execute if found.
@@ -976,8 +979,10 @@
     || ev->key()==Qt::Key_PageUp || ev->key()==Qt::Key_PageDown))
     scr->setHistCursor(scr->getHistLines());
 
-  if (cmd==CMD_send) {
-    if ((ev->state() & TQt::AltButton) && !metaspecified ) sendString("\033");
+  if (cmd==CMD_send)
+  {
+    if (((ev->state() & TQt::AltButton) || (metaKeyMode && (ev->state() & TQt::MetaButton))) && !metaspecified)
+      sendString("\033");
     emit sndBlock(txt,len);
     return;
   }
diff --git a/konsole/konsole/TEmulation.cpp b/konsole/konsole/TEmulation.cpp
index 939139d..3aa1cfa 100644
--- a/konsole/konsole/TEmulation.cpp
+++ b/konsole/konsole/TEmulation.cpp
@@ -98,6 +98,7 @@
   scr(0),
   connected(false),
   listenToKeyPress(false),
+  metaKeyMode(false),
   m_codec(0),
   decoder(0),
   keytrans(0),
diff --git a/konsole/konsole/TEmulation.h b/konsole/konsole/TEmulation.h
index a5f4321..6eac5f9 100644
--- a/konsole/konsole/TEmulation.h
+++ b/konsole/konsole/TEmulation.h
@@ -89,6 +89,7 @@
 
   virtual void setMode  (int) = 0;
   virtual void resetMode(int) = 0;
+  void setMetaKeyMode(bool mode) { metaKeyMode = mode; }
 
   virtual void sendString(const char*) = 0;
 
@@ -119,6 +120,7 @@
 
   bool   connected;    // communicate with widget
   bool   listenToKeyPress;  // listen to input
+  bool   metaKeyMode;       // true -> meta key is handled as Alt
 
   void setCodec(int c); // codec number, 0 = locale, 1=utf8
 
f69bb8df 2014-04-19 10:31:22 Michele Calgaro
Added support for handling Meta key as Alt key in konsolePart.
This relates to bug 1026.
M konsole/konsole/konsole.cpp
M konsole/konsole/konsole_part.cpp
M konsole/konsole/konsole_part.h
M konsole/konsole/session.cpp
M konsole/konsole/session.h
diff --git a/konsole/konsole/konsole.cpp b/konsole/konsole/konsole.cpp
index a7d3d73..26d3560 100644
--- a/konsole/konsole/konsole.cpp
+++ b/konsole/konsole/konsole.cpp
@@ -2953,21 +2953,21 @@
   s->enableFullScripting(b_fullScripting);
   // If you add any new signal-slot connection below, think about doing it in konsolePart too
   connect( s,TQT_SIGNAL(done(TESession*)),
-           this,TQT_SLOT(doneSession(TESession*)) );
-  connect( s, TQT_SIGNAL( updateTitle(TESession*) ),
-           this, TQT_SLOT( updateTitle(TESession*) ) );
-  connect( s, TQT_SIGNAL( notifySessionState(TESession*, int) ),
-           this, TQT_SLOT( notifySessionState(TESession*, int)) );
+           this,TQT_SLOT(doneSession(TESession*)));
+  connect( s, TQT_SIGNAL(updateTitle(TESession*)),
+           this, TQT_SLOT(updateTitle(TESession*)));
+  connect( s, TQT_SIGNAL(notifySessionState(TESession*, int)),
+           this, TQT_SLOT(notifySessionState(TESession*, int)));
   connect( s, TQT_SIGNAL(disableMasterModeConnections()),
-           this, TQT_SLOT(disableMasterModeConnections()) );
+           this, TQT_SLOT(disableMasterModeConnections()));
   connect( s, TQT_SIGNAL(enableMasterModeConnections()),
-           this, TQT_SLOT(enableMasterModeConnections()) );
+           this, TQT_SLOT(enableMasterModeConnections()));
   connect( s, TQT_SIGNAL(renameSession(TESession*,const TQString&)),
-           this, TQT_SLOT(slotRenameSession(TESession*, const TQString&)) );
+           this, TQT_SLOT(slotRenameSession(TESession*, const TQString&)));
   connect( s->getEmulation(), TQT_SIGNAL(changeColumns(int)),
            this, TQT_SLOT(changeColumns(int)) );
   connect( s->getEmulation(), TQT_SIGNAL(changeColLin(int,int)),
-           this, TQT_SLOT(changeColLin(int,int)) );
+           this, TQT_SLOT(changeColLin(int,int)));
   connect( s->getEmulation(), TQT_SIGNAL(ImageSizeChanged(int,int)),
            this, TQT_SLOT(notifySize(int,int)));
   connect( s, TQT_SIGNAL(zmodemDetected(TESession*)),
@@ -2983,7 +2983,7 @@
   connect( s, TQT_SIGNAL(setSessionSchema(TESession*, const TQString &)),
            this, TQT_SLOT(slotSetSessionSchema(TESession*, const TQString &)));
   connect( s, TQT_SIGNAL(changeTabTextColor(TESession*, int)),
-           this,TQT_SLOT(changeTabTextColor(TESession*, int)) );
+           this,TQT_SLOT(changeTabTextColor(TESession*, int)));
 
   s->widget()->setVTFont(defaultFont);// Hack to set font again after newSession
   s->setSchemaNo(schmno);
diff --git a/konsole/konsole/konsole_part.cpp b/konsole/konsole/konsole_part.cpp
index f1b2f28..87cd2b3 100644
--- a/konsole/konsole/konsole_part.cpp
+++ b/konsole/konsole/konsole_part.cpp
@@ -105,6 +105,7 @@
 ,rootxpm(0)
 ,blinkingCursor(0)
 ,showFrame(0)
+,metaAsAlt(0)
 ,m_useKonsoleSettings(0)
 ,selectBell(0)
 ,selectLineSpacing(0)
@@ -431,6 +432,11 @@
      showFrame->setCheckedState(i18n("Hide Fr&ame"));
      showFrame->plug(m_options);
 
+     // Meta key as Alt key
+     metaAsAlt = new TDEToggleAction(i18n("Me&ta key as Alt key"), 0,
+                                this, TQT_SLOT(slotToggleMetaAsAltMode()), settingsActions);
+     metaAsAlt->plug(m_options);
+
      // Word Connectors
      TDEAction *WordSeps = new TDEAction(i18n("Wor&d Connectors..."), 0, this,
                                   TQT_SLOT(slotWordSeps()), settingsActions);
@@ -505,6 +511,8 @@
      selectLineSpacing->setCurrentItem(te->lineSpacing());
   if (blinkingCursor)
      blinkingCursor->setChecked(te->blinkingCursor());
+  if (metaAsAlt)
+     metaAsAlt->setChecked(b_metaAsAlt);
   if (m_schema)
      m_schema->setItemChecked(curr_schema,true);
   if (selectSetEncoding)
@@ -532,6 +540,8 @@
    se->widget()->setVTFont( defaultFont );
    se->setSchemaNo( curr_schema );
    slotSetEncoding();
+
+   se->setMetaAsAltMode(b_metaAsAlt);
 }
 
 void konsolePart::setSettingsMenuEnabled( bool enable )
@@ -560,13 +570,13 @@
   config->setDesktopGroup();
 
   b_framevis = config->readBoolEntry("has frame",false);
+  b_metaAsAlt = config->readBoolEntry("metaAsAltMode",false);
   b_histEnabled = config->readBoolEntry("historyenabled",true);
   n_bell = TQMIN(config->readUnsignedNumEntry("bellmode",TEWidget::BELLSYSTEM),3);
   n_keytab=config->readNumEntry("keytab",0); // act. the keytab for this session
   n_scroll = TQMIN(config->readUnsignedNumEntry("scrollbar",TEWidget::SCRRIGHT),2);
   m_histSize = config->readNumEntry("history",DEFAULT_HISTORY_SIZE);
   s_word_seps= config->readEntry("wordseps",":@-./_~");
-
   n_encoding = config->readNumEntry("encoding",0);
 
   TQFont tmpFont = TDEGlobalSettings::fixedFont();
@@ -637,6 +647,7 @@
     config->writeEntry("historyenabled", b_histEnabled);
     config->writeEntry("keytab",n_keytab);
     config->writeEntry("has frame",b_framevis);
+    config->writeEntry("metaAsAltMode",b_metaAsAlt);
     config->writeEntry("LineSpacing", te->lineSpacing());
     config->writeEntry("schema",s_tdeconfigSchema);
     config->writeEntry("scrollbar",n_scroll);
@@ -914,14 +925,18 @@
   te->setBlinkingCursor(blinkingCursor->isChecked());
 }
 
+void konsolePart::slotToggleMetaAsAltMode()
+{
+  b_metaAsAlt ^= true;
+  if (!se) return;
+  se->setMetaAsAltMode(b_metaAsAlt);
+}
+
 void konsolePart::slotUseKonsoleSettings()
 {
    b_useKonsoleSettings = m_useKonsoleSettings->isChecked();
-
    setSettingsMenuEnabled( !b_useKonsoleSettings );
-
    readProperties();
-
    applySettingsToGUI();
 }
 
diff --git a/konsole/konsole/konsole_part.h b/konsole/konsole/konsole_part.h
index 1fd2ac9..766e4e5 100644
--- a/konsole/konsole/konsole_part.h
+++ b/konsole/konsole/konsole_part.h
@@ -118,6 +118,7 @@
     void slotSelectBell();
     void slotSelectLineSpacing();
     void slotBlinkingCursor();
+    void slotToggleMetaAsAltMode();
     void slotUseKonsoleSettings();
     void slotWordSeps();
     void slotSetEncoding();
@@ -136,9 +137,9 @@
     void setSchema(ColorSchema* s);
     void updateKeytabMenu();
 
-	bool doOpenStream( const TQString& );
-	bool doWriteStream( const TQByteArray& );
-	bool doCloseStream();
+	  bool doOpenStream( const TQString& );
+  	bool doWriteStream( const TQByteArray& );
+  	bool doCloseStream();
 
     TQWidget* parentWidget;
     TEWidget* te;
@@ -151,6 +152,7 @@
 
     TDEToggleAction* blinkingCursor;
     TDEToggleAction* showFrame;
+    TDEToggleAction* metaAsAlt;
     TDEToggleAction* m_useKonsoleSettings;
 
     TDESelectAction* selectBell;
@@ -174,6 +176,7 @@
     TQString     s_word_seps;			// characters that are considered part of a word
 
     bool        b_framevis:1;
+    bool        b_metaAsAlt:1;
 ** Diff limit reached (max: 250 lines) **
dfa62cdb 2014-04-21 03:49:25 Michele Calgaro
Added support for handling Meta key as Alt key in Konsole.
This relates to bug 1026.
M konsole/konsole/konsole.cpp
M konsole/konsole/konsole.h
 ** Diff limit reached (max: 250 lines) **
8b69d90d 2014-04-21 04:14:10 Michele Calgaro
Added Meta key as Alt key option in Kcontrol/Konsole. This relates to bug 1026.
Also improved options arrangement in the same configuration page.
M kcontrol/konsole/kcmkonsole.cpp
M kcontrol/konsole/kcmkonsoledialog.ui
 ** Diff limit reached (max: 250 lines) **
115138a5 2014-04-21 04:16:50 Michele Calgaro
Renamed two check box objects in KControl/Konsole to maintain name
consistency with other check boxes.
M kcontrol/konsole/kcmkonsole.cpp
M kcontrol/konsole/kcmkonsoledialog.ui
 ** Diff limit reached (max: 250 lines) **
c5a0a7ce 2014-04-21 04:22:55 Michele Calgaro
Added explicit keyboard shortcuts to missing options in KControl/Konsole.
M kcontrol/konsole/kcmkonsoledialog.ui
 ** Diff limit reached (max: 250 lines) **
cb770228 2014-04-22 01:22:23 Michele Calgaro
Fixed support for handling Meta key as Alt key in terminal emulation.
This resolves bug 1026.
M konsole/konsole/TEmuVt102.cpp
 ** Diff limit reached (max: 250 lines) **
4c12a981 2014-04-22 02:38:41 Michele Calgaro
Updated documentation for Konsole -> Settings -> General page.
Several options were missing. This also relates to bugs 909, 1026 and 1701.
M doc/kcontrol/kcmkonsole/index.docbook
M kcontrol/konsole/kcmkonsoledialog.ui
 ** Diff limit reached (max: 250 lines) **
335d526a 2014-04-22 04:54:29 Michele Calgaro
Fixed typo in docbook.
M doc/kcontrol/kcmkonsole/index.docbook
 ** Diff limit reached (max: 250 lines) **
83708272 2014-05-14 08:06:08 Michele Calgaro
Workaround Qt/Tde/X? bug for handling Meta key as Alt key in terminal emulation
after restored sessions. This resolves bug 1026 for good.
M konsole/konsole/TEWidget.cpp
M konsole/konsole/TEWidget.h
M konsole/konsole/TEmuVt102.cpp
M konsole/konsole/TEmuVt102.h
M konsole/konsole/TEmulation.cpp
M konsole/konsole/TEmulation.h
M konsole/konsole/konsole.cpp
 ** Diff limit reached (max: 250 lines) **
efdf0bbc 2014-05-16 04:32:17 Michele Calgaro
Improved code for workaround for Qt/Tde/X? bug for handling Meta key as Alt key
in terminal emulation after restored sessions. This relates to bug 1026.
M konsole/konsole/TEWidget.cpp
M konsole/konsole/TEWidget.h
M konsole/konsole/TEmulation.cpp
M konsole/konsole/TEmulation.h
M konsole/konsole/konsole.cpp
 ** Diff limit reached (max: 250 lines) **
3e7f4492 2014-09-15 04:37:36 Michele Calgaro
Merge changes related to bug1026 from local branch
M doc/kcontrol/kcmkonsole/index.docbook
M kcontrol/konsole/kcmkonsole.cpp
M kcontrol/konsole/kcmkonsoledialog.ui
M konsole/konsole/TEWidget.cpp
M konsole/konsole/TEWidget.h
M konsole/konsole/TEmuVt102.cpp
M konsole/konsole/TEmuVt102.h
M konsole/konsole/TEmulation.cpp
M konsole/konsole/TEmulation.h
M konsole/konsole/konsole.cpp
M konsole/konsole/konsole.h
M konsole/konsole/konsole_part.cpp
M konsole/konsole/konsole_part.h
M konsole/konsole/session.cpp
M konsole/konsole/session.h
 ** Diff limit reached (max: 250 lines) **
afedb89e 2014-09-15 04:52:37 Michele Calgaro
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/tdebase
M cmake
 ** Diff limit reached (max: 250 lines) **