コード例 #1
0
void QmlDesignerPlugin::onCurrentEditorChanged(Core::IEditor *editor)
{
    if (isQmlFile(editor) && isInDesignerMode())
    {
        m_shortCutManager.updateActions(editor);
        changeEditor();
    }
}
コード例 #2
0
void QmlDesignerPlugin::switchTextDesign()
{
    if (Core::ModeManager::currentMode()->id() == Core::Constants::MODE_EDIT) {
        if (isQmlFile(Core::EditorManager::currentEditor()))
            Core::ModeManager::activateMode(Core::Constants::MODE_DESIGN);
    } else if (Core::ModeManager::currentMode()->id() == Core::Constants::MODE_DESIGN) {
        Core::ModeManager::activateMode(Core::Constants::MODE_EDIT);
    }
}
コード例 #3
0
static bool checkIfEditorIsQtQuick(Core::IEditor *editor)
{
    if (isQmlFile(Core::EditorManager::currentEditor())) {
        QmlJS::Document::Ptr document = QmlJS::ModelManagerInterface::instance()->snapshot().document(
                Core::EditorManager::currentEditor()->document()->filePath());
        if (!document.isNull())
            return document->language() == QmlJS::Language::QmlQtQuick1
                    || document->language() == QmlJS::Language::QmlQtQuick2
                    || document->language() == QmlJS::Language::Qml;
    }

    return false;
}
コード例 #4
0
void QmlDesignerPlugin::onCurrentModeChanged(Core::IMode *newMode, Core::IMode *oldMode)
{
    if (Core::EditorManager::currentEditor()
            && checkIfEditorIsQtQuick(Core::EditorManager::currentEditor())
            && !documentIsAlreadyOpen(currentDesignDocument(), Core::EditorManager::currentEditor(), newMode)) {

        if (!isDesignerMode(newMode) && isDesignerMode(oldMode))
            hideDesigner();
        else  if (Core::EditorManager::currentEditor()
                  && isDesignerMode(newMode)
                  && isQmlFile(Core::EditorManager::currentEditor()))
            showDesigner();
        else if (currentDesignDocument())
            hideDesigner();
    }
}
コード例 #5
0
void QmlDesignerPlugin::onCurrentModeChanged(Core::IMode *newMode, Core::IMode *oldMode)
{
    if (!Core::EditorManager::currentEditor())
        return;

    if (Core::EditorManager::currentEditor()
            && Core::EditorManager::currentEditor()->id() != QmlJSEditor::Constants::C_QMLJSEDITOR_ID)
        return;

    if ((currentDesignDocument()
         && Core::EditorManager::currentEditor() == currentDesignDocument()->editor())
            && isDesignerMode(newMode))
        return;

    if (!isDesignerMode(newMode) && isDesignerMode(oldMode))
        hideDesigner();
    else  if (Core::EditorManager::currentEditor()
              && isDesignerMode(newMode)
              && isQmlFile(Core::EditorManager::currentEditor()))
        showDesigner();
    else if (currentDesignDocument())
        hideDesigner();

}