void EntityIdentifier::parseEntityDefinition(JSONObject *entity, QString const &category, QColor catcolor, int packID) { QString id; if (entity->has("id")) id = entity->at("id")->asString(); else id = "Unknown"; if (entity->has("catcolor")) { QString colorname = entity->at("catcolor")->asString(); catcolor.setNamedColor(colorname); assert(catcolor.isValid()); } QColor color; if (entity->has("color")) { QString colorname = entity->at("color")->asString(); color.setNamedColor(colorname); assert(color.isValid()); } else { // use hashed by name instead quint32 hue = qHash(id); color.setHsv(hue % 360, 255, 255); } QString name = id; if (entity->has("name")) { name = entity->at("name")->asString(); } // enter entity into manager TentityMap& map = getMapForPackID(packID); map.insert(id, EntityInfo(name, category, catcolor, color)); }
void CurveLine::drawPort(QPainter *painter, int portNumber) { if ((portNumber == 0) || (portNumber == mEdge->line().count() - 1)) { LineHandler::drawPort(painter, portNumber); return; } QPen pen; pen.setCapStyle(Qt::RoundCap); QColor color; QPointF p1(-0.25, 0); QPointF p2(0.25, 0); color.setNamedColor("#ffcc66"); pen.setWidth(12); pen.setColor(color); painter->setPen(pen); painter->drawLine(p1, p2); color.setNamedColor("#ff6666"); pen.setWidth(3); pen.setColor(color); painter->setPen(pen); painter->drawLine(p1, p2); }
QColor PrefDialog::GetCurBtnColor(const QPushButton* btn) { QColor color; if (mSettings != NULL) { if (btn == mRowHColorBgBtn) { color.setNamedColor(mSettings->mRowHColorBg); } else { color.setNamedColor(mSettings->mRowHColorFg); } } if (mSettings == NULL || !color.isValid()) { if (btn == mRowHColorBgBtn) { color = QApplication::palette().color(QPalette::Active, QPalette::Button); } else { color = QApplication::palette().color(QPalette::Active, QPalette::ButtonText); } } return color; }
void SyntaxHighligther::loadConfig<None>() { QColor textColor; QColor bgColor; textColor.setNamedColor("#aaaaaa"); bgColor.setNamedColor("#4d4d4d"); defaultFormat_.setBackground(bgColor); defaultFormat_.setForeground(textColor); }
void ConfigurationManager::decorateBrowser(ClipboardBrowser *c) const { QFont font; QPalette p; QColor color; /* fonts */ font.fromString( ui->pushButtonFont->property("VALUE").toString() ); c->setFont(font); /* scrollbars */ Qt::ScrollBarPolicy scrollbarPolicy = m_theme["show_scrollbars"].value().toBool() ? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff; c->setVerticalScrollBarPolicy(scrollbarPolicy); c->setHorizontalScrollBarPolicy(scrollbarPolicy); /* colors */ p = c->palette(); color.setNamedColor( m_theme["bg"].value().toString() ); p.setBrush(QPalette::Base, color); color.setNamedColor( m_theme["fg"].value().toString() ); p.setBrush(QPalette::Text, color); color.setNamedColor( m_theme["alt_bg"].value().toString() ); p.setBrush(QPalette::AlternateBase, color); color.setNamedColor( m_theme["sel_bg"].value().toString() ); p.setBrush(QPalette::Highlight, color); color.setNamedColor( m_theme["sel_fg"].value().toString() ); p.setBrush(QPalette::HighlightedText, color); c->setPalette(p); /* search style */ ItemDelegate *d = static_cast<ItemDelegate *>( c->itemDelegate() ); font.fromString( m_theme["find_font"].value().toString() ); color.setNamedColor( m_theme["find_bg"].value().toString() ); p.setColor(QPalette::Base, color); color.setNamedColor( m_theme["find_fg"].value().toString() ); p.setColor(QPalette::Text, color); d->setSearchStyle(font, p); /* editor style */ d->setSearchStyle(font, p); font.fromString( m_theme["edit_font"].value().toString() ); color.setNamedColor( m_theme["edit_bg"].value().toString() ); p.setColor(QPalette::Base, color); color.setNamedColor( m_theme["edit_fg"].value().toString() ); p.setColor(QPalette::Text, color); d->setEditorStyle(font, p); /* number style */ d->setShowNumber(m_theme["show_number"].value().toBool()); font.fromString( m_theme["num_font"].value().toString() ); color.setNamedColor( m_theme["num_fg"].value().toString() ); p.setColor(QPalette::Text, color); d->setNumberStyle(font, p); c->redraw(); }
void tst_QColor::setallowX11ColorNames() { #if defined(Q_OS_IRIX) QSKIP("This fails due to the gamma settings in the SGI X server", SkipAll); #else RGBData x11RgbTbl[] = { // a few standard X11 color names { "DodgerBlue1", qRgb(30, 144, 255) }, { "DodgerBlue2", qRgb(28, 134, 238) }, { "DodgerBlue3", qRgb(24, 116, 205) }, { "DodgerBlue4", qRgb(16, 78, 139) }, { "SteelBlue1", qRgb(99, 184, 255) }, { "SteelBlue2", qRgb(92, 172, 238) }, { "SteelBlue3", qRgb(79, 148, 205) }, { "SteelBlue4", qRgb(54, 100, 139) }, { "DeepSkyBlue1", qRgb(0, 191, 255) }, { "DeepSkyBlue2", qRgb(0, 178, 238) }, { "DeepSkyBlue3", qRgb(0, 154, 205) }, { "DeepSkyBlue4", qRgb(0, 104, 139) }, { "SkyBlue1", qRgb(135, 206, 255) }, { "SkyBlue2", qRgb(126, 192, 238) }, { "SkyBlue3", qRgb(108, 166, 205) }, { "SkyBlue4", qRgb(74, 112, 139) } }; static const int x11RgbTblSize = sizeof(x11RgbTbl) / sizeof(RGBData); // X11 color names should not work by default QVERIFY(!QColor::allowX11ColorNames()); for (int i = 0; i < x11RgbTblSize; ++i) { QString colorName = QLatin1String(x11RgbTbl[i].name); QColor color; color.setNamedColor(colorName); QVERIFY(!color.isValid()); } // enable X11 color names QColor::setAllowX11ColorNames(true); QVERIFY(QColor::allowX11ColorNames()); for (int i = 0; i < x11RgbTblSize; ++i) { QString colorName = QLatin1String(x11RgbTbl[i].name); QColor color; color.setNamedColor(colorName); QColor expected(x11RgbTbl[i].value); QCOMPARE(color, expected); } // should be able to turn off X11 color names QColor::setAllowX11ColorNames(false); QVERIFY(!QColor::allowX11ColorNames()); for (int i = 0; i < x11RgbTblSize; ++i) { QString colorName = QLatin1String(x11RgbTbl[i].name); QColor color; color.setNamedColor(colorName); QVERIFY(!color.isValid()); } #endif // Q_OS_IRIX }
ParConfWidget::ParConfWidget(QChar parName, bool withAnimateButton, bool withKeepTracksButton) : QGroupBox(), treeCreator(NORMAL_EXPR) { setTitle(tr("Adjustments for ") + parName + " :"); keepTracksButtonAvailable = withKeepTracksButton; defaultRange.start = 0; defaultRange.step = 1; defaultRange.end = 0.5; keepTracks = NULL; QHBoxLayout *widgetsLayout = new QHBoxLayout; widgetsLayout->setSpacing(3); addConfWidgets(widgetsLayout); startTree = endTree = stepTree = NULL; kState = valid = isStepGood = isEndGood = isStartGood = false; QColor color; color.setNamedColor(VALID_COLOR); validPalette.setColor(QPalette::Base, color); validPalette.setColor(QPalette::Text, Qt::black); color.setNamedColor(INVALID_COLOR); invalidPalette.setColor(QPalette::Base, color); invalidPalette.setColor(QPalette::Text, Qt::black); if(withAnimateButton) { QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setSpacing(3); mainLayout->addLayout(widgetsLayout); QHBoxLayout *animateLayout = new QHBoxLayout; animate = new QCheckBox(tr("Animate")); connect(animate, SIGNAL(toggled(bool)), this, SIGNAL(animateToggled(bool))); animateLayout->addWidget(animate); if(withKeepTracksButton) { keepTracks = new QCheckBox(tr("Keep tracks")); animateLayout->addWidget(keepTracks); treeCreator.allow_k(true); } animateLayout->addStretch(); mainLayout->addLayout(animateLayout); setLayout(mainLayout); } else setLayout(widgetsLayout);
void EntityIdentifier::parseEntityDefinition(JSONObject *entity, QString const &category, QColor catcolor, int packID) { QString id("unknown"); if (entity->has("id")) id = entity->at("id")->asString().toLower(); if (entity->has("catcolor")) { QString colorname = entity->at("catcolor")->asString(); catcolor.setNamedColor(colorname); assert(catcolor.isValid()); } QColor color; if (entity->has("color")) { QString colorname = entity->at("color")->asString(); color.setNamedColor(colorname); assert(color.isValid()); } else { // use hashed by name instead quint32 hue = qHash(id); color.setHsv(hue % 360, 255, 255); } QString name; if (entity->has("name")) { // use provided name name = entity->at("name")->asString(); } else { // or try to build name automatically // split at underscores QStringList tokens = id.toLower().replace('_',' ').split(" "); // make first character uppercase for (QList<QString>::iterator tokItr = tokens.begin(); tokItr != tokens.end(); ++tokItr) { (*tokItr) = (*tokItr).at(0).toUpper() + (*tokItr).mid(1); } name = tokens.join(" "); } // enter entity into manager TentityMap& map = getMapForPackID(packID); map.insert(id, EntityInfo(name, category, catcolor, color)); // add duplicates: when new 1.11+ or 1.13+ id definitions are available // legacy id is stored in own definition element (duplicates automatically) if (entity->has("idlist")) { JSONArray *idlist = dynamic_cast<JSONArray *>(entity->at("idlist")); int len = idlist->length(); for (int j = 0; j < len; j++) { QString idl = entity->at("idlist")->at(j)->asString().toLower(); map.insert(idl, EntityInfo(name, category, catcolor, color)); } } }
// Проверка скобок void MainWindow::on_pushButton_clicked() { SET_CODEC; StackType type; if (ui->radioButton_3->isChecked()) type = Array; else type = List; QString text = ui->lineEdit->text().trimmed(); if (text.length() == 0) { Error error((QString) "Пустой ввод!"); error.Show(); return; } if (!(text.contains('(') || text.contains(')') || text.contains('[') || text.contains(']') || text.contains('{') || text.contains('}'))) { Error error((QString) "Введенное выражение не содержит скобок!"); error.Show(); return; } ui->textEdit->clear(); // Проверка на правильность скобок bool result; try { result = isRightBrackets(text, type); // Вывод результата проверки QColor color; QPalette::ColorRole cr; QPalette palette; if (result) { ui->label_2->setText("Скобки расставлены верно!"); color.setNamedColor("green"); } else { ui->label_2->setText("Скобки расставлены неверно!"); color.setNamedColor("red"); } cr = QPalette::WindowText; palette.setColor(cr, color); ui->label_2->setPalette(palette); } catch(Error err) { this->Log((QString *) &(err.getErrorDescription())); err.Show(); } }
void PMWindow::slotFindAll(){ if (!toolButton_ALL->isChecked()){ textEdit_CHAT->setExtraSelections(QList<QTextEdit::ExtraSelection>()); return; } QList<QTextEdit::ExtraSelection> extraSelections; if (!lineEdit_FIND->text().isEmpty()) { QTextEdit::ExtraSelection selection; QColor color; color.setNamedColor(WSGET(WS_CHAT_FIND_COLOR)); color.setAlpha(WIGET(WI_CHAT_FIND_COLOR_ALPHA)); selection.format.setBackground(color); QTextCursor c = textEdit_CHAT->document()->find(lineEdit_FIND->text(), 0, 0); while (!c.isNull()){ selection.cursor = c; extraSelections.append(selection); c = textEdit_CHAT->document()->find(lineEdit_FIND->text(), c, 0); } } textEdit_CHAT->setExtraSelections(extraSelections); }
float Theme::getLightness(QString color) { QColor c; c.setNamedColor(color); QColor converted = c.toHsv(); return converted.valueF(); }
float Theme::getSaturation(QString color) { QColor c; c.setNamedColor(color); QColor converted = c.toHsv(); return converted.hsvSaturationF(); }
float Theme::getHue(QString color) { QColor c; c.setNamedColor(color); QColor converted = c.toHsv(); return converted.hsvHueF(); }
void toResultViewItem::paintCell(QPainter * p, const QColorGroup & cg, int column, int width, int align) { #if 0 // disabled, not overriding correct function anyhow // null related background handling QColorGroup colNull(cg); if ((toConfigurationSingle::Instance().indicateEmpty() && text(column) == "{null}") || text(column).isNull()) { QColor nullColor; nullColor.setNamedColor(toConfigurationSingle::Instance().indicateEmptyColor()); colNull.setColor(QColorGroup::Base, nullColor); } toTreeWidgetItem::paintCell(p, colNull, column, width, align); toResultView *view = dynamic_cast<toResultView *>(listView()); if (view && (itemBelow() == NULL || itemBelow()->itemBelow() == NULL)) view->addItem(); if (Gridlines) { p->setPen(Qt::gray); p->drawLine(width - 1, 0, width - 1, height()); p->drawLine(0, height() - 1, width - 1, height() - 1); } #endif }
void TagColorEditor::itemChanged(QTableWidgetItem *item) { uchar *colors = Global::tagColors(); int row = item->row(); int colm = item->column(); if (colm == 0) { QColor clr; clr.setNamedColor(item->data(Qt::DisplayRole).toString()); item->setData(Qt::DecorationRole, clr); colors[4*(row+1)+0] = clr.red(); colors[4*(row+1)+1] = clr.green(); colors[4*(row+1)+2] = clr.blue(); } else { double opv = item->data(Qt::DisplayRole).toDouble(); int op = opv*255; op = qMin(op, 255); colors[4*(row+1)+3] = op; } emit tagColorChanged(); }
QColor AppConfigGroup::optionAsColor(const QString &optionName) const { QColor color; color.setNamedColor(option(optionName)); return color; }
void UBWidgetUniboardAPI::setMarkerColor(const QString& penColor) { if (UBApplication::boardController->activeScene() != mScene) return; UBSettings* settings = UBSettings::settings(); bool conversionState = false; int index = penColor.toInt(&conversionState); if (conversionState && index > 0 && index <= 4) { UBApplication::boardController->setMarkerColorOnDarkBackground(settings->markerColors(true).at(index - 1)); UBApplication::boardController->setMarkerColorOnLightBackground(settings->markerColors(false).at(index - 1)); } else { QColor svgColor; svgColor.setNamedColor(penColor); if (svgColor.isValid()) { UBApplication::boardController->setMarkerColorOnDarkBackground(svgColor); UBApplication::boardController->setMarkerColorOnLightBackground(svgColor); } } }
void FamiliasTPV::on_mui_seleccionarcolor_clicked() { QColor coloractual; if (QColor::isValidColor(mui_colortpvfamilia->text())) { coloractual.setNamedColor(mui_colortpvfamilia->text()); } else { coloractual.setNamedColor("#FFFFFF"); } // end if QColorDialog colordialog; QColor color = colordialog.getColor(coloractual, this); mui_colortpvfamilia->setText(color.name()); }
void cuteGraphLib::GraphicItem::setColorFromAttributes() { std::vector<std::string> colors; colors.push_back("fillcolor"); colors.push_back("color"); colors.push_back("fontcolor"); for(size_t i = 0; i < colors.size(); i++) { if(userAttributes.count(colors.at(i)) > 0) { QColor newColor; std::string colorToUse = userAttributes.find(colors.at(i))->second; newColor.setNamedColor(QString(colorToUse.c_str())); if(newColor.isValid()) { if(colors.at(i) == "fillcolor") fillColor = newColor; if(colors.at(i) == "color") lineColor = newColor; if(colors.at(i) == "fontcolor") fontColor = newColor; } else std::cout << "Color " << colorToUse << " is not valid!" << std::endl; } } }
void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) { QPainter painter(lineNumberArea); QColor q = QColor(); q.setNamedColor("#323232"); QColor q2 = QColor(); q2.setNamedColor("#247EAF"); painter.fillRect(event->rect(), q); QTextBlock block = firstVisibleBlock(); int blockNumber = block.blockNumber(); int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top(); int bottom = top + (int) blockBoundingRect(block).height(); while (block.isValid() && top <= event->rect().bottom()) { if (block.isVisible() && bottom >= event->rect().top()) { QString number = QString::number(blockNumber + 1); painter.setPen(q2); painter.drawText(0, top, lineNumberArea->width()-5 , fontMetrics().height(), Qt::AlignRight, number); } block = block.next(); top = bottom; bottom = top + (int) blockBoundingRect(block).height(); ++blockNumber; } }
void EntityIdentifier::parseCategoryDefinition(JSONObject *data, int packID) { QString category; if (data->has("category")) category = data->at("category")->asString(); else category = "Unknown"; QColor catcolor; if (data->has("catcolor")) { QString colorname = data->at("catcolor")->asString(); catcolor.setNamedColor(colorname); assert(catcolor.isValid()); } else { // use hashed by name instead quint32 hue = qHash(category); catcolor.setHsv(hue % 360, 255, 255); } addCategory(qMakePair(category, catcolor)); if (data->has("entity")) { JSONArray *entities = dynamic_cast<JSONArray *>(data->at("entity")); int len = entities->length(); for (int e = 0; e < len; e++) parseEntityDefinition(dynamic_cast<JSONObject *>(entities->at(e)), category, catcolor, packID); } }
void QgsRasterShader::readXML( const QDomElement& elem ) { //only colorrampshader QDomElement colorRampShaderElem = elem.firstChildElement( "colorrampshader" ); if ( !colorRampShaderElem.isNull() ) { QgsColorRampShader* colorRampShader = new QgsColorRampShader(); colorRampShader->setColorRampType( colorRampShaderElem.attribute( "colorRampType", "INTERPOLATED" ) ); colorRampShader->setClip( colorRampShaderElem.attribute( "clip", "0" ) == "1" ); QList<QgsColorRampShader::ColorRampItem> itemList; QDomElement itemElem; QString itemLabel; double itemValue; QColor itemColor; QDomNodeList itemNodeList = colorRampShaderElem.elementsByTagName( "item" ); for ( int i = 0; i < itemNodeList.size(); ++i ) { itemElem = itemNodeList.at( i ).toElement(); itemValue = itemElem.attribute( "value" ).toDouble(); itemLabel = itemElem.attribute( "label" ); itemColor.setNamedColor( itemElem.attribute( "color" ) ); itemList.push_back( QgsColorRampShader::ColorRampItem( itemValue, itemColor, itemLabel ) ); } colorRampShader->setColorRampItemList( itemList ); setRasterShaderFunction( colorRampShader ); } }
QVariant FavoriteTagsModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.row() >= m_tags.size() || index.column() >= COLUMN_LAST) return QVariant(); QColor color; switch (role) { case Qt::ForegroundRole: switch (index.column()) { case COLUMN_NAME: color.setNamedColor(m_tags[index.row()].color); return color.isValid() ? QVariant(QBrush(color)) : QVariant(); default: return QVariant(); } case Qt::DisplayRole: case Qt::EditRole: switch (index.column()) { case COLUMN_INDEX: return index.row() + 1; case COLUMN_NAME: return m_tags[index.row()].name; case COLUMN_COLOR: return m_tags[index.row()].color; } default: return QVariant(); } Q_ASSERT(false); return QVariant(); }
void MainWindow::setupPlot() { plotTimer.setInterval(1000/settingsDialog->rate); connect(&plotTimer, SIGNAL(timeout()), this, SLOT(plotUpdate())); plotTimer.start(); if (!ui->plot->legend()) { QwtLegend* legend = new QwtLegend; legend->setItemMode(QwtLegend::CheckableItem); ui->plot->insertLegend(legend, QwtPlot::RightLegend); } ui->plot->setAxisTitle(QwtPlot::xBottom, "seconds"); ui->plot->setCanvasBackground(Qt::white); QColor gridColor; gridColor.setNamedColor("grey"); QPen gridPen(gridColor); gridPen.setStyle(Qt::DotLine); QwtPlotGrid* grid = new QwtPlotGrid; grid->setMajPen(gridPen); grid->attach(ui->plot); connect(ui->plot, SIGNAL(legendChecked(QwtPlotItem*,bool)), this, SLOT(showCurve(QwtPlotItem*,bool))); }
bool ColorSet::initColorSetFromFile(QString filename){ QFile f(filename); if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug() << "Open ColorSetFile failed." << endl; return false; } QTextStream txtInput(&f); QString lineStr; while (!txtInput.atEnd()) { txtInput >> lineStr ; bool ok = false; QColor newColor; newColor.setNamedColor(lineStr); //= QColor(lineStr.mid(0, 2).trimmed().toInt(&ok, 16), lineStr.mid(2, 2).trimmed().toInt(&ok, 16), lineStr.mid(4, 2).trimmed().toInt(&ok, 16), 255); colorSet.push_back(newColor); qDebug() << lineStr << lineStr.mid(0, 2).trimmed().toInt(&ok, 16)<<lineStr.mid(2, 2).trimmed().toInt(&ok, 16)<<lineStr.mid(4, 2).trimmed().toInt(&ok, 16) << endl; } f.close(); }
void LinkDialogGraphicsView::setDialogScene(LinkDialogGraphicsScene* scene) { QColor bgColor; bgColor.setNamedColor("#4d4d4d"); scene->setBackgroundBrush(bgColor); setScene(scene); scene_ = scene; }
void MessagesSettingsPage::updateHighlightColor(const QString &value) { QColor colorToSet; colorToSet.setNamedColor("#" + value); if (colorToSet.isValid()) { settingsCache->setChatHighlightColor(value); updateHighlightPreview(); } }
QColor loadColor(const QJsonObject& parent) { QColor color; if( !parent.isEmpty() ) { color.setNamedColor(parent[QStringLiteral("color")].toString()); } return color; }
QColor KConfigBase::readColorEntry(const char *pKey, const QColor *pDefault) const { QColor aRetColor; int nRed = 0, nGreen = 0, nBlue = 0; QString aValue = readEntry(pKey); if(!aValue.isEmpty()) { if(aValue.at(0) == '#') { aRetColor.setNamedColor(aValue); } else { bool bOK; // find first part (red) int nIndex = aValue.find(','); if(nIndex == -1) { // return a sensible default -- Bernd if(pDefault) aRetColor = *pDefault; return aRetColor; } nRed = aValue.left(nIndex).toInt(&bOK); // find second part (green) int nOldIndex = nIndex; nIndex = aValue.find(',', nOldIndex + 1); if(nIndex == -1) { // return a sensible default -- Bernd if(pDefault) aRetColor = *pDefault; return aRetColor; } nGreen = aValue.mid(nOldIndex + 1, nIndex - nOldIndex - 1).toInt(&bOK); // find third part (blue) nBlue = aValue.right(aValue.length() - nIndex - 1).toInt(&bOK); aRetColor.setRgb(nRed, nGreen, nBlue); } } else { if(pDefault) aRetColor = *pDefault; } return aRetColor; }
bool CalcSetColor::prepare(CalcParms& parms) { init(parms); checkOutputCount(1); if(1 == mIns.size()) { // Check format "<Foo> = SETCOLOR(<Color>)" // mIns look like: "red" QColor c; c.setNamedColor(mIns.at(0)); if(!c.isValid()) { error(FUNC, tr("Color '%1' not valid.").arg(mIns.at(0))); } } else if(3 == mIns.size()) { // Check format "<Foo> = SETCOLOR(<Variable>, <TrueColor>, <FalseColor>)" // mIns look like: "winday", "green", "red" checkInputVariable(0); QColor c; c.setNamedColor(mIns.at(1)); if(!c.isValid()) { error(FUNC, tr("Color No.1 '%1' not valid.").arg(mIns.at(1))); } c.setNamedColor(mIns.at(2)); if(!c.isValid()) { error(FUNC, tr("Color No.2 '%1' not valid.").arg(mIns.at(2))); } } else { error(FUNC, tr("Wrong parameter count.")); } if(hasError()) return false; return true; }