diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2014-09-15 18:37:36 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2014-09-15 18:37:36 +0900 |
commit | 3e7f4492e641b36751e356dcefb059be4bc823cb (patch) | |
tree | 5b85cc2260faa1803522bb956df5ba713ca8fcec | |
parent | 60d2edfb8529ef76f0a17892d48cc2bc02928b42 (diff) | |
parent | efdf0bbcd37d5aaa05649437b286aeecfd38c617 (diff) | |
download | tdebase-3e7f4492e641b36751e356dcefb059be4bc823cb.tar.gz tdebase-3e7f4492e641b36751e356dcefb059be4bc823cb.zip |
Merge changes related to bug1026 from local branch
-rw-r--r-- | doc/kcontrol/kcmkonsole/index.docbook | 93 | ||||
-rw-r--r-- | kcontrol/konsole/kcmkonsole.cpp | 15 | ||||
-rw-r--r-- | kcontrol/konsole/kcmkonsoledialog.ui | 117 | ||||
-rw-r--r-- | konsole/konsole/TEWidget.cpp | 27 | ||||
-rw-r--r-- | konsole/konsole/TEWidget.h | 2 | ||||
-rw-r--r-- | konsole/konsole/TEmuVt102.cpp | 54 | ||||
-rw-r--r-- | konsole/konsole/TEmuVt102.h | 3 | ||||
-rw-r--r-- | konsole/konsole/TEmulation.cpp | 69 | ||||
-rw-r--r-- | konsole/konsole/TEmulation.h | 13 | ||||
-rw-r--r-- | konsole/konsole/konsole.cpp | 60 | ||||
-rw-r--r-- | konsole/konsole/konsole.h | 1 | ||||
-rw-r--r-- | konsole/konsole/konsole_part.cpp | 23 | ||||
-rw-r--r-- | konsole/konsole/konsole_part.h | 9 | ||||
-rw-r--r-- | konsole/konsole/session.cpp | 6 | ||||
-rw-r--r-- | konsole/konsole/session.h | 1 |
15 files changed, 353 insertions, 140 deletions
diff --git a/doc/kcontrol/kcmkonsole/index.docbook b/doc/kcontrol/kcmkonsole/index.docbook index 4d730e59c..24208ded2 100644 --- a/doc/kcontrol/kcmkonsole/index.docbook +++ b/doc/kcontrol/kcmkonsole/index.docbook @@ -44,16 +44,6 @@ Daemon</guilabel>.</para> functions. It contains the following options:</para> <variablelist> -<varlistentry> -<term><guilabel>Use Konsole as default terminal -application</guilabel></term> -<listitem> -<para>If you wish to have &tde; use another terminal application by -default, uncheck this box and enter the preferred application -(<application>wterm</application>, <application>rxvt</application>, -&etc;) in the text field below.</para> -</listitem> -</varlistentry> <varlistentry> <term><guilabel>Show Terminal Size when Resizing</guilabel></term> @@ -72,9 +62,9 @@ behavior.</para></listitem> </varlistentry> <varlistentry> -<term><guilabel>Confirm quit with open sessions</guilabel></term> +<term><guilabel>Confirm quit when closing more than one session</guilabel></term> <listitem> -<para>When set, a warning appears when you try to close a &konsole; +<para>When set, a warning appears when you try to close a &konsole; window with multiple sessions.</para> </listitem> </varlistentry> @@ -87,12 +77,91 @@ attention.</para></listitem> </varlistentry> <varlistentry> +<term><guilabel>Require Ctrl key for drag and drop</guilabel></term> +<listitem><para>If unchecked, you can drag and drop selected text by using the mouse. +If checked, the Ctrl key needs to be held down to allow drag and drop (this is +a good way to avoid erroneous drag and drop operations). +</para></listitem> +</varlistentry> + +<varlistentry> +<term><guilabel>Triple click selects only from the current word forward</guilabel></term> +<listitem><para>If checked, a mouse triple click will select everything from the +current cursor position to the end of the lime. If unchecked, a mouse triple click will select +the entire current row. +</para></listitem> +</varlistentry> + +<varlistentry> +<term><guilabel>Allow programs to resize terminal window</guilabel></term> +<listitem><para>If checked, programs can resize the terminal window. +</para></listitem> +</varlistentry> + +<varlistentry> +<term><guilabel>Use Ctrl+S/Ctrl+Q flow control</guilabel></term> +<listitem><para>If checked, Ctrl+S/Ctrl+Q can be used to control the flow of output +characters sent to the terminal. After pressing CTRL-S, the system will not send any +more data to the screen until a CTRL-Q is pressed. +</para></listitem> +</varlistentry> + +<varlistentry> +<term><guilabel>Enable bidirectional text rendering</guilabel></term> +<listitem><para>If checked, text can be rendered from left to right or from right to left. +This is useful to support languages which are written in the second way. +</para></listitem> +</varlistentry> + +<varlistentry> +<term><guilabel>Set tab title to match window title</guilabel></term> +<listitem><para>If checked, the title of the tab representing the current session will match +the text displayed on the window title bar. Whenever the window title changes, the tab +tile changes as well. +</para></listitem> +</varlistentry> + +<varlistentry> +<term><guilabel>Cycle tabs with mouse wheel</guilabel></term> +<listitem><para>If checked, you can move through the different session tabs +using the mouse wheel over the tabbar control. If unchecked, the action is disabled. +</para></listitem> +</varlistentry> + +<varlistentry> +<term><guilabel>Enable main menu accelerator keys</guilabel></term> +<listitem><para>If checked, the main menu shortcut keys are enabled, otherwise +they are disabled. +</para> +<note><para>If menu accelerators are enabled, some Alt-key combinations may not +be handled correctly any longer in Konsole applications.</para></note> +</listitem> +</varlistentry> + +<varlistentry> +<term><guilabel>Handle Meta key as Alt Key</guilabel></term> +<listitem><para>If checked, the Meta key will be handled as if it was an Alt key. +</para> +<note><para>This is a useful option if you have enabled the main menu shortcut keys. +You can use the Meta key to activate those Alt-key combinations that otherwise +would not work any longer in Konsole.</para></note> +</listitem> +</varlistentry> + +<varlistentry> <term><guilabel>Line Spacing</guilabel></term> <listitem><para>Change the space between lines of text.</para> </listitem> </varlistentry> <varlistentry> +<term><guilabel>Seconds to detect silence</guilabel></term> +<listitem><para>Allows to specify the time interval used for monitoring the +Konsole for silence. +</para></listitem> +</varlistentry> + +<varlistentry> <term><guilabel>Consider the following characters part of a word when double clicking</guilabel></term> <listitem><para>It is a common &UNIX; behavior to select a whole word diff --git a/kcontrol/konsole/kcmkonsole.cpp b/kcontrol/konsole/kcmkonsole.cpp index 8c7892083..e2b280dfa 100644 --- a/kcontrol/konsole/kcmkonsole.cpp +++ b/kcontrol/konsole/kcmkonsole.cpp @@ -71,8 +71,9 @@ KCMKonsole::KCMKonsole(TQWidget * parent, const char *name, const TQStringList&) connect(dialog->frameCB,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); connect(dialog->line_spacingSB,TQT_SIGNAL(valueChanged(int)), TQT_SLOT( changed() )); connect(dialog->matchTabWinTitleCB,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); - connect(dialog->tabsCycleWheel,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); - connect(dialog->menuAccelerators,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); + connect(dialog->tabsCycleWheelCB,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); + connect(dialog->menuAcceleratorsCB,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); + connect(dialog->metaAsAltModeCB,TQT_SIGNAL(toggled(bool)), TQT_SLOT( changed() )); connect(dialog->silence_secondsSB,TQT_SIGNAL(valueChanged(int)), TQT_SLOT( changed() )); connect(dialog->word_connectorLE,TQT_SIGNAL(textChanged(const TQString &)), TQT_SLOT( changed() )); connect(dialog->SchemaEditor1, TQT_SIGNAL(changed()), TQT_SLOT( changed() )); @@ -97,8 +98,8 @@ void KCMKonsole::load(bool useDefaults) bidiOrig = config.readBoolEntry("EnableBidi",false); dialog->bidiCB->setChecked(bidiOrig); dialog->matchTabWinTitleCB->setChecked(config.readBoolEntry("MatchTabWinTitle",false)); - dialog->tabsCycleWheel->setChecked(config.readBoolEntry("TabsCycleWheel",true)); - dialog->menuAccelerators->setChecked(config.readBoolEntry("MenuAccelerators",false)); + dialog->tabsCycleWheelCB->setChecked(config.readBoolEntry("TabsCycleWheel",true)); + dialog->menuAcceleratorsCB->setChecked(config.readBoolEntry("MenuAccelerators",false)); dialog->warnCB->setChecked(config.readBoolEntry("WarnQuit",true)); dialog->ctrldragCB->setChecked(config.readBoolEntry("CtrlDrag",true)); dialog->cutToBeginningOfLineCB->setChecked(config.readBoolEntry("CutToBeginningOfLine",false)); @@ -110,6 +111,7 @@ void KCMKonsole::load(bool useDefaults) dialog->line_spacingSB->setValue(config.readUnsignedNumEntry( "LineSpacing", 0 )); dialog->silence_secondsSB->setValue(config.readUnsignedNumEntry( "SilenceSeconds", 10 )); dialog->word_connectorLE->setText(config.readEntry("wordseps",":@-./_~")); + dialog->metaAsAltModeCB->setChecked(config.readBoolEntry("metaAsAltMode",false)); dialog->SchemaEditor1->setSchema(config.readEntry("schema")); @@ -137,8 +139,8 @@ void KCMKonsole::save() bool bidiNew = dialog->bidiCB->isChecked(); config.writeEntry("EnableBidi", bidiNew); config.writeEntry("MatchTabWinTitle", dialog->matchTabWinTitleCB->isChecked()); - config.writeEntry("TabsCycleWheel", dialog->tabsCycleWheel->isChecked()); - config.writeEntry("MenuAccelerators", dialog->menuAccelerators->isChecked()); + config.writeEntry("TabsCycleWheel", dialog->tabsCycleWheelCB->isChecked()); + config.writeEntry("MenuAccelerators", dialog->menuAcceleratorsCB->isChecked()); config.writeEntry("WarnQuit", dialog->warnCB->isChecked()); config.writeEntry("CtrlDrag", dialog->ctrldragCB->isChecked()); config.writeEntry("CutToBeginningOfLine", dialog->cutToBeginningOfLineCB->isChecked()); @@ -150,6 +152,7 @@ void KCMKonsole::save() config.writeEntry("LineSpacing" , dialog->line_spacingSB->value()); config.writeEntry("SilenceSeconds" , dialog->silence_secondsSB->value()); config.writeEntry("wordseps", dialog->word_connectorLE->text()); + config.writeEntry("metaAsAltMode", dialog->metaAsAltModeCB->isChecked()); config.writeEntry("schema", dialog->SchemaEditor1->schema()); diff --git a/kcontrol/konsole/kcmkonsoledialog.ui b/kcontrol/konsole/kcmkonsoledialog.ui index 1ce6b2f8f..5034b42c4 100644 --- a/kcontrol/konsole/kcmkonsoledialog.ui +++ b/kcontrol/konsole/kcmkonsoledialog.ui @@ -66,9 +66,6 @@ <property name="name"> <cstring>GroupBox2</cstring> </property> - <property name="title"> - <string>Misc</string> - </property> <grid> <property name="name"> <cstring>unnamed</cstring> @@ -134,32 +131,15 @@ <cstring>xonXoffCB</cstring> </property> <property name="text"> - <string>Use Ctrl+S/Ctrl+Q flow control</string> + <string>&Use Ctrl+S/Ctrl+Q flow control</string> </property> </widget> - <spacer row="12" column="3"> - <property name="name"> - <cstring>Spacer3</cstring> - </property> - <property name="orientation"> - <enum>Horizontal</enum> - </property> - <property name="sizeType"> - <enum>Expanding</enum> - </property> - <property name="sizeHint"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> <widget class="TQCheckBox" row="8" column="0" rowspan="1" colspan="3"> <property name="name"> <cstring>bidiCB</cstring> </property> <property name="text"> - <string>Enable bidirectional text rendering</string> + <string>E&nable bidirectional text rendering</string> </property> </widget> <widget class="TQCheckBox" row="9" column="0" rowspan="1" colspan="4"> @@ -167,26 +147,70 @@ <cstring>matchTabWinTitleCB</cstring> </property> <property name="text"> - <string>Set tab title to match window title</string> + <string>Set &tab title to match window title</string> </property> </widget> <widget class="TQCheckBox" row="10" column="0" rowspan="1" colspan="3"> <property name="name"> - <cstring>tabsCycleWheel</cstring> + <cstring>tabsCycleWheelCB</cstring> </property> <property name="text"> - <string>Cycle tabs with mouse wheel</string> + <string>Cycle tabs &with mouse wheel</string> </property> </widget> <widget class="TQCheckBox" row="11" column="0" rowspan="1" colspan="3"> <property name="name"> - <cstring>menuAccelerators</cstring> + <cstring>menuAcceleratorsCB</cstring> </property> <property name="text"> - <string>Enable main menu accelerator keys</string> + <string>Enable main &menu accelerator keys</string> </property> </widget> - <widget class="KIntNumInput" row="12" column="2"> + <widget class="TQCheckBox" row="12" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>metaAsAltModeCB</cstring> + </property> + <property name="text"> + <string>Handle Meta &key as Alt Key</string> + </property> + </widget> + <widget class="TQLabel" row="13" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>TextLabel1_4</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Line spacing:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>line_spacingSB</cstring> + </property> + </widget> + <spacer row="12" column="3"> + <property name="name"> + <cstring>Spacer3</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KIntNumInput" row="13" column="2"> <property name="name"> <cstring>line_spacingSB</cstring> </property> @@ -205,25 +229,6 @@ <number>8</number> </property> </widget> - <widget class="TQLabel" row="12" column="0" rowspan="1" colspan="2"> - <property name="name"> - <cstring>TextLabel1_4</cstring> - </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>5</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>&Line spacing:</string> - </property> - <property name="buddy" stdset="0"> - <cstring>line_spacingSB</cstring> - </property> - </widget> <spacer row="12" column="3"> <property name="name"> <cstring>Spacer2</cstring> @@ -241,7 +246,7 @@ </size> </property> </spacer> - <widget class="TQLabel" row="13" column="0"> + <widget class="TQLabel" row="14" column="0" rowspan="1" colspan="2"> <property name="name"> <cstring>SilenceLabel</cstring> </property> @@ -260,7 +265,7 @@ <cstring>silence_secondsSB</cstring> </property> </widget> - <widget class="KIntNumInput" row="13" column="1" rowspan="1" colspan="2"> + <widget class="KIntNumInput" row="14" column="2"> <property name="name"> <cstring>silence_secondsSB</cstring> </property> @@ -276,20 +281,10 @@ <number>1</number> </property> </widget> - </grid> - </widget> - <widget class="TQGroupBox" row="1" column="0"> - <property name="name"> - <cstring>GroupBox3</cstring> - </property> - <property name="title"> - <string>Double Click</string> - </property> - <grid> <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="TQLabel" row="0" column="0"> + <widget class="TQLabel" row="15" column="0" colspan="3"> <property name="name"> <cstring>TextLabel1_3</cstring> </property> @@ -300,7 +295,7 @@ <cstring>word_connectorLE</cstring> </property> </widget> - <widget class="TQLineEdit" row="1" column="0"> + <widget class="TQLineEdit" row="16" column="0" colspan="3"> <property name="name"> <cstring>word_connectorLE</cstring> </property> diff --git a/konsole/konsole/TEWidget.cpp b/konsole/konsole/TEWidget.cpp index 75545a1e0..f16d97aac 100644 --- a/konsole/konsole/TEWidget.cpp +++ b/konsole/konsole/TEWidget.cpp @@ -1901,7 +1901,7 @@ bool TEWidget::eventFilter( TQObject *obj, TQEvent *e ) return false; // not us if ( e->type() == TQEvent::KeyPress ) { - TQKeyEvent* ke = (TQKeyEvent*)e; + TQKeyEvent *ke = TQT_TQKEYEVENT(e); actSel=0; // Key stroke implies a screen update, so TEWidget won't // know where the current selection is. @@ -1914,17 +1914,24 @@ bool TEWidget::eventFilter( TQObject *obj, TQEvent *e ) cursorBlinking = false; } - emit keyPressedSignal(ke); // expose - - // in Qt2 when key events were propagated up the tree - // (unhandled? -> parent widget) they passed the event filter only once at - // the beginning. in qt3 this has changed, that is, the event filter is - // called each time the event is sent (see loop in TQApplication::notify, - // when internalNotify() is called for KeyPress, whereas internalNotify - // activates also the global event filter) . That's why we stop propagation - // here. + emit keyPressedSignal(ke); return true; } + if ( e->type() == TQEvent::KeyRelease ) + { + TQKeyEvent *ke = TQT_TQKEYEVENT(e); + emit keyReleasedSignal(ke); + return true; + } + if ( e->type() == TQEvent::FocusIn ) + { + TQFocusEvent *fe = TQT_TQFOCUSEVENT(e); + if (fe->gotFocus()) + { + emit focusInSignal(fe); + return true; + } + } if ( e->type() == TQEvent::Enter ) { TQObject::disconnect( (TQObject*)cb, TQT_SIGNAL(dataChanged()), diff --git a/konsole/konsole/TEWidget.h b/konsole/konsole/TEWidget.h index 1e2c36d87..2baa2531c 100644 --- a/konsole/konsole/TEWidget.h +++ b/konsole/konsole/TEWidget.h @@ -153,6 +153,8 @@ public slots: signals: void keyPressedSignal(TQKeyEvent *e); + void keyReleasedSignal(TQKeyEvent *e); + void focusInSignal(TQFocusEvent *e); void mouseSignal(int cb, int cx, int cy); void changedFontMetricSignal(int height, int width); void changedContentSizeSignal(int height, int width); diff --git a/konsole/konsole/TEmuVt102.cpp b/konsole/konsole/TEmuVt102.cpp index c460693cd..e0efab745 100644 --- a/konsole/konsole/TEmuVt102.cpp +++ b/konsole/konsole/TEmuVt102.cpp @@ -927,37 +927,38 @@ void TEmuVt102::onScrollLock() the complications towards a configuration file [see KeyTrans class]. */ -void TEmuVt102::onKeyPress( TQKeyEvent* ev ) +void TEmuVt102::doKeyPress( TQKeyEvent* ev ) { - if (!listenToKeyPress) return; // someone else gets the keys emit notifySessionState(NOTIFYNORMAL); -//printf("State/Key: 0x%04x 0x%04x (%d,%d)\n",ev->state(),ev->key(),ev->text().length(),ev->text().length()?ev->text().ascii()[0]:0); + //printf("State/Key: 0x%04x 0x%04x (%d,%d)\n", ev->state(),ev->key(), + // ev->text().length(),ev->text().length()?ev->text().ascii()[0]:0); // 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); + keytrans->findEntry(ev->key(), bits, &cmd, &txt, &len, &metaspecified); if (connected) { - switch(cmd) // ... and execute if found. - { - case CMD_scrollPageUp : gui->doScroll(-gui->Lines()/2); return; - case CMD_scrollPageDown : gui->doScroll(+gui->Lines()/2); return; - case CMD_scrollLineUp : gui->doScroll(-1 ); return; - case CMD_scrollLineDown : gui->doScroll(+1 ); return; - case CMD_scrollLock : onScrollLock( ); return; - } + switch(cmd) // ... and execute if found. + { + case CMD_scrollPageUp : gui->doScroll(-gui->Lines()/2); return; + case CMD_scrollPageDown : gui->doScroll(+gui->Lines()/2); return; + case CMD_scrollLineUp : gui->doScroll(-1 ); return; + case CMD_scrollLineDown : gui->doScroll(+1 ); return; + case CMD_scrollLock : onScrollLock( ); return; + } } if (holdScreen) { @@ -976,8 +977,11 @@ void TEmuVt102::onKeyPress( TQKeyEvent* ev ) || 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) || metaIsPressed) && !metaspecified)) + sendString("\033"); emit sndBlock(txt,len); return; } @@ -985,7 +989,9 @@ void TEmuVt102::onKeyPress( TQKeyEvent* ev ) // fall back handling if (!ev->text().isEmpty()) { - if (ev->state() & TQt::AltButton) sendString("\033"); // ESC, this is the ALT prefix + if ((ev->state() & TQt::AltButton) || + (metaKeyMode && ((ev->state() & TQt::MetaButton) || metaIsPressed))) + sendString("\033"); // ESC, this is the ALT prefix TQCString s = m_codec->fromUnicode(ev->text()); // encode for application // FIXME: In Qt 2, TQKeyEvent::text() would return "\003" for Ctrl-C etc. // while in Qt 3 it returns the actual key ("c" or "C") which caused diff --git a/konsole/konsole/TEmuVt102.h b/konsole/konsole/TEmuVt102.h index 05f30ac04..8832a73d8 100644 --- a/konsole/konsole/TEmuVt102.h +++ b/konsole/konsole/TEmuVt102.h @@ -60,7 +60,8 @@ public: void changeGUI(TEWidget* newgui); ~TEmuVt102(); - virtual void onKeyPress(TQKeyEvent*); + virtual void doKeyPress(TQKeyEvent*); + public slots: // signals incoming from TEWidget void onMouse(int cb, int cx, int cy); diff --git a/konsole/konsole/TEmulation.cpp b/konsole/konsole/TEmulation.cpp index 939139d03..7576e9688 100644 --- a/konsole/konsole/TEmulation.cpp +++ b/konsole/konsole/TEmulation.cpp @@ -98,6 +98,8 @@ TEmulation::TEmulation(TEWidget* w) scr(0), connected(false), listenToKeyPress(false), + metaKeyMode(false), + metaIsPressed(false), m_codec(0), decoder(0), keytrans(0), @@ -123,6 +125,10 @@ void TEmulation::connectGUI() this,TQT_SLOT(onHistoryCursorChange(int))); TQObject::connect(gui,TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), this,TQT_SLOT(onKeyPress(TQKeyEvent*))); + TQObject::connect(gui,TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), + this,TQT_SLOT(onKeyReleased(TQKeyEvent*))); + TQObject::connect(gui,TQT_SIGNAL(focusInSignal(TQFocusEvent*)), + this,TQT_SLOT(onFocusIn(TQFocusEvent*))); TQObject::connect(gui,TQT_SIGNAL(beginSelectionSignal(const int,const int,const bool)), this,TQT_SLOT(onSelectionBegin(const int,const int,const bool)) ); TQObject::connect(gui,TQT_SIGNAL(extendSelectionSignal(const int,const int)), @@ -151,6 +157,10 @@ void TEmulation::changeGUI(TEWidget* newgui) this,TQT_SLOT(onHistoryCursorChange(int))); TQObject::disconnect(gui,TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), this,TQT_SLOT(onKeyPress(TQKeyEvent*))); + TQObject::disconnect(gui,TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), + this,TQT_SLOT(onKeyReleased(TQKeyEvent*))); + TQObject::disconnect(gui,TQT_SIGNAL(focusInSignal(TQFocusEvent*)), + this,TQT_SLOT(onFocusIn(TQFocusEvent*))); TQObject::disconnect(gui,TQT_SIGNAL(beginSelectionSignal(const int,const int,const bool)), this,TQT_SLOT(onSelectionBegin(const int,const int,const bool)) ); TQObject::disconnect(gui,TQT_SIGNAL(extendSelectionSignal(const int,const int)), @@ -275,11 +285,30 @@ void TEmulation::onRcvChar(int c) /*! */ - void TEmulation::onKeyPress( TQKeyEvent* ev ) { if (!listenToKeyPress) return; // someone else gets the keys + + // HACK - workaround for what looks like a bug in Qt. + // Specifically keep track of when the meta button is pressed or released. + // Upon restarting TDE, restored windows do not received the correct KeyEvent state + // when multiple keys are pressed: the MetaButton is missing. + // Instead on new created window, MetaButton information is correct. + // Ex: + // Meta is pressed --> the state is correct, both before and after + // State: Before=0x0000/After=0x0800 Key: 0x1022 + // Then h is presed --> the state does not contain the MetaButton anymore + // State: Before=0x0000/After=0x0000 Key: 0x0048 + if (ev->key() == TQt::Key_Meta) + metaIsPressed = true; + + doKeyPress(ev); +} + +void TEmulation::doKeyPress( TQKeyEvent* ev ) +{ emit notifySessionState(NOTIFYNORMAL); + if (scr->getHistCursor() != scr->getHistLines() && !ev->text().isEmpty()) scr->setHistCursor(scr->getHistLines()); if (!ev->text().isEmpty()) @@ -296,6 +325,44 @@ void TEmulation::onKeyPress( TQKeyEvent* ev ) } } +void TEmulation::onKeyReleased( TQKeyEvent* ev ) +{ + if (!listenToKeyPress) return; // someone else gets the keys + + // HACK - workaround for what looks like a bug in Qt. + // Specifically keep track of when the meta button is pressed or released. + // Upon restarting TDE, restored windows do not received the correct KeyEvent state + // when multiple keys are pressed: the MetaButton is missing. + // Instead on new created window, MetaButton information is correct. + // Ex: + // Meta is pressed --> the state is correct, both before and after + // State: Before=0x0000/After=0x0800 Key: 0x1022 + // Then h is presed --> the state does not contain the MetaButton anymore + // State: Before=0x0000/After=0x0000 Key: 0x0048 + if (ev->key() == TQt::Key_Meta || !(ev->stateAfter() & TQt::MetaButton)) + metaIsPressed = false; + + doKeyReleased(ev); +} + +void TEmulation::doKeyReleased( TQKeyEvent* ke ) +{ +} + +void TEmulation::onFocusIn( TQFocusEvent* fe ) +{ + // HACK - workaround for what looks like a bug in Qt. + // Always reset the status of 'metaIsPressed' when the emulation gets the focus, + // to avoid pending cases. A pending case is a case where the emulation lost the + // focus while Meta was pressed but gets the focus when Meta is no longer pressed. + metaIsPressed = false; + doFocusIn(fe); +} + +void TEmulation::doFocusIn( TQFocusEvent* fe ) +{ +} + // Unblocking, Byte to Unicode translation --------------------------------- -- /* diff --git a/konsole/konsole/TEmulation.h b/konsole/konsole/TEmulation.h index a5f432175..9ddc2a4c7 100644 --- a/konsole/konsole/TEmulation.h +++ b/konsole/konsole/TEmulation.h @@ -55,7 +55,15 @@ public slots: // signals incoming from TEWidget virtual void onImageSizeChange(int lines, int columns); virtual void onHistoryCursorChange(int cursor); - virtual void onKeyPress(TQKeyEvent*); + + // HACK - start + void onKeyPress(TQKeyEvent*); // This should not be overwritten by derived classes + virtual void doKeyPress(TQKeyEvent*); // Instead this function should be overwritten if necessary + void onKeyReleased(TQKeyEvent*); // This should not be overwritten by derived classes + virtual void doKeyReleased(TQKeyEvent*); // Instead this function should be overwritten if necessary + void onFocusIn(TQFocusEvent*); // This should not be overwritten by derived classes + virtual void doFocusIn(TQFocusEvent*); // Instead this function should be overwritten if necessary + // HACK - end virtual void clearSelection(); virtual void copySelection(); @@ -89,6 +97,7 @@ public: virtual void setMode (int) = 0; virtual void resetMode(int) = 0; + void setMetaKeyMode(bool mode) { metaKeyMode = mode; } virtual void sendString(const char*) = 0; @@ -119,6 +128,8 @@ protected: bool connected; // communicate with widget bool listenToKeyPress; // listen to input + bool metaKeyMode; // true -> meta key is handled as Alt + bool metaIsPressed; // true -> the meta key has been pressed down - HACK void setCodec(int c); // codec number, 0 = locale, 1=utf8 diff --git a/konsole/konsole/konsole.cpp b/konsole/konsole/konsole.cpp index a7d3d7333..569110b08 100644 --- a/konsole/konsole/konsole.cpp +++ b/konsole/konsole/konsole.cpp @@ -273,6 +273,7 @@ Konsole::Konsole(const char* name, int histon, bool menubaron, bool tabbaron, bo ,b_autoResizeTabs(false) ,b_installBitmapFonts(false) ,b_framevis(true) +,b_metaAsAlt(false) ,b_fullscreen(false) ,m_menuCreated(false) ,b_warnQuit(false) @@ -1622,6 +1623,7 @@ void Konsole::readProperties(TDEConfig* config, const TQString &schema, bool glo b_bidiEnabled = config->readBoolEntry("EnableBidi",false); s_word_seps= config->readEntry("wordseps",":@-./_~"); b_framevis = config->readBoolEntry("has frame",true); + b_metaAsAlt = config->readBoolEntry("metaAsAltMode",false); TQPtrList<TEWidget> tes = activeTEs(); for (TEWidget *_te = tes.first(); _te; _te = tes.next()) { _te->setWordCharacters(s_word_seps); @@ -1636,7 +1638,10 @@ void Konsole::readProperties(TDEConfig* config, const TQString &schema, bool glo monitorSilenceSeconds=config->readUnsignedNumEntry("SilenceSeconds", 10); for (TESession *ses = sessions.first(); ses; ses = sessions.next()) + { + ses->setMetaAsAltMode(b_metaAsAlt); ses->setMonitorSilenceSeconds(monitorSilenceSeconds); + } b_xonXoff = config->readBoolEntry("XonXoff",false); b_matchTabWinTitle = config->readBoolEntry("MatchTabWinTitle",false); @@ -2187,7 +2192,9 @@ void Konsole::reparseConfiguration() curr_schema = sch->numb(); pmPath = sch->imagePath(); - for (TESession *_se = sessions.first(); _se; _se = sessions.next()) { + for (TESession *_se = sessions.first(); _se; _se = sessions.next()) + { + _se->setMetaAsAltMode(b_metaAsAlt); ColorSchema* s = colors->find( _se->schemaNo() ); if (s) { if (s->hasSchemaFileChanged()) @@ -2369,8 +2376,14 @@ void Konsole::disableMasterModeConnections() for (; to_it.current(); ++to_it) { TESession *to = to_it.current(); if (to!=from) - disconnect(from->widget(),TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), - to->getEmulation(),TQT_SLOT(onKeyPress(TQKeyEvent*))); + { + disconnect(from->widget(), TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), + to->getEmulation(), TQT_SLOT(onKeyPress(TQKeyEvent*))); + disconnect(from->widget(), TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), + to->getEmulation(), TQT_SLOT(onKeyReleased(TQKeyEvent*))); + disconnect(from->widget(), TQT_SIGNAL(focusInSignal(TQFocusEvent*)), + to->getEmulation(), TQT_SLOT(onFocusIn(TQFocusEvent*))); + } } } } @@ -2385,9 +2398,14 @@ void Konsole::enableMasterModeConnections() TQPtrListIterator<TESession> to_it(sessions); for (; to_it.current(); ++to_it) { TESession *to = to_it.current(); - if (to!=from) { - connect(from->widget(),TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), - to->getEmulation(),TQT_SLOT(onKeyPress(TQKeyEvent*))); + if (to!=from) + { + connect(from->widget(), TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), + to->getEmulation(), TQT_SLOT(onKeyPress(TQKeyEvent*))); + connect(from->widget(), TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), + to->getEmulation(), TQT_SLOT(onKeyReleased(TQKeyEvent*))); + connect(from->widget(), TQT_SIGNAL(focusInSignal(TQFocusEvent*)), + to->getEmulation(), TQT_SLOT(onFocusIn(TQFocusEvent*))); } } } @@ -2951,23 +2969,25 @@ TQString Konsole::newSession(KSimpleConfig *co, TQString program, const TQStrLis s->setProgram(TQFile::encodeName(program),cmdArgs); s->setMonitorSilenceSeconds(monitorSilenceSeconds); s->enableFullScripting(b_fullScripting); + s->setMetaAsAltMode(b_metaAsAlt); + // 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 +3003,7 @@ TQString Konsole::newSession(KSimpleConfig *co, TQString program, const TQStrLis 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); @@ -3727,8 +3747,14 @@ void Konsole::detachSession(TESession* _se) { for(; from_it.current(); ++from_it) { TESession *from = from_it.current(); if(from->isMasterMode()) + { disconnect(from->widget(), TQT_SIGNAL(keyPressedSignal(TQKeyEvent*)), - _se->getEmulation(), TQT_SLOT(onKeyPress(TQKeyEvent*))); + _se->getEmulation(), TQT_SLOT(onKeyPress(TQKeyEvent*))); + disconnect(from->widget(), TQT_SIGNAL(keyReleasedSignal(TQKeyEvent*)), + _se->getEmulation(), TQT_SLOT(onKeyReleased(TQKeyEvent*))); + disconnect(from->widget(), TQT_SIGNAL(focusInSignal(TQFocusEvent*)), + _se->getEmulation(), TQT_SLOT(onFocusIn(TQFocusEvent*))); + } } } diff --git a/konsole/konsole/konsole.h b/konsole/konsole/konsole.h index 6bd3a2e81..976ac5cf8 100644 --- a/konsole/konsole/konsole.h +++ b/konsole/konsole/konsole.h @@ -435,6 +435,7 @@ private: bool b_installBitmapFonts; bool b_framevis:1; + bool b_metaAsAlt:1; bool b_fullscreen:1; bool m_menuCreated:1; bool b_warnQuit:1; diff --git a/konsole/konsole/konsole_part.cpp b/konsole/konsole/konsole_part.cpp index f1b2f28d8..87cd2b373 100644 --- a/konsole/konsole/konsole_part.cpp +++ b/konsole/konsole/konsole_part.cpp @@ -105,6 +105,7 @@ konsolePart::konsolePart(TQWidget *_parentWidget, const char *widgetName, TQObje ,rootxpm(0) ,blinkingCursor(0) ,showFrame(0) +,metaAsAlt(0) ,m_useKonsoleSettings(0) ,selectBell(0) ,selectLineSpacing(0) @@ -431,6 +432,11 @@ void konsolePart::makeGUI() 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 @@ void konsolePart::applySettingsToGUI() 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 @@ void konsolePart::applyProperties() se->widget()->setVTFont( defaultFont ); se->setSchemaNo( curr_schema ); slotSetEncoding(); + + se->setMetaAsAltMode(b_metaAsAlt); } void konsolePart::setSettingsMenuEnabled( bool enable ) @@ -560,13 +570,13 @@ void konsolePart::readProperties() 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 @@ void konsolePart::saveProperties() 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 @@ void konsolePart::slotBlinkingCursor() 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 1fd2ac95f..766e4e5d5 100644 --- a/konsole/konsole/konsole_part.h +++ b/konsole/konsole/konsole_part.h @@ -118,6 +118,7 @@ signals: void slotSelectBell(); void slotSelectLineSpacing(); void slotBlinkingCursor(); + void slotToggleMetaAsAltMode(); void slotUseKonsoleSettings(); void slotWordSeps(); void slotSetEncoding(); @@ -136,9 +137,9 @@ signals: 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 @@ signals: TDEToggleAction* blinkingCursor; TDEToggleAction* showFrame; + TDEToggleAction* metaAsAlt; TDEToggleAction* m_useKonsoleSettings; TDESelectAction* selectBell; @@ -174,6 +176,7 @@ signals: TQString s_word_seps; // characters that are considered part of a word bool b_framevis:1; + bool b_metaAsAlt:1; bool b_histEnabled:1; bool b_useKonsoleSettings:1; bool b_autoDestroy:1; diff --git a/konsole/konsole/session.cpp b/konsole/konsole/session.cpp index 8ecf469af..a6103da4f 100644 --- a/konsole/konsole/session.cpp +++ b/konsole/konsole/session.cpp @@ -464,6 +464,12 @@ void TESession::setFontNo(int fn) font_no = fn; } +void TESession::setMetaAsAltMode(bool mode) +{ + if (em) + em->setMetaKeyMode(mode); +} + void TESession::setTitle(const TQString& _title) { title = _title; diff --git a/konsole/konsole/session.h b/konsole/konsole/session.h index d15b8b5bd..bfcafdf47 100644 --- a/konsole/konsole/session.h +++ b/konsole/konsole/session.h @@ -123,6 +123,7 @@ public: void setSize(TQSize size); void setFont(const TQString &font); TQString font(); + void setMetaAsAltMode(bool mode); public slots: |