Union::Properties::FontPropertyGroup Class

class Union::Properties::FontPropertyGroup

A group containing properties relating to the font used for an element. More...

Header: #include <FontPropertyGroup.h>
CMake: find_package(Union REQUIRED)
target_link_libraries(mytarget PRIVATE Union::Union)

Public Functions

FontPropertyGroup()
FontPropertyGroup(const Union::Properties::FontPropertyGroup &other)
FontPropertyGroup(Union::Properties::FontPropertyGroup &&other)
std::optional<QFont::Capitalization> capitalization() const
std::optional<Union::Properties::TextDecorations> decorations() const
std::optional<QString> family() const
bool hasAnyValue() const
bool isEmpty() const
std::optional<qreal> letterSpacing() const
T safePropertyLookup(const T &defaultValue, LookupFunctions... functions) const
void setCapitalization(const std::optional<QFont::Capitalization> &newValue)
void setDecorations(const std::optional<Union::Properties::TextDecorations> &newValue)
void setFamily(const std::optional<QString> &newValue)
void setLetterSpacing(const std::optional<qreal> &newValue)
void setSize(const std::optional<qreal> &newValue)
void setStretch(const std::optional<int> &newValue)
void setStyle(const std::optional<QFont::Style> &newValue)
void setWeight(const std::optional<QFont::Weight> &newValue)
void setWordSpacing(const std::optional<qreal> &newValue)
std::optional<qreal> size() const
std::optional<int> stretch() const
std::optional<QFont::Style> style() const
QFont toQFont() const
QString toString(int indentation = 0, Union::Properties::ToStringFlags flags = ToStringFlags{}) const
std::optional<QFont::Weight> weight() const
std::optional<qreal> wordSpacing() const
Union::Properties::FontPropertyGroup &operator=(Union::Properties::FontPropertyGroup &&other)
Union::Properties::FontPropertyGroup &operator=(const Union::Properties::FontPropertyGroup &other)

Static Public Members

std::unique_ptr<Union::Properties::FontPropertyGroup> empty()
void resolveProperties(const Union::Properties::FontPropertyGroup *source, Union::Properties::FontPropertyGroup *destination)
QDebug operator<<(QDebug debug, Union::Properties::FontPropertyGroup *type)
bool operator==(const Union::Properties::FontPropertyGroup &left, const Union::Properties::FontPropertyGroup &right)

Detailed Description

Member Function Documentation

FontPropertyGroup::FontPropertyGroup()

Default constructor. Constructs a null instance.

A null instance in this case means an instance that does not have any values for its properties. This includes property groups.

FontPropertyGroup::FontPropertyGroup(const Union::Properties::FontPropertyGroup &other)

Copy constructor.

FontPropertyGroup::FontPropertyGroup(Union::Properties::FontPropertyGroup &&other)

Move constructor.

std::optional<QFont::Capitalization> FontPropertyGroup::capitalization() const

The capitalization style of the font used for an element.

See also setCapitalization().

std::optional<Union::Properties::TextDecorations> FontPropertyGroup::decorations() const

The decorations enabled for the font used for an element.

See also setDecorations().

[static] std::unique_ptr<Union::Properties::FontPropertyGroup> FontPropertyGroup::empty()

Create and return an empty FontPropertyGroup instance.

This will create an empty FontPropertyGroup instance, which is defined as an instance with all of its values default-constructed. Note that this is different from a default-constructed instance which will have all its values unset.

std::optional<QString> FontPropertyGroup::family() const

The name of the font family used for an element.

See also setFamily().

bool FontPropertyGroup::hasAnyValue() const

Returns if this property group has any value set.

Note that for any property that is also a property group, this will also check if that group has any value.

bool FontPropertyGroup::isEmpty() const

Returns if this property is considered empty.

A property is considered empty if it has no values or if the values it contains are all considered empty values.

std::optional<qreal> FontPropertyGroup::letterSpacing() const

The spacing between individual letters of the font used for an element.

See also setLetterSpacing().

[static] void FontPropertyGroup::resolveProperties(const Union::Properties::FontPropertyGroup *source, Union::Properties::FontPropertyGroup *destination)

Copy property values from source to destination if destination does not have a property value.

This will recursively copy property values of grouped properties.

source The source property group to copy from. destination The destination property group to copy to.

template <typename T, typename... LookupFunctions> requires (std::is_member_function_pointer_v<LookupFunctions> && ...) T FontPropertyGroup::safePropertyLookup(const T &defaultValue, LookupFunctions... functions) const

Perform safe property lookup of a property or the property of a subgroup.

This should be called with a list of property getter pointer-to-member functions in functions that indicate which properties to access. Each subgroup access will be checked to make sure the subgroup exists. If any of them does not exist, defaultValue will be returned. The final property lookup can be any member function of the final group. If that returns a pointer or std::optional<>, it is checked to see if it has a value. If it does, that value is returned. If not, defaultValue is returned. For functions returning anything else, the value returned by the function is returned.

Example usage:

// Lookup the value of the property "spacing" of the "layout" group.
auto spacing = StylePropertyGroup->safePropertyLookup(0.0, &StylePropertyGroup::layout, &LayoutPropertyGroup::spacing);

void FontPropertyGroup::setCapitalization(const std::optional<QFont::Capitalization> &newValue)

Set the value of capitalization.

newValue The new value or std::nullopt to unset the value.

See also capitalization().

void FontPropertyGroup::setDecorations(const std::optional<Union::Properties::TextDecorations> &newValue)

Set the value of decorations.

newValue The new value or std::nullopt to unset the value.

See also decorations().

void FontPropertyGroup::setFamily(const std::optional<QString> &newValue)

Set the value of family.

newValue The new value or std::nullopt to unset the value.

See also family().

void FontPropertyGroup::setLetterSpacing(const std::optional<qreal> &newValue)

Set the value of letterSpacing.

newValue The new value or std::nullopt to unset the value.

See also letterSpacing().

void FontPropertyGroup::setSize(const std::optional<qreal> &newValue)

Set the value of size.

newValue The new value or std::nullopt to unset the value.

See also size().

void FontPropertyGroup::setStretch(const std::optional<int> &newValue)

Set the value of stretch.

newValue The new value or std::nullopt to unset the value.

See also stretch().

void FontPropertyGroup::setStyle(const std::optional<QFont::Style> &newValue)

Set the value of style.

newValue The new value or std::nullopt to unset the value.

See also style().

void FontPropertyGroup::setWeight(const std::optional<QFont::Weight> &newValue)

Set the value of weight.

newValue The new value or std::nullopt to unset the value.

See also weight().

void FontPropertyGroup::setWordSpacing(const std::optional<qreal> &newValue)

Set the value of wordSpacing.

newValue The new value or std::nullopt to unset the value.

See also wordSpacing().

std::optional<qreal> FontPropertyGroup::size() const

The size of the font used for an element.

See also setSize().

std::optional<int> FontPropertyGroup::stretch() const

The amount the font used for an element is stretched.

See also setStretch().

std::optional<QFont::Style> FontPropertyGroup::style() const

The style of the font used for an element.

See also setStyle().

QFont FontPropertyGroup::toQFont() const

Returns a QFont representing the font.

QString FontPropertyGroup::toString(int indentation = 0, Union::Properties::ToStringFlags flags = ToStringFlags{}) const

Returns a string representation of this property group.

This is intended for debugging.

indentation The amount of indentation to apply. Defaults to 0. flags A set of flags that control conversion behavior.

std::optional<QFont::Weight> FontPropertyGroup::weight() const

The weight of the font used for an element.

See also setWeight().

std::optional<qreal> FontPropertyGroup::wordSpacing() const

The spacing between words of the font used for an element.

See also setWordSpacing().

Union::Properties::FontPropertyGroup &FontPropertyGroup::operator=(Union::Properties::FontPropertyGroup &&other)

Move assignment operator.

Union::Properties::FontPropertyGroup &FontPropertyGroup::operator=(const Union::Properties::FontPropertyGroup &other)

Copy assignment operator.

Related Non-Members

QDebug operator<<(QDebug debug, Union::Properties::FontPropertyGroup *type)

QDebug support for FontPropertyGroup.

bool operator==(const Union::Properties::FontPropertyGroup &left, const Union::Properties::FontPropertyGroup &right)

Equality comparison for FontPropertyGroup.