Skip to content

Commit

Permalink
new feature: rename known files
Browse files Browse the repository at this point in the history
  • Loading branch information
IARI committed Jun 12, 2020
1 parent d617806 commit 42684f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ class IOController : Controller() {
}
}

fun rename(doc: LabelsDocument) {
val oldFile = doc.labelsFile.value
inputDialog(oldFile.nameWithoutExtension, "rename ${oldFile.name}") { newDocName ->
val renamedFile = oldFile.parentFile.resolve("$newDocName.$labelsExtension")
if (!oldFile.renameTo(renamedFile)) {
warning("Could not rename", "renaming rile '${oldFile.absolutePath}' to ${renamedFile.name} failed.")
}
doc.labelsFile.value = renamedFile
}
}

fun open(file: File) = LabelsDocument().apply {
labelsFile.value = file
open(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class KnownDocuments : AppTab("Documents", MaterialDesignIcon.FILE_DOCUMENT.view
item("delete", graphic = FontAwesomeIcon.TRASH.view).action {
selectedItem?.let(io::delete)
}
item("rename", graphic = FontAwesomeIcon.TRASH.view).action {
selectedItem?.let(io::rename)
}
}

//copy
Expand Down

0 comments on commit 42684f1

Please sign in to comment.