-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index 6d5c6e9..b1ad008 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -935,199 +935,204 @@ void TEWidget::setSelection(const QString& t) | |||
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, state %d",ke->key(), ke->state()); |
1032 | 1032 | ||
1033 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker | 1033 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { |
1034 | //lets hardcode this sucker | ||
1034 | 1035 | ||
1035 | // qDebug("key pressed 2 is 0x%x",ke->key()); | 1036 | // qDebug("key pressed 2 is 0x%x",ke->key()); |
1036 | emitText("\\"); // expose | 1037 | emitText("\\"); // expose |
1037 | } else | 1038 | } |
1039 | else if( ke->state() == ControlButton && ke->key() == Key_V) { | ||
1040 | pasteClipboard(); | ||
1041 | } | ||
1042 | else | ||
1038 | emit keyPressedSignal(ke); // expose | 1043 | emit keyPressedSignal(ke); // expose |
1039 | ke->accept(); | 1044 | ke->accept(); |
1040 | #ifdef FAKE_CTRL_AND_ALT | 1045 | #ifdef FAKE_CTRL_AND_ALT |
1041 | if ( dele ) delete e; | 1046 | if ( dele ) delete e; |
1042 | #endif | 1047 | #endif |
1043 | return true; // stop the event | 1048 | return true; // stop the event |
1044 | } | 1049 | } |
1045 | if ( e->type() == QEvent::Enter ) { | 1050 | if ( e->type() == QEvent::Enter ) { |
1046 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1051 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
1047 | this, SLOT(onClearSelection()) ); | 1052 | this, SLOT(onClearSelection()) ); |
1048 | } | 1053 | } |
1049 | if ( e->type() == QEvent::Leave ) { | 1054 | if ( e->type() == QEvent::Leave ) { |
1050 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 1055 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
1051 | this, SLOT(onClearSelection()) ); | 1056 | this, SLOT(onClearSelection()) ); |
1052 | } | 1057 | } |
1053 | return QFrame::eventFilter( obj, e ); | 1058 | return QFrame::eventFilter( obj, e ); |
1054 | } | 1059 | } |
1055 | 1060 | ||
1056 | /* ------------------------------------------------------------------------- */ | 1061 | /* ------------------------------------------------------------------------- */ |
1057 | /* */ | 1062 | /* */ |
1058 | /* Frame */ | 1063 | /* Frame */ |
1059 | /* */ | 1064 | /* */ |
1060 | /* ------------------------------------------------------------------------- */ | 1065 | /* ------------------------------------------------------------------------- */ |
1061 | 1066 | ||
1062 | void TEWidget::frameChanged() | 1067 | void TEWidget::frameChanged() |
1063 | { | 1068 | { |
1064 | propagateSize(); | 1069 | propagateSize(); |
1065 | update(); | 1070 | update(); |
1066 | } | 1071 | } |
1067 | 1072 | ||
1068 | /* ------------------------------------------------------------------------- */ | 1073 | /* ------------------------------------------------------------------------- */ |
1069 | /* */ | 1074 | /* */ |
1070 | /* Sound */ | 1075 | /* Sound */ |
1071 | /* */ | 1076 | /* */ |
1072 | /* ------------------------------------------------------------------------- */ | 1077 | /* ------------------------------------------------------------------------- */ |
1073 | 1078 | ||
1074 | void TEWidget::Bell() | 1079 | void TEWidget::Bell() |
1075 | { | 1080 | { |
1076 | QApplication::beep(); | 1081 | QApplication::beep(); |
1077 | } | 1082 | } |
1078 | 1083 | ||
1079 | /* ------------------------------------------------------------------------- */ | 1084 | /* ------------------------------------------------------------------------- */ |
1080 | /* */ | 1085 | /* */ |
1081 | /* Auxiluary */ | 1086 | /* Auxiluary */ |
1082 | /* */ | 1087 | /* */ |
1083 | /* ------------------------------------------------------------------------- */ | 1088 | /* ------------------------------------------------------------------------- */ |
1084 | 1089 | ||
1085 | void TEWidget::clearImage() | 1090 | void TEWidget::clearImage() |
1086 | // initialize the image | 1091 | // initialize the image |
1087 | // for internal use only | 1092 | // for internal use only |
1088 | { | 1093 | { |
1089 | for (int y = 0; y < lines; y++) | 1094 | for (int y = 0; y < lines; y++) |
1090 | for (int x = 0; x < columns; x++) | 1095 | for (int x = 0; x < columns; x++) |
1091 | { | 1096 | { |
1092 | image[loc(x,y)].c = 0xff; //' '; | 1097 | image[loc(x,y)].c = 0xff; //' '; |
1093 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | 1098 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; |
1094 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | 1099 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; |
1095 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | 1100 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; |
1096 | } | 1101 | } |
1097 | } | 1102 | } |
1098 | 1103 | ||
1099 | // Create Image /////////////////////////////////////////////////////// | 1104 | // Create Image /////////////////////////////////////////////////////// |
1100 | 1105 | ||
1101 | void TEWidget::calcGeometry() | 1106 | void TEWidget::calcGeometry() |
1102 | { | 1107 | { |
1103 | //FIXME: set rimX == rimY == 0 when running in full screen mode. | 1108 | //FIXME: set rimX == rimY == 0 when running in full screen mode. |
1104 | 1109 | ||
1105 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1110 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), |
1106 | contentsRect().height()); | 1111 | contentsRect().height()); |
1107 | switch(scrollLoc) | 1112 | switch(scrollLoc) |
1108 | { | 1113 | { |
1109 | case SCRNONE : | 1114 | case SCRNONE : |
1110 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | 1115 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; |
1111 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | 1116 | blX = (contentsRect().width() - (columns*font_w) ) / 2; |
1112 | brX = blX; | 1117 | brX = blX; |
1113 | scrollbar->hide(); | 1118 | scrollbar->hide(); |
1114 | break; | 1119 | break; |
1115 | case SCRLEFT : | 1120 | case SCRLEFT : |
1116 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1121 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1117 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1122 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1118 | blX = brX + scrollbar->width(); | 1123 | blX = brX + scrollbar->width(); |
1119 | scrollbar->move(contentsRect().topLeft()); | 1124 | scrollbar->move(contentsRect().topLeft()); |
1120 | scrollbar->show(); | 1125 | scrollbar->show(); |
1121 | break; | 1126 | break; |
1122 | case SCRRIGHT: | 1127 | case SCRRIGHT: |
1123 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1128 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1124 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1129 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1125 | brX = blX; | 1130 | brX = blX; |
1126 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | 1131 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); |
1127 | scrollbar->show(); | 1132 | scrollbar->show(); |
1128 | break; | 1133 | break; |
1129 | } | 1134 | } |
1130 | //FIXME: support 'rounding' styles | 1135 | //FIXME: support 'rounding' styles |
1131 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | 1136 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; |
1132 | bY = (contentsRect().height() - (lines *font_h)) / 2; | 1137 | bY = (contentsRect().height() - (lines *font_h)) / 2; |
1133 | } | 1138 | } |