mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-25 15:40:28 +08:00
Closable tab
This commit is contained in:
parent
5ece8e95f9
commit
4b17c58de0
@ -16,6 +16,7 @@ import tornadofx.*
|
|||||||
class PrimaryView : View() {
|
class PrimaryView : View() {
|
||||||
|
|
||||||
private val controller = find<MiraiGraphicalUIController>()
|
private val controller = find<MiraiGraphicalUIController>()
|
||||||
|
private lateinit var mainTabPane : TabPane
|
||||||
|
|
||||||
override val root = borderpane {
|
override val root = borderpane {
|
||||||
|
|
||||||
@ -71,15 +72,22 @@ class PrimaryView : View() {
|
|||||||
|
|
||||||
center = jfxTabPane {
|
center = jfxTabPane {
|
||||||
|
|
||||||
tab("Login").content = find<LoginView>().root
|
logTab("Main", controller.mainLog)
|
||||||
|
|
||||||
tab("Plugins").content = find<PluginsView>().root
|
tab("Plugins").content = find<PluginsView>().root
|
||||||
|
|
||||||
tab("Settings").content = find<SettingsView>().root
|
tab("Settings").content = find<SettingsView>().root
|
||||||
|
|
||||||
logTab("Main", controller.mainLog)
|
tab("Login").content = find<LoginView>().root
|
||||||
|
|
||||||
|
mainTabPane = this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Tab.select() = apply {
|
||||||
|
if (!mainTabPane.tabs.contains(this)) mainTabPane.tabs.add(this)
|
||||||
|
mainTabPane.selectionModel.select(this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun TabPane.logTab(
|
private fun TabPane.logTab(
|
||||||
@ -87,13 +95,21 @@ private fun TabPane.logTab(
|
|||||||
logs: ObservableList<String>,
|
logs: ObservableList<String>,
|
||||||
op: Tab.() -> Unit = {}
|
op: Tab.() -> Unit = {}
|
||||||
) = tab(text) {
|
) = tab(text) {
|
||||||
listview(logs) {
|
|
||||||
|
|
||||||
fitToParentSize()
|
vbox {
|
||||||
cellFormat {
|
buttonbar {
|
||||||
graphic = label(it) {
|
button("导出日志").action { }
|
||||||
maxWidthProperty().bind(this@listview.widthProperty())
|
button("关闭").action { close() }
|
||||||
isWrapText = true
|
}
|
||||||
|
|
||||||
|
listview(logs) {
|
||||||
|
|
||||||
|
fitToParentSize()
|
||||||
|
cellFormat {
|
||||||
|
graphic = label(it) {
|
||||||
|
maxWidthProperty().bind(this@listview.widthProperty())
|
||||||
|
isWrapText = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user