2017-08-29 05:09:17 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-05-09 14:33:26 +00:00
|
|
|
"github.com/muesli/telephant/accounts/mastodon"
|
2017-08-29 05:09:17 +00:00
|
|
|
"github.com/therecipe/qt/core"
|
|
|
|
)
|
|
|
|
|
|
|
|
// UIBridge lets us trigger Go methods from QML
|
|
|
|
type UIBridge struct {
|
|
|
|
core.QObject
|
|
|
|
|
2019-05-10 17:14:56 +00:00
|
|
|
_ func(instance string) bool `slot:"connectButton"`
|
|
|
|
_ func(code string, redirectURI string) bool `slot:"authButton"`
|
2019-05-05 11:41:07 +00:00
|
|
|
|
2019-05-15 03:57:12 +00:00
|
|
|
_ func(body string) int `slot:"postLimitCount"`
|
|
|
|
|
2020-04-18 13:16:16 +00:00
|
|
|
_ func(replyid string, message string, visibility string) `slot:"postButton"`
|
|
|
|
_ func(id string) `slot:"deleteButton"`
|
|
|
|
_ func(id string) `slot:"shareButton"`
|
|
|
|
_ func(id string) `slot:"unshareButton"`
|
|
|
|
_ func(id string) `slot:"likeButton"`
|
|
|
|
_ func(id string) `slot:"unlikeButton"`
|
|
|
|
_ func(id string, follow bool) `slot:"followButton"`
|
|
|
|
_ func(url string) `slot:"uploadAttachment"`
|
|
|
|
_ func(id string) `slot:"loadConversation"`
|
|
|
|
_ func(id string) `slot:"loadAccount"`
|
|
|
|
_ func(token string) `slot:"search"`
|
|
|
|
_ func(token string) `slot:"tag"`
|
2017-08-29 05:09:17 +00:00
|
|
|
|
2019-05-13 20:42:03 +00:00
|
|
|
_ func(idx int64) `slot:"closePane"`
|
|
|
|
|
2017-08-29 05:09:17 +00:00
|
|
|
_ func(object *core.QObject) `slot:"registerToGo"`
|
|
|
|
_ func(objectName string) `slot:"deregisterToGo"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// AccountBridge makes an account plugin available in QML
|
|
|
|
type AccountBridge struct {
|
|
|
|
core.QObject
|
|
|
|
|
|
|
|
_ string `property:"username"`
|
2019-05-05 12:44:41 +00:00
|
|
|
_ string `property:"name"`
|
2017-08-29 05:09:17 +00:00
|
|
|
_ string `property:"avatar"`
|
2019-05-02 08:37:29 +00:00
|
|
|
_ string `property:"profileURL"`
|
2019-05-06 18:16:20 +00:00
|
|
|
_ string `property:"profileID"`
|
2019-05-05 12:44:41 +00:00
|
|
|
_ int64 `property:"posts"`
|
2019-05-08 22:34:27 +00:00
|
|
|
_ int64 `property:"followCount"`
|
|
|
|
_ int64 `property:"followerCount"`
|
2019-05-06 18:17:28 +00:00
|
|
|
_ int64 `property:"postSizeLimit"`
|
2017-08-29 05:09:17 +00:00
|
|
|
|
2019-05-10 13:45:38 +00:00
|
|
|
_ string `property:"error"`
|
|
|
|
|
2019-05-13 20:42:03 +00:00
|
|
|
_ *core.QAbstractListModel `property:"panes"`
|
2017-08-29 05:09:17 +00:00
|
|
|
_ *core.QAbstractListModel `property:"notifications"`
|
2019-05-19 06:08:40 +00:00
|
|
|
_ *core.QAbstractListModel `property:"attachments"`
|
2019-05-05 16:21:38 +00:00
|
|
|
_ *core.QAbstractListModel `property:"conversation"`
|
2019-05-06 18:16:20 +00:00
|
|
|
_ *core.QAbstractListModel `property:"accountMessages"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// ProfileBridge allows QML to access profile data
|
|
|
|
type ProfileBridge struct {
|
|
|
|
core.QObject
|
|
|
|
|
|
|
|
_ string `property:"username"`
|
|
|
|
_ string `property:"name"`
|
|
|
|
_ string `property:"avatar"`
|
|
|
|
_ string `property:"profileURL"`
|
|
|
|
_ string `property:"profileID"`
|
|
|
|
_ int64 `property:"posts"`
|
2019-05-08 22:34:27 +00:00
|
|
|
_ int64 `property:"followCount"`
|
|
|
|
_ int64 `property:"followerCount"`
|
2019-05-08 22:59:21 +00:00
|
|
|
_ bool `property:"following"`
|
|
|
|
_ bool `property:"followedBy"`
|
2017-08-29 05:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ConfigBridge allows QML to access the app's config
|
|
|
|
type ConfigBridge struct {
|
|
|
|
core.QObject
|
|
|
|
|
2019-05-09 05:51:24 +00:00
|
|
|
_ bool `property:"firstRun"`
|
|
|
|
_ string `property:"authURL"`
|
2019-05-10 13:46:39 +00:00
|
|
|
_ string `property:"redirectURL"`
|
2019-05-10 00:55:30 +00:00
|
|
|
_ string `property:"theme"`
|
2017-08-29 05:09:17 +00:00
|
|
|
_ string `property:"style"`
|
2019-05-19 02:33:37 +00:00
|
|
|
_ int `property:"positionX"`
|
|
|
|
_ int `property:"positionY"`
|
|
|
|
_ int `property:"width"`
|
|
|
|
_ int `property:"height"`
|
2020-04-20 18:06:19 +00:00
|
|
|
_ string `property:"fontfamily"`
|
|
|
|
_ string `property:"emojifont"`
|
2017-08-29 05:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
// qmlObjects = make(map[string]*core.QObject)
|
|
|
|
uiBridge *UIBridge
|
|
|
|
accountBridge *AccountBridge
|
|
|
|
configBridge *ConfigBridge
|
2019-05-06 18:16:20 +00:00
|
|
|
profileBridge *ProfileBridge
|
2019-05-01 15:15:56 +00:00
|
|
|
tc *mastodon.Account
|
2017-08-29 05:09:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// setupQmlBridges initializes the QML bridges
|
|
|
|
func setupQmlBridges() {
|
|
|
|
configBridge = NewConfigBridge(nil)
|
|
|
|
|
|
|
|
accountBridge = NewAccountBridge(nil)
|
2019-05-09 14:33:26 +00:00
|
|
|
accountBridge.SetUsername("Telephant!")
|
2017-08-29 05:09:17 +00:00
|
|
|
|
|
|
|
uiBridge = NewUIBridge(nil)
|
2019-05-05 11:41:07 +00:00
|
|
|
uiBridge.ConnectConnectButton(connectToInstance)
|
|
|
|
uiBridge.ConnectAuthButton(authInstance)
|
2019-05-15 03:57:12 +00:00
|
|
|
uiBridge.ConnectPostLimitCount(postLimitCount)
|
2019-05-01 16:43:14 +00:00
|
|
|
uiBridge.ConnectPostButton(reply)
|
2019-05-15 03:01:21 +00:00
|
|
|
uiBridge.ConnectDeleteButton(deletePost)
|
2019-05-01 16:55:30 +00:00
|
|
|
uiBridge.ConnectShareButton(share)
|
2019-05-06 20:51:31 +00:00
|
|
|
uiBridge.ConnectUnshareButton(unshare)
|
2017-08-29 05:09:17 +00:00
|
|
|
uiBridge.ConnectLikeButton(like)
|
2019-05-06 20:51:31 +00:00
|
|
|
uiBridge.ConnectUnlikeButton(unlike)
|
2019-05-08 23:00:02 +00:00
|
|
|
uiBridge.ConnectFollowButton(follow)
|
2019-05-19 06:08:40 +00:00
|
|
|
uiBridge.ConnectUploadAttachment(uploadAttachment)
|
2019-05-05 16:21:38 +00:00
|
|
|
uiBridge.ConnectLoadConversation(loadConversation)
|
2019-05-06 18:16:20 +00:00
|
|
|
uiBridge.ConnectLoadAccount(loadAccount)
|
2020-03-03 05:28:52 +00:00
|
|
|
uiBridge.ConnectSearch(search)
|
2019-05-13 20:44:23 +00:00
|
|
|
uiBridge.ConnectTag(tag)
|
2019-05-13 20:42:03 +00:00
|
|
|
uiBridge.ConnectClosePane(closePane)
|
2019-05-06 18:16:20 +00:00
|
|
|
|
|
|
|
profileBridge = NewProfileBridge(nil)
|
2017-08-29 05:09:17 +00:00
|
|
|
|
|
|
|
/* uiBridge.ConnectRegisterToGo(func(object *core.QObject) {
|
|
|
|
qmlObjects[object.ObjectName()] = object
|
|
|
|
})
|
|
|
|
uiBridge.ConnectDeregisterToGo(func(objectName string) {
|
|
|
|
qmlObjects[objectName] = nil
|
|
|
|
}) */
|
|
|
|
}
|