|
19 | 19 |
|
20 | 20 | import com.jfoenix.controls.JFXPopup; |
21 | 21 | import javafx.beans.property.ReadOnlyObjectProperty; |
22 | | -import javafx.scene.control.Label; |
23 | 22 | import org.jackhuang.hmcl.Metadata; |
24 | | -import org.jackhuang.hmcl.auth.Account; |
25 | 23 | import org.jackhuang.hmcl.event.EventBus; |
26 | 24 | import org.jackhuang.hmcl.event.RefreshedVersionsEvent; |
27 | 25 | import org.jackhuang.hmcl.game.HMCLGameRepository; |
|
37 | 35 | import org.jackhuang.hmcl.ui.FXUtils; |
38 | 36 | import org.jackhuang.hmcl.ui.SVG; |
39 | 37 | import org.jackhuang.hmcl.ui.account.AccountAdvancedListItem; |
| 38 | +import org.jackhuang.hmcl.ui.account.AccountListPopupMenu; |
40 | 39 | import org.jackhuang.hmcl.ui.animation.AnimationUtils; |
41 | 40 | import org.jackhuang.hmcl.ui.construct.AdvancedListBox; |
42 | 41 | import org.jackhuang.hmcl.ui.construct.AdvancedListItem; |
43 | 42 | import org.jackhuang.hmcl.ui.construct.MessageDialogPane; |
44 | | -import org.jackhuang.hmcl.ui.construct.PopupMenu; |
45 | 43 | import org.jackhuang.hmcl.ui.decorator.DecoratorAnimatedPage; |
46 | 44 | import org.jackhuang.hmcl.ui.decorator.DecoratorPage; |
47 | 45 | import org.jackhuang.hmcl.ui.download.ModpackInstallWizardProvider; |
@@ -148,7 +146,7 @@ protected Skin(RootPage control) { |
148 | 146 | // first item in left sidebar |
149 | 147 | AccountAdvancedListItem accountListItem = new AccountAdvancedListItem(); |
150 | 148 | accountListItem.setOnAction(e -> Controllers.navigate(Controllers.getAccountListPage())); |
151 | | - FXUtils.onSecondaryButtonClicked(accountListItem, () -> showAccountListPopupMenu(accountListItem)); |
| 149 | + FXUtils.onSecondaryButtonClicked(accountListItem, () -> AccountListPopupMenu.show(accountListItem, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.LEFT, accountListItem.getWidth(), 0)); |
152 | 150 | accountListItem.accountProperty().bind(Accounts.selectedAccountProperty()); |
153 | 151 |
|
154 | 152 | // second item in left sidebar |
@@ -251,36 +249,6 @@ else if (Platform.SYSTEM_PLATFORM.equals(OperatingSystem.LINUX, Architecture.LOO |
251 | 249 | setCenter(getSkinnable().getMainPage()); |
252 | 250 | } |
253 | 251 |
|
254 | | - public void showAccountListPopupMenu( |
255 | | - AccountAdvancedListItem accountListItem |
256 | | - ) { |
257 | | - PopupMenu popupMenu = new PopupMenu(); |
258 | | - JFXPopup popup = new JFXPopup(popupMenu); |
259 | | - AdvancedListBox scrollPane = new AdvancedListBox(); |
260 | | - scrollPane.getStyleClass().add("no-padding"); |
261 | | - scrollPane.setPrefWidth(220); |
262 | | - scrollPane.setPrefHeight(-1); |
263 | | - scrollPane.setMaxHeight(260); |
264 | | - |
265 | | - if (Accounts.getAccounts().isEmpty()) { |
266 | | - Label placeholder = new Label(i18n("account.empty")); |
267 | | - placeholder.setStyle("-fx-padding: 10px; -fx-text-fill: -monet-on-surface-variant; -fx-font-style: italic;"); |
268 | | - scrollPane.add(placeholder); |
269 | | - } else { |
270 | | - for (Account account : Accounts.getAccounts()) { |
271 | | - AccountAdvancedListItem item = new AccountAdvancedListItem(account); |
272 | | - item.setOnAction(e -> { |
273 | | - Accounts.setSelectedAccount(account); |
274 | | - popup.hide(); |
275 | | - }); |
276 | | - scrollPane.add(item); |
277 | | - } |
278 | | - } |
279 | | - |
280 | | - popupMenu.getContent().add(scrollPane); |
281 | | - popup.show(accountListItem, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.LEFT, accountListItem.getWidth(), 0); |
282 | | - } |
283 | | - |
284 | 252 | public void showGameListPopupMenu(AdvancedListItem gameListItem) { |
285 | 253 | GameListPopupMenu.show(gameListItem, |
286 | 254 | JFXPopup.PopupVPosition.TOP, |
|
0 commit comments