Compare commits
No commits in common. "46af4db9f19e3f5cc84de6f81a8c62a0c52b6aaf" and "7add73fe2880856443b5d95b0b445f51f432a1a1" have entirely different histories.
46af4db9f1
...
7add73fe28
@ -30,8 +30,6 @@ dependencies {
|
||||
|
||||
implementation(libs.segment)
|
||||
|
||||
implementation(libs.ikonli.javafx)
|
||||
|
||||
testImplementation(libs.kotest.core)
|
||||
testImplementation(libs.kotest.assertions)
|
||||
}
|
||||
|
@ -16,8 +16,6 @@ kotlinx-html-jvm = "0.11.0"
|
||||
|
||||
segment = "0.3.1"
|
||||
|
||||
ikonli-javafx = "12.3.1"
|
||||
|
||||
[libraries]
|
||||
chinese-transliteration = { module = "com.marvinelsen:chinese-transliteration", version.ref = "chinese-transliteration" }
|
||||
cedict-parser = { module = "com.marvinelsen:cedict-parser", version.ref = "cedict-parser" }
|
||||
@ -34,8 +32,6 @@ kotlinx-html-jvm = { module = "org.jetbrains.kotlinx:kotlinx-html-jvm", version.
|
||||
|
||||
segment = { module = "com.github.houbb:segment", version.ref = "segment" }
|
||||
|
||||
ikonli-javafx = { module = "org.kordamp.ikonli:ikonli-javafx", version.ref = "ikonli-javafx" }
|
||||
|
||||
# Detekt
|
||||
# See: https://detekt.dev
|
||||
detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
|
||||
|
@ -3,7 +3,6 @@ package com.marvinelsen.willow
|
||||
import com.marvinelsen.willow.domain.SearchMode
|
||||
import com.marvinelsen.willow.ui.DictionaryEntryFx
|
||||
import com.marvinelsen.willow.ui.util.ClipboardHelper
|
||||
import com.marvinelsen.willow.ui.util.FindCharacterService
|
||||
import com.marvinelsen.willow.ui.util.FindWordsService
|
||||
import com.marvinelsen.willow.ui.util.SearchService
|
||||
import javafx.beans.property.ObjectProperty
|
||||
@ -14,15 +13,10 @@ import javafx.collections.FXCollections
|
||||
import javafx.collections.ObservableList
|
||||
import javafx.event.EventHandler
|
||||
|
||||
class Model(
|
||||
private val searchService: SearchService,
|
||||
private val findWordsService: FindWordsService,
|
||||
private val findCharacterService: FindCharacterService,
|
||||
) {
|
||||
class Model(private val searchService: SearchService, private val findWordsService: FindWordsService) {
|
||||
private val internalSelectedEntry: ObjectProperty<DictionaryEntryFx> = SimpleObjectProperty()
|
||||
private val internalSearchResults: ObservableList<DictionaryEntryFx> = FXCollections.observableArrayList()
|
||||
private val internalWordsContaining: ObservableList<DictionaryEntryFx> = FXCollections.observableArrayList()
|
||||
private val internalCharacters: ObservableList<DictionaryEntryFx> = FXCollections.observableArrayList()
|
||||
|
||||
val selectedEntry: ReadOnlyObjectProperty<DictionaryEntryFx> = internalSelectedEntry
|
||||
|
||||
@ -30,12 +24,9 @@ class Model(
|
||||
FXCollections.unmodifiableObservableList(internalSearchResults)
|
||||
val wordsContaining: ObservableList<DictionaryEntryFx> =
|
||||
FXCollections.unmodifiableObservableList(internalWordsContaining)
|
||||
val characters: ObservableList<DictionaryEntryFx> =
|
||||
FXCollections.unmodifiableObservableList(internalCharacters)
|
||||
|
||||
val isSearching: ReadOnlyBooleanProperty = searchService.runningProperty()
|
||||
val isFindingWords: ReadOnlyBooleanProperty = findWordsService.runningProperty()
|
||||
val isFindingCharacters: ReadOnlyBooleanProperty = findCharacterService.runningProperty()
|
||||
|
||||
init {
|
||||
searchService.onSucceeded = EventHandler {
|
||||
@ -44,9 +35,6 @@ class Model(
|
||||
findWordsService.onSucceeded = EventHandler {
|
||||
internalWordsContaining.setAll(findWordsService.value)
|
||||
}
|
||||
findCharacterService.onSucceeded = EventHandler {
|
||||
internalCharacters.setAll(findCharacterService.value)
|
||||
}
|
||||
}
|
||||
|
||||
fun search(query: String, searchMode: SearchMode) {
|
||||
@ -60,14 +48,7 @@ class Model(
|
||||
findWordsService.restart()
|
||||
}
|
||||
|
||||
fun findCharacters() {
|
||||
findCharacterService.entry = internalSelectedEntry.value
|
||||
findCharacterService.restart()
|
||||
}
|
||||
|
||||
fun selectEntry(entry: DictionaryEntryFx) {
|
||||
internalWordsContaining.setAll(emptyList())
|
||||
internalCharacters.setAll(emptyList())
|
||||
internalSelectedEntry.value = entry
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,11 @@ import com.marvinelsen.willow.ui.controllers.MainController
|
||||
import com.marvinelsen.willow.ui.controllers.MenuController
|
||||
import com.marvinelsen.willow.ui.controllers.SearchController
|
||||
import com.marvinelsen.willow.ui.controllers.SearchResultsController
|
||||
import com.marvinelsen.willow.ui.util.FindCharacterService
|
||||
import com.marvinelsen.willow.ui.util.FindWordsService
|
||||
import com.marvinelsen.willow.ui.util.SearchService
|
||||
import javafx.application.Application
|
||||
import javafx.fxml.FXMLLoader
|
||||
import javafx.scene.Scene
|
||||
import javafx.scene.image.Image
|
||||
import javafx.scene.layout.BorderPane
|
||||
import javafx.scene.text.Font
|
||||
import javafx.stage.Stage
|
||||
@ -31,7 +29,7 @@ class WillowApplication : Application() {
|
||||
|
||||
private const val FONT_SIZE = 12.0
|
||||
|
||||
private const val JDBC_CONNECTION_STRING = "jdbc:sqlite::resource:data/dictionary.db"
|
||||
private const val JDBC_CONNECTION_STRING = "jdbc:sqlite:dictionary.db"
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
@ -45,8 +43,7 @@ class WillowApplication : Application() {
|
||||
val dictionary = SqliteDictionary(connection)
|
||||
val searchService = SearchService(dictionary)
|
||||
val findWordsService = FindWordsService(dictionary)
|
||||
val findCharacterService = FindCharacterService(dictionary)
|
||||
val model = Model(searchService, findWordsService, findCharacterService)
|
||||
val model = Model(searchService, findWordsService)
|
||||
val config = Config()
|
||||
config.load()
|
||||
|
||||
@ -72,7 +69,6 @@ class WillowApplication : Application() {
|
||||
minWidth = WINDOW_MIN_WIDTH
|
||||
minHeight = WINDOW_MIN_HEIGHT
|
||||
scene = primaryScene
|
||||
icons.add(Image(javaClass.getResourceAsStream("/img/icon.png")))
|
||||
}.show()
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,11 @@ class Config {
|
||||
private const val LOCALE_KEY = "locale"
|
||||
private const val THEME_KEY = "theme"
|
||||
private const val SCRIPT_KEY = "script"
|
||||
private const val DETAIL_HEADWORD_FONT_SIZE_KEY = "detailHeadwordFontSize"
|
||||
private const val DETAIL_PRONUNCIATION_FONT_SIZE_KEY = "detailPronunciationFontSize"
|
||||
|
||||
private const val DEFAULT_DETAIL_HEADWORD_FONT_SIZE = 40
|
||||
private const val DEFAULT_DETAIL_PRONUNCIATION_FONT_SIZE = 16
|
||||
private val DEFAULT_THEME = Theme.SYSTEM
|
||||
private val DEFAULT_SCRIPT = Script.SIMPLIFIED
|
||||
private val DEFAULT_LOCALE = Locale.ENGLISH
|
||||
@ -22,19 +26,21 @@ class Config {
|
||||
|
||||
private val preferences = Preferences.userNodeForPackage(this::class.java)
|
||||
val searchResults = SearchResultsConfig(preferences)
|
||||
val details = DetailsConfig(preferences)
|
||||
|
||||
val locale: ObjectProperty<Locale> = SimpleObjectProperty(DEFAULT_LOCALE)
|
||||
val theme: ObjectProperty<Theme> = SimpleObjectProperty(DEFAULT_THEME)
|
||||
val script: ObjectProperty<Script> = SimpleObjectProperty(DEFAULT_SCRIPT)
|
||||
val detailHeadwordFontSize: IntegerProperty = SimpleIntegerProperty(DEFAULT_DETAIL_HEADWORD_FONT_SIZE)
|
||||
val detailPronunciationFontSize: IntegerProperty = SimpleIntegerProperty(DEFAULT_DETAIL_PRONUNCIATION_FONT_SIZE)
|
||||
|
||||
fun save() {
|
||||
preferences.put(LOCALE_KEY, locale.value.toLanguageTag())
|
||||
preferences.put(THEME_KEY, theme.value.name)
|
||||
preferences.put(SCRIPT_KEY, script.value.name)
|
||||
preferences.putInt(DETAIL_HEADWORD_FONT_SIZE_KEY, detailHeadwordFontSize.value)
|
||||
preferences.putInt(DETAIL_PRONUNCIATION_FONT_SIZE_KEY, detailPronunciationFontSize.value)
|
||||
|
||||
searchResults.save()
|
||||
details.save()
|
||||
|
||||
preferences.flush()
|
||||
}
|
||||
@ -42,6 +48,16 @@ class Config {
|
||||
fun load() {
|
||||
preferences.sync()
|
||||
|
||||
detailHeadwordFontSize.value = preferences.getInt(
|
||||
DETAIL_HEADWORD_FONT_SIZE_KEY,
|
||||
DEFAULT_DETAIL_HEADWORD_FONT_SIZE
|
||||
)
|
||||
|
||||
detailPronunciationFontSize.value = preferences.getInt(
|
||||
DETAIL_PRONUNCIATION_FONT_SIZE_KEY,
|
||||
DEFAULT_DETAIL_PRONUNCIATION_FONT_SIZE
|
||||
)
|
||||
|
||||
theme.value = Theme.valueOf(
|
||||
preferences.get(
|
||||
THEME_KEY,
|
||||
@ -59,7 +75,10 @@ class Config {
|
||||
locale.value = Locale.forLanguageTag(preferences.get(LOCALE_KEY, DEFAULT_LOCALE.toLanguageTag()))
|
||||
|
||||
searchResults.load()
|
||||
details.load()
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
detailHeadwordFontSize.value = DEFAULT_DETAIL_HEADWORD_FONT_SIZE
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,42 +144,3 @@ class SearchResultsConfig(private val preferences: Preferences) {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class DetailsConfig(private val preferences: Preferences) {
|
||||
companion object {
|
||||
private const val PRONUNCIATION_KEY = "detailsPronunciation"
|
||||
private const val HEADWORD_FONT_SIZE_KEY = "detailsHeadwordFontSize"
|
||||
private const val PRONUNCIATION_FONT_SIZE_KEY = "detailsPronunciationFontSize"
|
||||
|
||||
private val DEFAULT_PRONUNCIATION = Pronunciation.PINYIN_WITH_TONE_MARKS
|
||||
private const val DEFAULT_HEADWORD_FONT_SIZE = 40
|
||||
private const val DEFAULT_PRONUNCIATION_FONT_SIZE = 16
|
||||
}
|
||||
|
||||
val pronunciation: ObjectProperty<Pronunciation> = SimpleObjectProperty(DEFAULT_PRONUNCIATION)
|
||||
val headwordFontSize: IntegerProperty = SimpleIntegerProperty(DEFAULT_HEADWORD_FONT_SIZE)
|
||||
val pronunciationFontSize: IntegerProperty = SimpleIntegerProperty(DEFAULT_PRONUNCIATION_FONT_SIZE)
|
||||
|
||||
fun save() {
|
||||
preferences.put(PRONUNCIATION_KEY, pronunciation.value.name)
|
||||
preferences.putInt(HEADWORD_FONT_SIZE_KEY, headwordFontSize.value)
|
||||
preferences.putInt(PRONUNCIATION_FONT_SIZE_KEY, pronunciationFontSize.value)
|
||||
}
|
||||
|
||||
fun load() {
|
||||
headwordFontSize.value = preferences.getInt(
|
||||
HEADWORD_FONT_SIZE_KEY,
|
||||
DEFAULT_HEADWORD_FONT_SIZE
|
||||
)
|
||||
pronunciationFontSize.value = preferences.getInt(
|
||||
PRONUNCIATION_FONT_SIZE_KEY,
|
||||
DEFAULT_PRONUNCIATION_FONT_SIZE
|
||||
)
|
||||
pronunciation.value = Pronunciation.valueOf(
|
||||
preferences.get(
|
||||
PRONUNCIATION_KEY,
|
||||
DEFAULT_PRONUNCIATION.name
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -78,11 +78,9 @@ class SqliteDictionary(private val connection: Connection) : Dictionary {
|
||||
}
|
||||
|
||||
private val findCharacters = """
|
||||
WITH cte(id, character) AS (VALUES ?)
|
||||
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, definitions
|
||||
FROM cedict INNER JOIN cte
|
||||
ON cte.character = cedict.traditional OR cte.character = cedict.simplified
|
||||
ORDER BY cte.id
|
||||
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, definitions
|
||||
FROM cedict
|
||||
WHERE traditional IN (?)
|
||||
""".trimIndent()
|
||||
|
||||
override fun search(query: String, searchMode: SearchMode) = when (searchMode) {
|
||||
@ -109,8 +107,7 @@ class SqliteDictionary(private val connection: Connection) : Dictionary {
|
||||
val characterList = entry.traditional
|
||||
.split("")
|
||||
.filter { it.isNotBlank() }
|
||||
.mapIndexed { index, s -> "($index, '$s')" }
|
||||
.joinToString(",")
|
||||
.joinToString(",") { "'$it'" }
|
||||
|
||||
val query = findCharacters.replace("?", characterList)
|
||||
|
||||
|
@ -2,19 +2,14 @@ package com.marvinelsen.willow.ui.controllers
|
||||
|
||||
import com.marvinelsen.willow.Model
|
||||
import com.marvinelsen.willow.config.Config
|
||||
import com.marvinelsen.willow.config.Pronunciation
|
||||
import com.marvinelsen.willow.config.Script
|
||||
import com.marvinelsen.willow.ui.DictionaryEntryFx
|
||||
import com.marvinelsen.willow.ui.cells.DictionaryEntryCellFactory
|
||||
import com.marvinelsen.willow.ui.util.createContextMenuForEntry
|
||||
import javafx.beans.binding.Bindings
|
||||
import javafx.fxml.FXML
|
||||
import javafx.scene.control.Label
|
||||
import javafx.scene.control.ListView
|
||||
import javafx.scene.control.ProgressIndicator
|
||||
import javafx.scene.control.TabPane
|
||||
import javafx.scene.input.ContextMenuEvent
|
||||
import javafx.scene.layout.FlowPane
|
||||
import javafx.scene.web.WebView
|
||||
import kotlinx.html.body
|
||||
import kotlinx.html.h1
|
||||
@ -24,113 +19,62 @@ import kotlinx.html.ol
|
||||
import kotlinx.html.stream.createHTML
|
||||
import java.util.ResourceBundle
|
||||
|
||||
@Suppress("UnusedPrivateMember")
|
||||
class DetailsController(private val model: Model, private val config: Config) {
|
||||
@FXML
|
||||
private lateinit var resources: ResourceBundle
|
||||
|
||||
@FXML
|
||||
private lateinit var flowPaneHeader: FlowPane
|
||||
|
||||
@FXML
|
||||
private lateinit var labelHeadword: Label
|
||||
|
||||
@FXML
|
||||
private lateinit var labelPronunciation: Label
|
||||
|
||||
@FXML
|
||||
private lateinit var tabPaneDetails: TabPane
|
||||
|
||||
@FXML
|
||||
private lateinit var webViewDefinition: WebView
|
||||
|
||||
@FXML
|
||||
@Suppress("UnusedPrivateProperty")
|
||||
private lateinit var listviewSentences: ListView<DictionaryEntryFx>
|
||||
|
||||
@FXML
|
||||
private lateinit var listViewWords: ListView<DictionaryEntryFx>
|
||||
|
||||
@FXML
|
||||
@Suppress("UnusedPrivateProperty")
|
||||
private lateinit var listViewCharacters: ListView<DictionaryEntryFx>
|
||||
|
||||
@FXML
|
||||
private lateinit var progressIndicatorCharacters: ProgressIndicator
|
||||
|
||||
@FXML
|
||||
private lateinit var progressIndicatorWords: ProgressIndicator
|
||||
|
||||
@FXML
|
||||
private lateinit var labelNoCharactersFound: Label
|
||||
|
||||
@FXML
|
||||
private lateinit var labelNoWordsFound: Label
|
||||
private lateinit var labelHeadword: Label
|
||||
|
||||
@FXML
|
||||
@Suppress("UnusedPrivateMember")
|
||||
private fun initialize() {
|
||||
initializeLabelHeadword()
|
||||
initializeLabelPronunciation()
|
||||
initializeTabPaneDetails()
|
||||
initializeListViewWords()
|
||||
initializeListViewCharacters()
|
||||
initializeWebViewDefinition()
|
||||
}
|
||||
|
||||
private fun initializeLabelHeadword() {
|
||||
labelHeadword.apply {
|
||||
textProperty().bind(
|
||||
Bindings.createStringBinding(
|
||||
{
|
||||
val selectedEntry = model.selectedEntry.value
|
||||
when (config.script.value!!) {
|
||||
Script.SIMPLIFIED -> selectedEntry?.simplifiedProperty?.value
|
||||
Script.TRADITIONAL -> selectedEntry?.traditionalProperty?.value
|
||||
}
|
||||
},
|
||||
config.script,
|
||||
model.selectedEntry
|
||||
)
|
||||
)
|
||||
styleProperty().bind(
|
||||
Bindings.concat(
|
||||
"-fx-font-size: ",
|
||||
config.details.headwordFontSize.asString(),
|
||||
"px;"
|
||||
)
|
||||
)
|
||||
model.selectedEntry.addListener { _, _, newEntry ->
|
||||
if (newEntry == null) return@addListener
|
||||
|
||||
when (tabPaneDetails.selectionModel.selectedItem.id) {
|
||||
"tabWords" -> {
|
||||
model.findWords()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
webViewDefinition.engine.loadContent(newEntry.createCedictDefinitionHtml())
|
||||
}
|
||||
}
|
||||
|
||||
private fun initializeLabelPronunciation() {
|
||||
labelPronunciation.apply {
|
||||
textProperty().bind(
|
||||
Bindings.createStringBinding(
|
||||
{
|
||||
val selectedEntry = model.selectedEntry.value
|
||||
when (config.details.pronunciation.value!!) {
|
||||
Pronunciation.PINYIN_WITH_TONE_MARKS ->
|
||||
selectedEntry
|
||||
?.pinyinWithToneMarksProperty
|
||||
?.value
|
||||
private fun initializeWebViewDefinition() {
|
||||
webViewDefinition.apply {
|
||||
engine.userStyleSheetLocation = this::class.java.getResource("/css/definitions.css")!!.toExternalForm()
|
||||
}
|
||||
}
|
||||
|
||||
Pronunciation.PINYIN_WITH_TONE_NUMBERS ->
|
||||
selectedEntry
|
||||
?.pinyinWithToneNumbersProperty
|
||||
?.value
|
||||
|
||||
Pronunciation.ZHUYIN ->
|
||||
selectedEntry
|
||||
?.zhuyinProperty
|
||||
?.value
|
||||
}
|
||||
},
|
||||
config.details.pronunciation,
|
||||
model.selectedEntry
|
||||
)
|
||||
)
|
||||
styleProperty().bind(
|
||||
Bindings.concat(
|
||||
"-fx-font-size: ",
|
||||
config.details.pronunciationFontSize.asString(),
|
||||
"px;"
|
||||
)
|
||||
)
|
||||
private fun initializeListViewWords() {
|
||||
listViewWords.apply {
|
||||
cellFactory = DictionaryEntryCellFactory(resources, config)
|
||||
items = model.wordsContaining
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,52 +85,32 @@ class DetailsController(private val model: Model, private val config: Config) {
|
||||
selectionModel.selectedItemProperty().addListener { _, _, selectedTab ->
|
||||
if (model.selectedEntry.value == null) return@addListener
|
||||
|
||||
lazyUpdateTabContent(selectedTab.id)
|
||||
when (selectedTab.id) {
|
||||
"tabWords" -> {
|
||||
model.findWords()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
model.selectedEntry.addListener { _, _, newEntry ->
|
||||
if (newEntry == null) return@addListener
|
||||
|
||||
lazyUpdateTabContent(tabPaneDetails.selectionModel.selectedItem.id)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initializeListViewWords() {
|
||||
listViewWords.apply {
|
||||
cellFactory = DictionaryEntryCellFactory(resources, config)
|
||||
items = model.wordsContaining
|
||||
|
||||
disableProperty().bind(Bindings.or(model.isFindingWords, Bindings.isEmpty(model.wordsContaining)))
|
||||
}
|
||||
progressIndicatorWords.visibleProperty().bind(model.isFindingWords)
|
||||
labelNoWordsFound
|
||||
.visibleProperty()
|
||||
.bind(Bindings.and(Bindings.isEmpty(model.wordsContaining), Bindings.not(model.isFindingWords)))
|
||||
}
|
||||
|
||||
private fun initializeListViewCharacters() {
|
||||
listViewCharacters.apply {
|
||||
cellFactory = DictionaryEntryCellFactory(resources, config)
|
||||
items = model.characters
|
||||
|
||||
disableProperty().bind(Bindings.or(model.isFindingCharacters, Bindings.isEmpty(model.characters)))
|
||||
}
|
||||
progressIndicatorCharacters.visibleProperty().bind(model.isFindingCharacters)
|
||||
labelNoCharactersFound
|
||||
.visibleProperty()
|
||||
.bind(Bindings.and(Bindings.isEmpty(model.characters), Bindings.not(model.isFindingCharacters)))
|
||||
}
|
||||
|
||||
private fun initializeWebViewDefinition() {
|
||||
webViewDefinition.apply {
|
||||
engine.userStyleSheetLocation = this::class.java.getResource("/css/definitions.css")!!.toExternalForm()
|
||||
}
|
||||
|
||||
model.selectedEntry.addListener { _, _, newEntry ->
|
||||
if (newEntry == null) return@addListener
|
||||
|
||||
webViewDefinition.engine.loadContent(newEntry.createCedictDefinitionHtml())
|
||||
private fun initializeLabelHeadword() {
|
||||
labelHeadword.apply {
|
||||
textProperty().bind(
|
||||
Bindings.createStringBinding(
|
||||
{
|
||||
when (config.script.value!!) {
|
||||
Script.SIMPLIFIED -> model.selectedEntry.value?.simplifiedProperty?.value
|
||||
Script.TRADITIONAL -> model.selectedEntry.value?.traditionalProperty?.value
|
||||
}
|
||||
},
|
||||
config.script,
|
||||
model.selectedEntry
|
||||
)
|
||||
)
|
||||
styleProperty().bind(Bindings.concat("-fx-font-size: ", config.detailHeadwordFontSize.asString(), "px;"))
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,33 +128,4 @@ class DetailsController(private val model: Model, private val config: Config) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
private fun headerOnContextMenuRequested(contextMenuEvent: ContextMenuEvent) {
|
||||
if (model.selectedEntry.value == null) return
|
||||
|
||||
createContextMenuForEntry(model.selectedEntry.value, resources).show(
|
||||
flowPaneHeader.scene.window,
|
||||
contextMenuEvent.screenX,
|
||||
contextMenuEvent.screenY
|
||||
)
|
||||
}
|
||||
|
||||
private fun lazyUpdateTabContent(selectedTabId: String?) {
|
||||
when (selectedTabId) {
|
||||
"tabWords" -> {
|
||||
if (model.wordsContaining.isNotEmpty()) return
|
||||
|
||||
model.findWords()
|
||||
}
|
||||
|
||||
"tabCharacters" -> {
|
||||
if (model.characters.isNotEmpty()) return
|
||||
|
||||
model.findCharacters()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,9 +42,6 @@ class PreferencesDialog(owner: Window?, config: Config) : Dialog<PreferencesDial
|
||||
@FXML
|
||||
private lateinit var comboBoxPronunciationSearchResults: ComboBox<Pronunciation>
|
||||
|
||||
@FXML
|
||||
private lateinit var comboBoxPronunciationDetails: ComboBox<Pronunciation>
|
||||
|
||||
@FXML
|
||||
private lateinit var checkBoxShowPronunciationSearchResults: CheckBox
|
||||
|
||||
@ -66,8 +63,8 @@ class PreferencesDialog(owner: Window?, config: Config) : Dialog<PreferencesDial
|
||||
@FXML
|
||||
private lateinit var spinnerDefinitionFontSizeSearchResults: Spinner<Int>
|
||||
|
||||
private val entryHeadwordFontSizeObjectProperty = config.details.headwordFontSize.asObject()
|
||||
private val entryPronunciationFontSizeObjectProperty = config.details.pronunciationFontSize.asObject()
|
||||
private val entryHeadwordFontSizeObjectProperty = config.detailHeadwordFontSize.asObject()
|
||||
private val entryPronunciationFontSizeObjectProperty = config.detailPronunciationFontSize.asObject()
|
||||
|
||||
private val searchResultHeadwordFontSizeObjectProperty = config.searchResults.headwordFontSize.asObject()
|
||||
private val searchResultPronunciationFontSizeObjectProperty = config.searchResults.pronunciationFontSize.asObject()
|
||||
@ -103,7 +100,6 @@ class PreferencesDialog(owner: Window?, config: Config) : Dialog<PreferencesDial
|
||||
comboBoxScript.valueProperty().bindBidirectional(config.script)
|
||||
comboBoxLocale.valueProperty().bindBidirectional(config.locale)
|
||||
comboBoxPronunciationSearchResults.valueProperty().bindBidirectional(config.searchResults.pronunciation)
|
||||
comboBoxPronunciationDetails.valueProperty().bindBidirectional(config.details.pronunciation)
|
||||
|
||||
checkBoxShowDefinitionSearchResults
|
||||
.selectedProperty()
|
||||
|
@ -30,13 +30,3 @@ class FindWordsService(private val dictionary: Dictionary) : Service<ObservableL
|
||||
FXCollections.observableList(dictionary.findWordsContaining(entry.toDomain()).map { it.toFx() })
|
||||
}
|
||||
}
|
||||
|
||||
class FindCharacterService(private val dictionary: Dictionary) : Service<ObservableList<DictionaryEntryFx>>() {
|
||||
lateinit var entry: DictionaryEntryFx
|
||||
|
||||
override fun createTask() = task {
|
||||
if (!this::entry.isInitialized) error("Entry is not initialized")
|
||||
|
||||
FXCollections.observableList(dictionary.findCharacters(entry.toDomain()).map { it.toFx() })
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,4 @@
|
||||
.headword {
|
||||
-fx-font-family: TW-Kai;
|
||||
}
|
||||
|
||||
.pronunciation {
|
||||
-fx-font-family: "Noto Sans TC";
|
||||
-fx-font-size: 40;
|
||||
}
|
||||
|
@ -1,3 +1,7 @@
|
||||
.root {
|
||||
-fx-font-family: "Inter Variable";
|
||||
}
|
||||
|
||||
.details-pronunciation {
|
||||
-fx-font: 16 "Noto Sans TC";
|
||||
}
|
@ -1,55 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import com.marvinelsen.willow.ui.cells.DictionaryEntryCellFactory?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.web.WebView?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<VBox xmlns="http://javafx.com/javafx/23" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="com.marvinelsen.willow.ui.controllers.DetailsController"
|
||||
stylesheets="/css/details.css">
|
||||
<FlowPane fx:id="flowPaneHeader" hgap="8.0" onContextMenuRequested="#headerOnContextMenuRequested"
|
||||
prefHeight="38.0" prefWidth="412.0" rowValignment="BASELINE" vgap="8.0" VBox.vgrow="NEVER">
|
||||
<Label fx:id="labelHeadword" styleClass="headword" text="Label">
|
||||
<padding>
|
||||
<Insets bottom="6.0" left="6.0" right="6.0" top="6.0"/>
|
||||
<Insets left="8" right="8" top="8" bottom="8"/>
|
||||
</padding>
|
||||
<Label fx:id="labelHeadword" styleClass="headword" text="Label">
|
||||
<padding>
|
||||
<Insets left="8" right="8" top="8" bottom="8"/>
|
||||
</padding>
|
||||
</Label>
|
||||
<Label fx:id="labelPronunciation" styleClass="pronunciation">
|
||||
</Label>
|
||||
</FlowPane>
|
||||
</Label>
|
||||
<TabPane fx:id="tabPaneDetails" tabClosingPolicy="UNAVAILABLE" disable="true" VBox.vgrow="ALWAYS">
|
||||
<Tab closable="false" text="%tab.definition">
|
||||
<WebView fx:id="webViewDefinition" minHeight="-1.0" minWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0"/>
|
||||
<Tab closable="false" disable="false" text="%tab.definition">
|
||||
<WebView fx:id="webViewDefinition" minHeight="-1.0" minWidth="-1.0" prefHeight="-1.0"
|
||||
prefWidth="-1.0"/>
|
||||
</Tab>
|
||||
<Tab id="tabSentences" closable="false" text="%tab.sentences">
|
||||
<ListView fx:id="listViewSentences"/>
|
||||
<Tab id="tabSentences" closable="false" disable="false" text="%tab.sentences">
|
||||
<ListView fx:id="listviewSentences"/>
|
||||
</Tab>
|
||||
<Tab id="tabWords" closable="false" text="%tab.words">
|
||||
<StackPane>
|
||||
<ListView fx:id="listViewWords"/>
|
||||
<Label fx:id="labelNoWordsFound" text="%list.no_words_found" textAlignment="CENTER"
|
||||
visible="false" wrapText="true">
|
||||
<padding>
|
||||
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0"/>
|
||||
</padding>
|
||||
</Label>
|
||||
<ProgressIndicator fx:id="progressIndicatorWords" visible="false"/>
|
||||
</StackPane>
|
||||
<Tab id="tabWords" closable="false" disable="false" text="%tab.words">
|
||||
<ListView fx:id="listViewWords"/>
|
||||
</Tab>
|
||||
<Tab id="tabCharacters" closable="false" text="%tab.characters">
|
||||
<StackPane>
|
||||
<ListView fx:id="listViewCharacters"/>
|
||||
<Label fx:id="labelNoCharactersFound" text="%list.no_characters_found" textAlignment="CENTER"
|
||||
visible="false" wrapText="true">
|
||||
<padding>
|
||||
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0"/>
|
||||
</padding>
|
||||
</Label>
|
||||
<ProgressIndicator fx:id="progressIndicatorCharacters" visible="false"/>
|
||||
</StackPane>
|
||||
<Tab closable="false" disable="false" text="%tab.characters">
|
||||
<ListView fx:id="listViewCharacters"/>
|
||||
</Tab>
|
||||
</TabPane>
|
||||
</VBox>
|
||||
|
@ -18,5 +18,3 @@ menubar.help=_Help
|
||||
menubar.help.about=_About…
|
||||
list.no_entries_found=No matching entries found
|
||||
search.mode.phrase=Phrase
|
||||
list.no_characters_found=No characters found
|
||||
list.no_words_found=No words found
|
||||
|
@ -18,5 +18,3 @@ menubar.help=_Hilfe
|
||||
menubar.help.about=_Über…
|
||||
list.no_entries_found=No matching entries found
|
||||
search.mode.phrase=Phrase
|
||||
list.no_characters_found=No characters found
|
||||
list.no_words_found=No words found
|
||||
|
@ -18,5 +18,3 @@ menubar.help=_Help
|
||||
menubar.help.about=_About…
|
||||
list.no_entries_found=No matching entries found
|
||||
search.mode.phrase=Phrase
|
||||
list.no_characters_found=No characters found
|
||||
list.no_words_found=No words found
|
||||
|
@ -18,5 +18,3 @@ menubar.help=_說明
|
||||
menubar.help.about=_關於 Willow…
|
||||
list.no_entries_found=No matching entries found
|
||||
search.mode.phrase=Phrase
|
||||
list.no_characters_found=No characters found
|
||||
list.no_words_found=No words found
|
||||
|
@ -18,5 +18,3 @@ menubar.help=_說明
|
||||
menubar.help.about=_關於 Willow…
|
||||
list.no_entries_found=No matching entries found
|
||||
search.mode.phrase=Phrase
|
||||
list.no_characters_found=No characters found
|
||||
list.no_words_found=No words found
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 65 KiB |
Binary file not shown.
Loading…
Reference in New Issue
Block a user