void VCMatrix::addCustomControl(VCMatrixControl *control) { if (control == NULL) return; QPushButton *controlButton = new QPushButton(this); if (control->m_type == VCMatrixControl::StartColor) { controlButton->setStyleSheet(controlBtnSS.arg(control->m_color.name())); controlButton->setFixedWidth(36); controlButton->setText("S"); } else if (control->m_type == VCMatrixControl::EndColor) { controlButton->setStyleSheet(controlBtnSS.arg(control->m_color.name())); controlButton->setFixedWidth(36); controlButton->setText("E"); } else if (control->m_type == VCMatrixControl::Animation || control->m_type == VCMatrixControl::Text) { controlButton->setStyleSheet(controlBtnSS.arg("#BBBBBB")); controlButton->setMinimumWidth(36); controlButton->setMaximumWidth(80); QString btnLabel = control->m_resource; if (!control->m_properties.isEmpty()) { btnLabel += " ("; QHashIterator<QString, QString> it(control->m_properties); while(it.hasNext()) { it.next(); btnLabel += it.value(); if (it.hasNext()) btnLabel += ","; } btnLabel += ")"; } controlButton->setToolTip(btnLabel); controlButton->setText(fontMetrics().elidedText(btnLabel, Qt::ElideRight, 72)); } if (mode() == Doc::Design) controlButton->setEnabled(false); connect(controlButton, SIGNAL(clicked()), this, SLOT(slotCustomControlClicked())); m_controls[controlButton] = new VCMatrixControl(control); m_controlsLayout->addWidget(controlButton); }
void VCMatrix::addCustomControl(VCMatrixControl *control) { if (control == NULL) return; QPushButton *controlButton = new QPushButton(this); if (control->m_type == VCMatrixControl::StartColor) { controlButton->setStyleSheet(controlBtnSS.arg(control->m_color.name())); controlButton->setFixedWidth(36); controlButton->setText("S"); } else if (control->m_type == VCMatrixControl::EndColor) { controlButton->setStyleSheet(controlBtnSS.arg(control->m_color.name())); controlButton->setFixedWidth(36); controlButton->setText("E"); } else if (control->m_type == VCMatrixControl::Animation || control->m_type == VCMatrixControl::Text) { controlButton->setStyleSheet(controlBtnSS.arg("#BBBBBB")); controlButton->setMaximumWidth(80); controlButton->setToolTip(control->m_resource); controlButton->setText(fontMetrics().elidedText(control->m_resource, Qt::ElideRight, 72)); } if (mode() == Doc::Design) controlButton->setEnabled(false); connect(controlButton, SIGNAL(clicked()), this, SLOT(slotCustomControlClicked())); m_controls[controlButton] = new VCMatrixControl(control); m_controlsLayout->addWidget(controlButton); }