Add general tab to preferences and refactor FX IDs

This commit is contained in:
Marvin Elsen 2024-09-27 11:39:55 +02:00
parent bc9d09c39f
commit 6446c2d9c8
Signed by: marvinelsen
GPG Key ID: 820672408CC318C2
2 changed files with 55 additions and 23 deletions

View File

@ -4,6 +4,7 @@ import com.marvinelsen.willow.Config
import com.marvinelsen.willow.WillowApplication import com.marvinelsen.willow.WillowApplication
import com.marvinelsen.willow.ui.Pronunciation import com.marvinelsen.willow.ui.Pronunciation
import com.marvinelsen.willow.ui.formatters.FontSizeTextFormatter import com.marvinelsen.willow.ui.formatters.FontSizeTextFormatter
import javafx.fxml.FXML
import javafx.fxml.FXMLLoader import javafx.fxml.FXMLLoader
import javafx.scene.control.ButtonType import javafx.scene.control.ButtonType
import javafx.scene.control.CheckBox import javafx.scene.control.CheckBox
@ -16,7 +17,6 @@ import javafx.stage.Stage
import javafx.stage.Window import javafx.stage.Window
import javafx.util.Callback import javafx.util.Callback
@Suppress("MemberVisibilityCanBePrivate")
class PreferencesDialog(owner: Window?, config: Config) : Dialog<PreferencesDialog.Result>() { class PreferencesDialog(owner: Window?, config: Config) : Dialog<PreferencesDialog.Result>() {
companion object { companion object {
private const val DIALOG_MIN_HEIGHT = 400.0 private const val DIALOG_MIN_HEIGHT = 400.0
@ -27,17 +27,32 @@ class PreferencesDialog(owner: Window?, config: Config) : Dialog<PreferencesDial
CHANGES, NO_CHANGES CHANGES, NO_CHANGES
} }
lateinit var comboBoxEntryPronunciation: ComboBox<Pronunciation> @FXML
lateinit var comboBoxListPronunciation: ComboBox<Pronunciation> private lateinit var comboBoxPronunciationDetails: ComboBox<Pronunciation>
lateinit var checkBoxListShowPronunciation: CheckBox @FXML
lateinit var checkBoxListShowDefinition: CheckBox private lateinit var comboBoxPronunciationSearchResults: ComboBox<Pronunciation>
lateinit var spinnerEntryHeadwordFontSize: Spinner<Int> @FXML
lateinit var spinnerEntryPronunciationFontSize: Spinner<Int> private lateinit var checkBoxShowPronunciationSearchResults: CheckBox
lateinit var spinnerListHeadwordFontSize: Spinner<Int>
lateinit var spinnerListPronunciationFontSize: Spinner<Int> @FXML
lateinit var spinnerListDefinitionFontSize: Spinner<Int> private lateinit var checkBoxShowDefinitionSearchResults: CheckBox
@FXML
private lateinit var spinnerHeadwordFontSizeDetails: Spinner<Int>
@FXML
private lateinit var spinnerPronunciationFontSizeDetails: Spinner<Int>
@FXML
private lateinit var spinnerHeadwordFontSizeSearchResults: Spinner<Int>
@FXML
private lateinit var spinnerPronunciationFontSizeSearchResults: Spinner<Int>
@FXML
private lateinit var spinnerDefinitionFontSizeSearchResults: Spinner<Int>
private val entryHeadwordFontSizeObjectProperty = config.detailHeadwordFontSize.asObject() private val entryHeadwordFontSizeObjectProperty = config.detailHeadwordFontSize.asObject()
@ -58,7 +73,7 @@ class PreferencesDialog(owner: Window?, config: Config) : Dialog<PreferencesDial
minHeight = DIALOG_MIN_HEIGHT minHeight = DIALOG_MIN_HEIGHT
} }
with(spinnerEntryHeadwordFontSize) { with(spinnerHeadwordFontSizeDetails) {
editor.textFormatter = FontSizeTextFormatter() editor.textFormatter = FontSizeTextFormatter()
valueFactory.valueProperty().bindBidirectional(entryHeadwordFontSizeObjectProperty) valueFactory.valueProperty().bindBidirectional(entryHeadwordFontSizeObjectProperty)
} }

View File

@ -18,7 +18,23 @@
<content> <content>
<TabPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" <TabPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
tabClosingPolicy="UNAVAILABLE"> tabClosingPolicy="UNAVAILABLE">
<Tab closable="false" text="Entry"> <Tab closable="false" text="General">
<GridPane alignment="TOP_CENTER" hgap="8.0" vgap="8.0">
<columnConstraints>
<ColumnConstraints halignment="RIGHT" hgrow="ALWAYS"/>
<ColumnConstraints halignment="LEFT" hgrow="ALWAYS"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" valignment="BASELINE" vgrow="NEVER"/>
</rowConstraints>
<padding>
<Insets bottom="12.0" left="12.0" right="12.0" top="12.0"/>
</padding>
<Label text="Script:"/>
<ComboBox fx:id="comboBoxScript" GridPane.columnIndex="1"/>
</GridPane>
</Tab>
<Tab closable="false" text="Details View">
<GridPane alignment="TOP_CENTER" hgap="8.0" vgap="8.0"> <GridPane alignment="TOP_CENTER" hgap="8.0" vgap="8.0">
<columnConstraints> <columnConstraints>
<ColumnConstraints halignment="RIGHT" hgrow="ALWAYS"/> <ColumnConstraints halignment="RIGHT" hgrow="ALWAYS"/>
@ -34,7 +50,7 @@
<Insets bottom="12.0" left="12.0" right="12.0" top="12.0"/> <Insets bottom="12.0" left="12.0" right="12.0" top="12.0"/>
</padding> </padding>
<Label text="Pronunciation:"/> <Label text="Pronunciation:"/>
<ComboBox fx:id="comboBoxEntryPronunciation" GridPane.columnIndex="1"> <ComboBox fx:id="comboBoxPronunciationDetails" items="$phoneticAlphabets" GridPane.columnIndex="1">
<value> <value>
<Pronunciation fx:value="PINYIN_WITH_TONE_MARKS"/> <Pronunciation fx:value="PINYIN_WITH_TONE_MARKS"/>
</value> </value>
@ -44,13 +60,13 @@
</ComboBox> </ComboBox>
<Label text="Headword font size:" GridPane.rowIndex="2"/> <Label text="Headword font size:" GridPane.rowIndex="2"/>
<Label text="Pronunciation font size:" GridPane.rowIndex="3"/> <Label text="Pronunciation font size:" GridPane.rowIndex="3"/>
<Spinner fx:id="spinnerEntryPronunciationFontSize" editable="true" GridPane.columnIndex="1" <Spinner fx:id="spinnerPronunciationFontSizeDetails" editable="true" GridPane.columnIndex="1"
GridPane.rowIndex="3"> GridPane.rowIndex="3">
<valueFactory> <valueFactory>
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" max="300" min="1"/> <SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" max="300" min="1"/>
</valueFactory> </valueFactory>
</Spinner> </Spinner>
<Spinner fx:id="spinnerEntryHeadwordFontSize" editable="true" GridPane.columnIndex="1" <Spinner fx:id="spinnerHeadwordFontSizeDetails" editable="true" GridPane.columnIndex="1"
GridPane.rowIndex="2"> GridPane.rowIndex="2">
<valueFactory> <valueFactory>
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" max="300" min="1"/> <SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" max="300" min="1"/>
@ -59,7 +75,7 @@
<Separator prefWidth="200.0" GridPane.columnSpan="2147483647" GridPane.rowIndex="1"/> <Separator prefWidth="200.0" GridPane.columnSpan="2147483647" GridPane.rowIndex="1"/>
</GridPane> </GridPane>
</Tab> </Tab>
<Tab closable="false" text="List"> <Tab closable="false" text="Search Results">
<GridPane alignment="TOP_CENTER" hgap="8.0" vgap="8.0"> <GridPane alignment="TOP_CENTER" hgap="8.0" vgap="8.0">
<columnConstraints> <columnConstraints>
<ColumnConstraints halignment="RIGHT" hgrow="ALWAYS"/> <ColumnConstraints halignment="RIGHT" hgrow="ALWAYS"/>
@ -79,7 +95,8 @@
<Insets bottom="12.0" left="12.0" right="12.0" top="12.0"/> <Insets bottom="12.0" left="12.0" right="12.0" top="12.0"/>
</padding> </padding>
<Label text="Pronunciation:"/> <Label text="Pronunciation:"/>
<ComboBox fx:id="comboBoxListPronunciation" GridPane.columnIndex="1"> <ComboBox fx:id="comboBoxPronunciationSearchResults" items="$phoneticAlphabets"
GridPane.columnIndex="1">
<value> <value>
<Pronunciation fx:value="PINYIN_WITH_TONE_MARKS"/> <Pronunciation fx:value="PINYIN_WITH_TONE_MARKS"/>
</value> </value>
@ -89,19 +106,19 @@
</ComboBox> </ComboBox>
<Label text="Headword font size:" GridPane.rowIndex="5"/> <Label text="Headword font size:" GridPane.rowIndex="5"/>
<Label text="Pronunciation font size:" GridPane.rowIndex="6"/> <Label text="Pronunciation font size:" GridPane.rowIndex="6"/>
<Spinner fx:id="spinnerListPronunciationFontSize" editable="true" GridPane.columnIndex="1" <Spinner fx:id="spinnerPronunciationFontSizeSearchResults" editable="true" GridPane.columnIndex="1"
GridPane.rowIndex="6"> GridPane.rowIndex="6">
<valueFactory> <valueFactory>
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" max="300" min="1"/> <SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" max="300" min="1"/>
</valueFactory> </valueFactory>
</Spinner> </Spinner>
<Spinner fx:id="spinnerListHeadwordFontSize" editable="true" GridPane.columnIndex="1" <Spinner fx:id="spinnerHeadwordFontSizeSearchResults" editable="true" GridPane.columnIndex="1"
GridPane.rowIndex="5"> GridPane.rowIndex="5">
<valueFactory> <valueFactory>
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" max="300" min="1"/> <SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" max="300" min="1"/>
</valueFactory> </valueFactory>
</Spinner> </Spinner>
<Spinner fx:id="spinnerListDefinitionFontSize" editable="true" GridPane.columnIndex="1" <Spinner fx:id="spinnerDefinitionFontSizeSearchResults" editable="true" GridPane.columnIndex="1"
GridPane.rowIndex="7"> GridPane.rowIndex="7">
<valueFactory> <valueFactory>
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" max="300" min="1"/> <SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" max="300" min="1"/>
@ -110,9 +127,9 @@
<Separator prefWidth="200.0" GridPane.columnSpan="2147483647" GridPane.rowIndex="4"/> <Separator prefWidth="200.0" GridPane.columnSpan="2147483647" GridPane.rowIndex="4"/>
<Label text="Definition font size:" GridPane.rowIndex="7"/> <Label text="Definition font size:" GridPane.rowIndex="7"/>
<Label text="Display:" GridPane.rowIndex="2"/> <Label text="Display:" GridPane.rowIndex="2"/>
<CheckBox fx:id="checkBoxListShowPronunciation" mnemonicParsing="false" selected="true" <CheckBox fx:id="checkBoxShowPronunciationSearchResults" mnemonicParsing="false" selected="true"
text="Show pronunciation" GridPane.columnIndex="1" GridPane.rowIndex="2"/> text="Show pronunciation" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<CheckBox fx:id="checkBoxListShowDefinition" mnemonicParsing="false" selected="true" <CheckBox fx:id="checkBoxShowDefinitionSearchResults" mnemonicParsing="false" selected="true"
text="Show definition" GridPane.columnIndex="1" GridPane.rowIndex="3"/> text="Show definition" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
<Separator prefWidth="200.0" GridPane.columnSpan="2147483647" GridPane.rowIndex="1"/> <Separator prefWidth="200.0" GridPane.columnSpan="2147483647" GridPane.rowIndex="1"/>
</GridPane> </GridPane>