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

View File

@ -3,16 +3,17 @@ 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 net.mamoe.mirai.console.plugins.PluginDescription
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
class PluginModel(
val name: String,
val version: String,
val author: String,
val description: String
) : RecursiveTreeObject<PluginModel>() {
constructor(plugin: PluginDescription):this(plugin.name, plugin.version, plugin.author, plugin.info)
val enabledProperty = SimpleBooleanProperty(this, "enabledProperty")
var enabled by enabledProperty

View File

@ -13,10 +13,21 @@ class PluginsView : View() {
override val root = jfxTreeTableView(plugins) {
columns.addAll(
JFXTreeTableColumn<PluginModel, String>("插件名").apply { },
JFXTreeTableColumn<PluginModel, String>("版本").apply { },
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.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))
}
)
}
}