Example #1
0
 void CanvasParameters::setDataModel(canvas::Interface* _canvas) {
   {
     QSignalBlocker blocker(this);
     mixin_data_model_type::setDataModel(_canvas);
     if (_canvas->scene()) {
       setScale(_canvas->scene()->size());
       setUnit(_canvas->scene()->unit().abbreviation());
       updateFrontend();
     }
   }
   emit dataModelChanged();
 }
Example #2
0
void ProxyAction::changeContexts(QList<int> contexts)
{
    LOG_TRACE("Context update request on proxy action", text());

    if (m_contextActions.isEmpty())
    {
        LOG_TRACE("No backend actions stored here.");
        return;
    }

    m_contexts = contexts;

    QAction *oldAction = m_activeAction;
    m_activeAction = 0;

    for (int n = 0; n < m_contexts.size(); n++)
    {
        QAction *a = m_contextActions.value(m_contexts.at(n), 0);
        if (a)
        {
            m_activeAction = a;
            m_activeAction->setObjectName(a->text());

            LOG_TRACE(QString("Backend action found: %1, shortcut: %2, proxy shortcut: %3")
                      .arg(m_activeAction->text())
                      .arg(m_activeAction->shortcut().toString())
                      .arg(m_action->shortcut().toString()));
            break;
        }
    }

    if (m_activeAction == oldAction && m_initialized)
    {
        updateFrontend();

        LOG_TRACE("New backend action is the same as the active action; nothing to be done.");
        return;
    }

    if (oldAction)
    {
        LOG_TRACE(QString("Disconnecting multi-context action from previous backend action in parent: %1")
                  .arg(oldAction->parent() ? oldAction->parent()->objectName() : "Unspecified parent"));

        disconnect(oldAction, SIGNAL(changed()), this, SLOT(updateFrontend()));
        disconnect(m_action, SIGNAL(triggered(bool)), oldAction, SIGNAL(triggered(bool)));
        disconnect(m_action, SIGNAL(toggled(bool)), oldAction, SLOT(setChecked(bool)));
    }

    if (m_activeAction)
    {
        LOG_TRACE(QString("Connecting base action: %1, shortcut: %2, parent: %3")
                  .arg(m_activeAction->text())
                  .arg(m_action->shortcut().toString())
                  .arg(m_activeAction->parent() ? m_activeAction->parent()->objectName() : "Unspecified parent"));

        connect(m_activeAction, SIGNAL(changed()), SLOT(updateFrontend()));
        connect(m_action, SIGNAL(triggered(bool)), m_activeAction, SIGNAL(triggered(bool)));
        connect(m_action, SIGNAL(toggled(bool)), m_activeAction, SLOT(setChecked(bool)));

        updateFrontend();

        m_initialized = true;

        return;
    }
    else
    {
        LOG_TRACE("New backend action could not be found; action will be disabled in this context.");
    }

    m_action->setEnabled(false);
}