Screen classification thresholds and utilities. More...
Functions | |
| AspectRatioClass | classify (qreal aspectRatio) |
| AspectRatioClass | classify (int width, int height) |
| QString | toString (AspectRatioClass cls) |
| AspectRatioClass | fromString (const QString &str) |
| AspectRatioClass | fromJsonValue (const QJsonValue &value) |
| Read a classification from either serialized JSON form. | |
| qreal | aspectRatioForClass (AspectRatioClass cls, qreal fallback=16.0/9.0) |
| Representative aspect ratio for a class. | |
| bool | matches (AspectRatioClass layoutClass, AspectRatioClass screenClass) |
| Check if a layout's aspect ratio class matches the given screen class. | |
Variables | |
| constexpr qreal | PortraitMax = 1.0 |
| AR < 1.0 → portrait. | |
| constexpr qreal | UltrawideMin = 1.9 |
| AR ∈ [UltrawideMin, SuperUltrawideMin) → ultrawide. | |
| constexpr qreal | SuperUltrawideMin = 2.8 |
| AR >= 2.8 → super-ultrawide. | |
Screen classification thresholds and utilities.
Free helpers separated from the enum so consumers can pull just the enum without dragging the threshold constants into namespace pollution.
|
inline |
Representative aspect ratio for a class.
| cls | The aspect ratio class. |
| fallback | Value to return for AspectRatioClass::Any (default 16:9). |
|
inline |
|
inline |
|
inline |
Read a classification from either serialized JSON form.
Both forms are on the wire: Layout::toJson emits the canonical string ("ultrawide"), while editor save round-trips carry the raw int, so a reader that accepts only one form resets the other to Any on a get→modify→update cycle.
Anything else — a missing key (Undefined), null, a wrong-typed value, an unknown string, or an int outside the enum range — reads as Any, so callers need no contains() pre-check.
|
inline |
|
inline |
Check if a layout's aspect ratio class matches the given screen class.
A layout with AspectRatioClass::Any matches every screen. Otherwise, exact match is required unless the layout specifies explicit min/max aspect ratio bounds (which take precedence at the layout consumer's level — this helper just does the class match).
|
inline |
|
constexpr |
AR < 1.0 → portrait.
|
constexpr |
AR >= 2.8 → super-ultrawide.
|
constexpr |
AR ∈ [UltrawideMin, SuperUltrawideMin) → ultrawide.