-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 | |||
@@ -1200,230 +1200,232 @@ void TEWidget::Bell() | |||
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 | } |