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
7ff9906b
Commit
7ff9906b
authored
Feb 18, 2020
by
ryoii
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
f*ck JFoenix
parent
db13a867
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
27 deletions
+76
-27
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/util/JFoenixAdaptor.kt
.../net/mamoe/mirai/console/graphical/util/JFoenixAdaptor.kt
+22
-6
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/LoginFragment.kt
...n/net/mamoe/mirai/console/graphical/view/LoginFragment.kt
+12
-8
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/PrimaryView.kt
...lin/net/mamoe/mirai/console/graphical/view/PrimaryView.kt
+38
-11
mirai-demos/mirai-demo-1/src/main/java/demo/subscribe/SubscribeSamples.kt
...i-demo-1/src/main/java/demo/subscribe/SubscribeSamples.kt
+3
-1
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt
...rai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt
+1
-1
No files found.
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/util/JFoenixAdaptor.kt
View file @
7ff9906b
package
net.mamoe.mirai.console.graphical.util
import
com.jfoenix.controls.JFXButton
import
com.jfoenix.controls.JFXListView
import
com.jfoenix.controls.JFXTabPane
import
com.jfoenix.controls.*
import
javafx.beans.value.ObservableValue
import
javafx.collections.ObservableList
import
javafx.event.EventTarget
import
javafx.scene.Node
import
javafx.scene.control.Button
import
javafx.scene.control.ListView
import
javafx.scene.control.TabPane
import
javafx.scene.control.*
import
tornadofx.SortedFilteredList
import
tornadofx.attachTo
import
tornadofx.bind
internal
fun
EventTarget
.
jfxTabPane
(
op
:
TabPane
.()
->
Unit
=
{})
=
JFXTabPane
().
attachTo
(
this
,
op
)
...
...
@@ -19,6 +17,24 @@ internal fun EventTarget.jfxButton(text: String = "", graphic: Node? = null, op:
if
(
graphic
!=
null
)
it
.
graphic
=
graphic
}
fun
EventTarget
.
jfxTextfield
(
value
:
String
?
=
null
,
op
:
TextField
.()
->
Unit
=
{})
=
JFXTextField
().
attachTo
(
this
,
op
)
{
if
(
value
!=
null
)
it
.
text
=
value
}
fun
EventTarget
.
jfxTextfield
(
property
:
ObservableValue
<
String
>,
op
:
TextField
.()
->
Unit
=
{})
=
jfxTextfield
().
apply
{
bind
(
property
)
op
(
this
)
}
fun
EventTarget
.
jfxPasswordfield
(
value
:
String
?
=
null
,
op
:
TextField
.()
->
Unit
=
{})
=
JFXPasswordField
().
attachTo
(
this
,
op
)
{
if
(
value
!=
null
)
it
.
text
=
value
}
fun
EventTarget
.
jfxPasswordfield
(
property
:
ObservableValue
<
String
>,
op
:
TextField
.()
->
Unit
=
{})
=
jfxPasswordfield
().
apply
{
bind
(
property
)
op
(
this
)
}
internal
fun
<
T
>
EventTarget
.
jfxListView
(
values
:
ObservableList
<
T
>?
=
null
,
op
:
ListView
<
T
>.()
->
Unit
=
{})
=
JFXListView
<
T
>().
attachTo
(
this
,
op
)
{
if
(
values
!=
null
)
{
...
...
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/LoginFragment.kt
View file @
7ff9906b
package
net.mamoe.mirai.console.graphical.view
import
com.jfoenix.controls.JFXTextField
import
javafx.beans.property.SimpleStringProperty
import
net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
import
net.mamoe.mirai.console.graphical.util.jfxButton
import
net.mamoe.mirai.console.graphical.util.jfxPasswordfield
import
net.mamoe.mirai.console.graphical.util.jfxTextfield
import
tornadofx.*
class
LoginFragment
:
Fragment
()
{
private
val
controller
=
find
<
MiraiGraphicalUIController
>(
FX
.
defaultScope
)
private
val
qq
=
SimpleStringProperty
()
private
val
psd
=
SimpleStringProperty
()
private
val
qq
=
SimpleStringProperty
(
"0"
)
private
val
psd
=
SimpleStringProperty
(
""
)
override
val
root
=
form
{
fieldset
(
"登录"
)
{
field
(
"QQ"
)
{
t
extfield
(
qq
)
jfxT
extfield
(
qq
)
}
field
(
"密码"
)
{
passwordfield
(
psd
)
}
button
(
"登录"
).
action
{
controller
.
login
(
qq
.
value
,
psd
.
value
)
close
()
jfxPasswordfield
(
psd
)
}
}
jfxButton
(
"登录"
).
action
{
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 @
7ff9906b
package
net.mamoe.mirai.console.graphical.view
import
com.jfoenix.controls.JFXListCell
import
javafx.geometry.Insets
import
javafx.geometry.Pos
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
...
...
@@ -27,16 +32,23 @@ class PrimaryView : View() {
// bot list
jfxListView
(
controller
.
botList
)
{
fitToParentSize
()
// prefHeight = 100.0
setCellFactory
{
object
:
JFXListCell
<
BotModel
>()
{
var
tab
:
Tab
?
=
null
init
{
onDoubleClick
{
(
center
as
TabPane
).
tab
(
item
.
uin
.
toString
())
{
listview
(
item
.
logHistory
)
select
()
onDoubleClick
{
close
()
}
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
()
}
}
...
...
@@ -54,11 +66,26 @@ class PrimaryView : View() {
}
}
gridpane
{
row
{
jfxButton
(
"登录"
)
jfxButton
(
"插件"
)
jfxButton
(
"设置"
)
hbox
{
padding
=
Insets
(
10.0
)
spacing
=
10.0
alignment
=
Pos
.
CENTER
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
)
}
}
}
...
...
@@ -78,4 +105,4 @@ class PrimaryView : View() {
}
}
}
}
\ No newline at end of file
}
mirai-demos/mirai-demo-1/src/main/java/demo/subscribe/SubscribeSamples.kt
View file @
7ff9906b
...
...
@@ -28,8 +28,10 @@ import net.mamoe.mirai.message.sendAsImageTo
import
net.mamoe.mirai.qqandroid.Bot
import
net.mamoe.mirai.qqandroid.QQAndroid
import
net.mamoe.mirai.utils.FileBasedDeviceInfo
import
net.mamoe.mirai.utils.MiraiInternalAPI
import
java.io.File
@MiraiInternalAPI
private
fun
readTestAccount
():
BotAccount
?
{
val
file
=
File
(
"testAccount.txt"
)
if
(!
file
.
exists
()
||
!
file
.
canRead
())
{
...
...
@@ -59,7 +61,7 @@ suspend fun main() {
bot
.
messageDSL
()
directlySubscribe
(
bot
)
bot
.
network
.
awaitDisconnectio
n
()
//等到直到断开连接
bot
.
joi
n
()
//等到直到断开连接
}
/**
...
...
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt
View file @
7ff9906b
...
...
@@ -176,7 +176,7 @@ suspend fun main() {
}
bot
.
network
.
awaitDisconnectio
n
()
//等到直到断开连接
bot
.
joi
n
()
//等到直到断开连接
}
private
fun
newTestTempFile
(
filename
:
String
=
"${UUID.randomUUID()}"
,
suffix
:
String
=
".tmp"
):
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