redis: initial work on connection dialog
This commit is contained in:
parent
bc82aacd57
commit
04ef53720f
14
main.go
14
main.go
@ -44,6 +44,7 @@ func (f *TMainForm) OnFormCreate(sender vcl.IObject) {
|
||||
f.ImageList = loadImages(f)
|
||||
|
||||
f.SetCaption("yvbolt")
|
||||
f.ScreenCenter()
|
||||
f.ImageList.GetIcon(imgDatabaseLightning, f.Icon())
|
||||
|
||||
mnuFile := vcl.NewMenuItem(f)
|
||||
@ -74,6 +75,12 @@ func (f *TMainForm) OnFormCreate(sender vcl.IObject) {
|
||||
mnuFileSqliteMemory.SetOnClick(f.OnMnuFileSqliteMemoryClick)
|
||||
mnuFile.Add(mnuFileSqliteMemory)
|
||||
|
||||
mnuFileRedisConnect := vcl.NewMenuItem(mnuFile)
|
||||
mnuFileRedisConnect.SetCaption("Connect to Redis...")
|
||||
mnuFileRedisConnect.SetImageIndex(imgDatabaseAdd)
|
||||
mnuFileRedisConnect.SetOnClick(f.OnMnuFileRedisConnectClick)
|
||||
mnuFile.Add(mnuFileRedisConnect)
|
||||
|
||||
mnuSep := vcl.NewMenuItem(mnuFile)
|
||||
mnuSep.SetCaption("-") // Creates separator
|
||||
mnuFile.Add(mnuSep)
|
||||
@ -234,6 +241,13 @@ func (f *TMainForm) OnMnuFileSqliteMemoryClick(sender vcl.IObject) {
|
||||
f.sqliteAddDatabaseFromFile(`:memory:`)
|
||||
}
|
||||
|
||||
func (f *TMainForm) OnMnuFileRedisConnectClick(sender vcl.IObject) {
|
||||
var child *TRedisConnectionDialog
|
||||
vcl.Application.CreateForm(&child)
|
||||
child.ShowModal()
|
||||
child.Free()
|
||||
}
|
||||
|
||||
func (f *TMainForm) OnMnuFileExitClick(sender vcl.IObject) {
|
||||
f.Close()
|
||||
}
|
||||
|
91
redisConnectionDialog.go
Normal file
91
redisConnectionDialog.go
Normal file
@ -0,0 +1,91 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/ying32/govcl/vcl"
|
||||
"github.com/ying32/govcl/vcl/types"
|
||||
)
|
||||
|
||||
type TRedisConnectionDialog struct {
|
||||
*vcl.TForm
|
||||
|
||||
Address *vcl.TEdit
|
||||
Port *vcl.TSpinEdit
|
||||
Password *vcl.TEdit
|
||||
IsResp3Protocol *vcl.TCheckBox
|
||||
}
|
||||
|
||||
func (f *TRedisConnectionDialog) OnFormCreate(sender vcl.IObject) {
|
||||
|
||||
f.SetCaption("Connect to Redis...")
|
||||
f.ScreenCenter()
|
||||
|
||||
// row 1
|
||||
|
||||
row1 := vcl.NewPanel(f)
|
||||
row1.SetParent(f)
|
||||
row1.SetBorderStyle(types.BsNone)
|
||||
row1.SetAlign(types.AlTop)
|
||||
row1.SetTop(1)
|
||||
row1.SetAutoSize(true)
|
||||
|
||||
lblAddress := vcl.NewStaticText(row1)
|
||||
lblAddress.SetParent(row1)
|
||||
lblAddress.SetCaption("Address:")
|
||||
lblAddress.SetAlign(types.AlLeft)
|
||||
lblAddress.SetLeft(1)
|
||||
//lblAddress.SetAutoSize(true)
|
||||
|
||||
f.Address = vcl.NewEdit(row1)
|
||||
f.Address.SetParent(row1)
|
||||
f.Address.SetAlign(types.AlLeft)
|
||||
f.Address.SetWidth(MY_WIDTH)
|
||||
f.Address.SetLeft(2)
|
||||
|
||||
lblPort := vcl.NewStaticText(row1)
|
||||
lblPort.SetParent(row1)
|
||||
lblPort.SetCaption(":")
|
||||
lblPort.SetAlign(types.AlLeft)
|
||||
lblPort.SetLeft(3)
|
||||
lblPort.SetAutoSize(true)
|
||||
|
||||
f.Port = vcl.NewSpinEdit(row1)
|
||||
f.Port.SetParent(row1)
|
||||
f.Port.SetMinValue(1)
|
||||
f.Port.SetMaxValue(65535)
|
||||
f.Port.SetValue(6379) // Redis default port
|
||||
f.Port.SetAlign(types.AlLeft)
|
||||
f.Port.SetLeft(4)
|
||||
|
||||
// row 2
|
||||
|
||||
row2 := vcl.NewPanel(f)
|
||||
row2.SetParent(f)
|
||||
row2.SetBorderStyle(types.BsNone)
|
||||
row2.SetAlign(types.AlTop)
|
||||
row2.SetTop(2)
|
||||
row2.SetAutoSize(true)
|
||||
|
||||
lblPassword := vcl.NewStaticText(row2)
|
||||
lblPassword.SetParent(row2)
|
||||
lblPassword.SetCaption("Password:")
|
||||
lblPassword.SetAlign(types.AlLeft)
|
||||
lblPassword.SetLeft(1)
|
||||
// lblPassword.SetAutoSize(true)
|
||||
|
||||
f.Password = vcl.NewEdit(row2)
|
||||
f.Password.SetParent(row2)
|
||||
f.Password.SetAlign(types.AlLeft)
|
||||
f.Password.SetLeft(2)
|
||||
f.Password.SetWidth(MY_WIDTH)
|
||||
f.Password.SetPasswordChar(uint16('*'))
|
||||
|
||||
// row 3
|
||||
|
||||
f.IsResp3Protocol = vcl.NewCheckBox(f)
|
||||
f.IsResp3Protocol.SetParent(f)
|
||||
f.IsResp3Protocol.SetCaption("Use RESP v3 protocol")
|
||||
f.IsResp3Protocol.SetChecked(true)
|
||||
f.IsResp3Protocol.SetAlign(types.AlTop)
|
||||
f.IsResp3Protocol.SetTop(3)
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user