summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-06-23 20:33:15 (UTC)
committer llornkcor <llornkcor>2002-06-23 20:33:15 (UTC)
commita4a53967e152ba595d315b2491bb78070c446ee2 (patch) (unidiff)
tree7c8fc3f5ba089bb87362c221aa5b811cb6147b96
parent682c35bee3ea3012ce0dfe70c531b87231d4fcf4 (diff)
downloadopie-a4a53967e152ba595d315b2491bb78070c446ee2.zip
opie-a4a53967e152ba595d315b2491bb78070c446ee2.tar.gz
opie-a4a53967e152ba595d315b2491bb78070c446ee2.tar.bz2
security enhancement
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TEWidget.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp
index a111e18..6d5c6e9 100644
--- a/core/apps/embeddedkonsole/TEWidget.cpp
+++ b/core/apps/embeddedkonsole/TEWidget.cpp
@@ -903,259 +903,261 @@ void TEWidget::setMouseMarks(bool on)
903#undef KeyPress 903#undef KeyPress
904 904
905void TEWidget::emitSelection() 905void 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
920void TEWidget::emitText(QString text) 920void 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
926void TEWidget::pasteClipboard( ) 926void TEWidget::pasteClipboard( )
927{ 927{
928 emitSelection(); 928 emitSelection();
929} 929}
930 930
931void TEWidget::setSelection(const QString& t) 931void 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
946void TEWidget::onClearSelection() 946void 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
971void TEWidget::doScroll(int lines) 971void TEWidget::doScroll(int lines)
972{ 972{
973 scrollbar->setValue(scrollbar->value()+lines); 973 scrollbar->setValue(scrollbar->value()+lines);
974} 974}
975 975
976bool TEWidget::eventFilter( QObject *obj, QEvent *e ) 976bool 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
1032 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker 1033 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
1033 qDebug("key pressed 2 is 0x%x",ke->key()); 1034
1035// qDebug("key pressed 2 is 0x%x",ke->key());
1034 emitText("\\"); // expose 1036 emitText("\\"); // expose
1035 } else 1037 } else
1036 emit keyPressedSignal(ke); // expose 1038 emit keyPressedSignal(ke); // expose
1037 ke->accept(); 1039 ke->accept();
1038#ifdef FAKE_CTRL_AND_ALT 1040#ifdef FAKE_CTRL_AND_ALT
1039 if ( dele ) delete e; 1041 if ( dele ) delete e;
1040#endif 1042#endif
1041 return true; // stop the event 1043 return true; // stop the event
1042 } 1044 }
1043 if ( e->type() == QEvent::Enter ) { 1045 if ( e->type() == QEvent::Enter ) {
1044 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1046 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1045 this, SLOT(onClearSelection()) ); 1047 this, SLOT(onClearSelection()) );
1046 } 1048 }
1047 if ( e->type() == QEvent::Leave ) { 1049 if ( e->type() == QEvent::Leave ) {
1048 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1050 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1049 this, SLOT(onClearSelection()) ); 1051 this, SLOT(onClearSelection()) );
1050 } 1052 }
1051 return QFrame::eventFilter( obj, e ); 1053 return QFrame::eventFilter( obj, e );
1052} 1054}
1053 1055
1054/* ------------------------------------------------------------------------- */ 1056/* ------------------------------------------------------------------------- */
1055/* */ 1057/* */
1056/* Frame */ 1058/* Frame */
1057/* */ 1059/* */
1058/* ------------------------------------------------------------------------- */ 1060/* ------------------------------------------------------------------------- */
1059 1061
1060void TEWidget::frameChanged() 1062void TEWidget::frameChanged()
1061{ 1063{
1062 propagateSize(); 1064 propagateSize();
1063 update(); 1065 update();
1064} 1066}
1065 1067
1066/* ------------------------------------------------------------------------- */ 1068/* ------------------------------------------------------------------------- */
1067/* */ 1069/* */
1068/* Sound */ 1070/* Sound */
1069/* */ 1071/* */
1070/* ------------------------------------------------------------------------- */ 1072/* ------------------------------------------------------------------------- */
1071 1073
1072void TEWidget::Bell() 1074void TEWidget::Bell()
1073{ 1075{
1074 QApplication::beep(); 1076 QApplication::beep();
1075} 1077}
1076 1078
1077/* ------------------------------------------------------------------------- */ 1079/* ------------------------------------------------------------------------- */
1078/* */ 1080/* */
1079/* Auxiluary */ 1081/* Auxiluary */
1080/* */ 1082/* */
1081/* ------------------------------------------------------------------------- */ 1083/* ------------------------------------------------------------------------- */
1082 1084
1083void TEWidget::clearImage() 1085void TEWidget::clearImage()
1084// initialize the image 1086// initialize the image
1085// for internal use only 1087// for internal use only
1086{ 1088{
1087 for (int y = 0; y < lines; y++) 1089 for (int y = 0; y < lines; y++)
1088 for (int x = 0; x < columns; x++) 1090 for (int x = 0; x < columns; x++)
1089 { 1091 {
1090 image[loc(x,y)].c = 0xff; //' '; 1092 image[loc(x,y)].c = 0xff; //' ';
1091 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; 1093 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
1092 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; 1094 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
1093 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; 1095 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
1094 } 1096 }
1095} 1097}
1096 1098
1097// Create Image /////////////////////////////////////////////////////// 1099// Create Image ///////////////////////////////////////////////////////
1098 1100
1099void TEWidget::calcGeometry() 1101void TEWidget::calcGeometry()
1100{ 1102{
1101 //FIXME: set rimX == rimY == 0 when running in full screen mode. 1103 //FIXME: set rimX == rimY == 0 when running in full screen mode.
1102 1104
1103 scrollbar->resize(QApplication::style().scrollBarExtent().width(), 1105 scrollbar->resize(QApplication::style().scrollBarExtent().width(),
1104 contentsRect().height()); 1106 contentsRect().height());
1105 switch(scrollLoc) 1107 switch(scrollLoc)
1106 { 1108 {
1107 case SCRNONE : 1109 case SCRNONE :
1108 columns = ( contentsRect().width() - 2 * rimX ) / font_w; 1110 columns = ( contentsRect().width() - 2 * rimX ) / font_w;
1109 blX = (contentsRect().width() - (columns*font_w) ) / 2; 1111 blX = (contentsRect().width() - (columns*font_w) ) / 2;
1110 brX = blX; 1112 brX = blX;
1111 scrollbar->hide(); 1113 scrollbar->hide();
1112 break; 1114 break;
1113 case SCRLEFT : 1115 case SCRLEFT :
1114 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1116 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1115 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1117 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1116 blX = brX + scrollbar->width(); 1118 blX = brX + scrollbar->width();
1117 scrollbar->move(contentsRect().topLeft()); 1119 scrollbar->move(contentsRect().topLeft());
1118 scrollbar->show(); 1120 scrollbar->show();
1119 break; 1121 break;
1120 case SCRRIGHT: 1122 case SCRRIGHT:
1121 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1123 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1122 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1124 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1123 brX = blX; 1125 brX = blX;
1124 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); 1126 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
1125 scrollbar->show(); 1127 scrollbar->show();
1126 break; 1128 break;
1127 } 1129 }
1128 //FIXME: support 'rounding' styles 1130 //FIXME: support 'rounding' styles
1129 lines = ( contentsRect().height() - 2 * rimY ) / font_h; 1131 lines = ( contentsRect().height() - 2 * rimY ) / font_h;
1130 bY = (contentsRect().height() - (lines *font_h)) / 2; 1132 bY = (contentsRect().height() - (lines *font_h)) / 2;
1131} 1133}
1132 1134
1133void TEWidget::makeImage() 1135void TEWidget::makeImage()
1134//FIXME: rename 'calcGeometry? 1136//FIXME: rename 'calcGeometry?
1135{ 1137{
1136 calcGeometry(); 1138 calcGeometry();
1137 image = (ca*) malloc(lines*columns*sizeof(ca)); 1139 image = (ca*) malloc(lines*columns*sizeof(ca));
1138 clearImage(); 1140 clearImage();
1139} 1141}
1140 1142
1141// calculate the needed size 1143// calculate the needed size
1142QSize TEWidget::calcSize(int cols, int lins) const 1144QSize TEWidget::calcSize(int cols, int lins) const
1143{ 1145{
1144 int frw = width() - contentsRect().width(); 1146 int frw = width() - contentsRect().width();
1145 int frh = height() - contentsRect().height(); 1147 int frh = height() - contentsRect().height();
1146 int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); 1148 int scw = (scrollLoc==SCRNONE?0:scrollbar->width());
1147 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); 1149 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh );
1148} 1150}
1149 1151
1150QSize TEWidget::sizeHint() const 1152QSize TEWidget::sizeHint() const
1151{ 1153{
1152 return size(); 1154 return size();
1153} 1155}
1154 1156
1155void TEWidget::styleChange(QStyle &) 1157void TEWidget::styleChange(QStyle &)
1156{ 1158{
1157 propagateSize(); 1159 propagateSize();
1158} 1160}
1159 1161
1160#ifndef QT_NO_DRAGANDDROP 1162#ifndef QT_NO_DRAGANDDROP
1161 1163