Skip to content

Commit

Permalink
Copy string to clipboard functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
NickP0is0n committed Jul 20, 2021
1 parent 61c705c commit 0afc45d
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions src/main/kotlin/me/nickp0is0n/easylocalize/ui/MainWindowView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import me.nickp0is0n.easylocalize.models.ParserSettings
import me.nickp0is0n.easylocalize.utils.AppInfo
import me.nickp0is0n.easylocalize.utils.LocalizeParser
import java.awt.FileDialog
import java.awt.Toolkit
import java.awt.datatransfer.StringSelection
import java.io.*

class MainWindowView {
Expand Down Expand Up @@ -69,19 +71,30 @@ class MainWindowView {
Column {
StringTextField()
CommentTextField()
Button (
onClick = {
controller.onExportButtonClick(stringList, window)
if (controller.exportedSuccessfully) {
val notifier = Notifier()
notifier.notify("Success", "Localization file has been successfully exported.")
controller.exportedSuccessfully = false // resets the value
}
},
colors = ButtonDefaults.buttonColors(backgroundColor = Color(30, 144, 255)),
modifier = Modifier.padding(top = 10.dp)
) {
Text(text ="Export translations to file...", color = Color.White)
Row (modifier = Modifier.padding(top = 10.dp)) {
Button (
onClick = {
controller.onExportButtonClick(stringList, window)
if (controller.exportedSuccessfully) {
val notifier = Notifier()
notifier.notify("Success", "Localization file has been successfully exported.")
controller.exportedSuccessfully = false // resets the value
}
},
colors = ButtonDefaults.buttonColors(backgroundColor = Color(30, 144, 255)),
) {
Text(text ="Export translations to file...", color = Color.White)
}
Button (
onClick = {
val selection = StringSelection(stringList[selectedID].toString())
Toolkit.getDefaultToolkit().systemClipboard.setContents(selection, null)
},
colors = ButtonDefaults.buttonColors(backgroundColor = Color(30, 144, 255)),
modifier = Modifier.padding(start = 6.dp)
) {
Text(text ="Copy string to clipboard", color = Color.White)
}
}
}
checkIfOpenButtonClicked()
Expand Down

0 comments on commit 0afc45d

Please sign in to comment.