mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-13 03:16:05 +08:00
graphic plugins view
This commit is contained in:
parent
ca9440d3e3
commit
eda936c2bf
@ -1,6 +1,7 @@
|
|||||||
package net.mamoe.mirai.console.graphical.controller
|
package net.mamoe.mirai.console.graphical.controller
|
||||||
|
|
||||||
import javafx.application.Platform
|
import javafx.application.Platform
|
||||||
|
import javafx.collections.ObservableList
|
||||||
import javafx.stage.Modality
|
import javafx.stage.Modality
|
||||||
import kotlinx.io.core.IoBuffer
|
import kotlinx.io.core.IoBuffer
|
||||||
import net.mamoe.mirai.Bot
|
import net.mamoe.mirai.Bot
|
||||||
@ -8,6 +9,7 @@ import net.mamoe.mirai.console.MiraiConsole
|
|||||||
import net.mamoe.mirai.console.MiraiConsoleUI
|
import net.mamoe.mirai.console.MiraiConsoleUI
|
||||||
import net.mamoe.mirai.console.graphical.model.BotModel
|
import net.mamoe.mirai.console.graphical.model.BotModel
|
||||||
import net.mamoe.mirai.console.graphical.model.ConsoleInfo
|
import net.mamoe.mirai.console.graphical.model.ConsoleInfo
|
||||||
|
import net.mamoe.mirai.console.graphical.model.PluginModel
|
||||||
import net.mamoe.mirai.console.graphical.model.VerificationCodeModel
|
import net.mamoe.mirai.console.graphical.model.VerificationCodeModel
|
||||||
import net.mamoe.mirai.console.graphical.view.VerificationCodeFragment
|
import net.mamoe.mirai.console.graphical.view.VerificationCodeFragment
|
||||||
import net.mamoe.mirai.utils.LoginSolver
|
import net.mamoe.mirai.utils.LoginSolver
|
||||||
@ -22,6 +24,7 @@ class MiraiGraphicalUIController : Controller(), MiraiConsoleUI {
|
|||||||
private val cache = mutableMapOf<Long, BotModel>()
|
private val cache = mutableMapOf<Long, BotModel>()
|
||||||
val mainLog = observableListOf<String>()
|
val mainLog = observableListOf<String>()
|
||||||
val botList = observableListOf<BotModel>()
|
val botList = observableListOf<BotModel>()
|
||||||
|
val pluginList: ObservableList<PluginModel> by lazy(::getPluginsFromConsole)
|
||||||
val consoleInfo = ConsoleInfo()
|
val consoleInfo = ConsoleInfo()
|
||||||
|
|
||||||
suspend fun login(qq: String, psd: String) {
|
suspend fun login(qq: String, psd: String) {
|
||||||
@ -70,6 +73,11 @@ class MiraiGraphicalUIController : Controller(), MiraiConsoleUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun createLoginSolver(): LoginSolver = loginSolver
|
override fun createLoginSolver(): LoginSolver = loginSolver
|
||||||
|
|
||||||
|
private fun getPluginsFromConsole(): ObservableList<PluginModel> {
|
||||||
|
// TODO
|
||||||
|
return observableListOf<PluginModel>()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GraphicalLoginSolver : LoginSolver() {
|
class GraphicalLoginSolver : LoginSolver() {
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package net.mamoe.mirai.console.graphical.model
|
||||||
|
|
||||||
|
import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject
|
||||||
|
import javafx.beans.property.SimpleBooleanProperty
|
||||||
|
import javafx.beans.property.SimpleStringProperty
|
||||||
|
import tornadofx.getValue
|
||||||
|
import tornadofx.setValue
|
||||||
|
|
||||||
|
class PluginModel : RecursiveTreeObject<PluginModel>() {
|
||||||
|
|
||||||
|
val nameProperty = SimpleStringProperty(this, "nameProperty")
|
||||||
|
val name by nameProperty
|
||||||
|
|
||||||
|
val descriptionProperty = SimpleStringProperty(this, "descriptionProperty")
|
||||||
|
val description by descriptionProperty
|
||||||
|
|
||||||
|
val enabledProperty = SimpleBooleanProperty(this, "enabledProperty")
|
||||||
|
var enabled by enabledProperty
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package net.mamoe.mirai.console.graphical.util
|
package net.mamoe.mirai.console.graphical.util
|
||||||
|
|
||||||
import com.jfoenix.controls.*
|
import com.jfoenix.controls.*
|
||||||
|
import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject
|
||||||
import javafx.beans.value.ObservableValue
|
import javafx.beans.value.ObservableValue
|
||||||
import javafx.collections.ObservableList
|
import javafx.collections.ObservableList
|
||||||
import javafx.event.EventTarget
|
import javafx.event.EventTarget
|
||||||
@ -42,3 +43,6 @@ internal fun <T> EventTarget.jfxListView(values: ObservableList<T>? = null, op:
|
|||||||
else it.items = values
|
else it.items = values
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun <T : RecursiveTreeObject<T>?> EventTarget.jfxTreeTableView(items: ObservableList<T>? = null, op: JFXTreeTableView<T>.() -> Unit = {})
|
||||||
|
= JFXTreeTableView<T>(RecursiveTreeItem(items, RecursiveTreeObject<T>::getChildren)).attachTo(this, op)
|
@ -0,0 +1,22 @@
|
|||||||
|
package net.mamoe.mirai.console.graphical.view
|
||||||
|
|
||||||
|
import com.jfoenix.controls.JFXTreeTableColumn
|
||||||
|
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
|
||||||
|
import net.mamoe.mirai.console.graphical.model.PluginModel
|
||||||
|
import net.mamoe.mirai.console.graphical.util.jfxTreeTableView
|
||||||
|
import tornadofx.View
|
||||||
|
|
||||||
|
class PluginsView : View() {
|
||||||
|
|
||||||
|
private val controller = find<MiraiGraphicalUIController>()
|
||||||
|
val plugins = controller.pluginList
|
||||||
|
|
||||||
|
override val root = jfxTreeTableView(plugins) {
|
||||||
|
columns.addAll(
|
||||||
|
JFXTreeTableColumn<PluginModel, String>("插件名").apply { },
|
||||||
|
JFXTreeTableColumn<PluginModel, String>("版本").apply { },
|
||||||
|
JFXTreeTableColumn<PluginModel, String>("作者").apply { },
|
||||||
|
JFXTreeTableColumn<PluginModel, String>("介绍").apply { }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -73,7 +73,9 @@ class PrimaryView : View() {
|
|||||||
this += find<LoginView>().root
|
this += find<LoginView>().root
|
||||||
}
|
}
|
||||||
|
|
||||||
tab("Plugin")
|
tab("Plugins") {
|
||||||
|
this += find<PluginsView>().root
|
||||||
|
}
|
||||||
|
|
||||||
tab("Settings")
|
tab("Settings")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user