Ticket #66: virtual_keyboard_font_palette.patch

File virtual_keyboard_font_palette.patch, 33.3 KB (added by jkondis <jkondis@…>, 19 years ago)

This replaces the previous patch - it adds palette and font support, which I had forgotten to do before.

  • 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        but[i]->setFont(parentWidget()->font());
     1954    }
     1955
     1956    if (iAltGr)
     1957    {
     1958        but[iAltGr]->setToggleButton(true);
     1959        but[iAltGr]->setOn(false);
     1960    }
     1961   
     1962    but[iShiftL]->setToggleButton(true);
     1963    but[iShiftL]->setOn(false);
     1964
     1965    but[iShiftR]->setToggleButton(true);
     1966    but[iShiftR]->setOn(false);
     1967   
     1968    but[iLock]->setToggleButton(true);
     1969    but[iLock]->setOn(false);
     1970
     1971    connect(but[iDone], SIGNAL( released() ), this, SLOT( close() ) );
     1972    connect(but[iShiftL], SIGNAL( released() ), this, SLOT( shiftLOnOff() ) );
     1973    connect(but[iShiftR], SIGNAL( released() ), this, SLOT( shiftROnOff() ) );
     1974    if (iAltGr) connect(but[iAltGr], SIGNAL( released() ), this, SLOT( altGrOnOff() ) );
     1975    connect(but[iComp], SIGNAL( released() ), this, SLOT( compOnOff() ) );
     1976    connect(but[iLock], SIGNAL( released() ), this, SLOT( lockOnOff() ) );
     1977    connect(but[iLeft], SIGNAL( released() ), this, SLOT( leftCursor() ) );
     1978    connect(but[iRight], SIGNAL( released() ), this, SLOT( rightCursor() ) );
     1979    connect(but[iBack], SIGNAL( released() ), this, SLOT( backspaceKey() ) );
     1980    connect(but[iDel], SIGNAL( released() ), this, SLOT( delKey() ) );
     1981}
     1982
     1983VKPopup::~VKPopup()
     1984{
     1985    for (int i=0; but[i]; i++)
     1986        delete but[i];
     1987}
     1988
     1989void VKPopup::leftCursor()
     1990{
     1991    QLineEdit *par = (QLineEdit *)parentWidget();
     1992    par->cursorBackward(but[iShiftL]->isOn());
     1993}
     1994
     1995void VKPopup::rightCursor()
     1996{
     1997    QLineEdit *par = (QLineEdit *)parentWidget();
     1998    par->cursorForward(but[iShiftL]->isOn());
     1999}
     2000
     2001void VKPopup::backspaceKey()
     2002{
     2003    QLineEdit *par = (QLineEdit *)parentWidget();
     2004    par->backspace();
     2005}
     2006
     2007void VKPopup::delKey()
     2008{
     2009    QLineEdit *par = (QLineEdit *)parentWidget();
     2010    par->del();
     2011}
     2012
     2013void VKPopup::hide()
     2014{
     2015    releaseKeyboard();
     2016    parentWidget()->setFocus();
     2017    QFrame::hide();
     2018}
     2019   
     2020void VKPopup::show()
     2021{
     2022    QWidget *pw = parentWidget();
     2023            QWidget *tlw = pw->topLevelWidget();
     2024    QRect pwg = pw->geometry();
     2025    QRect tlwg = tlw->frameGeometry();
     2026
     2027    setPalette(parentWidget()->palette());
     2028    QPoint newpos;
     2029    if (pw->mapTo(tlw, QPoint(0,pwg.height()+popuph+5)).y()
     2030        < tlwg.height())
     2031    {
     2032        newpos = QPoint(pwg.width()/2-popupw/2, pwg.height() + 5);
     2033    }
     2034    else {
     2035        newpos = QPoint(pwg.width()/2-popupw/2, -5-popuph);
     2036    }
     2037
     2038    int delx = pw->mapTo(tlw,newpos).x() + popupw-tlwg.width();
     2039    newpos = QPoint(newpos.x()-(delx > 0 ? delx : 0), newpos.y());
     2040    delx = pw->mapTo(tlw, newpos).x();
     2041    newpos = QPoint(newpos.x()-(delx < 0 ? delx : 0), newpos.y());
     2042    //  TODO: can we blank the cursor?
     2043    this->resize(popupw,popuph);
     2044    for (int i=0; but[i]; i++)
     2045        but[i]->highlight(false);
     2046    but[iDone]->highlight(true);   
     2047    but[iShiftL]->setOn(false);
     2048    but[iShiftR]->setOn(false);
     2049    if (iAltGr) but[iAltGr]->setOn(false);
     2050    but[iLock]->setOn(false);
     2051    if (compTrap) compOnOff();
     2052    updateButtons();
     2053    this->move( pw->mapToGlobal( newpos ) );
     2054    grabKeyboard();
     2055    QFrame::show();
     2056    pw->setFocus();
     2057}
     2058
     2059void VKPopup::makeInsert(QString c)
     2060{
     2061    QLineEdit *par = (QLineEdit *)parentWidget();
     2062    if (!compTrap)
     2063    {
     2064        par->insert(c);
     2065    }
     2066    else
     2067    {
     2068        if (comp1.isEmpty()) comp1 = c;
     2069        else
     2070        {
     2071            // Produce the composed key.
     2072            for (int i=0; i<numcomps; i++)
     2073            {
     2074                if ((comp1 == comps[i][0]) && (c == comps[i][1]))
     2075                {
     2076                    par->insert(comps[i][2]);
     2077                    break;
     2078                }
     2079            }
     2080            // Reset compTrap.
     2081            comp1 = "";
     2082            compTrap = false;
     2083        }
     2084    }
     2085}
     2086
     2087void VKPopup::altGrOnOff()
     2088{
     2089    if (but[iLock]->isOn())
     2090    {
     2091        but[iShiftL]->setOn(false);
     2092        but[iShiftR]->setOn(false);
     2093        if (iAltGr) but[iAltGr]->setOn(false);
     2094        but[iLock]->setOn(false);
     2095    }
     2096    updateButtons();
     2097}
     2098
     2099void VKPopup::compOnOff()
     2100{
     2101    compTrap = !compTrap;
     2102    comp1 = "";
     2103}
     2104
     2105void VKPopup::lockOnOff()
     2106{
     2107    if (but[iLock]->isOn())
     2108    {
     2109        if (!(iAltGr && but[iAltGr]->isOn()))
     2110        {
     2111            but[iShiftL]->setOn(true);
     2112            but[iShiftR]->setOn(true);
     2113        }
     2114    }
     2115    else
     2116    {
     2117        but[iShiftL]->setOn(false);
     2118        but[iShiftR]->setOn(false);
     2119        if (iAltGr) but[iAltGr]->setOn(false);
     2120    }
     2121    updateButtons();
     2122}
     2123
     2124void VKPopup::shiftOff()
     2125{
     2126    if (!but[iLock]->isOn())
     2127    {
     2128        but[iShiftL]->setOn(false);
     2129        but[iShiftR]->setOn(false);
     2130        if (iAltGr) but[iAltGr]->setOn(false);
     2131    }
     2132    updateButtons();
     2133}
     2134
     2135void VKPopup::updateButtons()
     2136{
     2137    bool st_shift = but[iShiftL]->isOn();
     2138    bool st_altgr = (iAltGr ? but[iAltGr]->isOn() : false);
     2139    for (int i=0; but[i]; i++)
     2140    {
     2141        but[i]->setShiftState(st_shift, st_altgr);
     2142    }
     2143}
     2144
     2145void VKPopup::shiftLOnOff()
     2146{
     2147    if (but[iLock]->isOn())
     2148    {
     2149        but[iShiftL]->setOn(false);
     2150        but[iShiftR]->setOn(false);
     2151        if (iAltGr) but[iAltGr]->setOn(false);
     2152        but[iLock]->setOn(false);
     2153    }
     2154    else but[iShiftR]->setOn(but[iShiftL]->isOn());
     2155    updateButtons();
     2156}
     2157
     2158void VKPopup::shiftROnOff()
     2159{
     2160    if (but[iLock]->isOn())
     2161    {
     2162        but[iShiftL]->setOn(false);
     2163        but[iShiftR]->setOn(false);
     2164        if (iAltGr) but[iAltGr]->setOn(false);
     2165        but[iLock]->setOn(false);
     2166    }
     2167    else but[iShiftL]->setOn(but[iShiftR]->isOn());
     2168    updateButtons();
     2169}
     2170
     2171VKButton * VKPopup::sideButton(VKButton * oldbut, int dirkey)
     2172{
     2173    QRect butrect = oldbut->frameGeometry();
     2174    QPoint newpoint;
     2175    switch (dirkey) {
     2176        case Qt::Key_Left:
     2177            newpoint = QPoint(butrect.left()-20, butrect.center().y());
     2178            break;
     2179        case Qt::Key_Right:
     2180            newpoint = QPoint(butrect.right()+20, butrect.center().y());
     2181            break;
     2182        case Qt::Key_Up:
     2183            newpoint = QPoint(butrect.center().x(), butrect.top()-20);
     2184            break;
     2185        case Qt::Key_Down:
     2186            newpoint = QPoint(butrect.center().x(), butrect.bottom()+20);
     2187            break;
     2188    }
     2189    int ibest = 0;
     2190    int bestdist = (newpoint - but[ibest]->frameGeometry().center()).manhattanLength();
     2191    for (int i=0; but[i]; i++)
     2192    {
     2193        int thisdist = (newpoint - but[i]->frameGeometry().center()).manhattanLength();
     2194        if (thisdist < bestdist) {
     2195            bestdist = thisdist;
     2196            ibest = i;
     2197        }
     2198    }
     2199    return but[ibest];
     2200}
     2201
     2202VKButton* VKPopup::highButton()
     2203{
     2204    for (int i=0; but[i]; i++)
     2205    {
     2206        if (but[i]->isHighlighted())
     2207            return but[i];
     2208    }
     2209    return but[0];
     2210}
     2211
     2212void VKPopup::keyPressEvent(QKeyEvent *e)
     2213{
     2214    switch (e->key())
     2215    {
     2216        case Qt::Key_Escape:
     2217            if (e->type() == QEvent::KeyPress) hide();
     2218            e->accept();
     2219            break;
     2220        case Qt::Key_Return :
     2221            if (e->type() == QEvent::KeyPress) highButton()->animateClick();
     2222            e->accept();
     2223            break;
     2224        case Qt::Key_Right :
     2225        case Qt::Key_Left :
     2226        case Qt::Key_Up :
     2227        case Qt::Key_Down :
     2228            if (e->type() == QEvent::KeyPress)
     2229            {
     2230                VKButton* selected = highButton();
     2231                selected->highlight(false);
     2232                sideButton(selected, e->key())->highlight(true);
     2233            }
     2234            e->accept();
     2235            break;
     2236        default :
     2237            e->ignore();
     2238    }
     2239
     2240    if (! e->isAccepted())
     2241    {
     2242        QApplication::postEvent(parentWidget(), new QKeyEvent(e->type(), e->key(),
     2243                 e->ascii(), e->state(), e->text(), e->isAutoRepeat(), e->count()));
     2244        parentWidget()->setFocus();
     2245    }
     2246}
  • 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());