author | llornkcor <llornkcor> | 2004-12-28 23:17:43 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-12-28 23:17:43 (UTC) |
commit | e2d6f156eacc312f270a1b5c3830e58be8941460 (patch) (unidiff) | |
tree | 85cc827910cd5617f01de4ded6cbc302ffd73bfe | |
parent | 47b3f934ed4f5d84356b5b052aed018dc97ab6a7 (diff) | |
download | opie-e2d6f156eacc312f270a1b5c3830e58be8941460.zip opie-e2d6f156eacc312f270a1b5c3830e58be8941460.tar.gz opie-e2d6f156eacc312f270a1b5c3830e58be8941460.tar.bz2 |
fix compile
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index 3cb1c0a..5171bf1 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -880,550 +880,552 @@ void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) | |||
880 | endSel.setX(x); | 880 | endSel.setX(x); |
881 | actSel = 2; // within selection | 881 | actSel = 2; // within selection |
882 | emit extendSelectionSignal( endSel.x(), endSel.y() ); | 882 | emit extendSelectionSignal( endSel.x(), endSel.y() ); |
883 | emit endSelectionSignal(preserve_line_breaks); | 883 | emit endSelectionSignal(preserve_line_breaks); |
884 | preserve_line_breaks = TRUE; | 884 | preserve_line_breaks = TRUE; |
885 | } | 885 | } |
886 | } | 886 | } |
887 | 887 | ||
888 | void TEWidget::focusInEvent( QFocusEvent * ) | 888 | void TEWidget::focusInEvent( QFocusEvent * ) |
889 | { | 889 | { |
890 | 890 | ||
891 | // do nothing, to prevent repainting | 891 | // do nothing, to prevent repainting |
892 | } | 892 | } |
893 | 893 | ||
894 | 894 | ||
895 | void TEWidget::focusOutEvent( QFocusEvent * ) | 895 | void TEWidget::focusOutEvent( QFocusEvent * ) |
896 | { | 896 | { |
897 | // do nothing, to prevent repainting | 897 | // do nothing, to prevent repainting |
898 | } | 898 | } |
899 | 899 | ||
900 | bool TEWidget::focusNextPrevChild( bool next ) | 900 | bool TEWidget::focusNextPrevChild( bool next ) |
901 | { | 901 | { |
902 | if (next) | 902 | if (next) |
903 | return false; // This disables changing the active part in konqueror | 903 | return false; // This disables changing the active part in konqueror |
904 | // when pressing Tab | 904 | // when pressing Tab |
905 | return QFrame::focusNextPrevChild( next ); | 905 | return QFrame::focusNextPrevChild( next ); |
906 | } | 906 | } |
907 | 907 | ||
908 | 908 | ||
909 | int TEWidget::charClass(char ch) const | 909 | int TEWidget::charClass(char ch) const |
910 | { | 910 | { |
911 | // This might seem like overkill, but imagine if ch was a Unicode | 911 | // This might seem like overkill, but imagine if ch was a Unicode |
912 | // character (Qt 2.0 QChar) - it might then be sensible to separate | 912 | // character (Qt 2.0 QChar) - it might then be sensible to separate |
913 | // the different language ranges, etc. | 913 | // the different language ranges, etc. |
914 | 914 | ||
915 | if ( isspace(ch) ) return ' '; | 915 | if ( isspace(ch) ) return ' '; |
916 | 916 | ||
917 | static const char *word_characters = ":@-./_~"; | 917 | static const char *word_characters = ":@-./_~"; |
918 | if ( isalnum(ch) || strchr(word_characters, ch) ) | 918 | if ( isalnum(ch) || strchr(word_characters, ch) ) |
919 | return 'a'; | 919 | return 'a'; |
920 | 920 | ||
921 | // Everything else is weird | 921 | // Everything else is weird |
922 | return 1; | 922 | return 1; |
923 | } | 923 | } |
924 | 924 | ||
925 | void TEWidget::setMouseMarks(bool on) | 925 | void TEWidget::setMouseMarks(bool on) |
926 | { | 926 | { |
927 | mouse_marks = on; | 927 | mouse_marks = on; |
928 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); | 928 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); |
929 | } | 929 | } |
930 | 930 | ||
931 | /* ------------------------------------------------------------------------- */ | 931 | /* ------------------------------------------------------------------------- */ |
932 | /* */ | 932 | /* */ |
933 | /* Clipboard */ | 933 | /* Clipboard */ |
934 | /* */ | 934 | /* */ |
935 | /* ------------------------------------------------------------------------- */ | 935 | /* ------------------------------------------------------------------------- */ |
936 | 936 | ||
937 | #undef KeyPress | 937 | #undef KeyPress |
938 | 938 | ||
939 | void TEWidget::emitSelection() | 939 | void TEWidget::emitSelection() |
940 | // Paste Clipboard by simulating keypress events | 940 | // Paste Clipboard by simulating keypress events |
941 | { | 941 | { |
942 | #ifndef QT_NO_CLIPBOARD | 942 | #ifndef QT_NO_CLIPBOARD |
943 | QString text = QApplication::clipboard()->text(); | 943 | QString text = QApplication::clipboard()->text(); |
944 | //odebug << text << oendl; | 944 | //odebug << text << oendl; |
945 | if ( ! text.isNull()) | 945 | if ( ! text.isNull()) |
946 | { | 946 | { |
947 | text.replace(QRegExp("\n"), "\r"); | 947 | text.replace(QRegExp("\n"), "\r"); |
948 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 948 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
949 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 949 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
950 | emit clearSelectionSignal(); | 950 | emit clearSelectionSignal(); |
951 | } | 951 | } |
952 | #endif | 952 | #endif |
953 | } | 953 | } |
954 | 954 | ||
955 | void TEWidget::emitText(QString text) | 955 | void TEWidget::emitText(QString text) |
956 | { | 956 | { |
957 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 957 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
958 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 958 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
959 | } | 959 | } |
960 | 960 | ||
961 | void TEWidget::pasteClipboard( ) | 961 | void TEWidget::pasteClipboard( ) |
962 | { | 962 | { |
963 | emitSelection(); | 963 | emitSelection(); |
964 | } | 964 | } |
965 | 965 | ||
966 | void TEWidget::setSelection(const QString& t) | 966 | void TEWidget::setSelection(const QString& t) |
967 | { | 967 | { |
968 | #ifndef QT_NO_CLIPBOARD | 968 | #ifndef QT_NO_CLIPBOARD |
969 | // Disconnect signal while WE set the clipboard | 969 | // Disconnect signal while WE set the clipboard |
970 | QObject *cb = QApplication::clipboard(); | 970 | QObject *cb = QApplication::clipboard(); |
971 | QObject::disconnect( cb, SIGNAL(dataChanged()), | 971 | QObject::disconnect( cb, SIGNAL(dataChanged()), |
972 | this, SLOT(onClearSelection()) ); | 972 | this, SLOT(onClearSelection()) ); |
973 | 973 | ||
974 | QApplication::clipboard()->setText(t); | 974 | QApplication::clipboard()->setText(t); |
975 | 975 | ||
976 | QObject::connect( cb, SIGNAL(dataChanged()), | 976 | QObject::connect( cb, SIGNAL(dataChanged()), |
977 | this, SLOT(onClearSelection()) ); | 977 | this, SLOT(onClearSelection()) ); |
978 | #endif | 978 | #endif |
979 | } | 979 | } |
980 | 980 | ||
981 | void TEWidget::onClearSelection() | 981 | void TEWidget::onClearSelection() |
982 | { | 982 | { |
983 | emit clearSelectionSignal(); | 983 | emit clearSelectionSignal(); |
984 | } | 984 | } |
985 | 985 | ||
986 | /* ------------------------------------------------------------------------- */ | 986 | /* ------------------------------------------------------------------------- */ |
987 | /* */ | 987 | /* */ |
988 | /* Keyboard */ | 988 | /* Keyboard */ |
989 | /* */ | 989 | /* */ |
990 | /* ------------------------------------------------------------------------- */ | 990 | /* ------------------------------------------------------------------------- */ |
991 | 991 | ||
992 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' | 992 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' |
993 | // due to a bug in `QT' or the ignorance of the author to prevent | 993 | // due to a bug in `QT' or the ignorance of the author to prevent |
994 | // repaint events being emitted to the screen whenever one leaves | 994 | // repaint events being emitted to the screen whenever one leaves |
995 | // or reenters the screen to/from another application. | 995 | // or reenters the screen to/from another application. |
996 | // | 996 | // |
997 | // Troll says one needs to change focusInEvent() and focusOutEvent(), | 997 | // Troll says one needs to change focusInEvent() and focusOutEvent(), |
998 | // which would also let you have an in-focus cursor and an out-focus | 998 | // which would also let you have an in-focus cursor and an out-focus |
999 | // cursor like xterm does. | 999 | // cursor like xterm does. |
1000 | 1000 | ||
1001 | // for the auto-hide cursor feature, I added empty focusInEvent() and | 1001 | // for the auto-hide cursor feature, I added empty focusInEvent() and |
1002 | // focusOutEvent() so that update() isn't called. | 1002 | // focusOutEvent() so that update() isn't called. |
1003 | // For auto-hide, we need to get keypress-events, but we only get them when | 1003 | // For auto-hide, we need to get keypress-events, but we only get them when |
1004 | // we have focus. | 1004 | // we have focus. |
1005 | 1005 | ||
1006 | void TEWidget::doScroll(int lines) | 1006 | void TEWidget::doScroll(int lines) |
1007 | { | 1007 | { |
1008 | scrollbar->setValue(scrollbar->value()+lines); | 1008 | scrollbar->setValue(scrollbar->value()+lines); |
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | void TEWidget::doHScroll(int lines) { | 1011 | void TEWidget::doHScroll(int lines) { |
1012 | hScrollbar->setValue( hScrollbar->value()+lines); | 1012 | hScrollbar->setValue( hScrollbar->value()+lines); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | 1015 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) |
1016 | { | 1016 | { |
1017 | if ( (e->type() == QEvent::Accel || | 1017 | if ( (e->type() == QEvent::Accel || |
1018 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | 1018 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { |
1019 | static_cast<QKeyEvent *>( e )->ignore(); | 1019 | static_cast<QKeyEvent *>( e )->ignore(); |
1020 | return true; | 1020 | return true; |
1021 | } | 1021 | } |
1022 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | 1022 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) |
1023 | return FALSE; // not us | 1023 | return FALSE; // not us |
1024 | if ( e->type() == QEvent::Wheel) { | 1024 | if ( e->type() == QEvent::Wheel) { |
1025 | QApplication::sendEvent(scrollbar, e); | 1025 | QApplication::sendEvent(scrollbar, e); |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | #ifdef FAKE_CTRL_AND_ALT | 1028 | #ifdef FAKE_CTRL_AND_ALT |
1029 | static bool control = FALSE; | 1029 | static bool control = FALSE; |
1030 | static bool alt = FALSE; | 1030 | static bool alt = FALSE; |
1031 | // odebug << " Has a keyboard with no CTRL and ALT keys, but we fake it:" << oendl; | 1031 | // odebug << " Has a keyboard with no CTRL and ALT keys, but we fake it:" << oendl; |
1032 | bool dele=FALSE; | 1032 | bool dele=FALSE; |
1033 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1033 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1034 | QKeyEvent* ke = (QKeyEvent*)e; | 1034 | QKeyEvent* ke = (QKeyEvent*)e; |
1035 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 1035 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
1036 | switch (ke->key()) { | 1036 | switch (ke->key()) { |
1037 | case Key_F9: // let this be "Control" | 1037 | case Key_F9: // let this be "Control" |
1038 | control = keydown; | 1038 | control = keydown; |
1039 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 1039 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
1040 | dele=TRUE; | 1040 | dele=TRUE; |
1041 | break; | 1041 | break; |
1042 | case Key_F13: // let this be "Alt" | 1042 | case Key_F13: // let this be "Alt" |
1043 | alt = keydown; | 1043 | alt = keydown; |
1044 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | 1044 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); |
1045 | dele=TRUE; | 1045 | dele=TRUE; |
1046 | break; | 1046 | break; |
1047 | default: | 1047 | default: |
1048 | if ( control ) { | 1048 | if ( control ) { |
1049 | int a = toupper(ke->ascii())-64; | 1049 | int a = toupper(ke->ascii())-64; |
1050 | if ( a >= 0 && a < ' ' ) { | 1050 | if ( a >= 0 && a < ' ' ) { |
1051 | e = new QKeyEvent(e->type(), ke->key(), | 1051 | e = new QKeyEvent(e->type(), ke->key(), |
1052 | a, ke->state()|ControlButton, QChar(a,0)); | 1052 | a, ke->state()|ControlButton, QChar(a,0)); |
1053 | dele=TRUE; | 1053 | dele=TRUE; |
1054 | } | 1054 | } |
1055 | } | 1055 | } |
1056 | if ( alt ) { | 1056 | if ( alt ) { |
1057 | e = new QKeyEvent(e->type(), ke->key(), | 1057 | e = new QKeyEvent(e->type(), ke->key(), |
1058 | ke->ascii(), ke->state()|AltButton, ke->text()); | 1058 | ke->ascii(), ke->state()|AltButton, ke->text()); |
1059 | dele=TRUE; | 1059 | dele=TRUE; |
1060 | } | 1060 | } |
1061 | } | 1061 | } |
1062 | } | 1062 | } |
1063 | #endif | 1063 | #endif |
1064 | 1064 | ||
1065 | if ( e->type() == QEvent::KeyPress ) { | 1065 | if ( e->type() == QEvent::KeyPress ) { |
1066 | QKeyEvent* ke = (QKeyEvent*)e; | 1066 | QKeyEvent* ke = (QKeyEvent*)e; |
1067 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1067 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1068 | // know where the current selection is. | 1068 | // know where the current selection is. |
1069 | 1069 | ||
1070 | // odebug << "key pressed is 0x" << ke->key() << ", ascii is 0x" << ke->ascii() << ", state " << ke->state() << "" << oendl; | 1070 | // odebug << "key pressed is 0x" << ke->key() << ", ascii is 0x" << ke->ascii() << ", state " << ke->state() << "" << oendl; |
1071 | 1071 | ||
1072 | bool special_function = true; | 1072 | bool special_function = true; |
1073 | switch(ke->key()) { | 1073 | switch(ke->key()) { |
1074 | //case 0x201b: // fn-5 | 1074 | //case 0x201b: // fn-5 |
1075 | //case Key_F1: | 1075 | //case Key_F1: |
1076 | // switch sessions (?) | 1076 | // switch sessions (?) |
1077 | // emitText("\\"); // expose (??) | 1077 | // emitText("\\"); // expose (??) |
1078 | // break; | 1078 | // break; |
1079 | 1079 | ||
1080 | case 0x2016: // fn-p | 1080 | case 0x2016: // fn-p |
1081 | case Key_F2: | 1081 | case Key_F2: |
1082 | pasteClipboard(); | 1082 | pasteClipboard(); |
1083 | break; | 1083 | break; |
1084 | 1084 | ||
1085 | case 0x2018: // fn-S | 1085 | case 0x2018: // fn-S |
1086 | case Key_F3: | 1086 | case Key_F3: |
1087 | emit changeSession(1); | 1087 | emit changeSession(1); |
1088 | break; | 1088 | break; |
1089 | 1089 | ||
1090 | case 0x2019: // fn-n | 1090 | case 0x2019: // fn-n |
1091 | emit newSession(); | 1091 | emit newSession(); |
1092 | break; | 1092 | break; |
1093 | 1093 | ||
1094 | case Qt::Key_Tab: | 1094 | case Qt::Key_Tab: |
1095 | if (ke->state() == ControlButton) { | 1095 | if (ke->state() == ControlButton) { |
1096 | emit changeSession(1); | 1096 | emit changeSession(1); |
1097 | } else { | 1097 | } else { |
1098 | special_function = false; | 1098 | special_function = false; |
1099 | } | 1099 | } |
1100 | break; | 1100 | break; |
1101 | 1101 | ||
1102 | #if 0 | 1102 | #if 0 |
1103 | case Qt::Key_Left: | 1103 | case Qt::Key_Left: |
1104 | if (vcolumns == 0) { | 1104 | if (vcolumns == 0) { |
1105 | emit changeSession(-1); | 1105 | emit changeSession(-1); |
1106 | } else { | 1106 | } else { |
1107 | special_function = false; | 1107 | special_function = false; |
1108 | } | 1108 | } |
1109 | break; | 1109 | break; |
1110 | 1110 | ||
1111 | case Qt::Key_Right: | 1111 | case Qt::Key_Right: |
1112 | if (vcolumns == 0) { | 1112 | if (vcolumns == 0) { |
1113 | emit changeSession(1); | 1113 | emit changeSession(1); |
1114 | } else { | 1114 | } else { |
1115 | special_function = false; | 1115 | special_function = false; |
1116 | } | 1116 | } |
1117 | break; | 1117 | break; |
1118 | #endif | 1118 | #endif |
1119 | 1119 | ||
1120 | case 0x201b: // fn-5 | 1120 | case 0x201b: // fn-5 |
1121 | case Key_F4: | 1121 | case Key_F4: |
1122 | emit toggleFullScreen(); | 1122 | emit toggleFullScreen(); |
1123 | break; | 1123 | break; |
1124 | 1124 | ||
1125 | case 0x200f: // fn-1 magnify minus | 1125 | case 0x200f: // fn-1 magnify minus |
1126 | case Key_F5: | 1126 | case Key_F5: |
1127 | emit changeFontSize(-1); | 1127 | emit changeFontSize(-1); |
1128 | break; | 1128 | break; |
1129 | 1129 | ||
1130 | case 0x2010: // fn-2 magnify plus | 1130 | case 0x2010: // fn-2 magnify plus |
1131 | case Key_F6: | 1131 | case Key_F6: |
1132 | emit changeFontSize(1); | 1132 | emit changeFontSize(1); |
1133 | break; | 1133 | break; |
1134 | 1134 | ||
1135 | default: | 1135 | default: |
1136 | special_function = false; | 1136 | special_function = false; |
1137 | } | 1137 | } |
1138 | if (special_function) { | 1138 | if (special_function) { |
1139 | return true; | 1139 | return true; |
1140 | } | 1140 | } |
1141 | // else if( ke->state() == ControlButton && ke->key() == Key_V) { | 1141 | // else if( ke->state() == ControlButton && ke->key() == Key_V) { |
1142 | // pasteClipboard(); | 1142 | // pasteClipboard(); |
1143 | // } | 1143 | // } |
1144 | // else if( ke->state() == ControlButton && ke->key() == Key_C) { | 1144 | // else if( ke->state() == ControlButton && ke->key() == Key_C) { |
1145 | // pasteClipboard(); | 1145 | // pasteClipboard(); |
1146 | // } | 1146 | // } |
1147 | emit keyPressedSignal(ke); // expose | 1147 | emit keyPressedSignal(ke); // expose |
1148 | ke->accept(); | 1148 | ke->accept(); |
1149 | #ifdef FAKE_CTRL_AND_ALT | 1149 | #ifdef FAKE_CTRL_AND_ALT |
1150 | if ( dele ) delete e; | 1150 | if ( dele ) delete e; |
1151 | #endif | 1151 | #endif |
1152 | return true; // stop the event | 1152 | return true; // stop the event |
1153 | } | 1153 | } |
1154 | if ( e->type() == QEvent::Enter ) { | 1154 | if ( e->type() == QEvent::Enter ) { |
1155 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1155 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
1156 | this, SLOT(onClearSelection()) ); | 1156 | this, SLOT(onClearSelection()) ); |
1157 | } | 1157 | } |
1158 | if ( e->type() == QEvent::Leave ) { | 1158 | if ( e->type() == QEvent::Leave ) { |
1159 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 1159 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
1160 | this, SLOT(onClearSelection()) ); | 1160 | this, SLOT(onClearSelection()) ); |
1161 | } | 1161 | } |
1162 | return QFrame::eventFilter( obj, e ); | 1162 | return QFrame::eventFilter( obj, e ); |
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | /* ------------------------------------------------------------------------- */ | 1165 | /* ------------------------------------------------------------------------- */ |
1166 | /* */ | 1166 | /* */ |
1167 | /* Frame */ | 1167 | /* Frame */ |
1168 | /* */ | 1168 | /* */ |
1169 | /* ------------------------------------------------------------------------- */ | 1169 | /* ------------------------------------------------------------------------- */ |
1170 | 1170 | ||
1171 | void TEWidget::frameChanged() | 1171 | void TEWidget::frameChanged() |
1172 | { | 1172 | { |
1173 | propagateSize(); | 1173 | propagateSize(); |
1174 | update(); | 1174 | update(); |
1175 | } | 1175 | } |
1176 | /* ------------------------------------------------------------------------- */ | 1176 | /* ------------------------------------------------------------------------- */ |
1177 | /* */ | 1177 | /* */ |
1178 | /* Sound */ | 1178 | /* Sound */ |
1179 | /* */ | 1179 | /* */ |
1180 | /* ------------------------------------------------------------------------- */ | 1180 | /* ------------------------------------------------------------------------- */ |
1181 | 1181 | ||
1182 | void TEWidget::Bell() | 1182 | void TEWidget::Bell() |
1183 | { | 1183 | { |
1184 | //#ifdef QT_QWS_SL5XXX | 1184 | //#ifdef QT_QWS_SL5XXX |
1185 | //# ifndef QT_NO_COP | 1185 | //# ifndef QT_NO_COP |
1186 | if(useBeep) | 1186 | if(useBeep) |
1187 | QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); | 1187 | QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); |
1188 | 1188 | ||
1189 | //# endif | 1189 | //# endif |
1190 | //#else | 1190 | //#else |
1191 | //# ifndef QT_NO_SOUND | 1191 | //# ifndef QT_NO_SOUND |
1192 | // QSound::play(Resource::findSound("alarm")); | 1192 | // QSound::play(Resource::findSound("alarm")); |
1193 | //# endif | 1193 | //# endif |
1194 | //#endif | 1194 | //#endif |
1195 | 1195 | ||
1196 | // QApplication::beep(); | 1196 | // QApplication::beep(); |
1197 | } | 1197 | } |
1198 | 1198 | ||
1199 | /* ------------------------------------------------------------------------- */ | 1199 | /* ------------------------------------------------------------------------- */ |
1200 | /* */ | 1200 | /* */ |
1201 | /* Auxiluary */ | 1201 | /* Auxiluary */ |
1202 | /* */ | 1202 | /* */ |
1203 | /* ------------------------------------------------------------------------- */ | 1203 | /* ------------------------------------------------------------------------- */ |
1204 | 1204 | ||
1205 | void TEWidget::clearImage() | 1205 | void TEWidget::clearImage() |
1206 | // initialize the image | 1206 | // initialize the image |
1207 | // for internal use only | 1207 | // for internal use only |
1208 | { | 1208 | { |
1209 | for (int y = 0; y < lines; y++) | 1209 | for (int y = 0; y < lines; y++) |
1210 | for (int x = 0; x < columns; x++) | 1210 | for (int x = 0; x < columns; x++) |
1211 | { | 1211 | { |
1212 | image[loc(x,y)].c = 0xff; //' '; | 1212 | image[loc(x,y)].c = 0xff; //' '; |
1213 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | 1213 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; |
1214 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | 1214 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; |
1215 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | 1215 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; |
1216 | } | 1216 | } |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | // Create Image /////////////////////////////////////////////////////// | 1219 | // Create Image /////////////////////////////////////////////////////// |
1220 | 1220 | ||
1221 | void TEWidget::calcGeometry() | 1221 | void TEWidget::calcGeometry() |
1222 | { | 1222 | { |
1223 | int showhscrollbar = 1; | 1223 | int showhscrollbar = 1; |
1224 | int hwidth = 0; | 1224 | int hwidth = 0; |
1225 | int dcolumns = 0; | 1225 | int dcolumns = 0; |
1226 | Config cfg( "Konsole" ); | 1226 | Config cfg( "Konsole" ); |
1227 | cfg.setGroup("ScrollBar"); | 1227 | cfg.setGroup("ScrollBar"); |
1228 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | 1228 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); |
1229 | 1229 | ||
1230 | if(vcolumns == 0) showhscrollbar = 0; | 1230 | if(vcolumns == 0) showhscrollbar = 0; |
1231 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); | 1231 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); |
1232 | 1232 | ||
1233 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1233 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), |
1234 | contentsRect().height() - hwidth); | 1234 | contentsRect().height() - hwidth); |
1235 | 1235 | ||
1236 | switch(scrollLoc) { | 1236 | switch(scrollLoc) { |
1237 | case SCRNONE : | 1237 | case SCRNONE : |
1238 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | 1238 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; |
1239 | dcolumns = columns; | 1239 | dcolumns = columns; |
1240 | if(vcolumns) columns = vcolumns; | 1240 | if(vcolumns) columns = vcolumns; |
1241 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | 1241 | blX = (contentsRect().width() - (columns*font_w) ) / 2; |
1242 | if(showhscrollbar) | 1242 | if(showhscrollbar) |
1243 | blX = -hposition * font_w; | 1243 | blX = -hposition * font_w; |
1244 | brX = blX; | 1244 | brX = blX; |
1245 | scrollbar->hide(); | 1245 | scrollbar->hide(); |
1246 | break; | 1246 | break; |
1247 | case SCRLEFT : | 1247 | case SCRLEFT : |
1248 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1248 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1249 | dcolumns = columns; | 1249 | dcolumns = columns; |
1250 | if(vcolumns) columns = vcolumns; | 1250 | if(vcolumns) columns = vcolumns; |
1251 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1251 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1252 | if(showhscrollbar) | 1252 | if(showhscrollbar) |
1253 | brX = -hposition * font_w; | 1253 | brX = -hposition * font_w; |
1254 | blX = brX + scrollbar->width(); | 1254 | blX = brX + scrollbar->width(); |
1255 | scrollbar->move(contentsRect().topLeft()); | 1255 | scrollbar->move(contentsRect().topLeft()); |
1256 | scrollbar->show(); | 1256 | scrollbar->show(); |
1257 | break; | 1257 | break; |
1258 | case SCRRIGHT: | 1258 | case SCRRIGHT: |
1259 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1259 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1260 | dcolumns = columns; | 1260 | dcolumns = columns; |
1261 | if(vcolumns) columns = vcolumns; | 1261 | if(vcolumns) columns = vcolumns; |
1262 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1262 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1263 | if(showhscrollbar) | 1263 | if(showhscrollbar) |
1264 | blX = -hposition * font_w; | 1264 | blX = -hposition * font_w; |
1265 | brX = blX; | 1265 | brX = blX; |
1266 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | 1266 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); |
1267 | scrollbar->show(); | 1267 | scrollbar->show(); |
1268 | break; | 1268 | break; |
1269 | } | 1269 | } |
1270 | //FIXME: support 'rounding' styles | 1270 | //FIXME: support 'rounding' styles |
1271 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | 1271 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; |
1272 | bY = (contentsRect().height() - (lines *font_h)) / 2; | 1272 | bY = (contentsRect().height() - (lines *font_h)) / 2; |
1273 | 1273 | ||
1274 | if(showhscrollbar == 1) { | 1274 | if(showhscrollbar == 1) { |
1275 | hScrollbar->resize(contentsRect().width() - hwidth, hwidth); | 1275 | hScrollbar->resize(contentsRect().width() - hwidth, hwidth); |
1276 | hScrollbar->setRange(0, vcolumns - dcolumns); | 1276 | hScrollbar->setRange(0, vcolumns - dcolumns); |
1277 | 1277 | ||
1278 | QPoint p = contentsRect().bottomLeft(); | 1278 | QPoint p = contentsRect().bottomLeft(); |
1279 | if(scrollLoc == SCRLEFT) | 1279 | if(scrollLoc == SCRLEFT) |
1280 | hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth)); | 1280 | hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth)); |
1281 | else | 1281 | else |
1282 | hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); | 1282 | hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); |
1283 | 1283 | ||
1284 | hScrollbar->show(); | 1284 | hScrollbar->show(); |
1285 | } | 1285 | } |
1286 | else hScrollbar->hide(); | 1286 | else hScrollbar->hide(); |
1287 | 1287 | ||
1288 | if(showhscrollbar == 1) { | 1288 | if(showhscrollbar == 1) { |
1289 | lines = lines - (hwidth / font_h) - 1; | 1289 | lines = lines - (hwidth / font_h) - 1; |
1290 | if(lines < 1) lines = 1; | 1290 | if(lines < 1) lines = 1; |
1291 | } | 1291 | } |
1292 | //FIXME: support 'rounding' styles | 1292 | //FIXME: support 'rounding' styles |
1293 | } | 1293 | } |
1294 | 1294 | ||
1295 | void TEWidget::makeImage() | 1295 | void TEWidget::makeImage() |
1296 | //FIXME: rename 'calcGeometry? | 1296 | //FIXME: rename 'calcGeometry? |
1297 | { | 1297 | { |
1298 | calcGeometry(); | 1298 | calcGeometry(); |
1299 | image = (ca*) malloc(lines*columns*sizeof(ca)); | 1299 | image = (ca*) malloc(lines*columns*sizeof(ca)); |
1300 | clearImage(); | 1300 | clearImage(); |
1301 | } | 1301 | } |
1302 | 1302 | ||
1303 | // calculate the needed size | 1303 | // calculate the needed size |
1304 | QSize TEWidget::calcSize(int cols, int lins) const | 1304 | QSize TEWidget::calcSize(int cols, int lins) const |
1305 | { | 1305 | { |
1306 | int frw = width() - contentsRect().width(); | 1306 | int frw = width() - contentsRect().width(); |
1307 | int frh = height() - contentsRect().height(); | 1307 | int frh = height() - contentsRect().height(); |
1308 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); | 1308 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); |
1309 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); | 1309 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); |
1310 | } | 1310 | } |
1311 | 1311 | ||
1312 | QSize TEWidget::sizeHint() const | 1312 | QSize TEWidget::sizeHint() const |
1313 | { | 1313 | { |
1314 | return size(); | 1314 | return size(); |
1315 | } | 1315 | } |
1316 | 1316 | ||
1317 | void TEWidget::styleChange(QStyle &) | 1317 | void TEWidget::styleChange(QStyle &) |
1318 | { | 1318 | { |
1319 | propagateSize(); | 1319 | propagateSize(); |
1320 | } | 1320 | } |
1321 | 1321 | ||
1322 | #ifndef QT_NO_DRAGANDDROP | 1322 | #ifndef QT_NO_DRAGANDDROP |
1323 | 1323 | ||
1324 | /* --------------------------------------------------------------------- */ | 1324 | /* --------------------------------------------------------------------- */ |
1325 | /* */ | 1325 | /* */ |
1326 | /* Drag & Drop */ | 1326 | /* Drag & Drop */ |
1327 | /* */ | 1327 | /* */ |
1328 | /* --------------------------------------------------------------------- */ | 1328 | /* --------------------------------------------------------------------- */ |
1329 | 1329 | ||
1330 | 1330 | ||
1331 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) | 1331 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) |
1332 | { | 1332 | { |
1333 | e->accept(QTextDrag::canDecode(e) || | 1333 | e->accept(QTextDrag::canDecode(e) || |
1334 | QUriDrag::canDecode(e)); | 1334 | QUriDrag::canDecode(e)); |
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | void TEWidget::dropEvent(QDropEvent* event) | 1337 | void TEWidget::dropEvent(QDropEvent* event) |
1338 | { | 1338 | { |
1339 | // The current behaviour when url(s) are dropped is | 1339 | // The current behaviour when url(s) are dropped is |
1340 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd | 1340 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd |
1341 | // * in all other cases, just paste | 1341 | // * in all other cases, just paste |
1342 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) | 1342 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) |
1343 | QStrList strlist; | 1343 | QStrList strlist; |
1344 | int file_count = 0; | 1344 | int file_count = 0; |
1345 | dropText = ""; | 1345 | dropText = ""; |
1346 | bool bPopup = true; | 1346 | bool bPopup = true; |
1347 | 1347 | ||
1348 | if(QUriDrag::decode(event, strlist)) { | 1348 | if(QUriDrag::decode(event, strlist)) { |
1349 | if (strlist.count()) { | 1349 | if (strlist.count()) { |
1350 | for(const char* p = strlist.first(); p; p = strlist.next()) { | 1350 | for(const char* p = strlist.first(); p; p = strlist.next()) { |
1351 | if(file_count++ > 0) { | 1351 | if(file_count++ > 0) { |
1352 | dropText += " "; | 1352 | dropText += " "; |
1353 | bPopup = false; // more than one file, don't popup | 1353 | bPopup = false; // more than one file, don't popup |
1354 | } | 1354 | } |
1355 | 1355 | ||
1356 | /* | 1356 | /* |
1357 | KURL url(p); | 1357 | KURL url(p); |
1358 | if (url.isLocalFile()) { | 1358 | if (url.isLocalFile()) { |
1359 | dropText += url.path(); // local URL : remove protocol | 1359 | dropText += url.path(); // local URL : remove protocol |
1360 | } | 1360 | } |
1361 | else { | 1361 | else { |
1362 | dropText += url.prettyURL(); | 1362 | dropText += url.prettyURL(); |
1363 | bPopup = false; // a non-local file, don't popup | 1363 | bPopup = false; // a non-local file, don't popup |
1364 | } | 1364 | } |
1365 | */ | 1365 | */ |
1366 | 1366 | ||
1367 | } | 1367 | } |
1368 | 1368 | ||
1369 | if (bPopup) | 1369 | if (bPopup) |
1370 | // m_drop->popup(pos() + event->pos()); | 1370 | // m_drop->popup(pos() + event->pos()); |
1371 | m_drop->popup(mapToGlobal(event->pos())); | 1371 | m_drop->popup(mapToGlobal(event->pos())); |
1372 | else | 1372 | else |
1373 | { | 1373 | { |
1374 | if (currentSession) { | 1374 | if (currentSession) { |
1375 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1375 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1376 | } | 1376 | } |
1377 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1377 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1378 | } | 1378 | } |
1379 | } | 1379 | } |
1380 | } | 1380 | } |
1381 | else if(QTextDrag::decode(event, dropText)) { | 1381 | else if(QTextDrag::decode(event, dropText)) { |
1382 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1382 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1383 | if (currentSession) { | 1383 | if (currentSession) { |
1384 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1384 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1385 | } | 1385 | } |
1386 | // Paste it | 1386 | // Paste it |
1387 | } | 1387 | } |
1388 | } | 1388 | } |
1389 | #endif | 1389 | #endif |
1390 | 1390 | ||
1391 | 1391 | ||
1392 | void TEWidget::drop_menu_activated(int /*item*/) | 1392 | void TEWidget::drop_menu_activated(int item) |
1393 | { | 1393 | { |
1394 | #ifndef QT_NO_DRAGANDDROP | 1394 | #ifndef QT_NO_DRAGANDDROP |
1395 | switch (item) | 1395 | switch (item) |
1396 | { | 1396 | { |
1397 | case 0: // paste | 1397 | case 0: // paste |
1398 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1398 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1399 | // KWM::activate((Window)this->winId()); | 1399 | // KWM::activate((Window)this->winId()); |
1400 | break; | 1400 | break; |
1401 | case 1: // cd ... | 1401 | case 1: // cd ... |
1402 | currentSession->getEmulation()->sendString("cd "); | 1402 | currentSession->getEmulation()->sendString("cd "); |
1403 | struct stat statbuf; | 1403 | struct stat statbuf; |
1404 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) | 1404 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) |
1405 | { | 1405 | { |
1406 | if ( !S_ISDIR(statbuf.st_mode) ) | 1406 | if ( !S_ISDIR(statbuf.st_mode) ) |
1407 | { | 1407 | { |
1408 | /* | 1408 | /* |
1409 | KURL url; | 1409 | KURL url; |
1410 | url.setPath( dropText ); | 1410 | url.setPath( dropText ); |
1411 | dropText = url.directory( true, false ); // remove filename | 1411 | dropText = url.directory( true, false ); // remove filename |
1412 | */ | 1412 | */ |
1413 | } | 1413 | } |
1414 | } | 1414 | } |
1415 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces | 1415 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces |
1416 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1416 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1417 | currentSession->getEmulation()->sendString("\n"); | 1417 | currentSession->getEmulation()->sendString("\n"); |
1418 | // KWM::activate((Window)this->winId()); | 1418 | // KWM::activate((Window)this->winId()); |
1419 | break; | 1419 | break; |
1420 | } | 1420 | } |
1421 | #else | ||
1422 | Q_UNUSED(item); | ||
1421 | #endif | 1423 | #endif |
1422 | } | 1424 | } |
1423 | 1425 | ||
1424 | void TEWidget::setWrapAt(int columns) | 1426 | void TEWidget::setWrapAt(int columns) |
1425 | { | 1427 | { |
1426 | vcolumns = columns; | 1428 | vcolumns = columns; |
1427 | propagateSize(); | 1429 | propagateSize(); |
1428 | update(); | 1430 | update(); |
1429 | } | 1431 | } |