mirror of
https://github.com/muesli/telephant
synced 2025-02-16 19:48:24 +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:"redirectURL"`
|
||||||
_ string `property:"theme"`
|
_ string `property:"theme"`
|
||||||
_ string `property:"style"`
|
_ string `property:"style"`
|
||||||
|
_ int `property:"positionX"`
|
||||||
|
_ int `property:"positionY"`
|
||||||
|
_ int `property:"width"`
|
||||||
|
_ int `property:"height"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
12
config.go
12
config.go
|
@ -17,10 +17,14 @@ type Account struct {
|
||||||
|
|
||||||
// Config holds telephant's config settings
|
// Config holds telephant's config settings
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Account []Account
|
Account []Account
|
||||||
Theme string
|
Theme string
|
||||||
Style string
|
Style string
|
||||||
FirstRun bool
|
PositionX int
|
||||||
|
PositionY int
|
||||||
|
Width int
|
||||||
|
Height int
|
||||||
|
FirstRun bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadConfig returns the current config as a Config struct
|
// LoadConfig returns the current config as a Config struct
|
||||||
|
|
|
@ -18,14 +18,29 @@ ApplicationWindow {
|
||||||
|
|
||||||
minimumWidth: 364
|
minimumWidth: 364
|
||||||
minimumHeight: 590
|
minimumHeight: 590
|
||||||
width: minimumWidth * 2
|
width: settings.width > 0 ? settings.width : minimumWidth * 2
|
||||||
height: minimumWidth * 1.5
|
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: {
|
Component.onCompleted: {
|
||||||
if (settings.firstRun) {
|
if (settings.firstRun) {
|
||||||
connectDialog.open()
|
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 {
|
Item {
|
||||||
AboutDialog {
|
AboutDialog {
|
||||||
|
|
|
@ -342,6 +342,10 @@ func main() {
|
||||||
configBridge.SetTheme(config.Theme)
|
configBridge.SetTheme(config.Theme)
|
||||||
configBridge.SetStyle(config.Style)
|
configBridge.SetStyle(config.Style)
|
||||||
configBridge.SetFirstRun(config.FirstRun)
|
configBridge.SetFirstRun(config.FirstRun)
|
||||||
|
configBridge.SetPositionX(config.PositionX)
|
||||||
|
configBridge.SetPositionY(config.PositionY)
|
||||||
|
configBridge.SetWidth(config.Width)
|
||||||
|
configBridge.SetHeight(config.Height)
|
||||||
|
|
||||||
setupMastodon(config.Account[0])
|
setupMastodon(config.Account[0])
|
||||||
runApp(config)
|
runApp(config)
|
||||||
|
@ -349,6 +353,10 @@ func main() {
|
||||||
// save config
|
// save config
|
||||||
config.Theme = configBridge.Theme()
|
config.Theme = configBridge.Theme()
|
||||||
config.Style = configBridge.Style()
|
config.Style = configBridge.Style()
|
||||||
|
config.PositionX = configBridge.PositionX()
|
||||||
|
config.PositionY = configBridge.PositionY()
|
||||||
|
config.Width = configBridge.Width()
|
||||||
|
config.Height = configBridge.Height()
|
||||||
config.FirstRun = false
|
config.FirstRun = false
|
||||||
SaveConfig(configFile, config)
|
SaveConfig(configFile, config)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue