summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/TEWidget.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp
index 1c83710..3d010cb 100644
--- a/noncore/apps/opie-console/TEWidget.cpp
+++ b/noncore/apps/opie-console/TEWidget.cpp
@@ -1027,316 +1027,320 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e )
1027 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 1027 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
1028 static_cast<QKeyEvent *>( e )->ignore(); 1028 static_cast<QKeyEvent *>( e )->ignore();
1029 return true; 1029 return true;
1030 } 1030 }
1031 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 1031 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
1032 return FALSE; // not us 1032 return FALSE; // not us
1033 if ( e->type() == QEvent::Wheel) { 1033 if ( e->type() == QEvent::Wheel) {
1034 QApplication::sendEvent(scrollbar, e); 1034 QApplication::sendEvent(scrollbar, e);
1035 } 1035 }
1036 1036
1037#ifdef FAKE_CTRL_AND_ALT 1037#ifdef FAKE_CTRL_AND_ALT
1038 static bool control = FALSE; 1038 static bool control = FALSE;
1039 static bool alt = FALSE; 1039 static bool alt = FALSE;
1040// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 1040// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
1041 bool dele=FALSE; 1041 bool dele=FALSE;
1042 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1042 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1043 QKeyEvent* ke = (QKeyEvent*)e; 1043 QKeyEvent* ke = (QKeyEvent*)e;
1044 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 1044 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
1045 switch (ke->key()) { 1045 switch (ke->key()) {
1046 case Key_F9: // let this be "Control" 1046 case Key_F9: // let this be "Control"
1047 control = keydown; 1047 control = keydown;
1048 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 1048 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
1049 dele=TRUE; 1049 dele=TRUE;
1050 break; 1050 break;
1051 case Key_F13: // let this be "Alt" 1051 case Key_F13: // let this be "Alt"
1052 alt = keydown; 1052 alt = keydown;
1053 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 1053 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
1054 dele=TRUE; 1054 dele=TRUE;
1055 break; 1055 break;
1056 default: 1056 default:
1057 if ( control ) { 1057 if ( control ) {
1058 int a = toupper(ke->ascii())-64; 1058 int a = toupper(ke->ascii())-64;
1059 if ( a >= 0 && a < ' ' ) { 1059 if ( a >= 0 && a < ' ' ) {
1060 e = new QKeyEvent(e->type(), ke->key(), 1060 e = new QKeyEvent(e->type(), ke->key(),
1061 a, ke->state()|ControlButton, QChar(a,0)); 1061 a, ke->state()|ControlButton, QChar(a,0));
1062 dele=TRUE; 1062 dele=TRUE;
1063 } 1063 }
1064 } 1064 }
1065 if ( alt ) { 1065 if ( alt ) {
1066 e = new QKeyEvent(e->type(), ke->key(), 1066 e = new QKeyEvent(e->type(), ke->key(),
1067 ke->ascii(), ke->state()|AltButton, ke->text()); 1067 ke->ascii(), ke->state()|AltButton, ke->text());
1068 dele=TRUE; 1068 dele=TRUE;
1069 } 1069 }
1070 } 1070 }
1071 } 1071 }
1072#endif 1072#endif
1073 1073
1074 if ( e->type() == QEvent::KeyPress ) { 1074 if ( e->type() == QEvent::KeyPress ) {
1075 QKeyEvent* ke = (QKeyEvent*)e; 1075 QKeyEvent* ke = (QKeyEvent*)e;
1076 actSel=0; // Key stroke implies a screen update, so TEWidget won't 1076 actSel=0; // Key stroke implies a screen update, so TEWidget won't
1077 // know where the current selection is. 1077 // know where the current selection is.
1078 1078
1079// qDebug("key pressed is 0x%x",ke->key()); 1079// qDebug("key pressed is 0x%x",ke->key());
1080 1080
1081 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker 1081 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
1082 1082
1083// qDebug("key pressed 2 is 0x%x",ke->key()); 1083// qDebug("key pressed 2 is 0x%x",ke->key());
1084 emitText("\\"); // expose 1084 emitText("\\"); // expose
1085 } else 1085 } else
1086 emit keyPressedSignal(ke); // expose 1086 emit keyPressedSignal(ke); // expose
1087 ke->accept(); 1087 ke->accept();
1088#ifdef FAKE_CTRL_AND_ALT 1088#ifdef FAKE_CTRL_AND_ALT
1089 if ( dele ) delete e; 1089 if ( dele ) delete e;
1090#endif 1090#endif
1091 return true; // stop the event 1091 return true; // stop the event
1092 } 1092 }
1093 if ( e->type() == QEvent::Enter ) { 1093 if ( e->type() == QEvent::Enter ) {
1094 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1094 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1095 this, SLOT(onClearSelection()) ); 1095 this, SLOT(onClearSelection()) );
1096 } 1096 }
1097 if ( e->type() == QEvent::Leave ) { 1097 if ( e->type() == QEvent::Leave ) {
1098 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1098 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1099 this, SLOT(onClearSelection()) ); 1099 this, SLOT(onClearSelection()) );
1100 } 1100 }
1101 return QFrame::eventFilter( obj, e ); 1101 return QFrame::eventFilter( obj, e );
1102} 1102}
1103 1103
1104/* ------------------------------------------------------------------------- */ 1104/* ------------------------------------------------------------------------- */
1105/* */ 1105/* */
1106/* Frame */ 1106/* Frame */
1107/* */ 1107/* */
1108/* ------------------------------------------------------------------------- */ 1108/* ------------------------------------------------------------------------- */
1109 1109
1110void TEWidget::frameChanged() 1110void TEWidget::frameChanged()
1111{ 1111{
1112 propagateSize(); 1112 propagateSize();
1113 update(); 1113 update();
1114} 1114}
1115 1115
1116/* ------------------------------------------------------------------------- */ 1116/* ------------------------------------------------------------------------- */
1117/* */ 1117/* */
1118/* Sound */ 1118/* Sound */
1119/* */ 1119/* */
1120/* ------------------------------------------------------------------------- */ 1120/* ------------------------------------------------------------------------- */
1121 1121
1122void TEWidget::Bell() 1122void TEWidget::Bell()
1123{ 1123{
1124 QApplication::beep(); 1124 QApplication::beep();
1125} 1125}
1126 1126
1127/* ------------------------------------------------------------------------- */ 1127/* ------------------------------------------------------------------------- */
1128/* */ 1128/* */
1129/* Auxiluary */ 1129/* Auxiluary */
1130/* */ 1130/* */
1131/* ------------------------------------------------------------------------- */ 1131/* ------------------------------------------------------------------------- */
1132 1132
1133void TEWidget::clearImage() 1133void TEWidget::clearImage()
1134// initialize the image 1134// initialize the image
1135// for internal use only 1135// for internal use only
1136{ 1136{
1137 for (int y = 0; y < lines; y++) 1137 for (int y = 0; y < lines; y++)
1138 for (int x = 0; x < columns; x++) 1138 for (int x = 0; x < columns; x++)
1139 { 1139 {
1140 image[loc(x,y)].c = 0xff; //' '; 1140 image[loc(x,y)].c = 0xff; //' ';
1141 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; 1141 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
1142 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; 1142 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
1143 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; 1143 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
1144 } 1144 }
1145} 1145}
1146 1146
1147// Create Image /////////////////////////////////////////////////////// 1147// Create Image ///////////////////////////////////////////////////////
1148 1148
1149void TEWidget::calcGeometry() 1149void TEWidget::calcGeometry()
1150{ 1150{
1151 //FIXME: set rimX == rimY == 0 when running in full screen mode. 1151 //FIXME: set rimX == rimY == 0 when running in full screen mode.
1152 1152
1153 int showhscrollbar = 1; 1153 int showhscrollbar = 1;
1154 int hwidth = 0; 1154 int hwidth = 0;
1155 int dcolumns;
1155 1156
1156 if(vcolumns == 0) showhscrollbar = 0; 1157 if(vcolumns == 0) showhscrollbar = 0;
1157 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); 1158 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width();
1158 1159
1159 scrollbar->resize(QApplication::style().scrollBarExtent().width(), 1160 scrollbar->resize(QApplication::style().scrollBarExtent().width(),
1160 contentsRect().height() - hwidth); 1161 contentsRect().height() - hwidth);
1161 1162
1162 if(!showhscrollbar) cornerButton()->move(0, 0); 1163 if(!showhscrollbar) cornerButton()->move(0, 0);
1163 else cornerButton()->move(contentsRect().width() - hwidth, contentsRect().height() - hwidth); 1164 else cornerButton()->move(contentsRect().width() - hwidth, contentsRect().height() - hwidth);
1164 1165
1165 1166
1166 if(showhscrollbar == 1)
1167 {
1168 hscrollbar->resize(contentsRect().width() - hwidth, hwidth);
1169 hscrollbar->setRange(0, 40);
1170
1171 QPoint p = contentsRect().bottomLeft();
1172 hscrollbar->move(QPoint(p.x(), p.y() - hwidth));
1173 hscrollbar->show();
1174 }
1175 else hscrollbar->hide();
1176
1177 switch(scrollLoc) 1167 switch(scrollLoc)
1178 { 1168 {
1179 case SCRNONE : 1169 case SCRNONE :
1180 columns = ( contentsRect().width() - 2 * rimX ) / font_w; 1170 columns = ( contentsRect().width() - 2 * rimX ) / font_w;
1171 dcolumns = columns;
1181 if(vcolumns) columns = vcolumns; 1172 if(vcolumns) columns = vcolumns;
1182 blX = (contentsRect().width() - (columns*font_w) ) / 2; 1173 blX = (contentsRect().width() - (columns*font_w) ) / 2;
1183 if(showhscrollbar) 1174 if(showhscrollbar)
1184 blX = -hposition * font_w; 1175 blX = -hposition * font_w;
1185 brX = blX; 1176 brX = blX;
1186 scrollbar->hide(); 1177 scrollbar->hide();
1187 break; 1178 break;
1188 case SCRLEFT : 1179 case SCRLEFT :
1189 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1180 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1181 dcolumns = columns;
1190 if(vcolumns) columns = vcolumns; 1182 if(vcolumns) columns = vcolumns;
1191 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1183 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1192 if(showhscrollbar) 1184 if(showhscrollbar)
1193 brX = -hposition * font_w; 1185 brX = -hposition * font_w;
1194 blX = brX + scrollbar->width(); 1186 blX = brX + scrollbar->width();
1195 scrollbar->move(contentsRect().topLeft()); 1187 scrollbar->move(contentsRect().topLeft());
1196 scrollbar->show(); 1188 scrollbar->show();
1197 break; 1189 break;
1198 case SCRRIGHT: 1190 case SCRRIGHT:
1199 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1191 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1192 dcolumns = columns;
1200 if(vcolumns) columns = vcolumns; 1193 if(vcolumns) columns = vcolumns;
1201 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1194 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1202 if(showhscrollbar) 1195 if(showhscrollbar)
1203 blX = -hposition * font_w; 1196 blX = -hposition * font_w;
1204 brX = blX; 1197 brX = blX;
1205 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); 1198 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
1206 scrollbar->show(); 1199 scrollbar->show();
1207 break; 1200 break;
1208 } 1201 }
1209 //FIXME: support 'rounding' styles 1202 //FIXME: support 'rounding' styles
1210 lines = ( contentsRect().height() - 2 * rimY ) / font_h; 1203 lines = ( contentsRect().height() - 2 * rimY ) / font_h;
1211 bY = (contentsRect().height() - (lines *font_h)) / 2; 1204 bY = (contentsRect().height() - (lines *font_h)) / 2;
1212 1205
1213 if(showhscrollbar == 1) 1206 if(showhscrollbar == 1)
1214 { 1207 {
1208 hscrollbar->resize(contentsRect().width() - hwidth, hwidth);
1209 hscrollbar->setRange(0, vcolumns - dcolumns);
1210
1211 QPoint p = contentsRect().bottomLeft();
1212 hscrollbar->move(QPoint(p.x(), p.y() - hwidth));
1213 hscrollbar->show();
1214 }
1215 else hscrollbar->hide();
1216
1217 if(showhscrollbar == 1)
1218 {
1215 lines = lines - (hwidth / font_h) - 1; 1219 lines = lines - (hwidth / font_h) - 1;
1216 if(lines < 1) lines = 1; 1220 if(lines < 1) lines = 1;
1217 } 1221 }
1218} 1222}
1219 1223
1220void TEWidget::makeImage() 1224void TEWidget::makeImage()
1221//FIXME: rename 'calcGeometry? 1225//FIXME: rename 'calcGeometry?
1222{ 1226{
1223 calcGeometry(); 1227 calcGeometry();
1224 image = (ca*) malloc(lines*columns*sizeof(ca)); 1228 image = (ca*) malloc(lines*columns*sizeof(ca));
1225 clearImage(); 1229 clearImage();
1226} 1230}
1227 1231
1228// calculate the needed size 1232// calculate the needed size
1229QSize TEWidget::calcSize(int cols, int lins) const 1233QSize TEWidget::calcSize(int cols, int lins) const
1230{ 1234{
1231 int frw = width() - contentsRect().width(); 1235 int frw = width() - contentsRect().width();
1232 int frh = height() - contentsRect().height(); 1236 int frh = height() - contentsRect().height();
1233 int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); 1237 int scw = (scrollLoc==SCRNONE?0:scrollbar->width());
1234 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); 1238 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh );
1235} 1239}
1236 1240
1237QSize TEWidget::sizeHint() const 1241QSize TEWidget::sizeHint() const
1238{ 1242{
1239 return size(); 1243 return size();
1240} 1244}
1241 1245
1242void TEWidget::styleChange(QStyle &) 1246void TEWidget::styleChange(QStyle &)
1243{ 1247{
1244 propagateSize(); 1248 propagateSize();
1245} 1249}
1246 1250
1247#ifndef QT_NO_DRAGANDDROP 1251#ifndef QT_NO_DRAGANDDROP
1248 1252
1249/* --------------------------------------------------------------------- */ 1253/* --------------------------------------------------------------------- */
1250/* */ 1254/* */
1251/* Drag & Drop */ 1255/* Drag & Drop */
1252/* */ 1256/* */
1253/* --------------------------------------------------------------------- */ 1257/* --------------------------------------------------------------------- */
1254 1258
1255 1259
1256void TEWidget::dragEnterEvent(QDragEnterEvent* e) 1260void TEWidget::dragEnterEvent(QDragEnterEvent* e)
1257{ 1261{
1258 e->accept(QTextDrag::canDecode(e) || 1262 e->accept(QTextDrag::canDecode(e) ||
1259 QUriDrag::canDecode(e)); 1263 QUriDrag::canDecode(e));
1260} 1264}
1261 1265
1262void TEWidget::dropEvent(QDropEvent* event) 1266void TEWidget::dropEvent(QDropEvent* event)
1263{ 1267{
1264 // The current behaviour when url(s) are dropped is 1268 // The current behaviour when url(s) are dropped is
1265 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd 1269 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd
1266 // * in all other cases, just paste 1270 // * in all other cases, just paste
1267 // (for non-local ones, or for a list of URLs, 'cd' is nonsense) 1271 // (for non-local ones, or for a list of URLs, 'cd' is nonsense)
1268 QStrList strlist; 1272 QStrList strlist;
1269 int file_count = 0; 1273 int file_count = 0;
1270 dropText = ""; 1274 dropText = "";
1271 bool bPopup = true; 1275 bool bPopup = true;
1272 1276
1273 if(QUriDrag::decode(event, strlist)) { 1277 if(QUriDrag::decode(event, strlist)) {
1274 if (strlist.count()) { 1278 if (strlist.count()) {
1275 for(const char* p = strlist.first(); p; p = strlist.next()) { 1279 for(const char* p = strlist.first(); p; p = strlist.next()) {
1276 if(file_count++ > 0) { 1280 if(file_count++ > 0) {
1277 dropText += " "; 1281 dropText += " ";
1278 bPopup = false; // more than one file, don't popup 1282 bPopup = false; // more than one file, don't popup
1279 } 1283 }
1280 1284
1281/* 1285/*
1282 KURL url(p); 1286 KURL url(p);
1283 if (url.isLocalFile()) { 1287 if (url.isLocalFile()) {
1284 dropText += url.path(); // local URL : remove protocol 1288 dropText += url.path(); // local URL : remove protocol
1285 } 1289 }
1286 else { 1290 else {
1287 dropText += url.prettyURL(); 1291 dropText += url.prettyURL();
1288 bPopup = false; // a non-local file, don't popup 1292 bPopup = false; // a non-local file, don't popup
1289 } 1293 }
1290*/ 1294*/
1291 1295
1292 } 1296 }
1293 1297
1294 if (bPopup) 1298 if (bPopup)
1295 // m_drop->popup(pos() + event->pos()); 1299 // m_drop->popup(pos() + event->pos());
1296 m_drop->popup(mapToGlobal(event->pos())); 1300 m_drop->popup(mapToGlobal(event->pos()));
1297 else 1301 else
1298 { 1302 {
1299 if (currentSession) { 1303 if (currentSession) {
1300 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1304 currentSession->getEmulation()->sendString(dropText.local8Bit());
1301 } 1305 }
1302// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1306// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1303 } 1307 }
1304 } 1308 }
1305 } 1309 }
1306 else if(QTextDrag::decode(event, dropText)) { 1310 else if(QTextDrag::decode(event, dropText)) {
1307// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1311// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1308 if (currentSession) { 1312 if (currentSession) {
1309 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1313 currentSession->getEmulation()->sendString(dropText.local8Bit());
1310 } 1314 }
1311 // Paste it 1315 // Paste it
1312 } 1316 }
1313} 1317}
1314#endif 1318#endif
1315 1319
1316 1320
1317void TEWidget::drop_menu_activated(int) 1321void TEWidget::drop_menu_activated(int)
1318{ 1322{
1319#ifndef QT_NO_DRAGANDDROP 1323#ifndef QT_NO_DRAGANDDROP
1320 switch (item) 1324 switch (item)
1321 { 1325 {
1322 case 0: // paste 1326 case 0: // paste
1323 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1327 currentSession->getEmulation()->sendString(dropText.local8Bit());
1324// KWM::activate((Window)this->winId()); 1328// KWM::activate((Window)this->winId());
1325 break; 1329 break;
1326 case 1: // cd ... 1330 case 1: // cd ...
1327 currentSession->getEmulation()->sendString("cd "); 1331 currentSession->getEmulation()->sendString("cd ");
1328 struct stat statbuf; 1332 struct stat statbuf;
1329 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) 1333 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 )
1330 { 1334 {
1331 if ( !S_ISDIR(statbuf.st_mode) ) 1335 if ( !S_ISDIR(statbuf.st_mode) )
1332 { 1336 {
1333/* 1337/*
1334 KURL url; 1338 KURL url;
1335 url.setPath( dropText ); 1339 url.setPath( dropText );
1336 dropText = url.directory( true, false ); // remove filename 1340 dropText = url.directory( true, false ); // remove filename
1337*/ 1341*/
1338 } 1342 }
1339 } 1343 }
1340 dropText.replace(QRegExp(" "), "\\ "); // escape spaces 1344 dropText.replace(QRegExp(" "), "\\ "); // escape spaces
1341 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1345 currentSession->getEmulation()->sendString(dropText.local8Bit());
1342 currentSession->getEmulation()->sendString("\n"); 1346 currentSession->getEmulation()->sendString("\n");