Graphic refactor plugin list

This commit is contained in:
ryoii 2020-02-23 16:36:19 +08:00
parent ca0e50a367
commit f41b831580
3 changed files with 27 additions and 19 deletions

View File

@ -13,10 +13,7 @@ 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.console.utils.MiraiConsoleUI import net.mamoe.mirai.console.utils.MiraiConsoleUI
import net.mamoe.mirai.utils.LoginSolver import net.mamoe.mirai.utils.LoginSolver
import tornadofx.Controller import tornadofx.*
import tornadofx.Scope
import tornadofx.find
import tornadofx.observableListOf
class MiraiGraphicalUIController : Controller(), MiraiConsoleUI { class MiraiGraphicalUIController : Controller(), MiraiConsoleUI {
@ -79,10 +76,9 @@ class MiraiGraphicalUIController : Controller(), MiraiConsoleUI {
override fun createLoginSolver(): LoginSolver = loginSolver override fun createLoginSolver(): LoginSolver = loginSolver
private fun getPluginsFromConsole(): ObservableList<PluginModel> { private fun getPluginsFromConsole(): ObservableList<PluginModel> =
// TODO MiraiConsole.pluginManager.getAllPluginDescriptions().map(::PluginModel).toObservable()
return observableListOf<PluginModel>()
}
} }
class GraphicalLoginSolver : LoginSolver() { class GraphicalLoginSolver : LoginSolver() {

View File

@ -3,16 +3,17 @@ package net.mamoe.mirai.console.graphical.model
import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject
import javafx.beans.property.SimpleBooleanProperty import javafx.beans.property.SimpleBooleanProperty
import javafx.beans.property.SimpleStringProperty import javafx.beans.property.SimpleStringProperty
import net.mamoe.mirai.console.plugins.PluginDescription
import tornadofx.getValue import tornadofx.getValue
import tornadofx.setValue import tornadofx.setValue
class PluginModel : RecursiveTreeObject<PluginModel>() { class PluginModel(
val name: String,
val nameProperty = SimpleStringProperty(this, "nameProperty") val version: String,
val name by nameProperty val author: String,
val description: String
val descriptionProperty = SimpleStringProperty(this, "descriptionProperty") ) : RecursiveTreeObject<PluginModel>() {
val description by descriptionProperty constructor(plugin: PluginDescription):this(plugin.name, plugin.version, plugin.author, plugin.info)
val enabledProperty = SimpleBooleanProperty(this, "enabledProperty") val enabledProperty = SimpleBooleanProperty(this, "enabledProperty")
var enabled by enabledProperty var enabled by enabledProperty

View File

@ -13,10 +13,21 @@ class PluginsView : View() {
override val root = jfxTreeTableView(plugins) { override val root = jfxTreeTableView(plugins) {
columns.addAll( columns.addAll(
JFXTreeTableColumn<PluginModel, String>("插件名").apply { }, JFXTreeTableColumn<PluginModel, String>("插件名").apply {
JFXTreeTableColumn<PluginModel, String>("版本").apply { }, prefWidthProperty().bind(this@jfxTreeTableView.widthProperty().multiply(0.1))
JFXTreeTableColumn<PluginModel, String>("作者").apply { }, },
JFXTreeTableColumn<PluginModel, String>("介绍").apply { } JFXTreeTableColumn<PluginModel, String>("版本").apply {
prefWidthProperty().bind(this@jfxTreeTableView.widthProperty().multiply(0.1))
},
JFXTreeTableColumn<PluginModel, String>("作者").apply {
prefWidthProperty().bind(this@jfxTreeTableView.widthProperty().multiply(0.1))
},
JFXTreeTableColumn<PluginModel, String>("介绍").apply {
prefWidthProperty().bind(this@jfxTreeTableView.widthProperty().multiply(0.6))
},
JFXTreeTableColumn<PluginModel, String>("操作").apply {
prefWidthProperty().bind(this@jfxTreeTableView.widthProperty().multiply(0.08))
}
) )
} }
} }