Implement space tags display mode
This commit is contained in:
parent
a150952990
commit
a54bd586d4
3 changed files with 26 additions and 13 deletions
|
@ -69,7 +69,7 @@ class MainPageController {
|
|||
/**
|
||||
* Controls how image tags are displayed on the screen.
|
||||
*/
|
||||
private var tagsDisplayMode: ImageTagsDisplayMode = ImageTagsDisplayMode.CommaSeparated
|
||||
private var tagsDisplayMode: ImageTagsDisplayMode = ImageTagsDisplayMode.Comma
|
||||
|
||||
@FXML
|
||||
private lateinit var progressBar: ProgressBar
|
||||
|
@ -102,10 +102,9 @@ class MainPageController {
|
|||
private fun initializeTagsDisplayMode() {
|
||||
// Tags display mode
|
||||
tagsDisplayModeSelection.items = FXCollections.observableArrayList(
|
||||
ImageTagsDisplayMode.CommaSeparated.toString(),
|
||||
ImageTagsDisplayMode.HashTags.toString()
|
||||
ImageTagsDisplayMode.entries.map { it.toString() }
|
||||
)
|
||||
tagsDisplayModeSelection.value = ImageTagsDisplayMode.CommaSeparated.toString()
|
||||
tagsDisplayModeSelection.value = ImageTagsDisplayMode.default().toString()
|
||||
|
||||
tagsDisplayModeSelection.selectionModel.selectedItemProperty().addListener { _, oldValue, newValue ->
|
||||
if (oldValue != newValue && newValue != null) {
|
||||
|
|
|
@ -4,20 +4,31 @@ package dev.nuculabs.imagetagger.ui.controls
|
|||
* Determines how tags are displayed
|
||||
*/
|
||||
enum class ImageTagsDisplayMode {
|
||||
CommaSeparated {
|
||||
override fun toString(): String {
|
||||
return "Comma Separated"
|
||||
}
|
||||
},
|
||||
HashTags;
|
||||
Comma,
|
||||
HashTags,
|
||||
Space;
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Builds the enum value from a given string.
|
||||
*
|
||||
* @param value - The string
|
||||
* @throws IllegalArgumentException when an invalid value is provided.
|
||||
*/
|
||||
fun fromString(value: String): ImageTagsDisplayMode {
|
||||
return when (value) {
|
||||
CommaSeparated.toString() -> CommaSeparated
|
||||
"Comma" -> Comma
|
||||
"Space" -> Space
|
||||
"HashTags" -> HashTags
|
||||
else -> throw IllegalArgumentException("Invalid argument $value")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default tags display mode.
|
||||
*/
|
||||
fun default(): ImageTagsDisplayMode {
|
||||
return Comma
|
||||
}
|
||||
}
|
||||
}
|
|
@ -48,7 +48,7 @@ class ImageTagsEntryControl(private val image: AnalyzedImage) : HBox() {
|
|||
/**
|
||||
* Sets the default image tags display mode.
|
||||
*/
|
||||
private var tagsDisplayMode: ImageTagsDisplayMode = ImageTagsDisplayMode.CommaSeparated
|
||||
private var tagsDisplayMode: ImageTagsDisplayMode = ImageTagsDisplayMode.Comma
|
||||
|
||||
/**
|
||||
* The file name label.
|
||||
|
@ -152,7 +152,7 @@ class ImageTagsEntryControl(private val image: AnalyzedImage) : HBox() {
|
|||
*/
|
||||
private fun updateTags() {
|
||||
predictedImageTags.text = when (tagsDisplayMode) {
|
||||
ImageTagsDisplayMode.CommaSeparated -> {
|
||||
ImageTagsDisplayMode.Comma -> {
|
||||
tags.joinToString { it }
|
||||
}
|
||||
ImageTagsDisplayMode.HashTags -> {
|
||||
|
@ -160,6 +160,9 @@ class ImageTagsEntryControl(private val image: AnalyzedImage) : HBox() {
|
|||
"#${it}"
|
||||
}
|
||||
}
|
||||
ImageTagsDisplayMode.Space -> {
|
||||
tags.joinToString(separator = " ") { it }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue