|
29 | 29 | import javafx.scene.Cursor; |
30 | 30 | import javafx.scene.Group; |
31 | 31 | import javafx.scene.control.Label; |
32 | | -import javafx.scene.layout.FlowPane; |
33 | | -import javafx.scene.layout.StackPane; |
34 | | -import javafx.scene.layout.VBox; |
| 32 | +import javafx.scene.layout.*; |
35 | 33 | import javafx.scene.shape.SVGPath; |
36 | 34 | import org.jackhuang.hmcl.auth.Account; |
37 | 35 | import org.jackhuang.hmcl.auth.AuthInfo; |
@@ -141,20 +139,22 @@ private void onStep(Step currentStep) { |
141 | 139 | setBody(rootContainer); |
142 | 140 | rootContainer.setAlignment(Pos.TOP_CENTER); |
143 | 141 |
|
144 | | - if (Accounts.OAUTH_CALLBACK.getClientId().isEmpty()) { |
145 | | - var snapshotHint = new HintPane(MessageDialogPane.MessageType.WARNING); |
| 142 | + StackPane warningPane = new StackPane(); |
| 143 | + |
| 144 | + if (!IntegrityChecker.isOfficial()) { |
| 145 | + var unofficialHintPane = new HintPane(MessageDialogPane.MessageType.WARNING); |
| 146 | + unofficialHintPane.setSegment(i18n("unofficial.hint")); |
| 147 | + warningPane.getChildren().add(unofficialHintPane); |
| 148 | + } else if (Accounts.OAUTH_CALLBACK.getClientId().isEmpty()) { |
| 149 | + HintPane snapshotHint = new HintPane(MessageDialogPane.MessageType.WARNING); |
146 | 150 | snapshotHint.setSegment(i18n("account.methods.microsoft.snapshot")); |
147 | | - rootContainer.getChildren().add(snapshotHint); |
| 151 | + warningPane.getChildren().add(snapshotHint); |
148 | 152 | btnLogin.setDisable(true); |
149 | 153 | loginButtonSpinner.setLoading(false); |
150 | 154 | return; |
151 | 155 | } |
152 | 156 |
|
153 | | - if (!IntegrityChecker.isOfficial()) { |
154 | | - var unofficialHintPane = new HintPane(MessageDialogPane.MessageType.WARNING); |
155 | | - unofficialHintPane.setSegment(i18n("unofficial.hint")); |
156 | | - rootContainer.getChildren().add(unofficialHintPane); |
157 | | - } |
| 157 | + rootContainer.getChildren().add(warningPane); |
158 | 158 |
|
159 | 159 | if (currentStep instanceof Step.Init) { |
160 | 160 | btnLogin.setOnAction(e -> this.step.set(new Step.StartAuthorizationCodeLogin())); |
@@ -198,6 +198,20 @@ private void onStep(Step currentStep) { |
198 | 198 | } else if (currentStep instanceof Step.WaitForScanQrCode wait) { |
199 | 199 | loginButtonSpinner.setLoading(true); |
200 | 200 |
|
| 201 | + VBox leftVBox = new VBox(6); |
| 202 | + leftVBox.setAlignment(Pos.CENTER); |
| 203 | + VBox rightVBox = new VBox(6); |
| 204 | + |
| 205 | + HBox hbox = new HBox(leftVBox, rightVBox); |
| 206 | + |
| 207 | + leftVBox.prefWidthProperty().bind(hbox.widthProperty().divide(2)); |
| 208 | + rightVBox.prefWidthProperty().bind(hbox.widthProperty().divide(2)); |
| 209 | + leftVBox.setMaxWidth(Double.MAX_VALUE); |
| 210 | + rightVBox.setMaxWidth(Double.MAX_VALUE); |
| 211 | + |
| 212 | + HBox.setHgrow(leftVBox, Priority.ALWAYS); |
| 213 | + HBox.setHgrow(rightVBox, Priority.ALWAYS); |
| 214 | + |
201 | 215 | String scanUri = "https://www.microsoft.com/link".equals(wait.verificationUri()) |
202 | 216 | ? "https://www.microsoft.com/link?otc=" + wait.userCode() |
203 | 217 | : wait.verificationUri(); |
@@ -225,7 +239,10 @@ private void onStep(Step currentStep) { |
225 | 239 | FXUtils.onClicked(codeBox, () -> FXUtils.copyText(wait.userCode())); |
226 | 240 | codeBox.setMaxWidth(USE_PREF_SIZE); |
227 | 241 |
|
228 | | - rootContainer.getChildren().addAll(deviceHint, new Group(qrCode), codeBox); |
| 242 | + leftVBox.getChildren().setAll(new Group(qrCode), codeBox); |
| 243 | + rightVBox.getChildren().setAll(warningPane, deviceHint); |
| 244 | + |
| 245 | + rootContainer.getChildren().setAll(hbox); |
229 | 246 | } else if (currentStep instanceof Step.DeviceLoginCompleted) { |
230 | 247 | loginButtonSpinner.setLoading(true); |
231 | 248 |
|
|
0 commit comments