当前位置: 首页>>代码示例>>C++>>正文


C++ QColor::name方法代码示例

本文整理汇总了C++中QColor::name方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::name方法的具体用法?C++ QColor::name怎么用?C++ QColor::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QColor的用法示例。


在下文中一共展示了QColor::name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: convertRasterProperties

void QgsProjectFileTransform::convertRasterProperties( QDomDocument& doc, QDomNode& parentNode,
    QDomElement& rasterPropertiesElem, QgsRasterLayer* rlayer )
{
  //no data
  //TODO: We would need to set no data on all bands, but we don't know number of bands here
  QDomNode noDataNode = rasterPropertiesElem.namedItem( "mNoDataValue" );
  QDomElement noDataElement = noDataNode.toElement();
  if ( !noDataElement.text().isEmpty() )
  {
    QgsDebugMsg( "mNoDataValue = " + noDataElement.text() );
    QDomElement noDataElem = doc.createElement( "noData" );

    QDomElement noDataRangeList = doc.createElement( "noDataRangeList" );
    noDataRangeList.setAttribute( "bandNo", 1 );

    QDomElement noDataRange =  doc.createElement( "noDataRange" );
    noDataRange.setAttribute( "min", noDataElement.text() );
    noDataRange.setAttribute( "max", noDataElement.text() );
    noDataRangeList.appendChild( noDataRange );

    noDataElem.appendChild( noDataRangeList );

    parentNode.appendChild( noDataElem );
  }

  QDomElement rasterRendererElem = doc.createElement( "rasterrenderer" );
  //convert general properties

  //invert color
  rasterRendererElem.setAttribute( "invertColor", "0" );
  QDomElement  invertColorElem = rasterPropertiesElem.firstChildElement( "mInvertColor" );
  if ( !invertColorElem.isNull() )
  {
    if ( invertColorElem.text() == "true" )
    {
      rasterRendererElem.setAttribute( "invertColor", "1" );
    }
  }

  //opacity
  rasterRendererElem.setAttribute( "opacity", "1" );
  QDomElement transparencyElem = parentNode.firstChildElement( "transparencyLevelInt" );
  if ( !transparencyElem.isNull() )
  {
    double transparency = transparencyElem.text().toInt();
    rasterRendererElem.setAttribute( "opacity", QString::number( transparency / 255.0 ) );
  }

  //alphaBand was not saved until now (bug)
  rasterRendererElem.setAttribute( "alphaBand", -1 );

  //gray band is used for several renderers
  int grayBand = rasterBandNumber( rasterPropertiesElem, "mGrayBandName", rlayer );

  //convert renderer specific properties
  QString drawingStyle = rasterPropertiesElem.firstChildElement( "mDrawingStyle" ).text();

  // While PalettedColor should normaly contain only integer values, usually
  // color palette 0-255, it may happen (Tim, issue #7023) that it contains
  // colormap classification with double values and text labels
  // (which should normaly only appear in SingleBandPseudoColor drawingStyle)
  // => we have to check first the values and change drawingStyle if necessary
  if ( drawingStyle == "PalettedColor" )
  {
    QDomElement customColorRampElem = rasterPropertiesElem.firstChildElement( "customColorRamp" );
    QDomNodeList colorRampEntryList = customColorRampElem.elementsByTagName( "colorRampEntry" );

    for ( int i = 0; i < colorRampEntryList.size(); ++i )
    {
      QDomElement colorRampEntryElem = colorRampEntryList.at( i ).toElement();
      QString strValue = colorRampEntryElem.attribute( "value" );
      double value = strValue.toDouble();
      if ( value < 0 || value > 10000 || value != ( int )value )
      {
        QgsDebugMsg( QString( "forcing SingleBandPseudoColor value = %1" ).arg( value ) );
        drawingStyle = "SingleBandPseudoColor";
        break;
      }
    }
  }

  if ( drawingStyle == "SingleBandGray" )
  {
    rasterRendererElem.setAttribute( "type", "singlebandgray" );
    rasterRendererElem.setAttribute( "grayBand", grayBand );
    transformContrastEnhancement( doc, rasterPropertiesElem, rasterRendererElem );
  }
  else if ( drawingStyle == "SingleBandPseudoColor" )
  {
    rasterRendererElem.setAttribute( "type", "singlebandpseudocolor" );
    rasterRendererElem.setAttribute( "band", grayBand );
    QDomElement newRasterShaderElem = doc.createElement( "rastershader" );
    QDomElement newColorRampShaderElem = doc.createElement( "colorrampshader" );
    newRasterShaderElem.appendChild( newColorRampShaderElem );
    rasterRendererElem.appendChild( newRasterShaderElem );

    //switch depending on mColorShadingAlgorithm
    QString colorShadingAlgorithm = rasterPropertiesElem.firstChildElement( "mColorShadingAlgorithm" ).text();
    if ( colorShadingAlgorithm == "PseudoColorShader" || colorShadingAlgorithm == "FreakOutShader" )
    {
//.........这里部分代码省略.........
开发者ID:ColeCummins,项目名称:QGIS,代码行数:101,代码来源:qgsprojectfiletransform.cpp

示例2: on_mBufferColorButton_colorChanged

void QgsLabelPropertyDialog::on_mBufferColorButton_colorChanged( const QColor &color )
{
  insertChangedValue( QgsPalLayerSettings::BufferColor, color.name() );
}
开发者ID:V17nika,项目名称:QGIS,代码行数:4,代码来源:qgslabelpropertydialog.cpp

示例3: colorToString

static QString colorToString(const QColor &color)
{
    if (color.alpha() != 255)
        return color.name(QColor::HexArgb);
    return color.name();
}
开发者ID:bjorn,项目名称:tiled,代码行数:6,代码来源:mapwriter.cpp

示例4: normalizeColor

static inline QColor normalizeColor(const QColor &color)
{
    QColor newColor = QColor(color.name());
    newColor.setAlpha(color.alpha());
    return newColor;
}
开发者ID:aizaimenghuangu,项目名称:QtTestor,代码行数:6,代码来源:gradientlineqmladaptor.cpp

示例5: saveXML

bool QLCCapability::saveXML(QXmlStreamWriter *doc)
{
    Q_ASSERT(doc != NULL);

    /* QLCCapability entry */
    doc->writeStartElement(KXMLQLCCapability);

    /* Min limit attribute */
    doc->writeAttribute(KXMLQLCCapabilityMin, QString::number(m_min));

    /* Max limit attribute */
    doc->writeAttribute(KXMLQLCCapabilityMax, QString::number(m_max));

    /* Preset attribute if not custom */
    if (m_preset != Custom)
        doc->writeAttribute(KXMLQLCCapabilityPreset, presetToString(m_preset));

    /* Resource attributes */
    for (int i = 0; i < m_resources.count(); i++)
    {
        switch (presetType())
        {
            case Picture:
            {
                QString modFilename = resource(i).toString();
                QDir dir = QDir::cleanPath(QLCFile::systemDirectory(GOBODIR).path());

                if (modFilename.contains(dir.path()))
                {
                    modFilename.remove(dir.path());
                    // The following line is a dirty workaround for an issue raised on Windows
                    // When building with MinGW, dir.path() is something like "C:/QLC+/Gobos"
                    // while QDir::separator() returns "\"
                    // So, to avoid any string mismatch I remove the first character
                    // no matter what it is
                    modFilename.remove(0, 1);
                }

                doc->writeAttribute(KXMLQLCCapabilityRes1, modFilename);
            }
            break;
            case SingleColor:
            case DoubleColor:
            {
                QColor col = resource(i).value<QColor>();
                if (i == 0 && col.isValid())
                    doc->writeAttribute(KXMLQLCCapabilityRes1, col.name());
                else if (i == 1 && col.isValid())
                    doc->writeAttribute(KXMLQLCCapabilityRes2, col.name());
            }
            break;
            case SingleValue:
            case DoubleValue:
            {
                if (i == 0)
                    doc->writeAttribute(KXMLQLCCapabilityRes1, QString::number(resource(i).toFloat()));
                else if (i == 1)
                    doc->writeAttribute(KXMLQLCCapabilityRes2, QString::number(resource(i).toFloat()));
            }
            break;
            default:
            break;
        }
    }

    /* Name */
    if (m_aliases.isEmpty())
        doc->writeCharacters(m_name);
    else
        doc->writeCharacters(QString("%1\n   ").arg(m_name)); // to preserve indentation

    /* Aliases */
    foreach (AliasInfo info, m_aliases)
    {
        doc->writeStartElement(KXMLQLCCapabilityAlias);
        doc->writeAttribute(KXMLQLCCapabilityAliasMode, info.targetMode);
        doc->writeAttribute(KXMLQLCCapabilityAliasSourceName, info.sourceChannel);
        doc->writeAttribute(KXMLQLCCapabilityAliasTargetName, info.targetChannel);
        doc->writeEndElement();
    }
开发者ID:janosvitok,项目名称:qlcplus,代码行数:80,代码来源:qlccapability.cpp

示例6: markerPixmap

QPixmap markerPixmap(const QColor& color, const QColor& bgColor) {
	// create unique string-name for color combinations
	QString cacheName(color.name()+bgColor.name());
	QPixmap px(16, 16);

	// The method signature was changed: it's
	// bool QPixmapCache::find ( const QString & key, QPixmap & pm ) in Qt <= 4.5
	// and
	// bool QPixmapCache::find ( const QString & key, QPixmap * pm ) in Qt >= 4.6
#if QT_VERSION >= 0x040600
	if ( QPixmapCache::find(cacheName, &px) ) {
#else
	if ( QPixmapCache::find(cacheName, px) ) {
#endif
		return px;
	}

	px.fill(bgColor);

	QPainter p(&px);
	// As we are using pixmap cache for most pixmap access
	// we can use more resource and time consuming rendering
	// to get better results (smooth rounded bullet in this case).
	// Remember: painting is performed only once per running juffed
	//           in the ideal case.
	p.setRenderHint(QPainter::Antialiasing);

	int red   = color.red();
	int green = color.green();
	int blue  = color.blue();

	QColor light(red + (255 - red) / 2, green + (255 - green) / 2, blue + (255 - blue) / 2);
	QColor dark(red / 2, green / 2, blue / 2);

	QRadialGradient gr(0.4, 0.4, 0.5, 0.4, 0.4);
	gr.setCoordinateMode(QGradient::ObjectBoundingMode);
	gr.setColorAt(0, light);
	gr.setColorAt(1, dark);
	p.setPen(dark);
	p.setBrush(gr);
	p.drawEllipse(1, 1, 14, 14);

	p.end();

	QPixmapCache::insert(cacheName, px);
	return px;
}

class SciDoc::Interior {
public:
	Interior(QWidget* w) {
//		LOGGER;

		curEdit_ = NULL;

		spl_ = new QSplitter(Qt::Vertical);
		QVBoxLayout* vBox = new QVBoxLayout();
		vBox->setContentsMargins(0, 0, 0, 0);
		vBox->addWidget(spl_);
		w->setLayout(vBox);

		edit1_ = createEdit();
		edit2_ = createEdit();
		spl_->addWidget(edit1_);
		spl_->addWidget(edit2_);
		edit1_->setDocument(edit2_->document());
		w->setFocusProxy(spl_);
		spl_->setSizes(QList<int>() << 0 << spl_->height());
		
		hlTimer_ = new QTimer( w );
		hlTimer_->setSingleShot( true );
		connect(hlTimer_, SIGNAL(timeout()), w, SLOT(highlightWord()));
	}

	JuffScintilla* createEdit() {
//		LOGGER;
		JuffScintilla* edit = new JuffScintilla();
		edit->setFocusPolicy(Qt::ClickFocus);
		edit->setUtf8(true);
		edit->setFolding(QsciScintilla::BoxedTreeFoldStyle);
		edit->setAutoIndent(true);
		edit->setBraceMatching(QsciScintilla::SloppyBraceMatch);

		// margins
		edit->setMarginLineNumbers(0, false);
		edit->setMarginLineNumbers(1, true);
		edit->setMarginSensitivity(0, true);
		edit->setMarginWidth(0, 20);
		edit->setMarginWidth(2, 12);

		// markers
		edit->markerDefine(QsciScintilla::Background, 2);
		//	Set the 0th margin accept markers numbered 1 and 2
		//	Binary mask for markers 1 and 2 is 00000110 ( == 6 )
		edit->setMarginMarkerMask(0, 6);
		edit->setMarginMarkerMask(1, 0);

		return edit;
	}

//.........这里部分代码省略.........
开发者ID:MikeTekOn,项目名称:juffed,代码行数:101,代码来源:SciDoc.cpp

示例7: getStrData

QString LC_List::getStrData(Plug_Entity *ent) {
    QHash<int, QVariant> data;
    QString str;
    double numA, numB, numC;
    QPointF ptA, ptB, ptC;
    //common entity data
    if (ent == 0)
        return QString("Empty Entity\n\n");
    ent->getData(&data);
    str = "Layer: " + data.value(DPI::LAYER).toString();
    QColor color = data.value(DPI::COLOR).value<QColor>();
    str.append("\n Color: " + color.name());
    str.append(" Line type: " + data.value(DPI::LTYPE).toString());
    str.append( "\n Line thickness: " + data.value(DPI::LWIDTH).toString());
    str.append( QString("\n ID: %1\n").arg(data.value(DPI::EID).toLongLong()));
    int et = data.value(DPI::ETYPE).toInt();

    //specific entity data
    switch (et) {
    case DPI::POINT:
        str.append( QString("     in point: X=%1 Y=%2\n\n").arg(
                d->realToStr(data.value(DPI::STARTX).toDouble()) ).arg(
                d->realToStr(data.value(DPI::STARTY).toDouble()) ) );
        return QString("POINT: ").append(str);
        break;
    case DPI::LINE:
        ptA.setX( data.value(DPI::STARTX).toDouble() );
        ptA.setY( data.value(DPI::STARTY).toDouble() );
        ptB.setX( data.value(DPI::ENDX).toDouble() );
        ptB.setY( data.value(DPI::ENDY).toDouble() );
        str.append( QString("     from point: X=%1 Y=%2\n     to point: X=%3 Y=%4\n").arg(
                    d->realToStr(ptA.x()) ).arg( d->realToStr(ptA.y()) ).arg(
                    d->realToStr(ptB.x()) ).arg( d->realToStr(ptB.y()) ) );
        ptC = ptB - ptA;
        numA = sqrt( (ptC.x()*ptC.x())+ (ptC.y()*ptC.y()));
        str.append( QString("   length: %1,").arg( d->realToStr(numA) ));
        numB = asin(ptC.y() / numA);
        numC = numB*180/M_PI;
        if (ptC.x() < 0) numC = 180 - numC;
        if (numC < 0) numC = 360 + numC;
        str.append( QString("  Angle in XY plane: %1\n").arg(d->realToStr(numC)) );
        str.append( QString("  Inc. X = %1,  Inc. Y = %2\n\n").arg(
                            d->realToStr(ptC.x()) ).arg( d->realToStr(ptC.y()) ));
         return QString("LINE: ").append(str);
       break;
    case DPI::ARC:
        str.append( QString("   certer point: X=%1 Y=%2\n").arg(
                d->realToStr(data.value(DPI::STARTX).toDouble()) ).arg(
                d->realToStr(data.value(DPI::STARTY).toDouble()) ) );
        numA = data.value(DPI::RADIUS).toDouble();
        numB = data.value(DPI::STARTANGLE).toDouble();
        numC = data.value(DPI::ENDANGLE).toDouble();
        str.append( QString("   radius: %1\n").arg(d->realToStr(numA)) );
        str.append( QString("   initial angle: %1\n").arg(d->realToStr(numB*180/M_PI)) );
        str.append( QString("   final angle: %1\n").arg(d->realToStr(numC*180/M_PI)) );
        str.append( QString("   length: %1\n").arg( d->realToStr((numC-numB)*numA) ) );
        return QString("ARC: ").append(str);
        break;
    case DPI::CIRCLE:
        str.append( QString("   certer point: X=%1 Y=%2\n").arg(
                d->realToStr(data.value(DPI::STARTX).toDouble()) ).arg(
                d->realToStr(data.value(DPI::STARTY).toDouble()) ) );
        numA = data.value(DPI::RADIUS).toDouble();
        str.append( QString("   radius: %1\n").arg(d->realToStr(numA)) );
        str.append( QString("   circumference: %1\n").arg(
                d->realToStr(numA*2*M_PI) ) );
        str.append( QString("   area: %1\n\n").arg(
                d->realToStr(numA*numA*M_PI) ) );
        return QString("CIRCLE: ").append(str);
        break;
    case DPI::ELLIPSE://toy aqui
        str.append( QString("   certer point: X=%1 Y=%2\n").arg(
                d->realToStr(data.value(DPI::STARTX).toDouble()) ).arg(
                d->realToStr(data.value(DPI::STARTY).toDouble()) ) );
        str.append( QString("   major axis: X=%1 Y=%2\n").arg(
                d->realToStr(data.value(DPI::ENDX).toDouble()) ).arg(
                d->realToStr(data.value(DPI::ENDY).toDouble()) ) );
/*        str.append( QString("   minor axis: X=%1 Y=%2\n").arg(
                data.value(DPI::ENDX).toDouble()).arg(
                data.value(DPI::ENDY).toDouble() ) );
        str.append( QString("   start point: X=%1 Y=%2\n").arg(
                data.value(DPI::ENDX).toDouble()).arg(
                data.value(DPI::ENDY).toDouble() ) );
        str.append( QString("   end point: X=%1 Y=%2\n").arg(
                data.value(DPI::ENDX).toDouble()).arg(
                data.value(DPI::ENDY).toDouble() ) );
        str.append( QString("   initial angle: %1\n").arg(numB*180/M_PI) );
        str.append( QString("   final angle: %1\n").arg(numC*180/M_PI) );
        str.append( QString("   radius ratio: %1\n").arg(numC*180/M_PI) );*/
        return QString("ELLIPSE: ").append(str);
        break;

    case DPI::CONSTRUCTIONLINE:
        return QString("CONSTRUCTIONLINE: ").append(str);
        break;
    case DPI::OVERLAYBOX:
        return QString("OVERLAYBOX: ").append(str);
        break;
    case DPI::SOLID:
        return QString("SOLID: ").append(str);
//.........这里部分代码省略.........
开发者ID:GreatDevelopers,项目名称:LibreCAD,代码行数:101,代码来源:list.cpp

示例8: formatBackgroundColor

void HtmlEditor::formatBackgroundColor()
{
    QColor color = QColorDialog::getColor(Qt::white, this);
    if (color.isValid())
        execCommand("hiliteColor", color.name());
}
开发者ID:Tarzanello,项目名称:graphics-dojo-qt5,代码行数:6,代码来源:htmleditor.cpp

示例9: QDialog

SetColorDialog::SetColorDialog(const QString & message, QColor & currentColor, QColor & standardColor, bool askPrefs, QWidget *parent) : QDialog(parent) 
{
	m_prefsCheckBox = NULL;
	m_message = message;
	m_currentColor = m_selectedColor = currentColor;
	m_standardColor = standardColor;

	this->setWindowTitle(tr("Set %1 Color...").arg(message));

	QVBoxLayout * vLayout = new QVBoxLayout(this);

	QLabel * label = new QLabel(tr("Choose a new %1 color.").arg(message.toLower()));
	vLayout->addWidget(label);

	QFrame * f1 = new QFrame();
	QHBoxLayout * hLayout1 = new QHBoxLayout(f1);
	QPushButton *button1 = new QPushButton("Choose");
	button1->setFixedWidth(BUTTON_WIDTH);
	connect(button1, SIGNAL(clicked()), this, SLOT(selectCurrent()));
	hLayout1->addWidget(button1);
	m_currentColorLabel = new ClickableLabel(tr("current %1 color (%2)").arg(message.toLower()).arg(currentColor.name()), this);
	connect(m_currentColorLabel, SIGNAL(clicked()), this, SLOT(selectCurrent()));
	m_currentColorLabel->setPalette(QPalette(currentColor));
	m_currentColorLabel->setAutoFillBackground(true);
	m_currentColorLabel->setMargin(MARGIN);
	hLayout1->addWidget(m_currentColorLabel);
	vLayout->addWidget(f1);

	QFrame * f2 = new QFrame();
	QHBoxLayout * hLayout2 = new QHBoxLayout(f2);
	QPushButton *button2 = new QPushButton("Choose");
	button2->setFixedWidth(BUTTON_WIDTH);
	connect(button2, SIGNAL(clicked()), this, SLOT(selectStandard()));
	hLayout2->addWidget(button2);
	m_standardColorLabel = new ClickableLabel(tr("standard %1 color (%2)").arg(message.toLower()).arg(standardColor.name()), this);
	connect(m_standardColorLabel, SIGNAL(clicked()), this, SLOT(selectStandard()));
	m_standardColorLabel->setPalette(QPalette(standardColor));
	m_standardColorLabel->setAutoFillBackground(true);
	m_standardColorLabel->setMargin(MARGIN);
	hLayout2->addWidget(m_standardColorLabel);
	vLayout->addWidget(f2);

	QFrame * f3 = new QFrame();
	QHBoxLayout * hLayout3 = new QHBoxLayout(f3);
	QPushButton *button3 = new QPushButton("Custom color ...");
	button3->setFixedWidth(BUTTON_WIDTH);
	connect(button3, SIGNAL(clicked()), this, SLOT(selectCustom()));
	hLayout3->addWidget(button3);
	m_customColorLabel = new ClickableLabel("", this);
	connect(m_customColorLabel, SIGNAL(clicked()), this, SLOT(selectLastCustom()));
	setCustomColor(currentColor);
	m_customColorLabel->setMargin(MARGIN);
	hLayout3->addWidget(m_customColorLabel);
	vLayout->addWidget(f3);

	QSpacerItem * spacerItem = new QSpacerItem( 0, 10 );
	vLayout->addSpacerItem(spacerItem);

	QFrame * f4 = new QFrame();
	QHBoxLayout * hLayout4 = new QHBoxLayout(f4);
	m_selectedColorLabel = new QLabel();
	setColor(currentColor);
	hLayout4->addWidget(m_selectedColorLabel);
	m_selectedColorLabel->setMargin(4);
	vLayout->addWidget(f4);

	if (askPrefs) {
		QFrame * f5 = new QFrame();
		QHBoxLayout * hLayout5 = new QHBoxLayout(f5);
		m_prefsCheckBox = new QCheckBox(tr("Make this the default %1 color").arg(message.toLower()));
		hLayout5->addWidget(m_prefsCheckBox);
		vLayout->addWidget(f5);
	}

    QDialogButtonBox * buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
	buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
	buttonBox->button(QDialogButtonBox::Ok)->setText(tr("OK"));
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

	vLayout->addWidget(buttonBox);

	this->setLayout(vLayout);
}
开发者ID:h4ck3rm1k3,项目名称:fritzing,代码行数:84,代码来源:setcolordialog.cpp

示例10: setColor

void SetColorDialog::setColor(const QColor & color) {
	m_selectedColor = color;
	m_selectedColorLabel->setText(tr("selected color (%1)").arg(color.name()));
	m_selectedColorLabel->setPalette(QPalette(color));
	m_selectedColorLabel->setAutoFillBackground(true);
}
开发者ID:h4ck3rm1k3,项目名称:fritzing,代码行数:6,代码来源:setcolordialog.cpp

示例11: onUpdateContent

void PresentationPropertyHolder::onUpdateContent(QColor content)
{
    setContent(content.name());
}
开发者ID:tklam,项目名称:See,代码行数:4,代码来源:presentationpropertyholder.cpp

示例12: log

/**
 * Adds a log entry
 */
void LogWidget::log(LogWidget::LogType logType, QString text) {
    // ignore "libpng sRGB profile" and "QXcbConnection: XCB error: 8" warnings
    if (logType == WarningLogType &&
        (text.contains("libpng warning: iCCP: known incorrect sRGB profile") ||
         text.contains("QXcbConnection: XCB error:"))) {
        return;
    }

#ifndef INTEGRATION_TESTS
    // log to the log file
    logToFileIfAllowed(logType, text);

    // return if logging wasn't enabled or if widget is not visible
    if (!qApp->property("loggingEnabled").toBool() || !isVisible()) {
        return;
    }

    QString type = logTypeText(logType);
    QColor color = QColor(Qt::black);

    switch (logType) {
        case DebugLogType:
            if (!ui->debugCheckBox->isChecked()) {
                return;
            }

            // print debug messages to stderr if in release-mode but debug
            // logging is enabled in the log panel
#ifndef QT_DEBUG
            fprintf(stderr, "Debug: %s\n", text.toLocal8Bit().constData());
#endif

            // gray
            color = QColor(98, 98, 98);
            break;
        case InfoLogType:
            if (!ui->infoCheckBox->isChecked()) {
                return;
            }
            color = QColor(Qt::darkBlue);
            break;
        case WarningLogType:
            if (!ui->warningCheckBox->isChecked()) {
                return;
            }

            // this is a "fix" for crashes that occur when a network goes away
            // and this message should be printed, I haven't managed to get
            // around this crash with other methods
            if (text.contains(
                    "/org/freedesktop/NetworkManager/ActiveConnection")) {
                return;
            }

            // orange
            color = QColor(255, 128, 0);
            break;
        case CriticalLogType:
            if (!ui->criticalCheckBox->isChecked()) {
                return;
            }
            // light red
            color = QColor(192, 0, 0);
            break;
        case FatalLogType:
            if (!ui->fatalCheckBox->isChecked()) {
                return;
            }
            // lighter red
            color = QColor(210, 0, 0);
            break;
        case StatusLogType:
            if (!ui->statusCheckBox->isChecked()) {
                return;
            }
            // green
            color = QColor(0, 128, 0);
            break;
        case ScriptingLogType:
            if (!ui->scriptingCheckBox->isChecked()) {
                return;
            }
            // blue
            color = QColor(0, 102, 255);
            break;
    }

    QDateTime dateTime = QDateTime::currentDateTime();
//    text.prepend("[" + dateTime.toString("hh:mm:ss") + "] [" + type + "] ");
//    text.append("\n");

    QString html = QString("<div style=\"color: %1\">[%2] [%3] %4</div>")
            .arg(color.name(), dateTime.toString("hh:mm:ss"), type,
                 text.toHtmlEscaped());

    QScrollBar *scrollBar = ui->logTextEdit->verticalScrollBar();

//.........这里部分代码省略.........
开发者ID:pbek,项目名称:QOwnNotes,代码行数:101,代码来源:logwidget.cpp

示例13: convertRasterProperties


//.........这里部分代码省略.........
      if ( colorShadingAlgorithm == "FreakOutShader" )
      {
        colorList << "#ff00ff" << "#00ffff" << "#ff0000" << "#00ff00";
      }
      else //pseudocolor
      {
        colorList << "#0000ff" << "#00ffff" << "#ffff00" << "#ff0000";
      }
      QStringList::const_iterator colorIt = colorList.constBegin();
      double boundValue = minValue;
      for ( ; colorIt != colorList.constEnd(); ++colorIt )
      {
        QDomElement newItemElem = doc.createElement( "item" );
        newItemElem.setAttribute( "value", QString::number( boundValue ) );
        newItemElem.setAttribute( "label", QString::number( boundValue ) );
        newItemElem.setAttribute( "color", *colorIt );
        newColorRampShaderElem.appendChild( newItemElem );
        boundValue += breakSize;
      }
    }
    else if ( colorShadingAlgorithm == "ColorRampShader" )
    {
      QDomElement customColorRampElem = rasterPropertiesElem.firstChildElement( "customColorRamp" );
      QString type = customColorRampElem.firstChildElement( "colorRampType" ).text();
      newColorRampShaderElem.setAttribute( "colorRampType", type );
      QDomNodeList colorNodeList = customColorRampElem.elementsByTagName( "colorRampEntry" );

      QString value, label;
      QColor newColor;
      int red, green, blue;
      QDomElement currentItemElem;
      for ( int i = 0; i < colorNodeList.size(); ++i )
      {
        currentItemElem = colorNodeList.at( i ).toElement();
        value = currentItemElem.attribute( "value" );
        label = currentItemElem.attribute( "label" );
        red = currentItemElem.attribute( "red" ).toInt();
        green = currentItemElem.attribute( "green" ).toInt();
        blue = currentItemElem.attribute( "blue" ).toInt();
        newColor = QColor( red, green, blue );
        QDomElement newItemElem = doc.createElement( "item" );
        newItemElem.setAttribute( "value", value );
        newItemElem.setAttribute( "label", label );
        newItemElem.setAttribute( "color", newColor.name() );
        newColorRampShaderElem.appendChild( newItemElem );
      }
    }
  }
  else if ( drawingStyle == "PalettedColor" )
  {
    rasterRendererElem.setAttribute( "type", "paletted" );
    rasterRendererElem.setAttribute( "band", grayBand );
    QDomElement customColorRampElem = rasterPropertiesElem.firstChildElement( "customColorRamp" );
    QDomNodeList colorRampEntryList = customColorRampElem.elementsByTagName( "colorRampEntry" );
    QDomElement newColorPaletteElem = doc.createElement( "colorPalette" );

    int red = 0;
    int green = 0;
    int blue = 0;
    int value = 0;
    QDomElement colorRampEntryElem;
    for ( int i = 0; i < colorRampEntryList.size(); ++i )
    {
      colorRampEntryElem = colorRampEntryList.at( i ).toElement();
      QDomElement newPaletteElem = doc.createElement( "paletteEntry" );
      value = ( int )( colorRampEntryElem.attribute( "value" ).toDouble() );
      newPaletteElem.setAttribute( "value", value );
      red = colorRampEntryElem.attribute( "red" ).toInt();
      green = colorRampEntryElem.attribute( "green" ).toInt();
      blue = colorRampEntryElem.attribute( "blue" ).toInt();
      newPaletteElem.setAttribute( "color", QColor( red, green, blue ).name() );
      newColorPaletteElem.appendChild( newPaletteElem );
    }
    rasterRendererElem.appendChild( newColorPaletteElem );
  }
  else if ( drawingStyle == "MultiBandColor" )
  {
    rasterRendererElem.setAttribute( "type", "multibandcolor" );

    //red band, green band, blue band
    int redBand = rasterBandNumber( rasterPropertiesElem, "mRedBandName", rlayer );
    int greenBand = rasterBandNumber( rasterPropertiesElem, "mGreenBandName", rlayer );
    int blueBand = rasterBandNumber( rasterPropertiesElem, "mBlueBandName", rlayer );
    rasterRendererElem.setAttribute( "redBand", redBand );
    rasterRendererElem.setAttribute( "greenBand", greenBand );
    rasterRendererElem.setAttribute( "blueBand", blueBand );

    transformContrastEnhancement( doc, rasterPropertiesElem, rasterRendererElem );
  }
  else
  {
    return;
  }

  //replace rasterproperties element with rasterrenderer element
  if ( !parentNode.isNull() )
  {
    parentNode.replaceChild( rasterRendererElem, rasterPropertiesElem );
  }
}
开发者ID:namhh,项目名称:Quantum-GIS,代码行数:101,代码来源:qgsprojectfiletransform.cpp

示例14: updatePixelInfo

void WBigBmpGraphicsView::updatePixelInfo(int x, int y, QColor color)
{
	QString info = QString(tr("Pixel(%0,%1)-%2")).
				   arg(x).arg(y).arg(color.name());
	pixelInfoLabel->setText(info);
}
开发者ID:joonhwan,项目名称:Waffle,代码行数:6,代码来源:WBigBmpGraphicsView.cpp

示例15: parseGroup

void ShapePlug::parseGroup(QDomNode &DOC)
{
    QString tmp = "";
    QString FillCol = "White";
    QString StrokeCol = "Black";
    QString defFillCol = "White";
    QString defStrokeCol = "Black";
    QColor stroke = Qt::black;
    QColor fill = Qt::white;
//	Qt::PenStyle Dash = Qt::SolidLine;
    Qt::PenCapStyle LineEnd = Qt::FlatCap;
    Qt::PenJoinStyle LineJoin = Qt::MiterJoin;
//	int fillStyle = 1;
    double strokewidth = 0.1;
//	bool poly = false;
    while(!DOC.isNull())
    {
        double x1, y1, x2, y2;
        StrokeCol = defStrokeCol;
        FillCol = defFillCol;
        stroke = Qt::black;
        fill = Qt::white;
        //	fillStyle = 1;
        strokewidth = 1.0;
        //	Dash = Qt::SolidLine;
        LineEnd = Qt::FlatCap;
        LineJoin = Qt::MiterJoin;
        FPointArray PoLine;
        PoLine.resize(0);
        QDomElement pg = DOC.toElement();
        QString STag = pg.tagName();
        QString style = pg.attribute( "style", "" ).simplified();
        if (style.isEmpty())
            style = pg.attribute( "svg:style", "" ).simplified();
        QStringList substyles = style.split(';', QString::SkipEmptyParts);
        for( QStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it )
        {
            QStringList substyle = (*it).split(':', QString::SkipEmptyParts);
            QString command(substyle[0].trimmed());
            QString params(substyle[1].trimmed());
            if (command == "fill")
            {
                if (!((params == "foreground") || (params == "background") || (params == "fg") || (params == "bg") || (params == "none") || (params == "default") || (params == "inverse")))
                {
                    if (params == "nofill")
                        FillCol = CommonStrings::None;
                    else
                    {
                        fill.setNamedColor( params );
                        FillCol = "FromDia"+fill.name();
                        ScColor tmp;
                        tmp.fromQColor(fill);
                        tmp.setSpotColor(false);
                        tmp.setRegistrationColor(false);
                        QString fNam = m_Doc->PageColors.tryAddColor(FillCol, tmp);
                        if (fNam == FillCol)
                            importedColors.append(FillCol);
                        FillCol = fNam;
                    }
                }
            }
            else if (command == "stroke")
            {
                if (!((params == "foreground") || (params == "background") || (params == "fg") || (params == "bg") || (params == "none") || (params == "default")) || (params == "inverse"))
                {
                    stroke.setNamedColor( params );
                    StrokeCol = "FromDia"+stroke.name();
                    ScColor tmp;
                    tmp.fromQColor(stroke);
                    tmp.setSpotColor(false);
                    tmp.setRegistrationColor(false);
                    QString fNam = m_Doc->PageColors.tryAddColor(StrokeCol, tmp);
                    if (fNam == StrokeCol)
                        importedColors.append(StrokeCol);
                    StrokeCol = fNam;
                }
            }
            else if (command == "stroke-width")
                strokewidth = ScCLocale::toDoubleC(params);
            else if( command == "stroke-linejoin" )
            {
                if( params == "miter" )
                    LineJoin = Qt::MiterJoin;
                else if( params == "round" )
                    LineJoin = Qt::RoundJoin;
                else if( params == "bevel" )
                    LineJoin = Qt::BevelJoin;
            }
            else if( command == "stroke-linecap" )
            {
                if( params == "butt" )
                    LineEnd = Qt::FlatCap;
                else if( params == "round" )
                    LineEnd = Qt::RoundCap;
                else if( params == "square" )
                    LineEnd = Qt::SquareCap;
            }
        }
        if (STag == "svg:line")
        {
//.........这里部分代码省略.........
开发者ID:gyuris,项目名称:scribus,代码行数:101,代码来源:importshape.cpp


注:本文中的QColor::name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。