From c0a05fcf8984f04f198c5c0f8be4f73090f99403 Mon Sep 17 00:00:00 2001 From: zelig Date: Thu, 26 Jun 2014 12:13:31 +0100 Subject: [PATCH] log slider - only add the gui logger after window is shown otherwise slider wont be shown - need to silence gui logger after window closed otherwise logsystem hangs - gui.GetLogLevelInt() extra function needed to give correcty int typecast value to gui widget that sets initial loglevel to default --- ethereal/assets/qml/wallet.qml | 2 +- ethereal/ui/gui.go | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml index eb3aa6df5..84f8fd5cf 100644 --- a/ethereal/assets/qml/wallet.qml +++ b/ethereal/assets/qml/wallet.qml @@ -319,7 +319,7 @@ ApplicationWindow { Slider { id: logLevelSlider - value: eth.getLogLevel() + value: eth.getLogLevelInt() anchors { right: parent.right top: parent.top diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go index f3a918ea0..8845f6af3 100644 --- a/ethereal/ui/gui.go +++ b/ethereal/ui/gui.go @@ -90,11 +90,12 @@ func (gui *Gui) Start(assetPath string) { var win *qml.Window var err error + var addlog = false if len(data) == 0 { win, err = gui.showKeyImport(context) } else { win, err = gui.showWallet(context) - ethlog.AddLogSystem(gui) + addlog = true } if err != nil { logger.Errorln("asset not found: you can set an alternative asset path on the command line using option 'asset_path'", err) @@ -105,8 +106,13 @@ func (gui *Gui) Start(assetPath string) { logger.Infoln("Starting GUI") win.Show() + // only add the gui logger after window is shown otherwise slider wont be shown + if addlog { + ethlog.AddLogSystem(gui) + } win.Wait() - + // need to silence gui logger after window closed otherwise logsystem hangs + gui.SetLogLevel(ethlog.Silence) gui.eth.Stop() } @@ -353,6 +359,12 @@ func (gui *Gui) GetLogLevel() ethlog.LogLevel { return gui.logLevel } +// this extra function needed to give int typecast value to gui widget +// that sets initial loglevel to default +func (gui *Gui) GetLogLevelInt() int { + return int(gui.logLevel) +} + func (gui *Gui) Println(v ...interface{}) { gui.printLog(fmt.Sprintln(v...)) }