github.com/jonasnick/go-ethereum@v0.7.12-0.20150216215225-22176f05d387/cmd/mist/errors.go (about)

     1  /*
     2  	This file is part of go-ethereum
     3  
     4  	go-ethereum is free software: you can redistribute it and/or modify
     5  	it under the terms of the GNU General Public License as published by
     6  	the Free Software Foundation, either version 3 of the License, or
     7  	(at your option) any later version.
     8  
     9  	go-ethereum is distributed in the hope that it will be useful,
    10  	but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  	GNU General Public License for more details.
    13  
    14  	You should have received a copy of the GNU General Public License
    15  	along with go-ethereum.  If not, see <http://www.gnu.org/licenses/>.
    16  */
    17  /**
    18   * @authors
    19   * 	Jeffrey Wilcke <i@jev.io>
    20   */
    21  package main
    22  
    23  import (
    24  	"fmt"
    25  	"os"
    26  
    27  	"github.com/obscuren/qml"
    28  )
    29  
    30  func ErrorWindow(err error) {
    31  	engine := qml.NewEngine()
    32  	component, e := engine.LoadString("local", qmlErr)
    33  	if e != nil {
    34  		fmt.Println("err:", err)
    35  		os.Exit(1)
    36  	}
    37  
    38  	win := component.CreateWindow(nil)
    39  	win.Root().ObjectByName("label").Set("text", err.Error())
    40  	win.Show()
    41  	win.Wait()
    42  }
    43  
    44  const qmlErr = `
    45  import QtQuick 2.0; import QtQuick.Controls 1.0;
    46  ApplicationWindow {
    47  	width: 600; height: 150;
    48  	flags: Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowCloseButtonHint
    49  	title: "Error"
    50  	Text {
    51  		x: parent.width / 2 - this.width / 2;
    52  		y: parent.height / 2 - this.height / 2;
    53  		objectName: "label";
    54  	}
    55  }
    56  `