9#include <phosphorzones_export.h>
52 return zoneNumber > 0;
73class PHOSPHORZONES_EXPORT
Layout :
public QObject
77 Q_PROPERTY(QUuid
id READ
id CONSTANT)
78 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
79 Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged)
80 Q_PROPERTY(
int zonePadding READ zonePadding WRITE setZonePadding NOTIFY zonePaddingChanged)
81 Q_PROPERTY(
int outerGap READ outerGap WRITE setOuterGap NOTIFY outerGapChanged)
82 Q_PROPERTY(
bool hasZonePaddingOverride READ hasZonePaddingOverride NOTIFY zonePaddingChanged)
83 Q_PROPERTY(
bool hasOuterGapOverride READ hasOuterGapOverride NOTIFY outerGapChanged)
84 Q_PROPERTY(
bool usePerSideOuterGap READ usePerSideOuterGap WRITE setUsePerSideOuterGap NOTIFY outerGapChanged)
85 Q_PROPERTY(
int outerGapTop READ outerGapTop WRITE setOuterGapTop NOTIFY outerGapChanged)
86 Q_PROPERTY(
int outerGapBottom READ outerGapBottom WRITE setOuterGapBottom NOTIFY outerGapChanged)
87 Q_PROPERTY(
int outerGapLeft READ outerGapLeft WRITE setOuterGapLeft NOTIFY outerGapChanged)
88 Q_PROPERTY(
int outerGapRight READ outerGapRight WRITE setOuterGapRight NOTIFY outerGapChanged)
89 Q_PROPERTY(
bool hasPerSideOuterGapOverride READ hasPerSideOuterGapOverride NOTIFY outerGapChanged)
90 Q_PROPERTY(
bool showZoneNumbers READ showZoneNumbers WRITE setShowZoneNumbers NOTIFY showZoneNumbersChanged)
92 int overlayDisplayMode READ overlayDisplayMode WRITE setOverlayDisplayMode NOTIFY overlayDisplayModeChanged)
93 Q_PROPERTY(
bool hasOverlayDisplayModeOverride READ hasOverlayDisplayModeOverride NOTIFY overlayDisplayModeChanged)
94 Q_PROPERTY(
int zoneCount READ zoneCount NOTIFY zonesChanged)
95 Q_PROPERTY(QString sourcePath READ sourcePath WRITE setSourcePath NOTIFY sourcePathChanged)
96 Q_PROPERTY(
bool isSystemLayout READ isSystemLayout NOTIFY sourcePathChanged)
97 Q_PROPERTY(QString shaderId READ shaderId WRITE setShaderId NOTIFY shaderIdChanged)
98 Q_PROPERTY(QVariantMap shaderParams READ shaderParams WRITE setShaderParams NOTIFY shaderParamsChanged)
101 Q_PROPERTY(QVariantList appRules READ appRulesVariant WRITE setAppRulesVariant NOTIFY appRulesChanged)
104 Q_PROPERTY(
bool autoAssign READ autoAssign WRITE setAutoAssign NOTIFY autoAssignChanged)
107 Q_PROPERTY(
bool useFullScreenGeometry READ useFullScreenGeometry WRITE setUseFullScreenGeometry NOTIFY
108 useFullScreenGeometryChanged)
112 int aspectRatioClass READ aspectRatioClassInt WRITE setAspectRatioClassInt NOTIFY aspectRatioClassChanged)
113 Q_PROPERTY(qreal minAspectRatio READ minAspectRatio WRITE setMinAspectRatio NOTIFY aspectRatioClassChanged)
114 Q_PROPERTY(qreal maxAspectRatio READ maxAspectRatio WRITE setMaxAspectRatio NOTIFY aspectRatioClassChanged)
118 bool hiddenFromSelector READ hiddenFromSelector WRITE setHiddenFromSelector NOTIFY hiddenFromSelectorChanged)
119 Q_PROPERTY(QStringList allowedScreens READ allowedScreens WRITE setAllowedScreens NOTIFY allowedScreensChanged)
120 Q_PROPERTY(QList<int> allowedDesktops READ allowedDesktops WRITE setAllowedDesktops NOTIFY allowedDesktopsChanged)
122 QStringList allowedActivities READ allowedActivities WRITE setAllowedActivities NOTIFY allowedActivitiesChanged)
125 explicit Layout(QObject* parent =
nullptr);
126 explicit Layout(
const QString& name, QObject* parent =
nullptr);
145 return m_description;
152 return m_zonePadding;
157 return m_zonePadding >= 0;
168 return m_outerGap >= 0;
175 return m_usePerSideOuterGap;
180 return m_outerGapTop;
185 return m_outerGapBottom;
190 return m_outerGapLeft;
195 return m_outerGapRight;
200 return m_usePerSideOuterGap
201 && (m_outerGapTop >= 0 || m_outerGapBottom >= 0 || m_outerGapLeft >= 0 || m_outerGapRight >= 0);
210 return {m_outerGapTop, m_outerGapBottom, m_outerGapLeft, m_outerGapRight};
215 return m_showZoneNumbers;
221 return m_overlayDisplayMode;
226 return m_overlayDisplayMode >= 0;
245 return m_systemSourcePath;
249 m_systemSourcePath = path;
253 return !m_systemSourcePath.isEmpty();
264 return m_shaderParams;
271 return m_aspectRatioClass;
276 return static_cast<int>(m_aspectRatioClass);
281 return m_minAspectRatio;
286 return m_maxAspectRatio;
300 return m_hiddenFromSelector;
305 return m_allowedScreens;
310 return m_allowedDesktops;
315 return m_allowedActivities;
339 return m_useFullScreenGeometry;
362 return m_defaultOrder;
366 m_defaultOrder = order;
372 return m_zones.size();
386 Q_INVOKABLE
void moveZone(
int fromIndex,
int toIndex);
392 Q_INVOKABLE QVector<Zone*>
adjacentZones(
const QPointF& point, qreal threshold = 20)
const;
398 return m_lastRecalcGeometry;
402 m_lastRecalcGeometry = geom;
488 void emitModifiedIfNotBatched();
496 void initFromJson(
const QJsonObject& json);
500 QString m_description;
501 int m_zonePadding = -1;
503 bool m_usePerSideOuterGap =
false;
504 int m_outerGapTop = -1;
505 int m_outerGapBottom = -1;
506 int m_outerGapLeft = -1;
507 int m_outerGapRight = -1;
508 bool m_showZoneNumbers =
true;
509 int m_overlayDisplayMode = -1;
510 QString m_sourcePath;
511 QString m_systemSourcePath;
512 int m_defaultOrder = 999;
513 QVector<Zone*> m_zones;
516 QVector<AppRule> m_appRules;
519 bool m_autoAssign =
false;
522 bool m_useFullScreenGeometry =
false;
526 QVariantMap m_shaderParams;
530 qreal m_minAspectRatio = 0.0;
531 qreal m_maxAspectRatio = 0.0;
534 bool m_hiddenFromSelector =
false;
535 QStringList m_allowedScreens;
536 QList<int> m_allowedDesktops;
537 QStringList m_allowedActivities;
540 mutable QRectF m_lastRecalcGeometry;
545 bool m_isSystemLayout =
false;
548 bool m_dirty =
false;
549 int m_batchModifyDepth = 0;
Represents a collection of zones that form a layout.
Definition Layout.h:74
bool hasOuterGapOverride() const
Definition Layout.h:166
int overlayDisplayMode() const
Definition Layout.h:219
Zone * nearestZone(const QPointF &point, qreal maxDistance=-1) const
int zonePadding() const
Definition Layout.h:150
QList< int > allowedDesktops() const
Definition Layout.h:308
int outerGapLeft() const
Definition Layout.h:188
::PhosphorLayout::EdgeGaps rawOuterGaps() const
Raw per-side gap overrides.
Definition Layout.h:208
bool usePerSideOuterGap() const
Definition Layout.h:173
bool isSystemLayout() const
bool isDirty() const
Definition Layout.h:438
void moveZone(int fromIndex, int toIndex)
Zone * zoneById(const QUuid &id) const
void setAppRules(const QVector< AppRule > &rules)
void setSourcePath(const QString &path)
QVector< AppRule > appRules() const
Definition Layout.h:320
void setAllowedActivities(const QStringList &activities)
QString systemSourcePath() const
Definition Layout.h:243
int defaultOrder() const
Definition Layout.h:360
void setShaderId(const QString &id)
void zoneRemoved(Zone *zone)
static Layout * createPriorityGridLayout(QObject *parent=nullptr)
int outerGapTop() const
Definition Layout.h:178
void allowedScreensChanged()
void aspectRatioClassChanged()
void setDefaultOrder(int order)
Definition Layout.h:364
bool hasFixedGeometryZones() const
Returns true if any zone uses fixed (pixel) geometry mode.
Layout(const Layout &other)
void setAspectRatioClass(::PhosphorLayout::AspectRatioClass cls)
void setOuterGapTop(int gap)
void clearOuterGapOverride()
void shaderParamsChanged()
void setLastRecalcGeometry(const QRectF &geom)
Definition Layout.h:400
void setUseFullScreenGeometry(bool enabled)
void setHiddenFromSelector(bool hidden)
qreal maxAspectRatio() const
Definition Layout.h:284
QRectF fixedZoneBoundingBox() const
Bounding box of all fixed-geometry zones in pixel coordinates, anchored at (0, 0).
void markDirty()
Definition Layout.h:442
void overlayDisplayModeChanged()
QRectF fixedZoneReferenceGeometry() const
Reference geometry suitable for normalizing fixed-pixel zones to 0–1 relative coordinates.
void setOuterGap(int gap)
bool matchesAspectRatio(qreal screenAspectRatio) const
Check if this layout is suitable for a screen with the given aspect ratio.
void setUsePerSideOuterGap(bool enabled)
bool hasZonePaddingOverride() const
Definition Layout.h:155
Layout(const QString &name, QObject *parent=nullptr)
QVariantMap shaderParams() const
Definition Layout.h:262
void setAppRulesVariant(const QVariantList &rules)
void setZonePadding(int padding)
QString sourcePath() const
Definition Layout.h:231
void setAutoAssign(bool enabled)
QVector< Zone * > adjacentZones(const QPointF &point, qreal threshold=20) const
bool hasSystemOrigin() const
Definition Layout.h:251
static void setScreenIdResolver(ScreenIdResolver resolver)
int zoneCount() const
Definition Layout.h:370
void recalculateZoneGeometries(const QRectF &screenGeometry)
Recalculate every zone's absolute geometry against screenGeometry.
QJsonObject toJson() const
Zone * zoneByNumber(int number) const
void hiddenFromSelectorChanged()
bool hasPerSideOuterGapOverride() const
Definition Layout.h:198
bool hasOverlayDisplayModeOverride() const
Definition Layout.h:224
Zone * zone(int index) const
std::function< QString(const QString &)> ScreenIdResolver
Screen-id resolver.
Definition Layout.h:421
QStringList allowedActivities() const
Definition Layout.h:313
void setOverlayDisplayMode(int mode)
int outerGapRight() const
Definition Layout.h:193
int outerGap() const
Definition Layout.h:161
static Layout * createGridLayout(int columns, int rows, QObject *parent=nullptr)
QVector< Zone * > zonesInRect(const QRectF &rect) const
static Layout * createFocusLayout(QObject *parent=nullptr)
Layout(QObject *parent=nullptr)
bool useFullScreenGeometry() const
Definition Layout.h:337
void setDescription(const QString &description)
bool hiddenFromSelector() const
Definition Layout.h:298
::PhosphorLayout::AspectRatioClass aspectRatioClass() const
Definition Layout.h:269
void setMinAspectRatio(qreal ratio)
QRectF lastRecalcGeometry() const
Definition Layout.h:396
void setSystemSourcePath(const QString &path)
Definition Layout.h:247
Zone * zoneAtPoint(const QPointF &point) const
QStringList allowedScreens() const
Definition Layout.h:303
bool showZoneNumbers() const
Definition Layout.h:213
void setAspectRatioClassInt(int cls)
void allowedDesktopsChanged()
void removeZone(Zone *zone)
void showZoneNumbersChanged()
void setAllowedScreens(const QStringList &screens)
QVariantList appRulesVariant() const
QString shaderId() const
Definition Layout.h:257
static ScreenIdResolver screenIdResolver()
Returns a copy of the currently-installed resolver (empty if none).
AppRuleMatch matchAppRule(const QString &windowClass) const
void allowedActivitiesChanged()
void setName(const QString &name)
void setOuterGapRight(int gap)
void clearOverlayDisplayModeOverride()
void setOuterGapBottom(int gap)
void setOuterGapLeft(int gap)
void clearZonePaddingOverride()
void removeZoneAt(int index)
QString name() const
Definition Layout.h:137
QUuid id() const
Definition Layout.h:133
void setMaxAspectRatio(qreal ratio)
void zonePaddingChanged()
QString description() const
Definition Layout.h:143
Layout & operator=(const Layout &other)
qreal minAspectRatio() const
Definition Layout.h:279
void useFullScreenGeometryChanged()
void setAllowedDesktops(const QList< int > &desktops)
static Layout * fromJson(const QJsonObject &json, QObject *parent=nullptr)
static Layout * createRowsLayout(int rows, QObject *parent=nullptr)
QVector< Zone * > zones() const
Definition Layout.h:374
int outerGapBottom() const
Definition Layout.h:183
bool autoAssign() const
Definition Layout.h:330
void descriptionChanged()
void zoneAdded(Zone *zone)
void setShaderParams(const QVariantMap ¶ms)
void setShowZoneNumbers(bool show)
int aspectRatioClassInt() const
Definition Layout.h:274
static Layout * createColumnsLayout(int columns, QObject *parent=nullptr)
void clearDirty()
Definition Layout.h:446
Represents a single zone within a layout.
Definition Zone.h:44
AspectRatioClass
Screen aspect-ratio classification.
Definition AspectRatioClass.h:21
@ Any
Suitable for all aspect ratios (default)
Definition IWindowTrackingService.h:22
LayoutCategory
Category for layout type.
Definition Layout.h:61
@ Autotile
Dynamic auto-tiling algorithm.
@ Manual
Traditional zone-based layout.
Per-side edge gap values (resolved, non-negative pixel values)
Definition EdgeGaps.h:27
Result of matching a window class against app rules.
Definition Layout.h:47
QString targetScreen
Definition Layout.h:49
bool matched() const
Definition Layout.h:50
App-to-zone auto-snap rule.
Definition Layout.h:29
QJsonObject toJson() const
static AppRule fromJson(const QJsonObject &obj)
static QVector< AppRule > fromJsonArray(const QJsonArray &array)
bool operator==(const AppRule &other) const =default
QString pattern
Definition Layout.h:30
QString targetScreen
Definition Layout.h:32