summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/TEWidget.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp
index bf9a313..2db214c 100644
--- a/noncore/apps/opie-console/TEWidget.cpp
+++ b/noncore/apps/opie-console/TEWidget.cpp
@@ -1082,268 +1082,274 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e )
1082// qDebug("key pressed 2 is 0x%x",ke->key()); 1082// qDebug("key pressed 2 is 0x%x",ke->key());
1083 emitText("\\"); // expose 1083 emitText("\\"); // expose
1084 } else 1084 } else
1085 emit keyPressedSignal(ke); // expose 1085 emit keyPressedSignal(ke); // expose
1086 ke->accept(); 1086 ke->accept();
1087#ifdef FAKE_CTRL_AND_ALT 1087#ifdef FAKE_CTRL_AND_ALT
1088 if ( dele ) delete e; 1088 if ( dele ) delete e;
1089#endif 1089#endif
1090 return true; // stop the event 1090 return true; // stop the event
1091 } 1091 }
1092 if ( e->type() == QEvent::Enter ) { 1092 if ( e->type() == QEvent::Enter ) {
1093 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1093 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1094 this, SLOT(onClearSelection()) ); 1094 this, SLOT(onClearSelection()) );
1095 } 1095 }
1096 if ( e->type() == QEvent::Leave ) { 1096 if ( e->type() == QEvent::Leave ) {
1097 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1097 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1098 this, SLOT(onClearSelection()) ); 1098 this, SLOT(onClearSelection()) );
1099 } 1099 }
1100 return QFrame::eventFilter( obj, e ); 1100 return QFrame::eventFilter( obj, e );
1101} 1101}
1102 1102
1103/* ------------------------------------------------------------------------- */ 1103/* ------------------------------------------------------------------------- */
1104/* */ 1104/* */
1105/* Frame */ 1105/* Frame */
1106/* */ 1106/* */
1107/* ------------------------------------------------------------------------- */ 1107/* ------------------------------------------------------------------------- */
1108 1108
1109void TEWidget::frameChanged() 1109void TEWidget::frameChanged()
1110{ 1110{
1111 propagateSize(); 1111 propagateSize();
1112 update(); 1112 update();
1113} 1113}
1114 1114
1115/* ------------------------------------------------------------------------- */ 1115/* ------------------------------------------------------------------------- */
1116/* */ 1116/* */
1117/* Sound */ 1117/* Sound */
1118/* */ 1118/* */
1119/* ------------------------------------------------------------------------- */ 1119/* ------------------------------------------------------------------------- */
1120 1120
1121void TEWidget::Bell() 1121void TEWidget::Bell()
1122{ 1122{
1123 QApplication::beep(); 1123 QApplication::beep();
1124} 1124}
1125 1125
1126/* ------------------------------------------------------------------------- */ 1126/* ------------------------------------------------------------------------- */
1127/* */ 1127/* */
1128/* Auxiluary */ 1128/* Auxiluary */
1129/* */ 1129/* */
1130/* ------------------------------------------------------------------------- */ 1130/* ------------------------------------------------------------------------- */
1131 1131
1132void TEWidget::clearImage() 1132void TEWidget::clearImage()
1133// initialize the image 1133// initialize the image
1134// for internal use only 1134// for internal use only
1135{ 1135{
1136 for (int y = 0; y < lines; y++) 1136 for (int y = 0; y < lines; y++)
1137 for (int x = 0; x < columns; x++) 1137 for (int x = 0; x < columns; x++)
1138 { 1138 {
1139 image[loc(x,y)].c = 0xff; //' '; 1139 image[loc(x,y)].c = 0xff; //' ';
1140 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; 1140 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
1141 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; 1141 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
1142 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; 1142 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
1143 } 1143 }
1144} 1144}
1145 1145
1146// Create Image /////////////////////////////////////////////////////// 1146// Create Image ///////////////////////////////////////////////////////
1147 1147
1148void TEWidget::calcGeometry() 1148void TEWidget::calcGeometry()
1149{ 1149{
1150 //FIXME: set rimX == rimY == 0 when running in full screen mode. 1150 //FIXME: set rimX == rimY == 0 when running in full screen mode.
1151 1151
1152 int showhscrollbar = 1; 1152 int showhscrollbar = 1;
1153 int hwidth = 0; 1153 int hwidth = 0;
1154 1154
1155 if(vcolumns == 0) showhscrollbar = 0; 1155 if(vcolumns == 0) showhscrollbar = 0;
1156 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); 1156 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width();
1157 1157
1158 scrollbar->resize(QApplication::style().scrollBarExtent().width(), 1158 scrollbar->resize(QApplication::style().scrollBarExtent().width(),
1159 contentsRect().height() - hwidth); 1159 contentsRect().height() - hwidth);
1160 1160
1161 if(showhscrollbar == 1) 1161 if(showhscrollbar == 1)
1162 { 1162 {
1163 hscrollbar->resize(contentsRect().width() - hwidth, hwidth); 1163 hscrollbar->resize(contentsRect().width() - hwidth, hwidth);
1164 hscrollbar->setRange(0, 40); 1164 hscrollbar->setRange(0, 40);
1165 1165
1166 QPoint p = contentsRect().bottomLeft(); 1166 QPoint p = contentsRect().bottomLeft();
1167 hscrollbar->move(QPoint(p.x(), p.y() - hwidth)); 1167 hscrollbar->move(QPoint(p.x(), p.y() - hwidth));
1168 hscrollbar->show(); 1168 hscrollbar->show();
1169 } 1169 }
1170 else hscrollbar->hide(); 1170 else hscrollbar->hide();
1171 1171
1172 switch(scrollLoc) 1172 switch(scrollLoc)
1173 { 1173 {
1174 case SCRNONE : 1174 case SCRNONE :
1175 columns = ( contentsRect().width() - 2 * rimX ) / font_w; 1175 columns = ( contentsRect().width() - 2 * rimX ) / font_w;
1176 if(vcolumns) columns = vcolumns; 1176 if(vcolumns) columns = vcolumns;
1177 blX = (contentsRect().width() - (columns*font_w) ) / 2; 1177 blX = (contentsRect().width() - (columns*font_w) ) / 2;
1178 if(showhscrollbar)
1179 blX = -hposition * font_w;
1178 brX = blX; 1180 brX = blX;
1179 scrollbar->hide(); 1181 scrollbar->hide();
1180 break; 1182 break;
1181 case SCRLEFT : 1183 case SCRLEFT :
1182 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1184 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1183 if(vcolumns) columns = vcolumns; 1185 if(vcolumns) columns = vcolumns;
1184 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1186 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1187 if(showhscrollbar)
1188 brX = -hposition * font_w;
1185 blX = brX + scrollbar->width(); 1189 blX = brX + scrollbar->width();
1186 scrollbar->move(contentsRect().topLeft()); 1190 scrollbar->move(contentsRect().topLeft());
1187 scrollbar->show(); 1191 scrollbar->show();
1188 break; 1192 break;
1189 case SCRRIGHT: 1193 case SCRRIGHT:
1190 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1194 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1191 if(vcolumns) columns = vcolumns; 1195 if(vcolumns) columns = vcolumns;
1192 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1196 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1193 if(showhscrollbar) 1197 if(showhscrollbar)
1194 blX = -hposition * font_w; 1198 blX = -hposition * font_w;
1195 brX = blX; 1199 brX = blX;
1196 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); 1200 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
1197 scrollbar->show(); 1201 scrollbar->show();
1198 break; 1202 break;
1199 } 1203 }
1200 //FIXME: support 'rounding' styles 1204 //FIXME: support 'rounding' styles
1201 lines = ( contentsRect().height() - 2 * rimY ) / font_h; 1205 lines = ( contentsRect().height() - 2 * rimY ) / font_h;
1202 bY = (contentsRect().height() - (lines *font_h)) / 2; 1206 bY = (contentsRect().height() - (lines *font_h)) / 2;
1203 1207
1204 if(showhscrollbar == 1) 1208 if(showhscrollbar == 1)
1205 { 1209 {
1206 //bY = bY - 10; 1210 //bY = bY - 10;
1207 lines = lines - 1; 1211 lines = lines - 1;
1208 } 1212 }
1209} 1213}
1210 1214
1211void TEWidget::makeImage() 1215void TEWidget::makeImage()
1212//FIXME: rename 'calcGeometry? 1216//FIXME: rename 'calcGeometry?
1213{ 1217{
1214 calcGeometry(); 1218 calcGeometry();
1215 image = (ca*) malloc(lines*columns*sizeof(ca)); 1219 image = (ca*) malloc(lines*columns*sizeof(ca));
1216 clearImage(); 1220 clearImage();
1217} 1221}
1218 1222
1219// calculate the needed size 1223// calculate the needed size
1220QSize TEWidget::calcSize(int cols, int lins) const 1224QSize TEWidget::calcSize(int cols, int lins) const
1221{ 1225{
1222 int frw = width() - contentsRect().width(); 1226 int frw = width() - contentsRect().width();
1223 int frh = height() - contentsRect().height(); 1227 int frh = height() - contentsRect().height();
1224 int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); 1228 int scw = (scrollLoc==SCRNONE?0:scrollbar->width());
1225 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); 1229 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh );
1226} 1230}
1227 1231
1228QSize TEWidget::sizeHint() const 1232QSize TEWidget::sizeHint() const
1229{ 1233{
1230 return size(); 1234 return size();
1231} 1235}
1232 1236
1233void TEWidget::styleChange(QStyle &) 1237void TEWidget::styleChange(QStyle &)
1234{ 1238{
1235 propagateSize(); 1239 propagateSize();
1236} 1240}
1237 1241
1238#ifndef QT_NO_DRAGANDDROP 1242#ifndef QT_NO_DRAGANDDROP
1239 1243
1240/* --------------------------------------------------------------------- */ 1244/* --------------------------------------------------------------------- */
1241/* */ 1245/* */
1242/* Drag & Drop */ 1246/* Drag & Drop */
1243/* */ 1247/* */
1244/* --------------------------------------------------------------------- */ 1248/* --------------------------------------------------------------------- */
1245 1249
1246 1250
1247void TEWidget::dragEnterEvent(QDragEnterEvent* e) 1251void TEWidget::dragEnterEvent(QDragEnterEvent* e)
1248{ 1252{
1249 e->accept(QTextDrag::canDecode(e) || 1253 e->accept(QTextDrag::canDecode(e) ||
1250 QUriDrag::canDecode(e)); 1254 QUriDrag::canDecode(e));
1251} 1255}
1252 1256
1253void TEWidget::dropEvent(QDropEvent* event) 1257void TEWidget::dropEvent(QDropEvent* event)
1254{ 1258{
1255 // The current behaviour when url(s) are dropped is 1259 // The current behaviour when url(s) are dropped is
1256 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd 1260 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd
1257 // * in all other cases, just paste 1261 // * in all other cases, just paste
1258 // (for non-local ones, or for a list of URLs, 'cd' is nonsense) 1262 // (for non-local ones, or for a list of URLs, 'cd' is nonsense)
1259 QStrList strlist; 1263 QStrList strlist;
1260 int file_count = 0; 1264 int file_count = 0;
1261 dropText = ""; 1265 dropText = "";
1262 bool bPopup = true; 1266 bool bPopup = true;
1263 1267
1264 if(QUriDrag::decode(event, strlist)) { 1268 if(QUriDrag::decode(event, strlist)) {
1265 if (strlist.count()) { 1269 if (strlist.count()) {
1266 for(const char* p = strlist.first(); p; p = strlist.next()) { 1270 for(const char* p = strlist.first(); p; p = strlist.next()) {
1267 if(file_count++ > 0) { 1271 if(file_count++ > 0) {
1268 dropText += " "; 1272 dropText += " ";
1269 bPopup = false; // more than one file, don't popup 1273 bPopup = false; // more than one file, don't popup
1270 } 1274 }
1271 1275
1272/* 1276/*
1273 KURL url(p); 1277 KURL url(p);
1274 if (url.isLocalFile()) { 1278 if (url.isLocalFile()) {
1275 dropText += url.path(); // local URL : remove protocol 1279 dropText += url.path(); // local URL : remove protocol
1276 } 1280 }
1277 else { 1281 else {
1278 dropText += url.prettyURL(); 1282 dropText += url.prettyURL();
1279 bPopup = false; // a non-local file, don't popup 1283 bPopup = false; // a non-local file, don't popup
1280 } 1284 }
1281*/ 1285*/
1282 1286
1283 } 1287 }
1284 1288
1285 if (bPopup) 1289 if (bPopup)
1286 // m_drop->popup(pos() + event->pos()); 1290 // m_drop->popup(pos() + event->pos());
1287 m_drop->popup(mapToGlobal(event->pos())); 1291 m_drop->popup(mapToGlobal(event->pos()));
1288 else 1292 else
1289 { 1293 {
1290 if (currentSession) { 1294 if (currentSession) {
1291 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1295 currentSession->getEmulation()->sendString(dropText.local8Bit());
1292 } 1296 }
1293// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1297// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1294 } 1298 }
1295 } 1299 }
1296 } 1300 }
1297 else if(QTextDrag::decode(event, dropText)) { 1301 else if(QTextDrag::decode(event, dropText)) {
1298// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1302// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1299 if (currentSession) { 1303 if (currentSession) {
1300 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1304 currentSession->getEmulation()->sendString(dropText.local8Bit());
1301 } 1305 }
1302 // Paste it 1306 // Paste it
1303 } 1307 }
1304} 1308}
1305#endif 1309#endif
1306 1310
1307 1311
1308void TEWidget::drop_menu_activated(int) 1312void TEWidget::drop_menu_activated(int)
1309{ 1313{
1310#ifndef QT_NO_DRAGANDDROP 1314#ifndef QT_NO_DRAGANDDROP
1311 switch (item) 1315 switch (item)
1312 { 1316 {
1313 case 0: // paste 1317 case 0: // paste
1314 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1318 currentSession->getEmulation()->sendString(dropText.local8Bit());
1315// KWM::activate((Window)this->winId()); 1319// KWM::activate((Window)this->winId());
1316 break; 1320 break;
1317 case 1: // cd ... 1321 case 1: // cd ...
1318 currentSession->getEmulation()->sendString("cd "); 1322 currentSession->getEmulation()->sendString("cd ");
1319 struct stat statbuf; 1323 struct stat statbuf;
1320 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) 1324 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 )
1321 { 1325 {
1322 if ( !S_ISDIR(statbuf.st_mode) ) 1326 if ( !S_ISDIR(statbuf.st_mode) )
1323 { 1327 {
1324/* 1328/*
1325 KURL url; 1329 KURL url;
1326 url.setPath( dropText ); 1330 url.setPath( dropText );
1327 dropText = url.directory( true, false ); // remove filename 1331 dropText = url.directory( true, false ); // remove filename
1328*/ 1332*/
1329 } 1333 }
1330 } 1334 }
1331 dropText.replace(QRegExp(" "), "\\ "); // escape spaces 1335 dropText.replace(QRegExp(" "), "\\ "); // escape spaces
1332 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1336 currentSession->getEmulation()->sendString(dropText.local8Bit());
1333 currentSession->getEmulation()->sendString("\n"); 1337 currentSession->getEmulation()->sendString("\n");
1334// KWM::activate((Window)this->winId()); 1338// KWM::activate((Window)this->winId());
1335 break; 1339 break;
1336 } 1340 }
1337#endif 1341#endif
1338} 1342}
1339 1343
1340QPushButton* TEWidget::cornerButton() { 1344QPushButton* TEWidget::cornerButton() {
1341 return m_cornerButton; 1345 return m_cornerButton;
1342} 1346}
1343 1347
1344void TEWidget::setWrapAt(int columns) 1348void TEWidget::setWrapAt(int columns)
1345{ 1349{
1346 vcolumns = columns; 1350 vcolumns = columns;
1351 propagateSize();
1352 update();
1347} 1353}
1348 1354
1349 1355