Graphical log color

This commit is contained in:
ryoii 2020-03-30 20:40:38 +08:00
parent 62e71ef3a5
commit 25083f8b2e
4 changed files with 18 additions and 6 deletions

View File

@ -27,7 +27,7 @@ class MiraiGraphicalUIController : Controller(), MiraiConsoleUI {
private val settingModel = find<GlobalSettingModel>()
private val loginSolver = GraphicalLoginSolver()
private val cache = mutableMapOf<Long, BotModel>()
val mainLog = observableListOf<String>()
val mainLog = observableListOf<Pair<String, String>>()
val botList = observableListOf<BotModel>()
@ -69,7 +69,7 @@ class MiraiGraphicalUIController : Controller(), MiraiConsoleUI {
} else {
cache[identity]?.logHistory
}?.apply {
add("[$time] $identityStr $message")
add("[$time] $identityStr $message" to priority.name)
trim()
}
}

View File

@ -11,7 +11,7 @@ class BotModel(val uin: Long) {
val botProperty = SimpleObjectProperty<Bot>(null)
var bot: Bot by botProperty
val logHistory = observableListOf<String>()
val logHistory = observableListOf<Pair<String, String>>()
val admins = observableListOf<Long>()
}

View File

@ -124,6 +124,15 @@ class PrimaryStyleSheet : BaseStyleSheet() {
}
listCell {
and(":WARNING") {
backgroundColor += c("FFFF00", 0.3) // Yellow
}
and(":ERROR") {
backgroundColor += c("FF0000", 0.3) // Red
}
and(":selected") {
backgroundColor += c(stressColor, 1.0)
}

View File

@ -151,7 +151,7 @@ private fun TabPane.fixedTab(title: String) = tab(title) { isClosable = false }
private fun TabPane.logTab(
text: String? = null,
logs: ObservableList<String>,
logs: ObservableList<Pair<String, String>>,
closeable: Boolean = true,
op: Tab.() -> Unit = {}
) = tab(text) {
@ -174,7 +174,7 @@ private fun TabPane.logTab(
path.firstOrNull()?.run {
if (!exists()) createNewFile()
writer().use {
logs.forEach { log -> it.appendln(log) }
logs.forEach { log -> it.appendln(log.first) }
}
true
} ?: false
@ -188,7 +188,10 @@ private fun TabPane.logTab(
fitToParentSize()
cellFormat {
graphic = label(it) {
addPseudoClass(it.second)
graphic = label(it.first) {
maxWidthProperty().bind(this@listview.widthProperty())
isWrapText = true
}