예제 #1
0
파일: mainwindow.go 프로젝트: visualfc/goqt
func (w *MainWindow) saveFile(fileName string) bool {
	file := ui.NewFileWithName(fileName)
	defer file.Delete()
	if !file.Open(ui.QIODevice_WriteOnly | ui.QIODevice_Text) {
		return false
	}
	file.Write([]byte(w.edit.ToPlainText()))
	w.setCurrentFile(fileName)
	w.StatusBar().ShowMessageWithTextTimeout("File saved", 2000)
	return true
}
예제 #2
0
파일: mainwindow.go 프로젝트: visualfc/goqt
func (w *MainWindow) loadFile(filename string) {
	file := ui.NewFileWithName(filename)
	defer file.Delete()

	if !file.Open(ui.QIODevice_ReadOnly) {
		return
	}
	w.edit.SetPlainText(string(file.ReadAll()))
	w.setCurrentFile(filename)
	w.StatusBar().ShowMessageWithTextTimeout("File loaded", 2000)
}
예제 #3
0
파일: gui.go 프로젝트: s-rah/recoil
func (w *MainWindow) loadFile(filename, fileType string) {
	file := ui.NewFileWithName(filename)
	defer file.Delete()
	if !file.Open(ui.QIODevice_ReadOnly) {
		w.StatusBar().ShowMessage("Error: Failed to load message file.")
		return
	} else if fileType == "message" {
		w.editMessage.SetPlainText(string(file.ReadAll()))
		w.setCurrentMessageFile(filename)
		w.StatusBar().ShowMessage("Message loaded.")
	} else if fileType == "onion-hostname" {
		w.editHostname.SetText(string(file.ReadAll()))
		w.StatusBar().ShowMessage("Onion service hostname loaded.")
	} else if fileType == "onion-key" {
		w.editKey.SetPlainText(string(file.ReadAll()))
		w.StatusBar().ShowMessage("Onion service key loaded.")
	}
}
예제 #4
0
func NewCalclatorForm() (*CalclatorForm, error) {
	w := &CalclatorForm{}
	w.QWidget = ui.NewWidget()

	file := ui.NewFileWithName(":/forms/calculatorform.ui")
	if !file.Open(ui.QIODevice_ReadOnly) {
		return nil, errors.New("error load ui")
	}

	loader := ui.NewUiLoader()
	formWidget := loader.Load(file)
	if formWidget == nil {
		return nil, errors.New("error load form widget")
	}

	w.spinBox1 = ui.NewSpinBoxFromDriver(formWidget.FindChild("inputSpinBox1"))
	w.spinBox2 = ui.NewSpinBoxFromDriver(formWidget.FindChild("inputSpinBox2"))
	w.outputLable = ui.NewLabelFromDriver(formWidget.FindChild("outputWidget"))

	if ui.IsValidDriver(w.spinBox1) && ui.IsValidDriver(w.spinBox2) && ui.IsValidDriver(w.outputLable) {
		fnChanged := func() {
			w.outputLable.SetText(fmt.Sprintf("%d", w.spinBox1.Value()+w.spinBox2.Value()))
		}

		w.spinBox1.OnValueChanged(func(string) {
			fnChanged()
		})
		w.spinBox2.OnValueChanged(func(string) {
			fnChanged()
		})
	}

	layout := ui.NewVBoxLayout()
	layout.AddWidget(formWidget)
	w.SetLayout(layout)

	w.SetWindowTitle("Calculator Builder")
	return w, nil
}