void EasyViewWidget::refreshDisplay() { if(this->layout()) { qDeleteAll(Boxes); Boxes.clear(); delete this->layout(); } QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); QComboBox* fileChoice = new QComboBox(); #if defined(_WIN32) && defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_APP) // Workaround render bug QString style = "QComboBox QAbstractItemView { border: 1px solid gray }"; fileChoice->setStyleSheet(style); #endif layout->addWidget(fileChoice); for (size_t Pos=0; Pos<C->Count_Get(); Pos++) fileChoice->addItem( wstring2QString(C->Get(Pos, Stream_General, 0, __T("CompleteName"))), (int)Pos); fileChoice->setCurrentIndex(FilePos); connect(fileChoice,SIGNAL(currentIndexChanged(int)),SLOT(changeFilePos(int))); QFrame *box; QGroupBox *subBox; for (size_t StreamPos=0; StreamPos<Stream_Max; StreamPos++) { bool addBox = false; box = new QFrame(); QHBoxLayout* boxLayout = new QHBoxLayout(); box->setLayout(boxLayout); for (size_t Pos=0; Pos<Boxes_Count_Get(StreamPos); Pos++) { subBox = createBox((stream_t)StreamPos,(int)Pos); if(subBox!=NULL) { boxLayout->addWidget(subBox); addBox = true; } } if(addBox) { layout->addWidget(box); Boxes.push_back(box); } } layout->addStretch(); }
void ResultForm::encodingChanged(const QString &encoding) { QTextCodec *codec = QTextCodec::codecForName(encoding.toLatin1()); QComboBox *comboBox = qobject_cast<QComboBox *>(sender()); if (codec) { if (comboBox) comboBox->setStyleSheet(""); if (ui->requestRadio->isChecked()) { ui->bodyText->setPlainText(codec->toUnicode(m_request->body)); } else if (ui->responseRadio->isChecked()) { ui->bodyText->setPlainText(codec->toUnicode(m_response->body)); } } else if (comboBox) comboBox->setStyleSheet("QComboBox:editable:!on { background: #FF7777; color: white }"); }
void MainWindow::updateState() { for (int i = 0; i < ui_->EventsTable->rowCount(); ++i) { QComboBox* level = dynamic_cast<QComboBox*>(ui_->EventsTable->cellWidget(i, 3)); if (level->currentText() == EVENT_LOW_RUS) level->setStyleSheet("QComboBox { background-color:" + LOW_COLOR + "; }"); if (level->currentText() == EVENT_MIDDLE_RUS) level->setStyleSheet("QComboBox { background-color:" + MIDDLE_COLOR + "; }"); if (level->currentText() == EVENT_HIGH_RUS) level->setStyleSheet("QComboBox { background-color:" + HIGH_COLOR + "; }"); } for (int i = 0; i < ui_->FriendsTable->rowCount(); ++i) { QComboBox* level = dynamic_cast<QComboBox*>(ui_->FriendsTable->cellWidget(i, 1)); if (level->currentText() == FRIEND_LOW_RUS) level->setStyleSheet("QComboBox { background-color:" + HIGH_COLOR + "; }"); if (level->currentText() == FRIEND_MIDDLE_RUS) level->setStyleSheet("QComboBox { background-color:" + MIDDLE_COLOR + "; }"); if (level->currentText() == FRIEND_HIGH_RUS) level->setStyleSheet("QComboBox { background-color:" + LOW_COLOR + "; }"); } }
QWidget* ConstraintTag::createWidget(QList<Tag *> tags, QWidget *parent) { // === Create Widget === QWidget* base = new QWidget(parent); QHBoxLayout* horLayout = new QHBoxLayout(); QStringList comboboxItems = QStringList() << tr("ignore") << tr("local") << tr("global"); QVBoxLayout* posLayout = new QVBoxLayout(); posLayout->setSpacing(0); posLayout->setContentsMargins(0,0,0,0); QComboBox* posComboBox = new QComboBox(base); posComboBox->addItems(comboboxItems); posLayout->addWidget(posComboBox); QCheckBox* affectXCB = new QCheckBox("x", base); QCheckBox* affectYCB = new QCheckBox("y", base); QHBoxLayout* l = new QHBoxLayout(); l->setContentsMargins(0,0,0,0); l->setSpacing(0); l->addWidget(affectXCB); l->addWidget(affectYCB); posLayout->addLayout(l); posLayout->addStretch(); ObjectEdit* posObject = new ObjectEdit(base); posObject->setProject(tags.first()->owner()->project()); posLayout->addWidget(posObject); QVBoxLayout* rotLayout = new QVBoxLayout(); rotLayout->setSpacing(0); rotLayout->setContentsMargins(0,0,0,0); QComboBox* rotComboBox = new QComboBox(base); rotComboBox->addItems(comboboxItems); rotLayout->addWidget(rotComboBox); rotLayout->addStretch(); ObjectEdit* rotObject = new ObjectEdit(base); rotObject->setProject(tags.first()->owner()->project()); rotLayout->addWidget(rotObject); QVBoxLayout* scaleLayout = new QVBoxLayout(); scaleLayout->setSpacing(0); scaleLayout->setContentsMargins(0,0,0,0); QComboBox* scaleComboBox = new QComboBox(base); scaleComboBox->addItems(comboboxItems); scaleLayout->addWidget(scaleComboBox); scaleLayout->addStretch(); ObjectEdit* scaleObject = new ObjectEdit(base); scaleObject->setProject(tags.first()->owner()->project()); scaleLayout->addWidget(scaleObject); horLayout->addLayout(posLayout); horLayout->addLayout(rotLayout); horLayout->addLayout(scaleLayout); // === end create Widget === // === define update function === auto update = [=]() { posComboBox->blockSignals(true); posObject->blockSignals(true); affectXCB->blockSignals(true); affectYCB->blockSignals(true); rotComboBox->blockSignals(true); rotObject->blockSignals(true); scaleComboBox->blockSignals(true); scaleObject->blockSignals(true); bool pModeDifference = false; bool affectXDifference = false; bool affectYDifference = false; bool pIdDifference = false; bool rModeDifference = false; bool rIdDifference = false; bool sModeDifference = false; bool sIdDifference = false; Mode pMode = ((ConstraintTag*) tags.first())->_positionMode; bool affectX = ((ConstraintTag*) tags.first())->_affectX; bool affectY = ((ConstraintTag*) tags.first())->_affectY; quint64 pId = ((ConstraintTag*) tags.first())->_posId; bool hasPId = ((ConstraintTag*) tags.first())->_hasPosId; Mode rMode = ((ConstraintTag*) tags.first())->_rotationMode; quint64 rId = ((ConstraintTag*) tags.first())->_rotId; bool hasRId = ((ConstraintTag*) tags.first())->_hasRotId; Mode sMode = ((ConstraintTag*) tags.first())->_scalationMode; quint64 sId = ((ConstraintTag*) tags.first())->_scaleId; bool hasSId = ((ConstraintTag*) tags.first())->_hasScaleId; foreach (Tag* t, tags) { ConstraintTag* ct = (ConstraintTag*) t; if (ct->_positionMode != pMode) pModeDifference = true; if (ct->_affectX != affectX) affectXDifference = true; if (ct->_affectY != affectY) affectYDifference = true; if ((ct->_hasPosId != hasPId) || (ct->_hasPosId && hasPId && ct->_posId != pId)) pIdDifference = true; if (ct->_rotationMode != rMode) rModeDifference = true; if ((ct->_hasRotId != hasRId) || (ct->_hasRotId && hasRId && ct->_rotId != rId)) rIdDifference = true; if (ct->_scalationMode != sMode) sModeDifference = true; if ((ct->_hasScaleId != hasSId) || (ct->_hasScaleId && hasSId && ct->_scaleId != sId)) sIdDifference = true; } if (pModeDifference) posComboBox->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR)); else posComboBox->setStyleSheet(""); if (affectXDifference) affectXCB->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR)); else affectXCB->setStyleSheet(""); if (affectYDifference) affectYCB->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR)); else affectYCB->setStyleSheet(""); if (pIdDifference) posObject->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR)); else posObject->setStyleSheet(""); posComboBox->setCurrentIndex(modeToIndex(pMode)); affectXCB->setChecked(affectX); affectXCB->setEnabled(pMode != Mode::ignore); affectYCB->setChecked(affectY); affectYCB->setEnabled(pMode != Mode::ignore); posObject->setEnabled(pMode != Mode::ignore); if (hasPId) posObject->setId(pId); else posObject->clear(); if (rModeDifference) rotComboBox->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR)); else rotComboBox->setStyleSheet(""); if (rIdDifference) rotObject->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR)); else rotObject->setStyleSheet(""); rotComboBox->setCurrentIndex(modeToIndex(rMode)); rotObject->setEnabled(rMode != Mode::ignore); if (hasRId) rotObject->setId(rId); else rotObject->clear(); if (sModeDifference) scaleComboBox->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR)); else scaleComboBox->setStyleSheet(""); if (sIdDifference) scaleObject->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR)); else scaleObject->setStyleSheet(""); scaleComboBox->setCurrentIndex(modeToIndex(sMode)); scaleObject->setEnabled(sMode != Mode::ignore); if (hasSId) scaleObject->setId(sId); else scaleObject->clear(); posComboBox->blockSignals(false); posObject->blockSignals(false); affectXCB->blockSignals(false); affectYCB->blockSignals(false); rotComboBox->blockSignals(false); rotObject->blockSignals(false); scaleComboBox->blockSignals(false); scaleObject->blockSignals(false); };