mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-13 20:02:57 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
48b15b8e27
@ -9,7 +9,8 @@ import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.console.command.CommandManager
|
||||
import net.mamoe.mirai.console.command.ConsoleCommandSender
|
||||
import net.mamoe.mirai.console.graphical.model.*
|
||||
import net.mamoe.mirai.console.graphical.view.VerificationCodeFragment
|
||||
import net.mamoe.mirai.console.graphical.view.dialog.InputDialog
|
||||
import net.mamoe.mirai.console.graphical.view.dialog.VerificationCodeFragment
|
||||
import net.mamoe.mirai.console.plugins.PluginManager
|
||||
import net.mamoe.mirai.console.utils.MiraiConsoleUI
|
||||
import net.mamoe.mirai.network.WrongPasswordException
|
||||
@ -80,13 +81,14 @@ class MiraiGraphicalUIController : Controller(), MiraiConsoleUI {
|
||||
}
|
||||
|
||||
override suspend fun requestInput(hint: String): String {
|
||||
// TODO: 2020/3/21 HINT
|
||||
val model = VerificationCodeModel()
|
||||
find<VerificationCodeFragment>(Scope(model)).openModal(
|
||||
modality = Modality.APPLICATION_MODAL,
|
||||
resizable = false
|
||||
)
|
||||
return model.code.value
|
||||
var ret: String? = null
|
||||
|
||||
// UI必须在UI线程执行,requestInput在协程种被调用
|
||||
Platform.runLater {
|
||||
ret = InputDialog(hint).open()
|
||||
}
|
||||
while (ret == null) { delay(1000) }
|
||||
return ret!!
|
||||
}
|
||||
|
||||
override fun pushBotAdminStatus(identity: Long, admins: List<Long>) = Platform.runLater {
|
||||
@ -104,7 +106,7 @@ class GraphicalLoginSolver : LoginSolver() {
|
||||
override suspend fun onSolvePicCaptcha(bot: Bot, data: ByteArray): String? {
|
||||
val code = VerificationCodeModel(VerificationCode(data))
|
||||
|
||||
// 界面需要运行在主线程
|
||||
// UI必须在UI线程执行,requestInput在协程种被调用
|
||||
Platform.runLater {
|
||||
find<VerificationCodeFragment>(Scope(code)).openModal(
|
||||
stageStyle = StageStyle.UNDECORATED,
|
||||
|
@ -0,0 +1,15 @@
|
||||
package net.mamoe.mirai.console.graphical.styleSheet
|
||||
|
||||
import tornadofx.Stylesheet
|
||||
import tornadofx.c
|
||||
|
||||
open class BaseStyleSheet : Stylesheet() {
|
||||
|
||||
companion object {
|
||||
const val primaryColor = "0EA987"
|
||||
const val stressColor = "35867C"
|
||||
const val secondaryColor = "32CABA"
|
||||
const val lightColor ="9FD1CC"
|
||||
const val FontColor = "FFFFFF"
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ import javafx.scene.paint.Color
|
||||
import javafx.scene.text.FontWeight
|
||||
import tornadofx.*
|
||||
|
||||
class LoginViewStyleSheet : Stylesheet() {
|
||||
class LoginViewStyleSheet : BaseStyleSheet() {
|
||||
|
||||
companion object {
|
||||
val vBox by csselement("VBox")
|
||||
@ -15,11 +15,14 @@ class LoginViewStyleSheet : Stylesheet() {
|
||||
|
||||
init {
|
||||
|
||||
/*
|
||||
* center box
|
||||
*/
|
||||
vBox {
|
||||
maxWidth = 500.px
|
||||
maxHeight = 500.px
|
||||
|
||||
backgroundColor += c("39c5BB", 0.3)
|
||||
backgroundColor += c(primaryColor, 0.3)
|
||||
backgroundRadius += box(15.px)
|
||||
|
||||
padding = box(50.px, 100.px)
|
||||
@ -35,8 +38,11 @@ class LoginViewStyleSheet : Stylesheet() {
|
||||
fontWeight = FontWeight.BOLD
|
||||
}
|
||||
|
||||
/*
|
||||
* login button
|
||||
*/
|
||||
button {
|
||||
backgroundColor += c("00BCD4", 0.8)
|
||||
backgroundColor += c(stressColor, 0.8)
|
||||
padding = box(10.px, 0.px)
|
||||
prefWidth = 500.px
|
||||
textFill = Color.WHITE
|
||||
|
@ -1,21 +1,51 @@
|
||||
package net.mamoe.mirai.console.graphical.styleSheet
|
||||
|
||||
import javafx.scene.Cursor
|
||||
import javafx.scene.paint.Color
|
||||
import tornadofx.*
|
||||
|
||||
class PrimaryStyleSheet : Stylesheet() {
|
||||
class PrimaryStyleSheet : BaseStyleSheet() {
|
||||
companion object {
|
||||
// window
|
||||
val jfxTitle by cssclass("jfx-decorator-buttons-container")
|
||||
val container by cssclass("jfx-decorator-content-container")
|
||||
|
||||
// tab
|
||||
val jfxTabPane by cssclass("tab-header-background")
|
||||
val closeButton by cssclass("tab-close-button")
|
||||
}
|
||||
|
||||
init {
|
||||
/*
|
||||
* window
|
||||
*/
|
||||
jfxTitle {
|
||||
backgroundColor += c("00BCD4")
|
||||
backgroundColor += c(primaryColor)
|
||||
}
|
||||
|
||||
container {
|
||||
borderColor += box(c("00BCD4"))
|
||||
borderColor += box(c(primaryColor))
|
||||
borderWidth += box(0.px, 4.px, 4.px, 4.px)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* tab pane
|
||||
*/
|
||||
jfxTabPane {
|
||||
backgroundColor += c(primaryColor)
|
||||
}
|
||||
|
||||
// 去除JFoenix默认样式
|
||||
tab {
|
||||
and(":closable") {
|
||||
borderWidth += box(0.px)
|
||||
borderInsets += box(6.px, 0.px)
|
||||
}
|
||||
|
||||
closeButton {
|
||||
and(hover) { cursor = Cursor.HAND }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -8,12 +8,11 @@ import javafx.event.EventTarget
|
||||
import javafx.scene.Node
|
||||
import javafx.scene.control.Button
|
||||
import javafx.scene.control.ListView
|
||||
import javafx.scene.control.TabPane
|
||||
import tornadofx.SortedFilteredList
|
||||
import tornadofx.attachTo
|
||||
import tornadofx.bind
|
||||
|
||||
internal fun EventTarget.jfxTabPane(op: TabPane.() -> Unit = {}) = JFXTabPane().attachTo(this, op)
|
||||
internal fun EventTarget.jfxTabPane(op: JFXTabPane.() -> Unit = {}) = JFXTabPane().attachTo(this, op)
|
||||
|
||||
internal fun EventTarget.jfxButton(text: String = "", graphic: Node? = null, op: Button.() -> Unit = {}) =
|
||||
JFXButton(text).attachTo(this, op) {
|
||||
|
@ -23,7 +23,9 @@ class PrimaryView : View() {
|
||||
|
||||
left = vbox {
|
||||
|
||||
imageview(Image(PrimaryView::class.java.classLoader.getResourceAsStream("logo.png")))
|
||||
imageview(Image(PrimaryView::class.java.classLoader.getResourceAsStream("logo.png"))) {
|
||||
isPreserveRatio = true
|
||||
}
|
||||
|
||||
// bot list
|
||||
jfxListView(controller.botList) {
|
||||
@ -70,13 +72,15 @@ class PrimaryView : View() {
|
||||
|
||||
center = jfxTabPane {
|
||||
|
||||
tabClosingPolicy = TabPane.TabClosingPolicy.ALL_TABS
|
||||
|
||||
logTab("Main", controller.mainLog, closeable = false)
|
||||
|
||||
tab("Plugins").content = find<PluginsView>().root
|
||||
tab("Plugins").apply { isClosable = false }.content = find<PluginsView>().root
|
||||
|
||||
tab("Settings").content = find<SettingsView>().root
|
||||
tab("Settings").apply { isClosable = false }.content = find<SettingsView>().root
|
||||
|
||||
tab("Login").content = find<LoginView>().root
|
||||
tab("Login").apply { isClosable = false }.content = find<LoginView>().root
|
||||
|
||||
mainTabPane = this
|
||||
}
|
||||
@ -95,6 +99,8 @@ private fun TabPane.logTab(
|
||||
op: Tab.() -> Unit = {}
|
||||
) = tab(text) {
|
||||
|
||||
this.isClosable = closeable
|
||||
|
||||
vbox {
|
||||
buttonbar {
|
||||
|
||||
@ -117,8 +123,6 @@ private fun TabPane.logTab(
|
||||
}.ui {// isSucceed: Boolean ->
|
||||
// notify something
|
||||
}
|
||||
|
||||
if (closeable) button("关闭").action { close() }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,39 @@
|
||||
package net.mamoe.mirai.console.graphical.view.dialog
|
||||
|
||||
import javafx.scene.control.TextField
|
||||
import javafx.stage.Modality
|
||||
import javafx.stage.StageStyle
|
||||
import tornadofx.*
|
||||
|
||||
class InputDialog(title: String) : Fragment() {
|
||||
|
||||
private lateinit var input: TextField
|
||||
|
||||
init {
|
||||
titleProperty.value = title
|
||||
}
|
||||
|
||||
override val root = form {
|
||||
|
||||
fieldset {
|
||||
field(title) {
|
||||
input = textfield("")
|
||||
}
|
||||
|
||||
buttonbar {
|
||||
|
||||
button("提交").action { close() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun open(): String {
|
||||
// 阻塞窗口直到关闭
|
||||
openModal(
|
||||
stageStyle = StageStyle.DECORATED,
|
||||
modality = Modality.APPLICATION_MODAL,
|
||||
block = true
|
||||
)
|
||||
return input.text
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.mamoe.mirai.console.graphical.view
|
||||
package net.mamoe.mirai.console.graphical.view.dialog
|
||||
|
||||
import javafx.scene.image.Image
|
||||
import net.mamoe.mirai.console.graphical.model.VerificationCodeModel
|
||||
@ -30,7 +30,8 @@ class VerificationCodeFragment : Fragment() {
|
||||
this@VerificationCodeFragment.close()
|
||||
}
|
||||
button("取消").action {
|
||||
code.code.value = MAGIC_KEY
|
||||
code.code.value =
|
||||
MAGIC_KEY
|
||||
code.commit()
|
||||
this@VerificationCodeFragment.close()
|
||||
}
|
Loading…
Reference in New Issue
Block a user