Пример #1
0
DragNDropResponse::DragNDropResponse(JsonClient *client, const QtJson::JsonObject &command) :
    DelayedResponse(client, command)
{
    WidgetLocatorContext<QWidget> ctx(static_cast<Player *>(jsonClient()), command, "srcoid");
    WidgetLocatorContext<QWidget> ctx2(static_cast<Player *>(jsonClient()), command, "destoid");

    if (ctx.hasError()) { writeResponse(ctx.lastError); return; }
    if (ctx2.hasError()) { writeResponse(ctx2.lastError); return; }

    QPoint srcPos;
    if (command.contains("srcpos") && ! command["srcpos"].isNull()) {
        srcPos = pointFromString(command["srcpos"].toString());
    } else {
        srcPos = ctx.widget->rect().center();
    }

    QPoint destPos;
    if (command.contains("destpos") && ! command["destpos"].isNull()) {
        destPos = pointFromString(command["destpos"].toString());
    } else {
        destPos = ctx2.widget->rect().center();
    }

    m_src = ctx.widget;
    m_dest = ctx2.widget;
    m_srcPos = srcPos;
    m_destPos = destPos;
}
Пример #2
0
ShortcutResponse::ShortcutResponse(JsonClient * client,
                                   const QtJson::JsonObject & command)
    : DelayedResponse(client, command), m_target(NULL) {
    if (command.contains("oid")) {
        WidgetLocatorContext<QWidget> ctx(static_cast<Player *>(jsonClient()),
                                          command, "oid");
        if (ctx.hasError()) {
            writeResponse(ctx.lastError);
            return;
        }
        m_target = ctx.widget;
    } else {
        m_target = qApp->activeWindow();
    }
    if (m_target) {
        connect(m_target, SIGNAL(destroyed()), this, SLOT(on_target_deleted()));
    }
    m_binding = QKeySequence::fromString(command["keysequence"].toString());
}