Exemplo n.º 1
0
void RGBMatrixEditor::slotTextEdited(const QString& text)
{
    if (m_matrix->algorithm() != NULL && m_matrix->algorithm()->type() == RGBAlgorithm::Text)
    {
        RGBText* algo = static_cast<RGBText*> (m_matrix->algorithm());
        Q_ASSERT(algo != NULL);
        algo->setText(text);
        slotRestartTest();
    }
}
Exemplo n.º 2
0
void RGBMatrixEditor::setAlgoText(QString text)
{
    if (m_matrix != NULL && m_matrix->algorithm() != NULL &&
        m_matrix->algorithm()->type() == RGBAlgorithm::Text)
    {
        RGBText* algo = static_cast<RGBText*> (m_matrix->algorithm());
        if (algo->text() == text)
            return;

        QMutexLocker algorithmLocker(&m_matrix->algorithmMutex());
        algo->setText(text);
        emit algoTextChanged(text);
    }
}
Exemplo n.º 3
0
void VCMatrix::slotCustomControlClicked()
{
    QPushButton *btn = qobject_cast<QPushButton*>(sender());
    VCMatrixControl *control = m_controls[btn];
    if (control != NULL)
    {
        RGBMatrix* matrix = qobject_cast<RGBMatrix*>(m_doc->function(m_matrixID));
        if (matrix == NULL || mode() == Doc::Design)
            return;

        if (control->m_type == VCMatrixControl::StartColor)
        {
            QPixmap px(42, 42);
            px.fill(control->m_color);

            m_startColorButton->setIcon(px);
            matrix->setStartColor(control->m_color);
            matrix->calculateColorDelta();
        }
        else if (control->m_type == VCMatrixControl::EndColor)
        {
            QPixmap px(42, 42);
            px.fill(control->m_color);

            m_endColorButton->setIcon(px);
            matrix->setEndColor(control->m_color);
            matrix->calculateColorDelta();
        }
        else if (control->m_type == VCMatrixControl::Animation)
        {
            RGBAlgorithm* algo = RGBAlgorithm::algorithm(m_doc, control->m_resource);
            matrix->setAlgorithm(algo);
            if (instantChanges() == true)
                matrix->calculateColorDelta();
        }
        else if (control->m_type == VCMatrixControl::Text)
        {
            RGBAlgorithm* algo = RGBAlgorithm::algorithm(m_doc, "Text");
            RGBText* text = static_cast<RGBText*> (algo);
            text->setText(control->m_resource);
            matrix->setAlgorithm(algo);
            if (instantChanges() == true)
                matrix->calculateColorDelta();
        }
    }
}
Exemplo n.º 4
0
void VCMatrix::slotCustomControlClicked()
{
    QPushButton *btn = qobject_cast<QPushButton*>(sender());
    VCMatrixControl *control = m_controls[btn];
    if (control != NULL)
    {
        RGBMatrix* matrix = qobject_cast<RGBMatrix*>(m_doc->function(m_matrixID));
        if (matrix == NULL || mode() == Doc::Design)
            return;

        if (control->m_type == VCMatrixControl::StartColor)
        {
            QPixmap px(42, 42);
            px.fill(control->m_color);

            m_startColorButton->setIcon(px);
            matrix->setStartColor(control->m_color);
            matrix->calculateColorDelta();
        }
        else if (control->m_type == VCMatrixControl::EndColor)
        {
            QPixmap px(42, 42);
            px.fill(control->m_color);

            m_endColorButton->setIcon(px);
            matrix->setEndColor(control->m_color);
            matrix->calculateColorDelta();
        }
        else if (control->m_type == VCMatrixControl::Animation)
        {
            RGBAlgorithm* algo = RGBAlgorithm::algorithm(m_doc, control->m_resource);
            if (!control->m_properties.isEmpty())
            {
                RGBScript *script = static_cast<RGBScript*> (algo);
                QHashIterator<QString, QString> it(control->m_properties);
                while(it.hasNext())
                {
                    it.next();
                    script->setProperty(it.key(), it.value());
                }
            }
            matrix->setAlgorithm(algo);
            if (instantChanges() == true)
                matrix->calculateColorDelta();
            m_presetCombo->blockSignals(true);
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
            m_presetCombo->setCurrentText(control->m_resource);
#else
            m_presetCombo->setCurrentIndex(m_presetCombo->findText(control->m_resource));
#endif
            m_presetCombo->blockSignals(false);
        }
        else if (control->m_type == VCMatrixControl::Text)
        {
            RGBAlgorithm* algo = RGBAlgorithm::algorithm(m_doc, "Text");
            RGBText* text = static_cast<RGBText*> (algo);
            text->setText(control->m_resource);
            matrix->setAlgorithm(algo);
            if (instantChanges() == true)
                matrix->calculateColorDelta();
        }
    }
}