add configure to prevent wshub event execution.

This commit is contained in:
aynakeya
2024-08-27 17:18:12 -07:00
parent 7960299f09
commit 539e8eabe3
4 changed files with 25 additions and 17 deletions

View File

@@ -1,14 +1,14 @@
package xfyne
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/widget"
"reflect"
)
func EntryDisableUndoRedo(entry *widget.Entry) *widget.Entry {
val := reflect.ValueOf(entry).Elem().FieldByName("shortcut").Addr().UnsafePointer()
(*fyne.ShortcutHandler)(val).RemoveShortcut(&fyne.ShortcutRedo{})
(*fyne.ShortcutHandler)(val).RemoveShortcut(&fyne.ShortcutUndo{})
// do nothing because the bug has been fixed in fyne@v2.5.1
return entry
//val := reflect.ValueOf(entry).Elem().FieldByName("shortcut").Addr().UnsafePointer()
//(*fyne.ShortcutHandler)(val).RemoveShortcut(&fyne.ShortcutRedo{})
//(*fyne.ShortcutHandler)(val).RemoveShortcut(&fyne.ShortcutUndo{})
//return entry
}

View File

@@ -48,8 +48,10 @@ func (c *wsClient) start() {
global.Logger.Warn("unmarshal event data failed", err)
return
}
if globalEnableWsHubControl {
global.EventManager.CallA(data.EventID, actualEventData)
}
}
}
type wsServer struct {

View File

@@ -23,6 +23,7 @@ type WsHub struct {
Enabled bool
Port int
LocalHostOnly bool
EnableWsHubControl bool
panel fyne.CanvasObject
server *wsServer
log logger.ILogger
@@ -33,12 +34,17 @@ func NewWsHub() *WsHub {
Enabled: false,
Port: 29629,
LocalHostOnly: true,
EnableWsHubControl: false,
log: global.Logger.WithPrefix("plugin.wshub"),
}
}
var globalEnableWsHubControl = false
func (w *WsHub) Enable() error {
config.LoadConfig(w)
// todo: should pass EnableWsHubControl to client instead of using global variable
globalEnableWsHubControl = w.EnableWsHubControl
w.server = newWsServer(&w.Port, &w.LocalHostOnly)
gui.AddConfigLayout(w)
w.registerEvents()

View File

@@ -18,7 +18,7 @@
----
Finished
- 2024.08.25 : 添加是否播放闲置歌单选项,修复退出时panic的问题
- 2024.08.25 : 添加是否播放闲置歌单选项,修复退出时panic的导致配置无法正确保存的问题
- 2024.08.14 : 网页输出模版上线
- 2024.08.06 : 修复使用身份码连接的时候房管无法切歌的问题
- 2024.07.25 : 或许修复配置无法正确保存的问题