Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
83611ac0
Commit
83611ac0
authored
Feb 19, 2020
by
ryoii
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
f**k javafx
parent
f68df356
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
68 deletions
+77
-68
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt
...otlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt
+7
-1
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/model/BotModel.kt
...otlin/net/mamoe/mirai/console/graphical/model/BotModel.kt
+6
-0
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/Decorator.kt
...otlin/net/mamoe/mirai/console/graphical/view/Decorator.kt
+9
-0
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/LoginFragment.kt
...n/net/mamoe/mirai/console/graphical/view/LoginFragment.kt
+23
-15
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/PrimaryView.kt
...lin/net/mamoe/mirai/console/graphical/view/PrimaryView.kt
+32
-52
No files found.
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt
View file @
83611ac0
package
net.mamoe.mirai.console.graphical
import
com.jfoenix.controls.JFXDecorator
import
javafx.scene.control.Button
import
javafx.stage.Stage
import
net.mamoe.mirai.console.MiraiConsole
import
net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
import
net.mamoe.mirai.console.graphical.view.Decorator
import
net.mamoe.mirai.console.graphical.view.PrimaryView
import
tornadofx.App
import
tornadofx.FX.Companion.primaryStage
import
tornadofx.UIComponent
import
tornadofx.find
import
tornadofx.launch
...
...
@@ -11,7 +17,7 @@ fun main(args: Array<String>) {
launch
<
MiraiGraphicalUI
>(
args
)
}
class
MiraiGraphicalUI
:
App
(
PrimaryView
::
class
)
{
class
MiraiGraphicalUI
:
App
(
Decorator
::
class
)
{
override
fun
init
()
{
super
.
init
()
...
...
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/model/BotModel.kt
View file @
83611ac0
...
...
@@ -11,3 +11,9 @@ class BotModel(val uin: Long) {
val
logHistory
=
observableListOf
<
String
>()
val
admins
=
observableListOf
<
Long
>()
}
class
BotViewModel
(
botModel
:
BotModel
?
=
null
)
:
ItemViewModel
<
BotModel
>(
botModel
)
{
val
bot
=
bind
(
BotModel
::
botProperty
)
val
logHistory
=
bind
(
BotModel
::
logHistory
)
val
admins
=
bind
(
BotModel
::
admins
)
}
\ No newline at end of file
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/Decorator.kt
0 → 100644
View file @
83611ac0
package
net.mamoe.mirai.console.graphical.view
import
com.jfoenix.controls.JFXDecorator
import
tornadofx.View
class
Decorator
:
View
()
{
override
val
root
=
JFXDecorator
(
primaryStage
,
find
<
PrimaryView
>().
root
)
}
\ No newline at end of file
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/LoginFragment.kt
View file @
83611ac0
package
net.mamoe.mirai.console.graphical.view
import
com.jfoenix.controls.JFXAlert
import
com.jfoenix.controls.JFXPopup
import
javafx.beans.property.SimpleStringProperty
import
javafx.scene.control.Label
import
kotlinx.coroutines.runBlocking
import
net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
import
net.mamoe.mirai.console.graphical.util.jfxButton
...
...
@@ -8,26 +11,31 @@ import net.mamoe.mirai.console.graphical.util.jfxPasswordfield
import
net.mamoe.mirai.console.graphical.util.jfxTextfield
import
tornadofx.*
class
Login
Fragment
:
Fragment
()
{
class
Login
View
:
View
()
{
private
val
controller
=
find
<
MiraiGraphicalUIController
>(
FX
.
defaultScope
)
private
val
qq
=
SimpleStringProperty
(
"
0
"
)
private
val
controller
=
find
<
MiraiGraphicalUIController
>()
private
val
qq
=
SimpleStringProperty
(
""
)
private
val
psd
=
SimpleStringProperty
(
""
)
override
val
root
=
form
{
fieldset
(
"登录"
)
{
field
(
"QQ"
)
{
jfxTextfield
(
qq
)
override
val
root
=
pane
{
form
{
fieldset
(
"登录"
)
{
field
(
"QQ"
)
{
jfxTextfield
(
qq
)
}
field
(
"密码"
)
{
jfxPasswordfield
(
psd
)
}
}
field
(
"密码"
)
{
jfxPasswordfield
(
psd
)
jfxButton
(
"登录"
).
action
{
runAsync
{
runBlocking
{
controller
.
login
(
qq
.
value
,
psd
.
value
)
}
}.
ui
{
// show dialog
}
}
}
jfxButton
(
"登录"
).
action
{
runBlocking
{
controller
.
login
(
qq
.
value
,
psd
.
value
)
}
close
()
}
}
}
\ No newline at end of file
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/PrimaryView.kt
View file @
83611ac0
package
net.mamoe.mirai.console.graphical.view
import
com.jfoenix.controls.JFXListCell
import
javafx.geometry.Insets
import
javafx.geometry.Pos
import
com.jfoenix.controls.*
import
javafx.collections.ObservableList
import
javafx.scene.control.Tab
import
javafx.scene.control.TabPane
import
javafx.scene.image.Image
import
javafx.scene.paint.Color
import
javafx.scene.text.FontWeight
import
net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
import
net.mamoe.mirai.console.graphical.model.BotModel
import
net.mamoe.mirai.console.graphical.util.jfxButton
import
net.mamoe.mirai.console.graphical.util.jfxListView
import
net.mamoe.mirai.console.graphical.util.jfxTabPane
import
tornadofx.*
import
java.io.FileInputStream
class
PrimaryView
:
View
()
{
...
...
@@ -35,20 +30,12 @@ class PrimaryView : View() {
setCellFactory
{
object
:
JFXListCell
<
BotModel
>()
{
var
tab
:
Tab
?
=
null
init
{
onDoubleClick
{
if
(
tab
==
null
)
{
(
center
as
TabPane
).
tab
(
item
.
uin
.
toString
())
{
listview
(
item
.
logHistory
)
onDoubleClick
{
close
()
}
tab
=
this
}
}
else
{
(
center
as
TabPane
).
tabs
.
add
(
tab
)
}
tab
?.
select
()
(
center
as
TabPane
).
logTab
(
text
=
item
.
uin
.
toString
(),
logs
=
item
.
logHistory
).
select
()
}
}
...
...
@@ -65,44 +52,37 @@ class PrimaryView : View() {
}
}
}
}
hbox
{
padding
=
Insets
(
10.0
)
spacing
=
10.0
alignment
=
Pos
.
CENTER
center
=
jfxTabPane
{
jfxButton
(
"L"
).
action
{
find
<
LoginFragment
>().
openModal
()
}
jfxButton
(
"P"
)
jfxButton
(
"S"
)
style
{
backgroundColor
+=
c
(
"00BCD4"
)
}
children
.
style
(
true
)
{
backgroundColor
+=
c
(
"00BCD4"
)
fontSize
=
15
.
px
fontWeight
=
FontWeight
.
BOLD
textFill
=
Color
.
WHITE
borderRadius
+=
box
(
25
.
px
)
backgroundRadius
+=
box
(
25
.
px
)
}
tab
(
"Login"
)
{
this
+=
find
<
LoginView
>().
root
}
tab
(
"Plugin"
)
tab
(
"Settings"
)
logTab
(
"Main"
,
controller
.
mainLog
)
}
}
}
center
=
jfxTabPane
{
tab
(
"Main"
)
{
listview
(
controller
.
mainLog
)
{
fitToParentSize
()
cellFormat
{
graphic
=
label
(
it
)
{
maxWidthProperty
().
bind
(
this
@
listview
.
widthProperty
()
)
isWrapText
=
true
}
}
}
private
fun
TabPane
.
logTab
(
text
:
String
?
=
null
,
logs
:
ObservableList
<
String
>,
op
:
Tab
.()
->
Unit
=
{}
)=
tab
(
text
)
{
listview
(
logs
)
{
fitToParentSize
(
)
cellFormat
{
graphic
=
label
(
it
)
{
maxWidthProperty
().
bind
(
this
@
listview
.
widthProperty
())
isWrapText
=
true
}
}
}
}
also
(
op
)
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment