86 lines
1.9 KiB
Go
86 lines
1.9 KiB
Go
package ui
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/cmd/v2/lib"
|
|
"go_dreamfactory/cmd/v2/lib/common"
|
|
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/container"
|
|
"fyne.io/fyne/v2/theme"
|
|
"fyne.io/fyne/v2/widget"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
var perfWin *PerfWindowImpl
|
|
|
|
type PerfWindow interface {
|
|
WindowInterface
|
|
}
|
|
|
|
type PerfWindowImpl struct {
|
|
UIImpl
|
|
parent fyne.Window
|
|
w fyne.Window
|
|
statusbar *statusBar //状态栏
|
|
tabs *appContainer //tabs
|
|
toolbar *toolBar //工具条
|
|
assistant lib.Aiassistant
|
|
}
|
|
|
|
func NewPerfWindow(ui *UIImpl, parent fyne.Window) PerfWindow {
|
|
|
|
pw := &PerfWindowImpl{
|
|
UIImpl: *ui,
|
|
parent: parent,
|
|
}
|
|
|
|
perfWin = pw
|
|
return pw
|
|
}
|
|
|
|
func (ui *PerfWindowImpl) GetWin() WindowInterface {
|
|
return perfWin
|
|
}
|
|
|
|
func (ui *PerfWindowImpl) CreateWindow(_ string, width, height float32, _ bool) {
|
|
title := fmt.Sprintf(common.APP_WIN_TITLE, "自动化性能测试工具", ui.app.Metadata().Version, ui.app.Metadata().Build, common.APP_NAME)
|
|
w := ui.app.NewWindow(title)
|
|
ui.AddWindow("main", w)
|
|
ui.w = w
|
|
|
|
w.Resize(fyne.NewSize(width, height))
|
|
w.CenterOnScreen()
|
|
w.SetCloseIntercept(func() {
|
|
ui.parent.Show()
|
|
})
|
|
|
|
ui.statusbar = newStatusBar()
|
|
toolbar := widget.NewToolbar(
|
|
widget.NewToolbarAction(theme.MediaVideoIcon(), func() {
|
|
openApp(ui.tabs, common.TOOLBAR_PERF_TIP)
|
|
}),
|
|
widget.NewToolbarAction(theme.MediaVideoIcon(), func() {
|
|
openApp(ui.tabs, common.TOOLBAR_PERF_CONF)
|
|
}),
|
|
)
|
|
ui.toolbar = newToolBar(toolbar)
|
|
|
|
ui.tabs = newAppContainer(appRegister, ui.pttService, ui.obs)
|
|
content := container.NewBorder(ui.toolbar.toolbar, ui.statusbar.widget, nil, nil, ui.tabs)
|
|
ui.w.SetContent(content)
|
|
|
|
defer func() {
|
|
appName, err := ui.tabs.openDefaultApp(common.TOOLBAR_PERF_TIP)
|
|
if err != nil {
|
|
logrus.WithField("appName", appName).Error(err)
|
|
}
|
|
}()
|
|
|
|
w.SetCloseIntercept(func() {
|
|
ui.parent.Show()
|
|
w.Close()
|
|
})
|
|
w.Show()
|
|
}
|