Skip to content

Commit f89fd11

Browse files
committed
fix:(lock): add portrait layout support for vertical monitors
1 parent a16c957 commit f89fd11

3 files changed

Lines changed: 108 additions & 28 deletions

File tree

modules/lock/Center.qml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ ColumnLayout {
99
id: root
1010

1111
required property var lock
12-
readonly property real centerScale: Math.min(1, (lock.screen?.height ?? 1440) / 1440)
12+
required property bool isPortrait
13+
required property real lockHeight
14+
readonly property real centerScale: isPortrait ? Math.min(1, lockHeight / 1440) : Math.min(1, (lock.screen?.height ?? 1440) / 1440)
1315
readonly property int centerWidth: Tokens.sizes.lock.centerWidth * centerScale
1416

1517
Layout.preferredWidth: centerWidth

modules/lock/Content.qml

Lines changed: 91 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,62 @@ import Caelestia.Config
44
import qs.components
55
import qs.services
66

7-
RowLayout {
7+
Item {
88
id: root
99

1010
required property var lock
11+
required property bool isPortrait
12+
required property real lockHeight
1113

12-
spacing: Tokens.spacing.largeIncreased * 2
13-
14+
// Portrait layout
1415
ColumnLayout {
15-
Layout.fillWidth: true
16+
anchors.fill: parent
17+
visible: root.isPortrait
1618
spacing: Tokens.spacing.medium
1719

18-
WeatherInfo {
20+
RowLayout {
1921
Layout.fillWidth: true
20-
rootHeight: root.height
22+
spacing: Tokens.spacing.largeIncreased * 2
23+
24+
WeatherInfo {
25+
Layout.fillWidth: true
26+
rootHeight: root.height / Tokens.sizes.lock.ratio
27+
}
28+
29+
Resources {
30+
Layout.fillWidth: true
31+
}
2132
}
2233

23-
Fetch {
34+
Center {
35+
Layout.alignment: Qt.AlignHCenter
36+
lock: root.lock
37+
isPortrait: root.isPortrait
38+
lockHeight: root.lockHeight
39+
}
40+
41+
RowLayout {
2442
Layout.fillWidth: true
25-
rootHeight: root.height
43+
44+
spacing: Tokens.spacing.largeIncreased * 2
45+
46+
Fetch {
47+
Layout.fillWidth: true
48+
rootHeight: root.height
49+
}
50+
51+
StyledRect {
52+
Layout.fillWidth: true
53+
Layout.fillHeight: true
54+
55+
bottomRightRadius: Tokens.rounding.extraLarge
56+
radius: Tokens.rounding.medium
57+
color: Colours.tPalette.m3surfaceContainer
58+
59+
NotifDock {
60+
lock: root.lock
61+
}
62+
}
2663
}
2764

2865
Media {
@@ -32,28 +69,59 @@ RowLayout {
3269
}
3370
}
3471

35-
Center {
36-
lock: root.lock
37-
}
72+
// Landscape layout
73+
RowLayout {
74+
anchors.fill: parent
75+
visible: !root.isPortrait
76+
spacing: Tokens.spacing.largeIncreased * 2
3877

39-
ColumnLayout {
40-
Layout.fillWidth: true
41-
spacing: Tokens.spacing.medium
42-
43-
Resources {
78+
ColumnLayout {
4479
Layout.fillWidth: true
80+
spacing: Tokens.spacing.medium
81+
82+
WeatherInfo {
83+
Layout.fillWidth: true
84+
rootHeight: root.height
85+
}
86+
87+
Fetch {
88+
Layout.fillWidth: true
89+
rootHeight: root.height
90+
}
91+
92+
Media {
93+
Layout.fillWidth: true
94+
Layout.fillHeight: true
95+
96+
lock: root.lock
97+
}
4598
}
4699

47-
StyledRect {
100+
Center {
101+
lock: root.lock
102+
isPortrait: root.isPortrait
103+
lockHeight: root.lockHeight
104+
}
105+
106+
ColumnLayout {
48107
Layout.fillWidth: true
49-
Layout.fillHeight: true
108+
spacing: Tokens.spacing.medium
50109

51-
bottomRightRadius: Tokens.rounding.extraLarge
52-
radius: Tokens.rounding.medium
53-
color: Colours.tPalette.m3surfaceContainer
110+
Resources {
111+
Layout.fillWidth: true
112+
}
54113

55-
NotifDock {
56-
lock: root.lock
114+
StyledRect {
115+
Layout.fillWidth: true
116+
Layout.fillHeight: true
117+
118+
bottomRightRadius: Tokens.rounding.extraLarge
119+
radius: Tokens.rounding.medium
120+
color: Colours.tPalette.m3surfaceContainer
121+
122+
NotifDock {
123+
lock: root.lock
124+
}
57125
}
58126
}
59127
}

modules/lock/LockSurface.qml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ WlSessionLockSurface {
1414
required property Pam pam
1515

1616
readonly property alias unlocking: unlockAnim.running
17+
readonly property real lockHeight: Math.min(root.screen?.width ?? 0, root.screen?.height ?? 0)
18+
19+
readonly property bool isPortrait: {
20+
const monitor = Hypr.monitors.values.find(m => m.name === root.screen?.name);
21+
const transform = monitor?.lastIpcObject?.transform ?? 0;
22+
return transform === 1 || transform === 3 || transform === 5 || transform === 7;
23+
}
1724

1825
contentItem.Config.screen: screen.name
1926
contentItem.Tokens.screen: screen.name
@@ -143,12 +150,12 @@ WlSessionLockSurface {
143150
Anim {
144151
target: lockContent
145152
property: "implicitWidth"
146-
to: (root.screen?.height ?? 0) * lockContent.Tokens.sizes.lock.heightMult * lockContent.Tokens.sizes.lock.ratio
153+
to: root.isPortrait ? root.lockHeight * lockContent.Tokens.sizes.lock.heightMult : root.lockHeight * lockContent.Tokens.sizes.lock.heightMult * lockContent.Tokens.sizes.lock.ratio
147154
}
148155
Anim {
149156
target: lockContent
150157
property: "implicitHeight"
151-
to: (root.screen?.height ?? 0) * lockContent.Tokens.sizes.lock.heightMult
158+
to: root.isPortrait ? root.lockHeight * lockContent.Tokens.sizes.lock.heightMult * lockContent.Tokens.sizes.lock.ratio : root.lockHeight * lockContent.Tokens.sizes.lock.heightMult
152159
}
153160
}
154161
}
@@ -212,9 +219,12 @@ WlSessionLockSurface {
212219
Content {
213220
id: content
214221

222+
isPortrait: root.isPortrait
223+
lockHeight: root.lockHeight
224+
215225
anchors.centerIn: parent
216-
width: (root.screen?.height ?? 0) * Tokens.sizes.lock.heightMult * Tokens.sizes.lock.ratio - Tokens.padding.extraLargeIncreased
217-
height: (root.screen?.height ?? 0) * Tokens.sizes.lock.heightMult - Tokens.padding.extraLargeIncreased
226+
width: root.isPortrait ? root.lockHeight * Tokens.sizes.lock.heightMult - Tokens.padding.extraLargeIncreased : root.lockHeight * Tokens.sizes.lock.heightMult * Tokens.sizes.lock.ratio - Tokens.padding.extraLargeIncreased
227+
height: root.isPortrait ? root.lockHeight * Tokens.sizes.lock.heightMult * Tokens.sizes.lock.ratio - Tokens.padding.extraLargeIncreased : root.lockHeight * Tokens.sizes.lock.heightMult - Tokens.padding.extraLargeIncreased
218228

219229
lock: root
220230
opacity: 0

0 commit comments

Comments
 (0)