Commit 7ff9906b authored by ryoii's avatar ryoii

f*ck JFoenix

parent db13a867
package net.mamoe.mirai.console.graphical.util
import com.jfoenix.controls.JFXButton
import com.jfoenix.controls.JFXListView
import com.jfoenix.controls.JFXTabPane
import com.jfoenix.controls.*
import javafx.beans.value.ObservableValue
import javafx.collections.ObservableList
import javafx.event.EventTarget
import javafx.scene.Node
import javafx.scene.control.Button
import javafx.scene.control.ListView
import javafx.scene.control.TabPane
import javafx.scene.control.*
import tornadofx.SortedFilteredList
import tornadofx.attachTo
import tornadofx.bind
internal fun EventTarget.jfxTabPane(op: TabPane.() -> Unit = {}) = JFXTabPane().attachTo(this, op)
......@@ -19,6 +17,24 @@ internal fun EventTarget.jfxButton(text: String = "", graphic: Node? = null, op:
if (graphic != null) it.graphic = graphic
}
fun EventTarget.jfxTextfield(value: String? = null, op: TextField.() -> Unit = {}) = JFXTextField().attachTo(this, op) {
if (value != null) it.text = value
}
fun EventTarget.jfxTextfield(property: ObservableValue<String>, op: TextField.() -> Unit = {}) = jfxTextfield().apply {
bind(property)
op(this)
}
fun EventTarget.jfxPasswordfield(value: String? = null, op: TextField.() -> Unit = {}) = JFXPasswordField().attachTo(this, op) {
if (value != null) it.text = value
}
fun EventTarget.jfxPasswordfield(property: ObservableValue<String>, op: TextField.() -> Unit = {}) = jfxPasswordfield().apply {
bind(property)
op(this)
}
internal fun <T> EventTarget.jfxListView(values: ObservableList<T>? = null, op: ListView<T>.() -> Unit = {}) =
JFXListView<T>().attachTo(this, op) {
if (values != null) {
......
package net.mamoe.mirai.console.graphical.view
import com.jfoenix.controls.JFXTextField
import javafx.beans.property.SimpleStringProperty
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
import net.mamoe.mirai.console.graphical.util.jfxButton
import net.mamoe.mirai.console.graphical.util.jfxPasswordfield
import net.mamoe.mirai.console.graphical.util.jfxTextfield
import tornadofx.*
class LoginFragment : Fragment() {
private val controller = find<MiraiGraphicalUIController>(FX.defaultScope)
private val qq = SimpleStringProperty()
private val psd = SimpleStringProperty()
private val qq = SimpleStringProperty("0")
private val psd = SimpleStringProperty("")
override val root = form {
fieldset("登录") {
field("QQ") {
textfield(qq)
jfxTextfield(qq)
}
field("密码") {
passwordfield(psd)
}
button("登录").action {
controller.login(qq.value, psd.value)
close()
jfxPasswordfield(psd)
}
}
jfxButton("登录").action {
controller.login(qq.value, psd.value)
close()
}
}
}
\ No newline at end of file
package net.mamoe.mirai.console.graphical.view
import com.jfoenix.controls.JFXListCell
import javafx.geometry.Insets
import javafx.geometry.Pos
import javafx.scene.control.Tab
import javafx.scene.control.TabPane
import javafx.scene.image.Image
import javafx.scene.paint.Color
import javafx.scene.text.FontWeight
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
import net.mamoe.mirai.console.graphical.model.BotModel
import net.mamoe.mirai.console.graphical.util.jfxButton
......@@ -27,16 +32,23 @@ class PrimaryView : View() {
// bot list
jfxListView(controller.botList) {
fitToParentSize()
// prefHeight = 100.0
setCellFactory {
object : JFXListCell<BotModel>() {
var tab: Tab? = null
init {
onDoubleClick {
(center as TabPane).tab(item.uin.toString()) {
listview(item.logHistory)
select()
onDoubleClick { close() }
if (tab == null) {
(center as TabPane).tab(item.uin.toString()) {
listview(item.logHistory)
onDoubleClick { close() }
tab = this
}
} else {
(center as TabPane).tabs.add(tab)
}
tab?.select()
}
}
......@@ -54,11 +66,26 @@ class PrimaryView : View() {
}
}
gridpane {
row {
jfxButton("登录")
jfxButton("插件")
jfxButton("设置")
hbox {
padding = Insets(10.0)
spacing = 10.0
alignment = Pos.CENTER
jfxButton("L").action {
find<LoginFragment>().openModal()
}
jfxButton("P")
jfxButton("S")
style { backgroundColor += c("00BCD4") }
children.style(true) {
backgroundColor += c("00BCD4")
fontSize = 15.px
fontWeight = FontWeight.BOLD
textFill = Color.WHITE
borderRadius += box(25.px)
backgroundRadius += box(25.px)
}
}
}
......@@ -78,4 +105,4 @@ class PrimaryView : View() {
}
}
}
}
\ No newline at end of file
}
......@@ -28,8 +28,10 @@ import net.mamoe.mirai.message.sendAsImageTo
import net.mamoe.mirai.qqandroid.Bot
import net.mamoe.mirai.qqandroid.QQAndroid
import net.mamoe.mirai.utils.FileBasedDeviceInfo
import net.mamoe.mirai.utils.MiraiInternalAPI
import java.io.File
@MiraiInternalAPI
private fun readTestAccount(): BotAccount? {
val file = File("testAccount.txt")
if (!file.exists() || !file.canRead()) {
......@@ -59,7 +61,7 @@ suspend fun main() {
bot.messageDSL()
directlySubscribe(bot)
bot.network.awaitDisconnection()//等到直到断开连接
bot.join()//等到直到断开连接
}
/**
......
......@@ -176,7 +176,7 @@ suspend fun main() {
}
bot.network.awaitDisconnection()//等到直到断开连接
bot.join()//等到直到断开连接
}
private fun newTestTempFile(filename: String = "${UUID.randomUUID()}", suffix: String = ".tmp"): File =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment