Пример #1
0
void FontDescription::setTraits(FontTraits traits)
{
    setStyle(traits.style());
    setVariant(traits.variant());
    setWeight(traits.weight());
    setStretch(traits.stretch());
}
void BuildInfoJSON::fromJSONVariant(JSONValue *json_value, bool ignore_extras)
  {
    assert(json_value != NULL);
    const JSONStringValue *json_string = json_value->string_value();
    if (json_string == NULL)
        throw("The value for field Variant of BuildInfoJSON is not a string.");
    setVariant(std::string(json_string->getData()));
  }
Пример #3
0
bool SimpleMessageStyle::changeOptions(QWidget *AWidget, const IMessageStyleOptions &AOptions, bool AClear)
{
	StyleViewer *view = qobject_cast<StyleViewer *>(AWidget);
	if (view && AOptions.styleId==styleId())
	{
		bool isNewView = !FWidgetStatus.contains(view);
		if (AClear || isNewView)
		{
			WidgetStatus &wstatus = FWidgetStatus[view];
			wstatus.lastKind = -1;
			wstatus.lastId = QString::null;
			wstatus.lastTime = QDateTime();
			wstatus.scrollStarted = false;
			wstatus.content.clear();

			if (isNewView)
			{
				view->installEventFilter(this);
				connect(view,SIGNAL(anchorClicked(const QUrl &)),SLOT(onStyleWidgetLinkClicked(const QUrl &)));
				connect(view,SIGNAL(destroyed(QObject *)),SLOT(onStyleWidgetDestroyed(QObject *)));
				emit widgetAdded(view);
			}

			QString html = makeStyleTemplate();
			fillStyleKeywords(html,AOptions);
			view->setHtml(html);

			QTextCursor cursor(view->document());
			cursor.movePosition(QTextCursor::End);
			wstatus.contentStartPosition = cursor.position();
		}
		else
		{
			FWidgetStatus[view].lastKind = -1;
		}

		setVariant(view, AOptions.extended.value(MSO_VARIANT).toString());

		QFont font;
		int fontSize = AOptions.extended.value(MSO_FONT_SIZE).toInt();
		QString fontFamily = AOptions.extended.value(MSO_FONT_FAMILY).toString();
		if (fontSize>0)
			font.setPointSize(fontSize);
		if (!fontFamily.isEmpty())
			font.setFamily(fontFamily);
		view->document()->setDefaultFont(font);

		emit optionsChanged(view,AOptions,AClear);
		return true;
	}
	else if (view == NULL)
	{
		REPORT_ERROR("Failed to change simple style options: Invalid style view");
	}
	return false;
}
Пример #4
0
PgnStream::PgnStream(const QString& variant)
	: m_board(0),
	  m_pos(0),
	  m_lineNumber(1),
	  m_tokenType(NoToken),
	  m_device(0),
	  m_string(0),
	  m_status(Ok),
	  m_phase(OutOfGame)
{
	setVariant(variant);
}
Пример #5
0
bool Text::setProperty(P_ID propertyId, const QVariant& v)
      {
      score()->addRefresh(canvasBoundingRect());
      Property<Text>* p = property(propertyId);
      bool rv = true;
      if (p) {
            setVariant(propertyId, ((*this).*(p->data))(), v);
            setGenerated(false);
            }
      else
            rv = Element::setProperty(propertyId, v);
      score()->setLayoutAll(true);
      return rv;
      }
Пример #6
0
ExceptionOr<Ref<FontFace>> FontFace::create(JSC::ExecState& state, Document& document, const String& family, JSC::JSValue source, const Descriptors& descriptors)
{
    auto result = adoptRef(*new FontFace(document.fontSelector()));

    bool dataRequiresAsynchronousLoading = true;

    auto setFamilyResult = result->setFamily(family);
    if (setFamilyResult.hasException())
        return setFamilyResult.releaseException();

    if (source.isString()) {
        auto value = FontFace::parseString(source.getString(&state), CSSPropertySrc);
        if (!is<CSSValueList>(value.get()))
            return Exception { SYNTAX_ERR };
        CSSFontFace::appendSources(result->backing(), downcast<CSSValueList>(*value), &document, false);
    } else if (auto arrayBufferView = toUnsharedArrayBufferView(source))
        dataRequiresAsynchronousLoading = populateFontFaceWithArrayBuffer(result->backing(), arrayBufferView.releaseNonNull());
    else if (auto arrayBuffer = toUnsharedArrayBuffer(source)) {
        auto arrayBufferView = JSC::Uint8Array::create(arrayBuffer, 0, arrayBuffer->byteLength());
        dataRequiresAsynchronousLoading = populateFontFaceWithArrayBuffer(result->backing(), arrayBufferView.releaseNonNull());
    }

    // These ternaries match the default strings inside the FontFaceDescriptors dictionary inside FontFace.idl.
    auto setStyleResult = result->setStyle(descriptors.style.isEmpty() ? ASCIILiteral("normal") : descriptors.style);
    if (setStyleResult.hasException())
        return setStyleResult.releaseException();
    auto setWeightResult = result->setWeight(descriptors.weight.isEmpty() ? ASCIILiteral("normal") : descriptors.weight);
    if (setWeightResult.hasException())
        return setWeightResult.releaseException();
    auto setStretchResult = result->setStretch(descriptors.stretch.isEmpty() ? ASCIILiteral("normal") : descriptors.stretch);
    if (setStretchResult.hasException())
        return setStretchResult.releaseException();
    auto setUnicodeRangeResult = result->setUnicodeRange(descriptors.unicodeRange.isEmpty() ? ASCIILiteral("U+0-10FFFF") : descriptors.unicodeRange);
    if (setUnicodeRangeResult.hasException())
        return setUnicodeRangeResult.releaseException();
    auto setVariantResult = result->setVariant(descriptors.variant.isEmpty() ? ASCIILiteral("normal") : descriptors.variant);
    if (setVariantResult.hasException())
        return setVariantResult.releaseException();
    auto setFeatureSettingsResult = result->setFeatureSettings(descriptors.featureSettings.isEmpty() ? ASCIILiteral("normal") : descriptors.featureSettings);
    if (setFeatureSettingsResult.hasException())
        return setFeatureSettingsResult.releaseException();

    if (!dataRequiresAsynchronousLoading) {
        result->backing().load();
        ASSERT(result->backing().status() == CSSFontFace::Status::Success);
    }

    return WTFMove(result);
}
Пример #7
0
bool Box::setProperty(const QString& name, const QDomElement& e)
{
    for (int i = 0;; ++i) {
        P_ID id = propertyList[i].id;
        if (id == P_END)
            break;
        if (propertyName(id) == name) {
            QVariant v = ::getProperty(id, e);
            setVariant(id, ((*this).*(propertyList[i].data))(), v);
            setGenerated(false);
            return true;
        }
    }
    return Element::setProperty(name, e);
}
Пример #8
0
PgnStream::PgnStream(const QByteArray* string, const QString& variant)
	: m_board(0)
{
	setVariant(variant);
	setString(string);
}
Пример #9
0
PgnStream::PgnStream(QIODevice* device, const QString& variant)
	: m_board(0)
{
	setVariant(variant);
	setDevice(device);
}