예제 #1
0
void MInputContext::update(Qt::InputMethodQueries queries)
{
    if (debug) qDebug() << InputContextName << "in" << __PRETTY_FUNCTION__;

    Q_UNUSED(queries) // fetching everything

    if (queries & Qt::ImPlatformData) {
        updateInputMethodExtensions();
    }

    bool effectiveFocusChange = false;
    if (queries & Qt::ImEnabled) {
        bool newAcceptance = inputMethodAccepted();
        if (newAcceptance && !active) {
            setFocusObject(QGuiApplication::focusObject());
            return;
        }

        if (newAcceptance != currentFocusAcceptsInput) {
            currentFocusAcceptsInput = newAcceptance;
            effectiveFocusChange = true;
        }
    }
    // get the state information of currently focused widget, and pass it to input method server
    QMap<QString, QVariant> stateInformation = getStateInformation();
    imServer->updateWidgetInformation(stateInformation, effectiveFocusChange);
}
예제 #2
0
void MInputContext::invokeAction(QInputMethod::Action action, int x)
{
    if (debug) qDebug() << InputContextName << "in" << __PRETTY_FUNCTION__;

    if (!inputMethodAccepted())
        return;

    if (action == QInputMethod::Click) {
        if (x < 0 || x >= preedit.length()) {
            reset();
            return;
        }

        // To preserve the wire protocol, the "x" argument gets
        // transferred in widget state instead of being an extra
        // argument to mouseClickedOnPreedit().
        QMap<QString, QVariant> stateInformation = getStateInformation();
        stateInformation["preeditClickPos"] = x;
        imServer->updateWidgetInformation(stateInformation, false);

        // FIXME: proper positions and preeditClickPos
        QRect preeditRect;
        QPoint globalPos;
        imServer->mouseClickedOnPreedit(globalPos, preeditRect);

    } else {
        QPlatformInputContext::invokeAction(action, x);
    }
}
void MInputContext::update()
{
    qDebug() << "MInputContext" << "in" << __PRETTY_FUNCTION__;

    const QWidget *const focused = focusWidget();

    if (focused == 0) {
        return;
    }

    // get the state information of currently focused widget, and pass it to input method server
    QMap<QString, QVariant> stateInformation = getStateInformation();

    imServer->updateWidgetInformation(stateInformation, false);
}
예제 #4
0
void MInputContext::setFocusObject(QObject *focused)
{
    if (debug) qDebug() << InputContextName << "in" << __PRETTY_FUNCTION__ << focused;

    updateInputMethodExtensions();

    QWindow *newFocusWindow = qGuiApp->focusWindow();
    if (newFocusWindow != window.data()) {
       if (window) {
           disconnect(window.data(), SIGNAL(contentOrientationChanged(Qt::ScreenOrientation)),
                      this, SLOT(updateServerOrientation(Qt::ScreenOrientation)));
       }

       window = newFocusWindow;
       if (window) {
           connect(window.data(), SIGNAL(contentOrientationChanged(Qt::ScreenOrientation)),
                   this, SLOT(updateServerOrientation(Qt::ScreenOrientation)));
           updateServerOrientation(window->contentOrientation());
       }
    }

    bool oldAcceptInput = currentFocusAcceptsInput;
    currentFocusAcceptsInput = inputMethodAccepted();

    if (!active && currentFocusAcceptsInput) {
        imServer->activateContext();
        active = true;
        updateServerOrientation(newFocusWindow->contentOrientation());
    }

    if (active && (currentFocusAcceptsInput || oldAcceptInput)) {
        const QMap<QString, QVariant> stateInformation = getStateInformation();
        imServer->updateWidgetInformation(stateInformation, true);
    }

    if (inputPanelState == InputPanelShowPending && currentFocusAcceptsInput) {
        sipHideTimer.stop();
        imServer->showInputMethod();
        inputPanelState = InputPanelShown;
    }
}
예제 #5
0
//==============================================================================
void AudioProcessor::getCurrentProgramStateInformation (juce::MemoryBlock& destData)
{
    getStateInformation (destData);
}
예제 #6
0
 void getCurrentProgramStateInformation (MemoryBlock& destData)
 {
     getStateInformation (destData);
 }
void MInputContext::setFocusWidget(QWidget *focused)
{
    QObject *focusedObject = focused;
    QGraphicsItem *focusItem = 0;
    qDebug() << "MInputContext" << "in" << __PRETTY_FUNCTION__ << focused;
    QInputContext::setFocusWidget(focused);

    // get detailed focus information from inside qgraphicsview
    QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(focusWidget());

    if (graphicsView && graphicsView->scene()) {
        focusItem = graphicsView->scene()->focusItem();

        if (focusItem) {
            focusedObject = dynamic_cast<QObject *>(focusItem);
        }
    }

    const QMap<QString, QVariant> stateInformation = getStateInformation();
    if (focused) {
        // for non-null focus widgets, we'll have this context activated
        if (!active) {
            imServer->activateContext();
            active = true;

#ifdef HAVE_MEEGOTOUCH
            // Notify whatever application's orientation is currently.
            notifyOrientationChanged(currOrientation);
#endif
        }

        imServer->updateWidgetInformation(stateInformation, true);

        // check if copyable text is selected
        Qt::InputMethodQuery query = Qt::ImCurrentSelection;
        QVariant queryResult = focused->inputMethodQuery(query);
        if (queryResult.isValid()) {
            copyAvailable = !queryResult.toString().isEmpty();
        }

        if (focusItem) {
            copyAllowed = !(focusItem->inputMethodHints() & Qt::ImhHiddenText);
        } else {
            copyAllowed = !(focused->inputMethodHints() & Qt::ImhHiddenText);
        }

        pasteAvailable = !QApplication::clipboard()->text().isEmpty();

        connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(handleClipboardDataChange()), Qt::UniqueConnection);
    } else {
        copyAvailable = false;
        copyAllowed = false;
        imServer->updateWidgetInformation(stateInformation, true);

        disconnect(QApplication::clipboard(), SIGNAL(dataChanged()), this, 0);
    }

    // show or hide Copy/Paste button on input method server
    notifyCopyPasteState();

    if (inputPanelState == InputPanelShowPending && focused) {
        imServer->showInputMethod();
        inputPanelState = InputPanelShown;
    }

    if (connectedObject) {
        connectedObject->disconnect(this);
        connectedObject = 0;
    }

    if (focusedObject && focusedObject->metaObject()) {
        if (focusedObject->metaObject()->indexOfSignal("copyAvailable(bool)") != -1) {
            // for MTextEdit
            connect(focusedObject, SIGNAL(copyAvailable(bool)),
                    this, SLOT(handleCopyAvailabilityChange(bool)));
            connectedObject = focusedObject;
        } else if (focusedObject->metaObject()->indexOfSignal("selectedTextChanged()") != -1) {
//==============================================================================
void AudioProcessor::getCurrentProgramStateInformation (JUCE_NAMESPACE::MemoryBlock& destData)
{
    getStateInformation (destData);
}