コード例 #1
0
void QKeyboardLineEdit::mousePressEvent(QMouseEvent *e)
{
    if(!m_isBeingEdited)
    {
        m_isBeingEdited = true;
        m_keyboardWidget = new Keyboard;
        connect(m_keyboardWidget, SIGNAL(closed()), this, SLOT(keyboardClosed()));
        m_keyboardWidget->setLineEdit(this);
        m_keyboardWidget->showMaximized();
    }
    if(m_isBeingEdited && m_keyboardWidget)
        qApp->setActiveWindow(m_keyboardWidget);
    QLineEdit::mousePressEvent(e);
}
コード例 #2
0
ファイル: main.cpp プロジェクト: special/maliit-plugins
int main(int argc,
         char ** argv)
{
    QApplication app(argc, argv);

    MaliitKeyboard::Dashboard *dashboard = new MaliitKeyboard::Dashboard;
    dashboard->show();

    MaliitKeyboard::Renderer renderer;
//    renderer.setSurfaceFactory(dashboard);
    dashboard->setRenderer(&renderer);

    MaliitKeyboard::Glass glass;
//    glass.setWindow(renderer.viewport());

    // One layout updater can only manage one layout. If more layouts need to
    // be managed, then more layout updaters are required.
    MaliitKeyboard::LayoutUpdater lu0;

    MaliitKeyboard::SharedLayout l0(new MaliitKeyboard::Layout);
    l0->setAlignment(MaliitKeyboard::Layout::Bottom);
    l0->setScreenSize(dashboard->size());

    MaliitKeyboard::Font font;
    font.setColor(QByteArray("#ddd"));
    font.setSize(20);

    MaliitKeyboard::WordRibbon ribbon;
    MaliitKeyboard::Area area;
    area.setBackground(QByteArray("key-background.png"));
    area.setBackgroundBorders(QMargins(10, 10, 10, 10));
    area.setSize(QSize(856, 40));
    ribbon.setArea(area);

    l0->setWordRibbon(ribbon);

    renderer.addLayout(l0);
    glass.addLayout(l0);
    lu0.setLayout(l0);

    MaliitKeyboard::SharedLayout l1(new MaliitKeyboard::Layout);
    l1->setAlignment(MaliitKeyboard::Layout::Top);
    l1->setScreenSize(dashboard->size());
    renderer.addLayout(l1);
    glass.addLayout(l1);

    MaliitKeyboard::LayoutUpdater lu1;
    lu1.setLayout(l1);

    MaliitKeyboard::Logic::WordEngine word_engine;
    DefaultFeedback feedback;
    MaliitKeyboard::Setup::connectAll(&glass, &lu0, &renderer, dashboard->editor(), &word_engine, &feedback);

    MaliitKeyboard::Setup::connectGlassToLayoutUpdater(&glass, &lu1);
    MaliitKeyboard::Setup::connectLayoutUpdaterToRenderer(&lu1, &renderer);


    QObject::connect(&glass,    SIGNAL(keyboardClosed()),
                     dashboard, SLOT(onHide()));

    QObject::connect(dashboard, SIGNAL(orientationChanged(Layout::Orientation)),
                     &lu0,      SLOT(setOrientation(Layout::Orientation)));

    QObject::connect(dashboard, SIGNAL(orientationChanged(Layout::Orientation)),
                     &lu1,      SLOT(setOrientation(Layout::Orientation)));

    QObject::connect(&glass,    SIGNAL(keyboardClosed()),
                     dashboard, SIGNAL(keyboardClosed()));

    QObject::connect(dashboard, SIGNAL(keyboardClosed()),
                     &lu0,      SLOT(resetOnKeyboardClosed()));

    QObject::connect(dashboard, SIGNAL(keyboardClosed()),
                     &lu1,      SLOT(resetOnKeyboardClosed()));

    QObject::connect(dashboard, SIGNAL(keyboardClosed()),
                     &renderer, SLOT(hide()));

    QObject::connect(dashboard, SIGNAL(keyboardClosed()),
                     dashboard, SLOT(onHide()));

    // Allow to specify keyboard id via command line:
    QString keyboard_id("en_gb");
    bool found_keyboard_id = false;

    Q_FOREACH (const QString &arg, QApplication::arguments()) {
        if (found_keyboard_id && not arg.isEmpty()) {
            keyboard_id = arg;
        }

        if (arg == "--id" || arg == "-id") {
            found_keyboard_id = true;
        }
    }

    lu0.setActiveKeyboardId(keyboard_id);
    lu1.setActiveKeyboardId("toolbar");
    renderer.show();

    return app.exec();
}