void UBKeyboardPalette::setLocale(int nLocale)
{
    if (locales != NULL)
    {
        nCurrentLocale = nLocale;

        setInput(locales[nCurrentLocale]);
        onLocaleChanged(locales[nCurrentLocale]);
        update();

		UBSettings::settings()->KeyboardLocale->set(nCurrentLocale);
    }
    emit localeChanged(nLocale);
}
void UBKeyboardPalette::onActivated(bool activated)
{
    if (activated)
    {
        if (storage)
        {
            qDebug() << "Keybard already activated....";
            return;
        }

        Display *display = XOpenDisplay(0);
        if(display == NULL)
           return;

        XDisplayKeycodes(display, &this->min_keycodes, &this->max_keycodes);
        KeySym* keySyms = XGetKeyboardMapping(display, min_keycodes,
                           max_keycodes - min_keycodes, &byte_per_code);

        storage = keySyms;

        XCloseDisplay(display);

        onLocaleChanged(locales[nCurrentLocale]);

    }
    else
    {
        Display *display = XOpenDisplay(0);
        if(display == NULL)
        {
            qDebug() << "Keybard not activated....";
            return;
        }

        KeySym* keySyms = (KeySym*)storage;
        if (keySyms!=NULL)
        {
            qDebug() << "Default key table restored.....";

            XChangeKeyboardMapping(display, min_keycodes, byte_per_code,
                                   keySyms, max_keycodes - min_keycodes);

            XFree(keySyms);
            storage = NULL;
        }

        XCloseDisplay(display);
    }
}
Exemple #3
0
void Homepage::initialUI()
{
    QString langImagePath = g_appPath + QString("/data/image_cn/homepage/english_n.png");
    QString helpImagePath = g_appPath + QString("/data/image_cn/homepage/help_n.png");

    Utility::addButton(QImage(langImagePath).size(), HM_LANG_POS,
                           g_appPath + "/data/image_cn/homepage/english_n.png*" + g_appPath + "/data/image_cn/homepage/english_p.png",
                           g_appPath + "/data/image_en/homepage/chinese_n.png*" + g_appPath + "/data/image_en/homepage/chinese_p.png",
                           this, SLOT(onLocaleChanged()),
                           QString(""), this);

    Utility::addButton(QImage(helpImagePath).size(), HM_HELP_POS,
                           g_appPath + "/data/image_cn/homepage/help_n.png*" + g_appPath + "/data/image_cn/homepage/help_p.png",
                           g_appPath + "/data/image_en/homepage/help_n.png*" + g_appPath + "/data/image_en/homepage/help_p.png",
                           this, SLOT(sltHelp()),
                           QString(""), this);

    QVector<QString> adFiles;
    QDir dir(g_appPath + QString("/data/ads/banner_cn/"));
    QFileInfoList f_list=dir.entryInfoList();
    dir.setFilter(QDir::Files|QDir::NoDot|QDir::NoDotAndDotDot|QDir::NoSymLinks);
        qDebug() << trUtf8("--------从本地获取广告文件 begin--------");
    for(int i=0;i<f_list.count();i++){
            QFileInfo f_info=f_list.at(i);
            QString stt=f_info.fileName();
            if(stt != QString(".")  &&  stt != QString(".."))
            {
                    qDebug() << stt;
                adFiles.append(stt);
            }
    }
        qDebug() << trUtf8("--------从本地获取广告文件 end--------");

    AdWgt* adWgt = new AdWgt(this);
    adWgt->resize(QSize(720, 485));
    adWgt->move(60, 110);
    for(int i = 0; i < adFiles.count(); i++)
    {
        QString suffix = adFiles.at(i).right(3);
        if(suffix == QString("jpg") || suffix == QString("png"))
        {
            adWgt->addAdItem(AdWgt::AdItemType_Picture, adFiles.at(i));
        }

        if(suffix == QString("avi"))
        {
            adWgt->addAdItem(AdWgt::AdItemType_Video, adFiles.at(i));
        }
    }
    adWgt->show();
    adWgt->startAnimation(true);

    // 4;
    QSize imageBtnSize = QImage(g_appPath + QString("/data/image_cn/homepage/courierin_n.png")).size();
    Utility::addButton(imageBtnSize, HM_CJ_POS,
                           g_appPath + "/data/image_cn/homepage/courierin_n.png*" + g_appPath + "/data/image_cn/homepage/courierin_p.png",
                           g_appPath + "/data/image_en/homepage/courierin_n.png*" + g_appPath + "/data/image_en/homepage/courierin_p.png",
                           this, SLOT(sltCj()),
                           QString(""), this);

    Utility::addButton(imageBtnSize, HM_QJ_POS,
                           g_appPath + "/data/image_cn/homepage/fetch_n.png*" + g_appPath + "/data/image_cn/homepage/fetch_p.png",
                           g_appPath + "/data/image_en/homepage/fetch_n.png*" + g_appPath + "/data/image_en/homepage/fetch_p.png",
                           this, SLOT(sltQj()),
                           QString(""), this);

    Utility::addButton(imageBtnSize, HM_CX_POS,
                           g_appPath + "/data/image_cn/homepage/query_n.png*" + g_appPath + "/data/image_cn/homepage/query_p.png",
                           g_appPath + "/data/image_en/homepage/query_n.png*" + g_appPath + "/data/image_en/homepage/query_p.png",
                           this, SLOT(sltCx()),
                           QString(""), this);

//    Utility::addButton(imageBtnSize, HM_JJ_POS,
//                           g_appPath + "/data/pic/main/jj.jpg*" + g_appPath + "/data/pic/main/jj_2.jpg",
//                           g_appPath + "/data/piceng/main/jj.jpg*" + g_appPath + "/data/piceng/main/jj_2.jpg",
//                           this, SLOT(sltJj()),
//                           QString(""), this);

    TerminalConfig info = g_transaction->terminalConfig();
    sltAdInfoChanged(info.adInfo);
}