Commit eda936c2 authored by ryoii's avatar ryoii

graphic plugins view

parent ca9440d3
package net.mamoe.mirai.console.graphical.controller
import javafx.application.Platform
import javafx.collections.ObservableList
import javafx.stage.Modality
import kotlinx.io.core.IoBuffer
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.graphical.model.BotModel
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.view.VerificationCodeFragment
import net.mamoe.mirai.utils.LoginSolver
......@@ -22,6 +24,7 @@ class MiraiGraphicalUIController : Controller(), MiraiConsoleUI {
private val cache = mutableMapOf<Long, BotModel>()
val mainLog = observableListOf<String>()
val botList = observableListOf<BotModel>()
val pluginList: ObservableList<PluginModel> by lazy(::getPluginsFromConsole)
val consoleInfo = ConsoleInfo()
suspend fun login(qq: String, psd: String) {
......@@ -70,6 +73,11 @@ class MiraiGraphicalUIController : Controller(), MiraiConsoleUI {
}
override fun createLoginSolver(): LoginSolver = loginSolver
private fun getPluginsFromConsole(): ObservableList<PluginModel> {
// TODO
return observableListOf<PluginModel>()
}
}
class GraphicalLoginSolver : LoginSolver() {
......
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
}
\ No newline at end of file
package net.mamoe.mirai.console.graphical.util
import com.jfoenix.controls.*
import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject
import javafx.beans.value.ObservableValue
import javafx.collections.ObservableList
import javafx.event.EventTarget
......@@ -42,3 +43,6 @@ internal fun <T> EventTarget.jfxListView(values: ObservableList<T>? = null, op:
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)
\ No newline at end of file
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 { }
)
}
}
\ No newline at end of file
......@@ -73,7 +73,9 @@ class PrimaryView : View() {
this += find<LoginView>().root
}
tab("Plugin")
tab("Plugins") {
this += find<PluginsView>().root
}
tab("Settings")
......
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