mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-13 20:02:57 +08:00
Replace buttonBar
This commit is contained in:
parent
3fff04760d
commit
bf9b06e60d
@ -0,0 +1,13 @@
|
||||
package net.mamoe.mirai.console.graphical.util
|
||||
|
||||
import javafx.event.EventTarget
|
||||
import javafx.geometry.Pos
|
||||
import javafx.scene.layout.HBox
|
||||
import tornadofx.addClass
|
||||
import tornadofx.hbox
|
||||
|
||||
fun EventTarget.myButtonBar(alignment: Pos = Pos.BASELINE_LEFT, op: HBox.() -> Unit = {}) = hbox {
|
||||
addClass("my-button-bar")
|
||||
this.alignment = alignment
|
||||
op()
|
||||
}
|
@ -2,6 +2,7 @@ package net.mamoe.mirai.console.graphical.view
|
||||
|
||||
import com.jfoenix.controls.JFXListCell
|
||||
import javafx.collections.ObservableList
|
||||
import javafx.geometry.Pos
|
||||
import javafx.scene.control.Tab
|
||||
import javafx.scene.control.TabPane
|
||||
import javafx.scene.image.Image
|
||||
@ -10,8 +11,10 @@ import javafx.stage.FileChooser
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
|
||||
import net.mamoe.mirai.console.graphical.model.BotModel
|
||||
import net.mamoe.mirai.console.graphical.util.jfxButton
|
||||
import net.mamoe.mirai.console.graphical.util.jfxListView
|
||||
import net.mamoe.mirai.console.graphical.util.jfxTabPane
|
||||
import net.mamoe.mirai.console.graphical.util.myButtonBar
|
||||
import tornadofx.*
|
||||
|
||||
class PrimaryView : View() {
|
||||
@ -104,13 +107,14 @@ private fun TabPane.logTab(
|
||||
this.isClosable = closeable
|
||||
|
||||
vbox {
|
||||
buttonbar {
|
||||
myButtonBar(alignment = Pos.BASELINE_RIGHT) {
|
||||
|
||||
button("导出日志").action {
|
||||
jfxButton("导出日志").action {
|
||||
val path = chooseFile(
|
||||
"选择保存路径",
|
||||
arrayOf(FileChooser.ExtensionFilter("日志", "txt")),
|
||||
FileChooserMode.Save
|
||||
FileChooserMode.Save,
|
||||
owner = FX.primaryStage
|
||||
) {
|
||||
initialFileName = "$text.txt"
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package net.mamoe.mirai.console.graphical.view
|
||||
|
||||
import javafx.geometry.Pos
|
||||
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
|
||||
import net.mamoe.mirai.console.graphical.model.GlobalSettingModel
|
||||
import net.mamoe.mirai.console.graphical.util.jfxButton
|
||||
import net.mamoe.mirai.console.graphical.util.jfxTextfield
|
||||
import net.mamoe.mirai.console.graphical.util.myButtonBar
|
||||
import tornadofx.*
|
||||
import java.awt.Desktop
|
||||
import java.io.File
|
||||
@ -13,33 +15,33 @@ class SettingsView : View() {
|
||||
private val controller = find<MiraiGraphicalUIController>()
|
||||
private val settingModel = find<GlobalSettingModel>()
|
||||
|
||||
override val root = form {
|
||||
override val root = vbox {
|
||||
|
||||
fieldset {
|
||||
field {
|
||||
jfxButton("撤掉").action {
|
||||
settingModel.rollback()
|
||||
}
|
||||
jfxButton("保存").action {
|
||||
settingModel.commit()
|
||||
}
|
||||
myButtonBar(alignment = Pos.BASELINE_RIGHT) {
|
||||
jfxButton("撤掉").action {
|
||||
settingModel.rollback()
|
||||
}
|
||||
jfxButton("保存").action {
|
||||
settingModel.commit()
|
||||
}
|
||||
}
|
||||
|
||||
fieldset("插件目录") {
|
||||
field {
|
||||
jfxTextfield((System.getProperty("user.dir") + "/plugins/").replace("//", "/")) { isEditable = false }
|
||||
jfxButton("打开目录").action {
|
||||
(System.getProperty("user.dir") + "/plugins/").replace("//", "/").also { path ->
|
||||
Desktop.getDesktop().takeIf { it.isSupported(Desktop.Action.OPEN) }?.open(File(path))
|
||||
form {
|
||||
fieldset("插件目录") {
|
||||
field {
|
||||
jfxTextfield((System.getProperty("user.dir") + "/plugins/").replace("//", "/")) { isEditable = false }
|
||||
jfxButton("打开目录").action {
|
||||
(System.getProperty("user.dir") + "/plugins/").replace("//", "/").also { path ->
|
||||
Desktop.getDesktop().takeIf { it.isSupported(Desktop.Action.OPEN) }?.open(File(path))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fieldset("最大日志容量") {
|
||||
field {
|
||||
jfxTextfield().bind(settingModel.maxLogNum)
|
||||
fieldset("最大日志容量") {
|
||||
field {
|
||||
jfxTextfield().bind(settingModel.maxLogNum)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user