-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index 0cd7ed1..a111e18 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -896,193 +896,193 @@ void TEWidget::setMouseMarks(bool on) | |||
896 | 896 | ||
897 | /* ------------------------------------------------------------------------- */ | 897 | /* ------------------------------------------------------------------------- */ |
898 | /* */ | 898 | /* */ |
899 | /* Clipboard */ | 899 | /* Clipboard */ |
900 | /* */ | 900 | /* */ |
901 | /* ------------------------------------------------------------------------- */ | 901 | /* ------------------------------------------------------------------------- */ |
902 | 902 | ||
903 | #undef KeyPress | 903 | #undef KeyPress |
904 | 904 | ||
905 | void TEWidget::emitSelection() | 905 | void TEWidget::emitSelection() |
906 | // Paste Clipboard by simulating keypress events | 906 | // Paste Clipboard by simulating keypress events |
907 | { | 907 | { |
908 | #ifndef QT_NO_CLIPBOARD | 908 | #ifndef QT_NO_CLIPBOARD |
909 | QString text = QApplication::clipboard()->text(); | 909 | QString text = QApplication::clipboard()->text(); |
910 | if ( ! text.isNull() ) | 910 | if ( ! text.isNull() ) |
911 | { | 911 | { |
912 | text.replace(QRegExp("\n"), "\r"); | 912 | text.replace(QRegExp("\n"), "\r"); |
913 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 913 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
914 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 914 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
915 | emit clearSelectionSignal(); | 915 | emit clearSelectionSignal(); |
916 | } | 916 | } |
917 | #endif | 917 | #endif |
918 | } | 918 | } |
919 | 919 | ||
920 | void TEWidget::emitText(QString text) | 920 | void TEWidget::emitText(QString text) |
921 | { | 921 | { |
922 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 922 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
923 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 923 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
924 | } | 924 | } |
925 | 925 | ||
926 | void TEWidget::pasteClipboard( ) | 926 | void TEWidget::pasteClipboard( ) |
927 | { | 927 | { |
928 | emitSelection(); | 928 | emitSelection(); |
929 | } | 929 | } |
930 | 930 | ||
931 | void TEWidget::setSelection(const QString& t) | 931 | void TEWidget::setSelection(const QString& t) |
932 | { | 932 | { |
933 | #ifndef QT_NO_CLIPBOARD | 933 | #ifndef QT_NO_CLIPBOARD |
934 | // Disconnect signal while WE set the clipboard | 934 | // Disconnect signal while WE set the clipboard |
935 | QObject *cb = QApplication::clipboard(); | 935 | QObject *cb = QApplication::clipboard(); |
936 | QObject::disconnect( cb, SIGNAL(dataChanged()), | 936 | QObject::disconnect( cb, SIGNAL(dataChanged()), |
937 | this, SLOT(onClearSelection()) ); | 937 | this, SLOT(onClearSelection()) ); |
938 | 938 | ||
939 | QApplication::clipboard()->setText(t); | 939 | QApplication::clipboard()->setText(t); |
940 | 940 | ||
941 | QObject::connect( cb, SIGNAL(dataChanged()), | 941 | QObject::connect( cb, SIGNAL(dataChanged()), |
942 | this, SLOT(onClearSelection()) ); | 942 | this, SLOT(onClearSelection()) ); |
943 | #endif | 943 | #endif |
944 | } | 944 | } |
945 | 945 | ||
946 | void TEWidget::onClearSelection() | 946 | void TEWidget::onClearSelection() |
947 | { | 947 | { |
948 | emit clearSelectionSignal(); | 948 | emit clearSelectionSignal(); |
949 | } | 949 | } |
950 | 950 | ||
951 | /* ------------------------------------------------------------------------- */ | 951 | /* ------------------------------------------------------------------------- */ |
952 | /* */ | 952 | /* */ |
953 | /* Keyboard */ | 953 | /* Keyboard */ |
954 | /* */ | 954 | /* */ |
955 | /* ------------------------------------------------------------------------- */ | 955 | /* ------------------------------------------------------------------------- */ |
956 | 956 | ||
957 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' | 957 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' |
958 | // due to a bug in `QT' or the ignorance of the author to prevent | 958 | // due to a bug in `QT' or the ignorance of the author to prevent |
959 | // repaint events being emitted to the screen whenever one leaves | 959 | // repaint events being emitted to the screen whenever one leaves |
960 | // or reenters the screen to/from another application. | 960 | // or reenters the screen to/from another application. |
961 | // | 961 | // |
962 | // Troll says one needs to change focusInEvent() and focusOutEvent(), | 962 | // Troll says one needs to change focusInEvent() and focusOutEvent(), |
963 | // which would also let you have an in-focus cursor and an out-focus | 963 | // which would also let you have an in-focus cursor and an out-focus |
964 | // cursor like xterm does. | 964 | // cursor like xterm does. |
965 | 965 | ||
966 | // for the auto-hide cursor feature, I added empty focusInEvent() and | 966 | // for the auto-hide cursor feature, I added empty focusInEvent() and |
967 | // focusOutEvent() so that update() isn't called. | 967 | // focusOutEvent() so that update() isn't called. |
968 | // For auto-hide, we need to get keypress-events, but we only get them when | 968 | // For auto-hide, we need to get keypress-events, but we only get them when |
969 | // we have focus. | 969 | // we have focus. |
970 | 970 | ||
971 | void TEWidget::doScroll(int lines) | 971 | void TEWidget::doScroll(int lines) |
972 | { | 972 | { |
973 | scrollbar->setValue(scrollbar->value()+lines); | 973 | scrollbar->setValue(scrollbar->value()+lines); |
974 | } | 974 | } |
975 | 975 | ||
976 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | 976 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) |
977 | { | 977 | { |
978 | if ( (e->type() == QEvent::Accel || | 978 | if ( (e->type() == QEvent::Accel || |
979 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | 979 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { |
980 | static_cast<QKeyEvent *>( e )->ignore(); | 980 | static_cast<QKeyEvent *>( e )->ignore(); |
981 | return true; | 981 | return true; |
982 | } | 982 | } |
983 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | 983 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) |
984 | return FALSE; // not us | 984 | return FALSE; // not us |
985 | if ( e->type() == QEvent::Wheel) { | 985 | if ( e->type() == QEvent::Wheel) { |
986 | QApplication::sendEvent(scrollbar, e); | 986 | QApplication::sendEvent(scrollbar, e); |
987 | } | 987 | } |
988 | 988 | ||
989 | #ifdef FAKE_CTRL_AND_ALT | 989 | #ifdef FAKE_CTRL_AND_ALT |
990 | static bool control = FALSE; | 990 | static bool control = FALSE; |
991 | static bool alt = FALSE; | 991 | static bool alt = FALSE; |
992 | qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); | 992 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); |
993 | bool dele=FALSE; | 993 | bool dele=FALSE; |
994 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 994 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
995 | QKeyEvent* ke = (QKeyEvent*)e; | 995 | QKeyEvent* ke = (QKeyEvent*)e; |
996 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 996 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
997 | switch (ke->key()) { | 997 | switch (ke->key()) { |
998 | case Key_F9: // let this be "Control" | 998 | case Key_F9: // let this be "Control" |
999 | control = keydown; | 999 | control = keydown; |
1000 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 1000 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
1001 | dele=TRUE; | 1001 | dele=TRUE; |
1002 | break; | 1002 | break; |
1003 | case Key_F13: // let this be "Alt" | 1003 | case Key_F13: // let this be "Alt" |
1004 | alt = keydown; | 1004 | alt = keydown; |
1005 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | 1005 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); |
1006 | dele=TRUE; | 1006 | dele=TRUE; |
1007 | break; | 1007 | break; |
1008 | default: | 1008 | default: |
1009 | if ( control ) { | 1009 | if ( control ) { |
1010 | int a = toupper(ke->ascii())-64; | 1010 | int a = toupper(ke->ascii())-64; |
1011 | if ( a >= 0 && a < ' ' ) { | 1011 | if ( a >= 0 && a < ' ' ) { |
1012 | e = new QKeyEvent(e->type(), ke->key(), | 1012 | e = new QKeyEvent(e->type(), ke->key(), |
1013 | a, ke->state()|ControlButton, QChar(a,0)); | 1013 | a, ke->state()|ControlButton, QChar(a,0)); |
1014 | dele=TRUE; | 1014 | dele=TRUE; |
1015 | } | 1015 | } |
1016 | } | 1016 | } |
1017 | if ( alt ) { | 1017 | if ( alt ) { |
1018 | e = new QKeyEvent(e->type(), ke->key(), | 1018 | e = new QKeyEvent(e->type(), ke->key(), |
1019 | ke->ascii(), ke->state()|AltButton, ke->text()); | 1019 | ke->ascii(), ke->state()|AltButton, ke->text()); |
1020 | dele=TRUE; | 1020 | dele=TRUE; |
1021 | } | 1021 | } |
1022 | } | 1022 | } |
1023 | } | 1023 | } |
1024 | #endif | 1024 | #endif |
1025 | 1025 | ||
1026 | if ( e->type() == QEvent::KeyPress ) { | 1026 | if ( e->type() == QEvent::KeyPress ) { |
1027 | QKeyEvent* ke = (QKeyEvent*)e; | 1027 | QKeyEvent* ke = (QKeyEvent*)e; |
1028 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1028 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1029 | // know where the current selection is. | 1029 | // know where the current selection is. |
1030 | 1030 | ||
1031 | qDebug("key pressed is 0x%x",ke->key()); | 1031 | qDebug("key pressed is 0x%x",ke->key()); |
1032 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker | 1032 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker |
1033 | qDebug("key pressed 2 is 0x%x",ke->key()); | 1033 | qDebug("key pressed 2 is 0x%x",ke->key()); |
1034 | emitText("\\"); // expose | 1034 | emitText("\\"); // expose |
1035 | } else | 1035 | } else |
1036 | emit keyPressedSignal(ke); // expose | 1036 | emit keyPressedSignal(ke); // expose |
1037 | ke->accept(); | 1037 | ke->accept(); |
1038 | #ifdef FAKE_CTRL_AND_ALT | 1038 | #ifdef FAKE_CTRL_AND_ALT |
1039 | if ( dele ) delete e; | 1039 | if ( dele ) delete e; |
1040 | #endif | 1040 | #endif |
1041 | return true; // stop the event | 1041 | return true; // stop the event |
1042 | } | 1042 | } |
1043 | if ( e->type() == QEvent::Enter ) { | 1043 | if ( e->type() == QEvent::Enter ) { |
1044 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1044 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
1045 | this, SLOT(onClearSelection()) ); | 1045 | this, SLOT(onClearSelection()) ); |
1046 | } | 1046 | } |
1047 | if ( e->type() == QEvent::Leave ) { | 1047 | if ( e->type() == QEvent::Leave ) { |
1048 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 1048 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
1049 | this, SLOT(onClearSelection()) ); | 1049 | this, SLOT(onClearSelection()) ); |
1050 | } | 1050 | } |
1051 | return QFrame::eventFilter( obj, e ); | 1051 | return QFrame::eventFilter( obj, e ); |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | /* ------------------------------------------------------------------------- */ | 1054 | /* ------------------------------------------------------------------------- */ |
1055 | /* */ | 1055 | /* */ |
1056 | /* Frame */ | 1056 | /* Frame */ |
1057 | /* */ | 1057 | /* */ |
1058 | /* ------------------------------------------------------------------------- */ | 1058 | /* ------------------------------------------------------------------------- */ |
1059 | 1059 | ||
1060 | void TEWidget::frameChanged() | 1060 | void TEWidget::frameChanged() |
1061 | { | 1061 | { |
1062 | propagateSize(); | 1062 | propagateSize(); |
1063 | update(); | 1063 | update(); |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | /* ------------------------------------------------------------------------- */ | 1066 | /* ------------------------------------------------------------------------- */ |
1067 | /* */ | 1067 | /* */ |
1068 | /* Sound */ | 1068 | /* Sound */ |
1069 | /* */ | 1069 | /* */ |
1070 | /* ------------------------------------------------------------------------- */ | 1070 | /* ------------------------------------------------------------------------- */ |
1071 | 1071 | ||
1072 | void TEWidget::Bell() | 1072 | void TEWidget::Bell() |
1073 | { | 1073 | { |
1074 | QApplication::beep(); | 1074 | QApplication::beep(); |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | /* ------------------------------------------------------------------------- */ | 1077 | /* ------------------------------------------------------------------------- */ |
1078 | /* */ | 1078 | /* */ |
1079 | /* Auxiluary */ | 1079 | /* Auxiluary */ |
1080 | /* */ | 1080 | /* */ |
1081 | /* ------------------------------------------------------------------------- */ | 1081 | /* ------------------------------------------------------------------------- */ |
1082 | 1082 | ||
1083 | void TEWidget::clearImage() | 1083 | void TEWidget::clearImage() |
1084 | // initialize the image | 1084 | // initialize the image |
1085 | // for internal use only | 1085 | // for internal use only |
1086 | { | 1086 | { |
1087 | for (int y = 0; y < lines; y++) | 1087 | for (int y = 0; y < lines; y++) |
1088 | for (int x = 0; x < columns; x++) | 1088 | for (int x = 0; x < columns; x++) |