Skip to content

Commit

Permalink
refactor: move Tooltip declaration to FXML (#157)
Browse files Browse the repository at this point in the history
* Add tooltips to UI elements and refactor tooltip management to prepare i18n

* Rename and restructure CSS files for better organization
  • Loading branch information
hizumiaoba authored Jan 14, 2025
1 parent 7553fa3 commit 2d46ca2
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import javafx.scene.control.SpinnerValueFactory.IntegerSpinnerValueFactory;
import javafx.scene.control.TabPane;
import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip;
import javafx.stage.FileChooser;
import javafx.stage.Modality;
import javafx.stage.Stage;
Expand Down Expand Up @@ -187,14 +186,8 @@ void initialize() {
Boolean.parseBoolean(mainConfig.load("special_backup_on_shortcut")));
enableAutoExitOnQuittingGamesChkbox.setSelected(
Boolean.parseBoolean(mainConfig.load("exit_on_quitting_minecraft")));
Tooltip backupNowTooltip = new Tooltip("ランチャーをここから起動した際、Minecraft終了を自動で検知してこのアプリを終了します。");
backupNowTooltip.setStyle("-fx-font-size: 12px;");
enableAutoExitOnQuittingGamesChkbox.setTooltip(backupNowTooltip);
enableAutoBackupOnQuittingGamesChkbox.setSelected(
Boolean.parseBoolean(mainConfig.load("backup_on_quitting_minecraft")));
Tooltip backupOnQuitTooltip = new Tooltip("ランチャーをここから起動した際、Minecraft終了を自動で検知してバックアップを作成します。");
backupOnQuitTooltip.setStyle("-fx-font-size: 12px;");
enableAutoBackupOnQuittingGamesChkbox.setTooltip(backupOnQuitTooltip);
backupUtils = new BackupUtils(backupSavingFolderPathField.getText(), savesFolderPathField.getText());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.Tooltip;
import javafx.stage.Modality;
import javafx.stage.Stage;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -60,10 +59,6 @@ public class UpdateModalController {
@FXML
void initialize() {
log.trace("UpdateModalController initialized");
Tooltip checkUpdateBtnTooltip = new Tooltip("リポジトリに接続し、最新かどうかの確認を行います");
checkUpdateBtn.setTooltip(checkUpdateBtnTooltip);
Tooltip downloadInstallerBtnTooltip = new Tooltip("最新のインストーラをダウンロードします。");
downloadInstallerBtn.setTooltip(downloadInstallerBtnTooltip);
downloadInstallerBtn.setDisable(true);
if(remoteVersionCache != null) {
this.versionInfoLabel.setText(this.versionInfo.formatted(clientVersion, downConvert(remoteVersionCache).asStringNotation()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<?import java.net.URL?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
Expand All @@ -40,11 +41,16 @@
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.Tooltip?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<TabPane fx:id="mainTabPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="190.0" prefWidth="920.0" tabClosingPolicy="UNAVAILABLE" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.github.hizumiaoba.mctimemachine.MainController">
<stylesheets>
<URL value="@styles/shared.css" />
<URL value="@styles/main.css" />
</stylesheets>
<tabs>
<Tab text="メインツール">
<content>
Expand Down Expand Up @@ -158,8 +164,20 @@
<Spinner fx:id="backupCountSpinner" editable="true" prefHeight="25.0" prefWidth="70.0" />
<Label layoutX="10.0" layoutY="10.0" text="自動バックアップ間隔(分)" />
<Spinner fx:id="backupScheduleDurationSpinner" editable="true" layoutX="38.0" layoutY="10.0" prefHeight="25.0" prefWidth="70.0" />
<CheckBox fx:id="enableAutoExitOnQuittingGamesChkbox" mnemonicParsing="false" text="自動で終了する" />
<CheckBox fx:id="enableAutoBackupOnQuittingGamesChkbox" layoutX="514.0" layoutY="27.0" mnemonicParsing="false" text="自動でバックアップする" />
<CheckBox fx:id="enableAutoExitOnQuittingGamesChkbox"
mnemonicParsing="false" text="自動で終了する">
<tooltip>
<Tooltip styleClass="tooltip" text="ランチャーをここから起動した際、Minecraft終了を自動で検知してこのアプリを終了します。"/>
</tooltip>
</CheckBox>
<CheckBox fx:id="enableAutoBackupOnQuittingGamesChkbox"
layoutX="513.0" layoutY="27.0" mnemonicParsing="false"
text="自動でバックアップする">
<tooltip>
<Tooltip styleClass="tooltip"
text="ランチャーをここから起動した際、Minecraft終了を自動で検知してバックアップを作成します。"/>
</tooltip>
</CheckBox>
</children>
<padding>
<Insets left="20.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.tooltip {
-fx-font-size: 12px;
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.net.URL?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ProgressBar?>
<?import javafx.scene.control.Tooltip?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<AnchorPane prefHeight="200.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/17.0.12" xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.github.hizumiaoba.mctimemachine.UpdateModalController">
<stylesheets>
<URL value="@styles/shared.css" />
</stylesheets>
<children>
<VBox alignment="TOP_CENTER" prefHeight="200.0" prefWidth="100.0" spacing="40.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
Expand All @@ -32,8 +37,16 @@
</AnchorPane>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="30.0">
<children>
<Button fx:id="checkUpdateBtn" mnemonicParsing="false" onAction="#onCheckUpdateClicked" prefWidth="150.0" text="更新を確認" HBox.hgrow="ALWAYS" />
<Button fx:id="downloadInstallerBtn" mnemonicParsing="false" onAction="#onDownloadInstallerClicked" prefWidth="150.0" text="インストーラを取得" HBox.hgrow="ALWAYS" />
<Button fx:id="checkUpdateBtn" mnemonicParsing="false" onAction="#onCheckUpdateClicked" prefWidth="150.0" text="更新を確認" HBox.hgrow="ALWAYS">
<tooltip>
<Tooltip text="リポジトリに接続し、最新かどうかの確認を行います" />
</tooltip>
</Button>
<Button fx:id="downloadInstallerBtn" mnemonicParsing="false" onAction="#onDownloadInstallerClicked" prefWidth="150.0" text="インストーラを取得" HBox.hgrow="ALWAYS">
<tooltip>
<Tooltip text="最新のインストーラをダウンロードします。" />
</tooltip>
</Button>
<Button layoutX="225.0" layoutY="10.0" mnemonicParsing="false" onAction="#onOpenReleasePageButton" prefWidth="150.0" text="リリースページを表示" />
<Button mnemonicParsing="false" onAction="#onCloseClicked" prefWidth="150.0" text="閉じる" HBox.hgrow="ALWAYS" />
</children>
Expand Down

0 comments on commit 2d46ca2

Please sign in to comment.