Ticket #66: virtual_keyboard.patch

File virtual_keyboard.patch, 33.2 KB (added by jkondis <jkondis@…>, 20 years ago)

Provides a virtual keyboard for line edits for 0.18.x.

  • libs/libmyth/mythwidgets.cpp

     
    319319    QSlider::focusOutEvent(e);
    320320}
    321321
     322void MythLineEdit::Init()
     323{
     324    popup = 0;
     325    if (gContext->GetNumSetting("UseVirtualKeyboard", 1) == 1)
     326    {
     327        popup = new VKPopup(this, "Popup Virtual Keyboard",
     328                            gContext->GetLanguage());
     329    }
     330}
     331
    322332void MythLineEdit::keyPressEvent(QKeyEvent *e)
    323333{
    324334    bool handled = false;
     
    335345            else if (action == "DOWN")
    336346                focusNextPrevChild(true);
    337347            else if (action == "SELECT" && e->text().isNull())
    338                 e->ignore();
     348            {
     349                if (popup and !popup->isShown()) popup->show();
     350                else e->ignore();
     351            }
    339352            else
    340353                handled = false;
    341354        }
     
    12561269    QListBox::focusInEvent(e);
    12571270}
    12581271
     1272
     1273const int popupw = 438;
     1274const int popuph = 158;
     1275
     1276
     1277// English (US)
     1278
     1279const QString c_eng[] = {
     1280        "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "\\", "`",
     1281        "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]",
     1282        "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'",
     1283        "z", "x", "c", "v", "b", "n", "m", ",", ".", "/",
     1284        " ",
     1285        "Shift", "Lock", "<-", "->", "Shift", "Back", "Comp", "Del", "Done"
     1286};
     1287
     1288const QString c_eng_s[] = {
     1289        "!", "@", "#", "$", "%", "^", "&&", "*", "(", ")", "_", "+", "|", "~",
     1290        "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "{", "}",
     1291        "A", "S", "D", "F", "G", "H", "J", "K", "L", ":", "\"",
     1292        "Z", "X", "C", "V", "B", "N", "M", "<", ">", "?",
     1293        " ",
     1294        "", "", "", "", "", "", "", "", ""
     1295};
     1296
     1297const int x_eng[] = {
     1298        5, 35, 65,  95, 125, 155, 185, 215, 245, 275, 305, 335, 365, 395,
     1299        15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345,
     1300        25, 55, 85, 115, 145, 175, 205, 235, 265, 295, 325,
     1301        35, 65, 95, 125, 155, 185, 215, 245, 275, 305,
     1302        165,
     1303        5, 70, 285, 330, 375, 375, 335, 395, 355
     1304};
     1305
     1306const int y_eng[] = {
     1307        5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
     1308        35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
     1309        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
     1310        95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
     1311        125,
     1312        125, 125, 125, 125, 125, 35, 95, 95, 65
     1313};
     1314
     1315const int w_eng[] = {
     1316        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1317        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1318        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1319        28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1320        88,
     1321        63, 63, 43, 43, 58, 58, 58, 38, 78
     1322};
     1323
     1324
     1325// Greek
     1326
     1327const QString c_grk[] = {
     1328        "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "\\", "`",
     1329        "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]",
     1330        "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'",
     1331        "z", "x", "c", "v", "b", "n", "m", ",", ".", "/",
     1332        " ",
     1333        "Shift", "Lock", "AltGr", "<-", "->", "Shift", "Back", "Comp", "Del", "Done"
     1334};
     1335
     1336const QString c_grk_s[] = {
     1337        "!", "@", "#", "$", "%", "^", "&&", "*", "(", ")", "_", "+", "|", "~",
     1338        "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "{", "}",
     1339        "A", "S", "D", "F", "G", "H", "J", "K", "L", ":", "\"",
     1340        "Z", "X", "C", "V", "B", "N", "M", "<", ">", "?",
     1341        " ",
     1342        "", "", "", "", "", "", "", "", "", ""
     1343};
     1344
     1345const QString c_grk_m[] = {
     1346        "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "\\", "`",
     1347        (QChar)0x03b8, (QChar)0x03c9, (QChar)0x03b5, (QChar)0x03c1, (QChar)0x03c4, (QChar)0x03c8,
     1348                       (QChar)0x03c5, (QChar)0x03b9, (QChar)0x03bf, (QChar)0x03c0,  "[", "]",
     1349        (QChar)0x03b1, (QChar)0x03c3, (QChar)0x03b4, (QChar)0x03c6, (QChar)0x03b3, (QChar)0x03b7,
     1350                       "", (QChar)0x03ba, (QChar)0x03bb, ";", "'",
     1351        (QChar)0x03b6, (QChar)0x03be, (QChar)0x03c7, "", (QChar)0x03b2, (QChar)0x03bd,
     1352                       (QChar)0x03bc, ",", ".", "/",
     1353        " ",
     1354        "", "", "", "", "", "", "", "", "", ""
     1355};
     1356
     1357const QString c_grk_sm[] = {
     1358        "!", "@", "#", "$", "%", "^", "&&", "*", "(", ")", "_", "+", "|", "~",
     1359        (QChar)0x0398, (QChar)0x03a9, (QChar)0x0395, (QChar)0x03a1, (QChar)0x03a4, (QChar)0x03a8,
     1360                       (QChar)0x03a5, (QChar)0x0399, (QChar)0x039f, (QChar)0x03a0,  "[", "]",
     1361        (QChar)0x0391, (QChar)0x03a3, (QChar)0x0394, (QChar)0x03a6, (QChar)0x0393, (QChar)0x0397,
     1362                       "", (QChar)0x039a, (QChar)0x039b, ";", "'",
     1363        (QChar)0x0396, (QChar)0x039e, (QChar)0x03a7, "", (QChar)0x0392, (QChar)0x039d,
     1364                       (QChar)0x039c, ",", ".", "/",
     1365        " ",
     1366        "", "", "", "", "", "", "", "", "", ""
     1367};
     1368
     1369const int x_grk[] = {
     1370        5, 35, 65,  95, 125, 155, 185, 215, 245, 275, 305, 335, 365, 395,
     1371        15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345,
     1372        25, 55, 85, 115, 145, 175, 205, 235, 265, 295, 325,
     1373        35, 65, 95, 125, 155, 185, 215, 245, 275, 305,
     1374        135,
     1375        5, 70, 220, 285, 330, 375, 375, 335, 395, 355
     1376};
     1377
     1378const int y_grk[] = {
     1379        5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
     1380        35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
     1381        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
     1382        95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
     1383        125,
     1384        125, 125, 125, 125, 125, 125, 35, 95, 95, 65
     1385};
     1386
     1387const int w_grk[] = {
     1388        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1389        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1390        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1391        28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1392        83,
     1393        63, 63, 63, 43, 43, 58, 58, 58, 38, 78
     1394};
     1395
     1396
     1397// German
     1398
     1399const QString c_ger[] = {
     1400        "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "?", "`", "^", "#",
     1401        "q", "w", "e", "r", "t", "z", "u", "i", "o", "p", (QChar)0xfc, "+",
     1402        "a", "s", "d", "f", "g", "h", "j", "k", "l", (QChar)0xf6, (QChar)0xe4,
     1403        "<", "y", "x", "c", "v", "b", "n", "m", ",", ".", "-",
     1404        " ",
     1405        "Shift", "Lock", "AltGr", "<-", "->", "Shift", "Back", "Comp", "Del", "Done"
     1406};
     1407
     1408const QString c_ger_s[] = {
     1409        "!", "\"", (QChar)0xa7, "$", "%", "&&", "/", "(", ")", "=", (QChar)0xdf, "'", (QChar)0xb0, "|",
     1410        "Q", "W", "E", "R", "T", "Z", "U", "I", "O", "P", (QChar)0xdc, "*",
     1411        "A", "S", "D", "F", "G", "H", "J", "K", "L", (QChar)0xd6, (QChar)0xc4,
     1412        ">", "Y", "X", "C", "V", "B", "N", "M", ";", ":", "_",
     1413        " ",
     1414        "", "", "", "", "", "", "", "", "", ""
     1415};
     1416
     1417const QString c_ger_m[] = {
     1418        (QChar)0xb9, (QChar)0xb2, (QChar)0xb3, (QChar)0xa3, (QChar)0xac, (QChar)0xa9, "{", "[", "]", "}",
     1419                     "\\", "`", "^", "#",
     1420        "@", "w", "e", "r", "t", "z", "u", "i", "o", "p", (QChar)0xfc, "~",
     1421        "a", "s", "d", "f", "g", "h", "j", "k", "l", (QChar)0xf6, (QChar)0xe4,
     1422        "|", "y", "x", "c", "v", "b", "n", (QChar)0xb5, ",", ".", "_",
     1423        " ",
     1424        "", "", "", "", "", "", "", "", "", ""
     1425};
     1426
     1427const QString c_ger_sm[] = {
     1428        "!", "\"", (QChar)0xa7, "$", "%", "&&", "/", "(", ")", "=", (QChar)0xdf, "'", (QChar)0xb0, "|",
     1429        "Q", "W", "E", "R", "T", "Z", "U", "I", "O", "P", (QChar)0xdc, "*",
     1430        "A", "S", "D", "F", "G", "H", "J", "K", "L", (QChar)0xd6, (QChar)0xc4,
     1431        ">", "Y", "X", "C", "V", "B", "N", "M", ";", ":", "_",
     1432        " ",
     1433        "", "", "", "", "", "", "", "", "", ""
     1434};
     1435
     1436const int x_ger[] = {
     1437        5, 35, 65,  95, 125, 155, 185, 215, 245, 275, 305, 335, 365, 395,
     1438        15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345,
     1439        25, 55, 85, 115, 145, 175, 205, 235, 265, 295, 325,
     1440        5, 35, 65, 95, 125, 155, 185, 215, 245, 275, 305,
     1441        135,
     1442        5, 70, 220, 285, 330, 375, 375, 335, 395, 355
     1443};
     1444
     1445const int y_ger[] = {
     1446        5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
     1447        35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
     1448        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
     1449        95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
     1450        125,
     1451        125, 125, 125, 125, 125, 125, 35, 95, 95, 65
     1452};
     1453
     1454const int w_ger[] = {
     1455        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1456        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1457        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1458        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1459        83,
     1460        63, 63, 63, 43, 43, 58, 58, 58, 38, 78
     1461};
     1462
     1463 
     1464// French
     1465
     1466const QString c_frn[] = {
     1467        "&&", (QChar)0x00e9, "\"", "'", "(", "-", (QChar)0x00e8, "_", (QChar)0x00e7, (QChar)0x00e0,
     1468                ")", "=", (QChar)0x00b2, "*",
     1469        "a", "z", "e", "r", "t", "y", "u", "i", "o", "p", "^", "$",
     1470        "q", "s", "d", "f", "g", "h", "j", "k", "l", "m", (QChar)0x00f9,
     1471        "<", "w", "x", "c", "v", "b", "n", ",", ";", ":", "!",
     1472        " ",
     1473        "Shift", "Lock", "AltGr", "<-", "->", "Shift", "Back", "Comp", "Del", "Done"
     1474};
     1475
     1476const QString c_frn_s[] = {
     1477        "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", (QChar)0x00b0, "+", (QChar)0x00b3, (QChar)0x00b5,     
     1478        "A", "Z", "E", "R", "T", "Y", "U", "I", "O", "P", (QChar)0x00a8, (QChar)0x00a3,
     1479        "Q", "S", "D", "F", "G", "H", "J", "K", "L", "M", "%",
     1480        ">", "W", "X", "C", "V", "B", "N", "?", ".", "/", (QChar)0x00a7,
     1481        " ",
     1482        "", "", "", "", "", "", "", "", "", ""
     1483};
     1484
     1485const QString c_frn_m[] = {
     1486        "&&", "~", "#", "{", "[", "|", "`", "\\", "^", "@", "]", "}", (QChar)0x00b2, "*",
     1487        "a", "z", "e", "r", "t", "y", "u", "i", "o", "p", "^", (QChar)0x00a4,
     1488        "q", "s", "d", "f", "g", "h", "j", "k", "l", "m", (QChar)0x00f9,
     1489        "<", "w", "x", "c", "v", "b", "n", ",", ";", ":", "!",
     1490        " ",
     1491        "", "", "", "", "", "", "", "", "", ""
     1492};
     1493
     1494const QString c_frn_sm[] = {
     1495        "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", (QChar)0x00b0, "+", (QChar)0x00b3, (QChar)0x00b5,     
     1496        "A", "Z", "E", "R", "T", "Y", "U", "I", "O", "P", (QChar)0x00a8, (QChar)0x00a3,
     1497        "Q", "S", "D", "F", "G", "H", "J", "K", "L", "M", "%",
     1498        ">", "W", "X", "C", "V", "B", "N", "?", ".", "/", (QChar)0x00a7,
     1499        " ",
     1500        "", "", "", "", "", "", "", "", "", ""
     1501};
     1502
     1503const int x_frn[] = {
     1504        5, 35, 65,  95, 125, 155, 185, 215, 245, 275, 305, 335, 365, 395,
     1505        15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345,
     1506        25, 55, 85, 115, 145, 175, 205, 235, 265, 295, 325,
     1507        5, 35, 65, 95, 125, 155, 185, 215, 245, 275, 305,
     1508        135,
     1509        5, 70, 220, 285, 330, 375, 375, 335, 395, 355
     1510};
     1511
     1512const int y_frn[] = {
     1513        5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
     1514        35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
     1515        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
     1516        95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
     1517        125,
     1518        125, 125, 125, 125, 125, 125, 35, 95, 95, 65
     1519};
     1520
     1521const int w_frn[] = {
     1522        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1523        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1524        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1525        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1526        83,
     1527        63, 63, 63, 43, 43, 58, 58, 58, 38, 78
     1528};
     1529
     1530
     1531// Spanish
     1532
     1533const QString c_spa[] = {
     1534        "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "'", (QChar)0xbf, (QChar)0xba, (QChar)0xe7,
     1535        "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "`", "+",
     1536        "a", "s", "d", "f", "g", "h", "j", "k", "l", (QChar)0xf1, "'",
     1537        "<", "z", "x", "c", "v", "b", "n", "m", ",", ".", "-",
     1538        " ",
     1539        "Shift", "Lock", "AltGr", "<-", "->", "Shift", "Back", "Comp", "Del", "Done"
     1540};
     1541
     1542const QString c_spa_s[] = {
     1543        "!", "\"", (QChar)0xb7, "$", "%", "&&", "/", "(", ")", "=", "?", (QChar)0xa1, (QChar)0xaa, (QChar)0xc7,
     1544        "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "^", "*",
     1545        "A", "S", "D", "F", "G", "H", "J", "K", "L", (QChar)0xd1, "~",
     1546        ">", "Z", "X", "C", "V", "B", "N", "M", ";", ":", "_",
     1547        " ",
     1548        "", "", "", "", "", "", "", "", "", ""
     1549};
     1550
     1551const QString c_spa_m[] = {
     1552        "|", "@", "#", "4", "5", (QChar)0xac, "7", "8", "9", "0", "'", (QChar)0xbf, "\\", "}",
     1553        "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]",
     1554        "a", "s", "d", "f", "g", "h", "j", "k", "l", (QChar)0xf1, "{",
     1555        "<", "z", "x", "c", "v", "b", "n", "m", ",", ".", "-",
     1556        " ",
     1557        "Shift", "Lock", "AltGr", "<-", "->", "Shift", "Back", "Comp", "Del", "Done"
     1558};
     1559
     1560const QString c_spa_sm[] = {
     1561        "!", "\"", (QChar)0xb7, "$", "%", "&&", "/", "(", ")", "=", "?", (QChar)0xa1, (QChar)0xaa, (QChar)0xc7,
     1562        "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "^", "*",
     1563        "A", "S", "D", "F", "G", "H", "J", "K", "L", (QChar)0xd1, "~",
     1564        ">", "Z", "X", "C", "V", "B", "N", "M", ";", ":", "_",
     1565        " ",
     1566        "", "", "", "", "", "", "", "", "", ""
     1567};
     1568
     1569const int x_spa[] = {
     1570        5, 35, 65,  95, 125, 155, 185, 215, 245, 275, 305, 335, 365, 395,
     1571        15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345,
     1572        25, 55, 85, 115, 145, 175, 205, 235, 265, 295, 325,
     1573        5, 35, 65, 95, 125, 155, 185, 215, 245, 275, 305,
     1574        135,
     1575        5, 70, 220, 285, 330, 375, 375, 335, 395, 355
     1576};
     1577
     1578const int y_spa[] = {
     1579        5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
     1580        35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
     1581        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
     1582        95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
     1583        125,
     1584        125, 125, 125, 125, 125, 125, 35, 95, 95, 65
     1585};
     1586
     1587const int w_spa[] = {
     1588        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1589        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1590        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1591        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1592        83,
     1593        63, 63, 63, 43, 43, 58, 58, 58, 38, 78
     1594};
     1595
     1596
     1597// Italian
     1598
     1599const QString c_ita[] = {
     1600        "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "'", (QChar)0xec, "\\", (QChar)0xfa,
     1601        "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", (QChar)0xe8, "+",
     1602        "a", "s", "d", "f", "g", "h", "j", "k", "l", (QChar)0xf2, (QChar)0xe0,
     1603        "<", "z", "x", "c", "v", "b", "n", "m", ",", ".", "-",
     1604        " ",
     1605        "Shift", "Lock", "AltGr", "<-", "->", "Shift", "Back", "Comp", "Del", "Done"
     1606};
     1607
     1608const QString c_ita_s[] = {
     1609        "!", "\"", (QChar)0xa3, "$", "%", "&&", "/", "(", ")", "=", "?", "^", "|", (QChar)0xa7,
     1610        "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", (QChar)0xe9, "*",
     1611        "A", "S", "D", "F", "G", "H", "J", "K", "L", (QChar)0xe7, (QChar)0xb0,
     1612        ">", "Z", "X", "C", "V", "B", "N", "M", ";", ":", "_",
     1613        " ",
     1614        "", "", "", "", "", "", "", "", "", ""
     1615};
     1616
     1617const QString c_ita_m[] = {
     1618        "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "'", (QChar)0xec, "\\", (QChar)0xfa,
     1619        "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]",
     1620        "a", "s", "d", "f", "g", "h", "j", "k", "l", "@", "#",
     1621        "<", "z", "x", "c", "v", "b", "n", "m", ",", ".", "-",
     1622        " ",
     1623        "", "", "", "", "", "", "", "", "", ""
     1624};
     1625
     1626const QString c_ita_sm[] = {
     1627        "!", "\"", (QChar)0xa3, "$", "%", "&&", "/", "(", ")", "=", "?", "^", "|", (QChar)0xa7,
     1628        "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", (QChar)0xe9, "*",
     1629        "A", "S", "D", "F", "G", "H", "J", "K", "L", (QChar)0xe7, (QChar)0xb0,
     1630        ">", "Z", "X", "C", "V", "B", "N", "M", ";", ":", "_",
     1631        " ",
     1632        "", "", "", "", "", "", "", "", "", ""
     1633};
     1634
     1635const int x_ita[] = {
     1636        5, 35, 65,  95, 125, 155, 185, 215, 245, 275, 305, 335, 365, 395,
     1637        15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345,
     1638        25, 55, 85, 115, 145, 175, 205, 235, 265, 295, 325,
     1639        5, 35, 65, 95, 125, 155, 185, 215, 245, 275, 305,
     1640        135,
     1641        5, 70, 220, 285, 330, 375, 375, 335, 395, 355
     1642};
     1643
     1644const int y_ita[] = {
     1645        5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
     1646        35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
     1647        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
     1648        95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
     1649        125,
     1650        125, 125, 125, 125, 125, 125, 35, 95, 95, 65
     1651};
     1652
     1653const int w_ita[] = {
     1654        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1655        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1656        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1657        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1658        83,
     1659        63, 63, 63, 43, 43, 58, 58, 58, 38, 78
     1660};
     1661
     1662
     1663// English (UK)
     1664
     1665const QString c_uke[] = {
     1666        "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "`", "#",
     1667        "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]",
     1668        "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'",
     1669        "\\", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/",
     1670        " ",
     1671        "Shift", "Lock", "<-", "->", "Shift", "Back", "Comp", "Del", "Done"
     1672};
     1673
     1674const QString c_uke_s[] = {
     1675        "!", "\"", (QChar)0xa3, "$", "%", "^", "&&", "=", "(", ")", "_", "+", (QChar)0xac, "~",
     1676        "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "{", "}",
     1677        "A", "S", "D", "F", "G", "H", "J", "K", "L", ":", "@",
     1678        "|", "Z", "X", "C", "V", "B", "N", "M", "<", ">", "?",
     1679        " ",
     1680        "", "", "", "", "", "", "", "", ""
     1681};
     1682
     1683const int x_uke[] = {
     1684        5, 35, 65,  95, 125, 155, 185, 215, 245, 275, 305, 335, 365, 395,
     1685        15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345,
     1686        25, 55, 85, 115, 145, 175, 205, 235, 265, 295, 325,
     1687        5, 35, 65, 95, 125, 155, 185, 215, 245, 275, 305,
     1688        165,
     1689        5, 70, 285, 330, 375, 375, 335, 395, 355
     1690};
     1691
     1692const int y_uke[] = {
     1693        5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
     1694        35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
     1695        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
     1696        95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
     1697        125,
     1698        125, 125, 125, 125, 125, 35, 95, 95, 65
     1699};
     1700
     1701const int w_uke[] = {
     1702        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1703        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1704        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1705        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
     1706        88,
     1707        63, 63, 43, 43, 58, 58, 58, 38, 78
     1708};
     1709
     1710
     1711const int numcomps = 95;
     1712
     1713const QString comps[numcomps][3] = {
     1714        {"!", "!", (QChar)0xa1},        {"c", "/", (QChar)0xa2},
     1715        {"l", "-", (QChar)0xa3},        {"o", "x", (QChar)0xa4},
     1716        {"y", "-", (QChar)0xa5},        {"|", "|", (QChar)0xa6},
     1717        {"s", "o", (QChar)0xa7},        {"\"", "\"", (QChar)0xa8},
     1718        {"c", "o", (QChar)0xa9},        {"-", "a", (QChar)0xaa},
     1719        {"<", "<", (QChar)0xab},        {"-", "|", (QChar)0xac},
     1720        {"-", "-", (QChar)0xad},        {"r", "o", (QChar)0xae},
     1721        {"^", "-", (QChar)0xaf},        {"^", "0", (QChar)0xb0},
     1722        {"+", "-", (QChar)0xb1},        {"^", "2", (QChar)0xb2},
     1723        {"^", "3", (QChar)0xb3},        {"/", "/", (QChar)0xb4},
     1724        {"/", "u", (QChar)0xb5},        {"P", "!", (QChar)0xb6},
     1725        {"^", ".", (QChar)0xb7},        {",", ",", (QChar)0xb8},
     1726        {"^", "1", (QChar)0xb9},        {"_", "o", (QChar)0xba},
     1727        {">", ">", (QChar)0xbb},        {"1", "4", (QChar)0xbc},
     1728        {"1", "2", (QChar)0xbd},        {"3", "4", (QChar)0xbe},
     1729        {"?", "?", (QChar)0xbf},        {"A", "`", (QChar)0xc0},
     1730        {"A", "'", (QChar)0xc1},        {"A", "^", (QChar)0xc2},
     1731        {"A", "~", (QChar)0xc3},        {"A", "\"", (QChar)0xc4},
     1732        {"A", "*", (QChar)0xc5},        {"A", "E", (QChar)0xc6},
     1733        {"C", ",", (QChar)0xc7},        {"E", "`", (QChar)0xc8},
     1734        {"E", "'", (QChar)0xc9},        {"E", "^", (QChar)0xca},
     1735        {"E", "\"", (QChar)0xcb},       {"I", "`", (QChar)0xcc},
     1736        {"I", "'", (QChar)0xcd},        {"I", "^", (QChar)0xce},
     1737        {"I", "\"", (QChar)0xcf},       {"D", "-", (QChar)0xd0},
     1738        {"N", "~", (QChar)0xd1},        {"O", "`", (QChar)0xd2},
     1739        {"O", "'", (QChar)0xd3},        {"O", "^", (QChar)0xd4},
     1740        {"O", "~", (QChar)0xd5},        {"O", "\"", (QChar)0xd6},
     1741        {"x", "x", (QChar)0xd7},        {"O", "/", (QChar)0xd8},
     1742        {"U", "`", (QChar)0xd9},        {"U", "'", (QChar)0xda},
     1743        {"U", "^", (QChar)0xdb},        {"U", "\"", (QChar)0xdc},
     1744        {"Y", "'", (QChar)0xdd},        {"T", "H", (QChar)0xde},
     1745        {"s", "s", (QChar)0xdf},        {"a", "`", (QChar)0xe0},
     1746        {"a", "'", (QChar)0xe1},        {"a", "^", (QChar)0xe2},
     1747        {"a", "~", (QChar)0xe3},        {"a", "\"", (QChar)0xe4},
     1748        {"a", "*", (QChar)0xe5},        {"a", "e", (QChar)0xe6},
     1749        {"c", ",", (QChar)0xe7},        {"e", "`", (QChar)0xe8},
     1750        {"e", "'", (QChar)0xe9},        {"e", "^", (QChar)0xea},       
     1751        {"e", "\"", (QChar)0xeb},       {"i", "`", (QChar)0xec},
     1752        {"i", "'", (QChar)0xed},        {"i", "^", (QChar)0xee},
     1753        {"i", "\"", (QChar)0xef},       {"d", "-", (QChar)0xf0},
     1754        {"n", "~", (QChar)0xf1},        {"o", "`", (QChar)0xf2},
     1755        {"o", "'", (QChar)0xf3},        {"o", "^", (QChar)0xf4},
     1756        {"o", "~", (QChar)0xf5},        {"o", "\"", (QChar)0xf6},
     1757        {"-", ":", (QChar)0xf7},        {"o", "/", (QChar)0xf8},
     1758        {"u", "`", (QChar)0xf9},        {"u", "'", (QChar)0xfa},
     1759        {"u", "^", (QChar)0xfb},        {"u", "\"", (QChar)0xfc},
     1760        {"y", "'", (QChar)0xfd},        {"t", "h", (QChar)0xfe},
     1761        {"y", "\"", (QChar)0xff}
     1762};
     1763
     1764
     1765VKButton::VKButton(QWidget *parent, const char* name, QString ckey,
     1766                         QString ckey_s, QString ckey_m, QString ckey_sm):
     1767    QPushButton(name, parent, name)
     1768{
     1769    mykey = ckey;
     1770    mykey_s = ckey_s;
     1771    mykey_m = ckey_m;
     1772    mykey_sm = ckey_sm;
     1773    setText(name);
     1774    setShiftState(false, false);
     1775    highlight(false);
     1776    if (!mykey_s.isEmpty())
     1777    {
     1778        // Regular keys pass their own text and tell the shift button
     1779        // they've been pressed.
     1780        connect (this, SIGNAL( pressed() ), SLOT ( pressKey() ) );
     1781        connect (this, SIGNAL( released() ), parent, SLOT( shiftOff() ) );
     1782    }
     1783}
     1784
     1785void VKButton::highlight(bool b)
     1786{
     1787    // QnD way to highlight a button when popup doesn't get focus.
     1788    setFlat(!b);
     1789    setDefault(b);
     1790}
     1791
     1792bool VKButton::isHighlighted()
     1793{
     1794    return (!isFlat());
     1795}
     1796
     1797void VKButton::setShiftState(bool sh, bool ag)
     1798{
     1799    if (!mykey.isEmpty())
     1800    {
     1801        if (sh)
     1802        {
     1803            if (ag) this->setText(mykey_sm);
     1804            else this->setText(mykey_s);
     1805        }
     1806        else
     1807        {
     1808            if (ag) this->setText(mykey_m);
     1809            else this->setText(mykey);
     1810        }
     1811    }
     1812}
     1813
     1814void VKButton::pressKey()
     1815{
     1816    VKPopup *par = (VKPopup *)parentWidget();
     1817    if (text().mid(0,1) == "&")  // Special treatment for underline character '&'
     1818        par->makeInsert(text().mid(1,1));
     1819    else
     1820        par->makeInsert(text().mid(0,1));
     1821}
     1822
     1823   
     1824VKPopup::VKPopup(QWidget *parent, const char* name, QString lang)
     1825    : QFrame(parent, name, WType_Popup)
     1826{
     1827    setFrameStyle( WinPanel|Raised );
     1828    compTrap = false;
     1829    iComp = iAltGr = iShiftL = iShiftR = iDone = 0;
     1830    iLock = iDel = iBack = iLeft = iRight = 0;
     1831   
     1832    for (int i=0; i<100; i++) but[i]=0;
     1833   
     1834    bool finished=false;
     1835    for (int i=0; !finished; i++)
     1836    {
     1837        QString k, k_s, k_m, k_sm;
     1838        int x, y, w;
     1839        if (lang.lower() == "gr")
     1840        {
     1841            k = c_grk[i];
     1842            k_s = c_grk_s[i];
     1843            k_m = c_grk_m[i];
     1844            k_sm = c_grk_sm[i];
     1845            x = x_grk[i];
     1846            y = y_grk[i];
     1847            w = w_grk[i];
     1848        }
     1849        else if (lang.lower() == "fr")
     1850        {
     1851            k = c_frn[i];
     1852            k_s = c_frn_s[i];
     1853            k_m = c_frn_m[i];
     1854            k_sm = c_frn_sm[i];
     1855            x = x_frn[i];
     1856            y = y_frn[i];
     1857            w = w_frn[i];
     1858        }
     1859        else if (lang.lower() == "de")
     1860        {
     1861            k = c_ger[i];
     1862            k_s = c_ger_s[i];
     1863            k_m = c_ger_m[i];
     1864            k_sm = c_ger_sm[i];
     1865            x = x_ger[i];
     1866            y = y_ger[i];
     1867            w = w_ger[i];
     1868        }
     1869        else if (lang.lower() == "es")
     1870        {
     1871            k = c_spa[i];
     1872            k_s = c_spa_s[i];
     1873            k_m = c_spa_m[i];
     1874            k_sm = c_spa_sm[i];
     1875            x = x_spa[i];
     1876            y = y_spa[i];
     1877            w = w_spa[i];
     1878        }
     1879        else if (lang.lower() == "it")
     1880        {
     1881            k = c_ita[i];
     1882            k_s = c_ita_s[i];
     1883            k_m = c_ita_m[i];
     1884            k_sm = c_ita_sm[i];
     1885            x = x_ita[i];
     1886            y = y_ita[i];
     1887            w = w_ita[i];
     1888        }
     1889        else if (lang.lower() == "en")
     1890        {
     1891            QString alang = getenv("LANG");
     1892            if (alang.contains("en_uk", false))
     1893            {
     1894                k = c_uke[i];
     1895                k_s = c_uke_s[i];
     1896                k_m = k;
     1897                k_sm = k_s;
     1898                x = x_uke[i];
     1899                y = y_uke[i];
     1900                w = w_uke[i];
     1901            }
     1902            else
     1903            {
     1904                k = c_eng[i];
     1905                k_s = c_eng_s[i];
     1906                k_m = k;
     1907                k_sm = k_s;
     1908                x = x_eng[i];
     1909                y = y_eng[i];
     1910                w = w_eng[i];
     1911            }
     1912        }
     1913        else
     1914        {
     1915            k = c_eng[i];
     1916            k_s = c_eng_s[i];
     1917            k_m = k;
     1918            k_sm = k_s;
     1919            x = x_eng[i];
     1920            y = y_eng[i];
     1921            w = w_eng[i];
     1922        }
     1923       
     1924        if (!k_s.isEmpty())
     1925        {
     1926            QString bname;
     1927            bname.setNum(i);
     1928            but[i] = new VKButton(this, "Key"+bname, k, k_s, k_m, k_sm);
     1929        }
     1930        else
     1931        {
     1932            but[i] = new VKButton(this, k);
     1933            if (k == "Shift")
     1934            {
     1935                if (iShiftL) iShiftR = i;
     1936                else iShiftL = i;
     1937            }
     1938            else if (k == "Lock") iLock = i;
     1939            else if (k == "AltGr") iAltGr = i;
     1940            else if (k == "Comp") iComp = i;
     1941            else if (k == "<-") iLeft = i;
     1942            else if (k == "->") iRight = i;
     1943            else if (k == "Back") iBack = i;
     1944            else if (k == "Del") iDel = i;
     1945            else if (k == "Done")
     1946            {
     1947                iDone = i;
     1948                but[iDone]->highlight(true);
     1949                finished = true;
     1950            }
     1951        }
     1952        but[i]->setGeometry(x, y, w, 28);
     1953    }
     1954
     1955    if (iAltGr)
     1956    {
     1957        but[iAltGr]->setToggleButton(true);
     1958        but[iAltGr]->setOn(false);
     1959    }
     1960   
     1961    but[iShiftL]->setToggleButton(true);
     1962    but[iShiftL]->setOn(false);
     1963
     1964    but[iShiftR]->setToggleButton(true);
     1965    but[iShiftR]->setOn(false);
     1966   
     1967    but[iLock]->setToggleButton(true);
     1968    but[iLock]->setOn(false);
     1969
     1970    connect(but[iDone], SIGNAL( released() ), this, SLOT( close() ) );
     1971    connect(but[iShiftL], SIGNAL( released() ), this, SLOT( shiftLOnOff() ) );
     1972    connect(but[iShiftR], SIGNAL( released() ), this, SLOT( shiftROnOff() ) );
     1973    if (iAltGr) connect(but[iAltGr], SIGNAL( released() ), this, SLOT( altGrOnOff() ) );
     1974    connect(but[iComp], SIGNAL( released() ), this, SLOT( compOnOff() ) );
     1975    connect(but[iLock], SIGNAL( released() ), this, SLOT( lockOnOff() ) );
     1976    connect(but[iLeft], SIGNAL( released() ), this, SLOT( leftCursor() ) );
     1977    connect(but[iRight], SIGNAL( released() ), this, SLOT( rightCursor() ) );
     1978    connect(but[iBack], SIGNAL( released() ), this, SLOT( backspaceKey() ) );
     1979    connect(but[iDel], SIGNAL( released() ), this, SLOT( delKey() ) );
     1980}
     1981
     1982VKPopup::~VKPopup()
     1983{
     1984    for (int i=0; but[i]; i++)
     1985        delete but[i];
     1986}
     1987
     1988void VKPopup::leftCursor()
     1989{
     1990    QLineEdit *par = (QLineEdit *)parentWidget();
     1991    par->cursorBackward(but[iShiftL]->isOn());
     1992}
     1993
     1994void VKPopup::rightCursor()
     1995{
     1996    QLineEdit *par = (QLineEdit *)parentWidget();
     1997    par->cursorForward(but[iShiftL]->isOn());
     1998}
     1999
     2000void VKPopup::backspaceKey()
     2001{
     2002    QLineEdit *par = (QLineEdit *)parentWidget();
     2003    par->backspace();
     2004}
     2005
     2006void VKPopup::delKey()
     2007{
     2008    QLineEdit *par = (QLineEdit *)parentWidget();
     2009    par->del();
     2010}
     2011
     2012void VKPopup::hide()
     2013{
     2014    releaseKeyboard();
     2015    parentWidget()->setFocus();
     2016    QFrame::hide();
     2017}
     2018   
     2019void VKPopup::show()
     2020{
     2021    QWidget *pw = parentWidget();
     2022            QWidget *tlw = pw->topLevelWidget();
     2023    QRect pwg = pw->geometry();
     2024    QRect tlwg = tlw->frameGeometry();
     2025
     2026    QPoint newpos;
     2027    if (pw->mapTo(tlw, QPoint(0,pwg.height()+popuph+5)).y()
     2028        < tlwg.height())
     2029    {
     2030        newpos = QPoint(pwg.width()/2-popupw/2, pwg.height() + 5);
     2031    }
     2032    else {
     2033        newpos = QPoint(pwg.width()/2-popupw/2, -5-popuph);
     2034    }
     2035
     2036    int delx = pw->mapTo(tlw,newpos).x() + popupw-tlwg.width();
     2037    newpos = QPoint(newpos.x()-(delx > 0 ? delx : 0), newpos.y());
     2038    delx = pw->mapTo(tlw, newpos).x();
     2039    newpos = QPoint(newpos.x()-(delx < 0 ? delx : 0), newpos.y());
     2040    //  TODO: can we blank the cursor?
     2041    this->resize(popupw,popuph);
     2042    for (int i=0; but[i]; i++)
     2043        but[i]->highlight(false);
     2044    but[iDone]->highlight(true);   
     2045    but[iShiftL]->setOn(false);
     2046    but[iShiftR]->setOn(false);
     2047    if (iAltGr) but[iAltGr]->setOn(false);
     2048    but[iLock]->setOn(false);
     2049    if (compTrap) compOnOff();
     2050    updateButtons();
     2051    this->move( pw->mapToGlobal( newpos ) );
     2052    grabKeyboard();
     2053    QFrame::show();
     2054    pw->setFocus();
     2055}
     2056
     2057void VKPopup::makeInsert(QString c)
     2058{
     2059    QLineEdit *par = (QLineEdit *)parentWidget();
     2060    if (!compTrap)
     2061    {
     2062        par->insert(c);
     2063    }
     2064    else
     2065    {
     2066        if (comp1.isEmpty()) comp1 = c;
     2067        else
     2068        {
     2069            // Produce the composed key.
     2070            for (int i=0; i<numcomps; i++)
     2071            {
     2072                if ((comp1 == comps[i][0]) && (c == comps[i][1]))
     2073                {
     2074                    par->insert(comps[i][2]);
     2075                    break;
     2076                }
     2077            }
     2078            // Reset compTrap.
     2079            comp1 = "";
     2080            compTrap = false;
     2081        }
     2082    }
     2083}
     2084
     2085void VKPopup::altGrOnOff()
     2086{
     2087    if (but[iLock]->isOn())
     2088    {
     2089        but[iShiftL]->setOn(false);
     2090        but[iShiftR]->setOn(false);
     2091        if (iAltGr) but[iAltGr]->setOn(false);
     2092        but[iLock]->setOn(false);
     2093    }
     2094    updateButtons();
     2095}
     2096
     2097void VKPopup::compOnOff()
     2098{
     2099    compTrap = !compTrap;
     2100    comp1 = "";
     2101}
     2102
     2103void VKPopup::lockOnOff()
     2104{
     2105    if (but[iLock]->isOn())
     2106    {
     2107        if (!(iAltGr && but[iAltGr]->isOn()))
     2108        {
     2109            but[iShiftL]->setOn(true);
     2110            but[iShiftR]->setOn(true);
     2111        }
     2112    }
     2113    else
     2114    {
     2115        but[iShiftL]->setOn(false);
     2116        but[iShiftR]->setOn(false);
     2117        if (iAltGr) but[iAltGr]->setOn(false);
     2118    }
     2119    updateButtons();
     2120}
     2121
     2122void VKPopup::shiftOff()
     2123{
     2124    if (!but[iLock]->isOn())
     2125    {
     2126        but[iShiftL]->setOn(false);
     2127        but[iShiftR]->setOn(false);
     2128        if (iAltGr) but[iAltGr]->setOn(false);
     2129    }
     2130    updateButtons();
     2131}
     2132
     2133void VKPopup::updateButtons()
     2134{
     2135    bool st_shift = but[iShiftL]->isOn();
     2136    bool st_altgr = (iAltGr ? but[iAltGr]->isOn() : false);
     2137    for (int i=0; but[i]; i++)
     2138    {
     2139        but[i]->setShiftState(st_shift, st_altgr);
     2140    }
     2141}
     2142
     2143void VKPopup::shiftLOnOff()
     2144{
     2145    if (but[iLock]->isOn())
     2146    {
     2147        but[iShiftL]->setOn(false);
     2148        but[iShiftR]->setOn(false);
     2149        if (iAltGr) but[iAltGr]->setOn(false);
     2150        but[iLock]->setOn(false);
     2151    }
     2152    else but[iShiftR]->setOn(but[iShiftL]->isOn());
     2153    updateButtons();
     2154}
     2155
     2156void VKPopup::shiftROnOff()
     2157{
     2158    if (but[iLock]->isOn())
     2159    {
     2160        but[iShiftL]->setOn(false);
     2161        but[iShiftR]->setOn(false);
     2162        if (iAltGr) but[iAltGr]->setOn(false);
     2163        but[iLock]->setOn(false);
     2164    }
     2165    else but[iShiftL]->setOn(but[iShiftR]->isOn());
     2166    updateButtons();
     2167}
     2168
     2169VKButton * VKPopup::sideButton(VKButton * oldbut, int dirkey)
     2170{
     2171    QRect butrect = oldbut->frameGeometry();
     2172    QPoint newpoint;
     2173    switch (dirkey) {
     2174        case Qt::Key_Left:
     2175            newpoint = QPoint(butrect.left()-20, butrect.center().y());
     2176            break;
     2177        case Qt::Key_Right:
     2178            newpoint = QPoint(butrect.right()+20, butrect.center().y());
     2179            break;
     2180        case Qt::Key_Up:
     2181            newpoint = QPoint(butrect.center().x(), butrect.top()-20);
     2182            break;
     2183        case Qt::Key_Down:
     2184            newpoint = QPoint(butrect.center().x(), butrect.bottom()+20);
     2185            break;
     2186    }
     2187    int ibest = 0;
     2188    int bestdist = (newpoint - but[ibest]->frameGeometry().center()).manhattanLength();
     2189    for (int i=0; but[i]; i++)
     2190    {
     2191        int thisdist = (newpoint - but[i]->frameGeometry().center()).manhattanLength();
     2192        if (thisdist < bestdist) {
     2193            bestdist = thisdist;
     2194            ibest = i;
     2195        }
     2196    }
     2197    return but[ibest];
     2198}
     2199
     2200VKButton* VKPopup::highButton()
     2201{
     2202    for (int i=0; but[i]; i++)
     2203    {
     2204        if (but[i]->isHighlighted())
     2205            return but[i];
     2206    }
     2207    return but[0];
     2208}
     2209
     2210void VKPopup::keyPressEvent(QKeyEvent *e)
     2211{
     2212    switch (e->key())
     2213    {
     2214        case Qt::Key_Escape:
     2215            if (e->type() == QEvent::KeyPress) hide();
     2216            e->accept();
     2217            break;
     2218        case Qt::Key_Return :
     2219            if (e->type() == QEvent::KeyPress) highButton()->animateClick();
     2220            e->accept();
     2221            break;
     2222        case Qt::Key_Right :
     2223        case Qt::Key_Left :
     2224        case Qt::Key_Up :
     2225        case Qt::Key_Down :
     2226            if (e->type() == QEvent::KeyPress)
     2227            {
     2228                VKButton* selected = highButton();
     2229                selected->highlight(false);
     2230                sideButton(selected, e->key())->highlight(true);
     2231            }
     2232            e->accept();
     2233            break;
     2234        default :
     2235            e->ignore();
     2236    }
     2237
     2238    if (! e->isAccepted())
     2239    {
     2240        QApplication::postEvent(parentWidget(), new QKeyEvent(e->type(), e->key(),
     2241                 e->ascii(), e->state(), e->text(), e->isAutoRepeat(), e->count()));
     2242        parentWidget()->setFocus();
     2243    }
     2244}
  • libs/libmyth/mythwidgets.h

     
    117117    Q_OBJECT
    118118  public:
    119119    MythLineEdit(QWidget *parent=NULL, const char* widgetName=0) :
    120       QLineEdit(parent, widgetName) { rw = true; };
     120      QLineEdit(parent, widgetName) { rw = true; Init(); };
    121121
    122122    MythLineEdit(const QString& contents, QWidget *parent=NULL,
    123123                 const char* widgetName=0) :
    124       QLineEdit(contents, parent, widgetName) { rw = true; };
     124      QLineEdit(contents, parent, widgetName) { rw = true; Init(); };
    125125
     126    virtual ~MythLineEdit() { if (popup) { delete popup; } };
     127
    126128    void setHelpText(QString help) { helptext = help; };
    127129    void setRW(bool readwrite = true) { rw = readwrite; };
    128130    void setRO() { rw = false; };
     
    137139    virtual void keyPressEvent(QKeyEvent *e);
    138140    virtual void focusInEvent(QFocusEvent *e);
    139141    virtual void focusOutEvent(QFocusEvent *e);
     142    void Init(void);
    140143
    141144  private:
     145    QFrame * popup;
    142146    QString helptext;
    143147    bool rw;
    144148};
     
    345349    QString helptext;
    346350};
    347351
     352
     353class VKButton : public QPushButton
     354{
     355     Q_OBJECT
     356 public:
     357     VKButton( QWidget *parent=0, const char*  name=0, QString ckey="",
     358                  QString ckey_s="", QString ckey_m="", QString ckey_sm="");
     359     void setShiftState(bool sh, bool ag);
     360     void highlight(bool b);
     361     bool isHighlighted();
     362
     363 private slots:
     364     void pressKey();
     365     
     366 private:
     367     QString mykey, mykey_s, mykey_m, mykey_sm;
     368};
     369
     370
     371class VKPopup : public QFrame
     372{
     373     Q_OBJECT
     374 public:
     375     VKPopup(QWidget *parent=0, const char* name=0, QString lang="en");
     376     virtual ~VKPopup();
     377     void makeInsert(QString c);
     378
     379 protected:
     380     VKButton * highButton();
     381     VKButton * sideButton(VKButton * oldbut, int dirkey);
     382
     383 public slots:
     384     virtual void show();
     385     virtual void hide();
     386
     387 private slots:
     388     virtual void keyPressEvent(QKeyEvent *e);
     389     void lockOnOff();
     390     void shiftLOnOff();
     391     void shiftROnOff();
     392     void shiftOff();
     393     void altGrOnOff();
     394     void compOnOff();
     395     void updateButtons();
     396     void leftCursor();
     397     void rightCursor();
     398     void backspaceKey();
     399     void delKey();
     400
     401 private:
     402     VKButton *but[100];
     403     bool compTrap;
     404     QString comp1;
     405     int iDone, iShiftL, iShiftR, iAltGr, iComp, iLock,
     406         iLeft, iRight, iBack, iDel;
     407};
     408
    348409#endif
  • programs/mythfrontend/globalsettings.cpp

     
    10131013    return gc;
    10141014}
    10151015
     1016static HostCheckBox *UseVirtualKeyboard()
     1017{
     1018    HostCheckBox *gc = new HostCheckBox("UseVirtualKeyboard");
     1019    gc->setLabel(QObject::tr("Use line edit virtual keyboards"));
     1020    gc->setValue(true);
     1021    gc->setHelpText(QObject::tr("Allows you to use a virtual keyboard "
     1022                    "in Myth line edit boxes.  To use, hit OK/Select "
     1023                    "while a line edit is in focus."));
     1024    return gc;
     1025}
     1026
    10161027static HostComboBox *AllowQuitShutdown()
    10171028{
    10181029    HostComboBox *gc = new HostComboBox("AllowQuitShutdown");
     
    30323043    qttheme->addChild(QtFontBig());
    30333044    qttheme->addChild(PlayBoxTransparency());
    30343045    qttheme->addChild(PlayBoxShading());
     3046    qttheme->addChild(UseVirtualKeyboard());
    30353047    addChild(qttheme );
    30363048
    30373049    addChild(new LcdSettings());