mirror of
https://github.com/muesli/telephant
synced 2024-11-10 05:54:19 +00:00
Store and restore window state on startup
This commit is contained in:
parent
deaae7beab
commit
53855adda8
4 changed files with 37 additions and 6 deletions
|
@ -78,6 +78,10 @@ type ConfigBridge struct {
|
|||
_ string `property:"redirectURL"`
|
||||
_ string `property:"theme"`
|
||||
_ string `property:"style"`
|
||||
_ int `property:"positionX"`
|
||||
_ int `property:"positionY"`
|
||||
_ int `property:"width"`
|
||||
_ int `property:"height"`
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
12
config.go
12
config.go
|
@ -17,10 +17,14 @@ type Account struct {
|
|||
|
||||
// Config holds telephant's config settings
|
||||
type Config struct {
|
||||
Account []Account
|
||||
Theme string
|
||||
Style string
|
||||
FirstRun bool
|
||||
Account []Account
|
||||
Theme string
|
||||
Style string
|
||||
PositionX int
|
||||
PositionY int
|
||||
Width int
|
||||
Height int
|
||||
FirstRun bool
|
||||
}
|
||||
|
||||
// LoadConfig returns the current config as a Config struct
|
||||
|
|
|
@ -18,14 +18,29 @@ ApplicationWindow {
|
|||
|
||||
minimumWidth: 364
|
||||
minimumHeight: 590
|
||||
width: minimumWidth * 2
|
||||
height: minimumWidth * 1.5
|
||||
width: settings.width > 0 ? settings.width : minimumWidth * 2
|
||||
height: settings.height > 0 ? settings.height : minimumWidth * 1.5
|
||||
Binding on x {
|
||||
when: settings.positionX > 0
|
||||
value: settings.positionX
|
||||
}
|
||||
Binding on y {
|
||||
when: settings.positionY > 0
|
||||
value: settings.positionY
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (settings.firstRun) {
|
||||
connectDialog.open()
|
||||
}
|
||||
}
|
||||
onClosing: function() {
|
||||
console.log("Closing mainWindow")
|
||||
settings.positionX = mainWindow.x
|
||||
settings.positionY = mainWindow.y
|
||||
settings.width = mainWindow.width
|
||||
settings.height = mainWindow.height
|
||||
}
|
||||
|
||||
Item {
|
||||
AboutDialog {
|
||||
|
|
|
@ -342,6 +342,10 @@ func main() {
|
|||
configBridge.SetTheme(config.Theme)
|
||||
configBridge.SetStyle(config.Style)
|
||||
configBridge.SetFirstRun(config.FirstRun)
|
||||
configBridge.SetPositionX(config.PositionX)
|
||||
configBridge.SetPositionY(config.PositionY)
|
||||
configBridge.SetWidth(config.Width)
|
||||
configBridge.SetHeight(config.Height)
|
||||
|
||||
setupMastodon(config.Account[0])
|
||||
runApp(config)
|
||||
|
@ -349,6 +353,10 @@ func main() {
|
|||
// save config
|
||||
config.Theme = configBridge.Theme()
|
||||
config.Style = configBridge.Style()
|
||||
config.PositionX = configBridge.PositionX()
|
||||
config.PositionY = configBridge.PositionY()
|
||||
config.Width = configBridge.Width()
|
||||
config.Height = configBridge.Height()
|
||||
config.FirstRun = false
|
||||
SaveConfig(configFile, config)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue