uic: support QTabWidget.title, QDockWidget locations

This commit is contained in:
mappu 2024-09-28 14:39:56 +12:00
parent 18e30eaf70
commit 7de20812b2
2 changed files with 17 additions and 1 deletions

View File

@ -82,11 +82,24 @@ func generateWidget(w UiWidget, parentName string, parentClass string) (string,
ret.WriteString(`ui.` + w.Name + setterFunc + `(qt.` + strings.Replace(*prop.EnumVal, `::`, `__`, -1) + ")\n")
} else {
ret.WriteString("/* miqt-uic: no handler for property '" + prop.Name + "' */\n")
ret.WriteString("/* miqt-uic: no handler for " + w.Name + " property '" + prop.Name + "' */\n")
}
}
// Attributes
for _, attr := range w.Attributes {
if parentClass == "QTabWidget" && attr.Name == "title" {
ret.WriteString(parentName + `.SetTabText(` + parentName + ".IndexOf(ui." + w.Name + "), " + generateString(attr.StringVal, parentClass) + ")\n")
} else if w.Class == "QDockWidget" && parentClass == "QMainWindow" && attr.Name == "dockWidgetArea" {
ret.WriteString(parentName + `.AddDockWidget(qt.DockWidgetArea(` + *attr.NumberVal + `), ui.` + w.Name + `)` + "\n")
} else {
ret.WriteString("/* miqt-uic: no handler for " + w.Name + " attribute '" + attr.Name + "' */\n")
}
}
// TODO
// w.Attributes

View File

@ -117,6 +117,7 @@ func NewMainWindowUi() *MainWindowUi {
ui.dockWidget = qt.NewQDockWidget5(ui.MainWindow.QWidget)
ui.dockWidget.SetObjectName("dockWidget")
ui.MainWindow.AddDockWidget(qt.DockWidgetArea(1), ui.dockWidget)
ui.dockWidgetContents = qt.NewQWidget2(ui.dockWidget.QWidget)
ui.dockWidgetContents.SetObjectName("dockWidgetContents")
@ -140,10 +141,12 @@ func (ui *MainWindowUi) Retranslate() {
ui.action_New.SetText(qt.QMainWindow_Tr("&New..."))
ui.actionE_xit.SetText(qt.QMainWindow_Tr("E&xit"))
ui.actionE_xit.SetShortcut(qt.NewQKeySequence2(qt.QMainWindow_Tr("Ctrl+Q")))
ui.tabWidget.SetTabText(ui.tabWidget.IndexOf(ui.tab), qt.QTabWidget_Tr("Tab 1"))
ui.label.SetText(qt.QWidget_Tr("Dropdown:"))
ui.comboBox.SetItemText(0, qt.QComboBox_Tr("First"))
ui.comboBox.SetItemText(1, qt.QComboBox_Tr("Second"))
ui.label_2.SetText(qt.QWidget_Tr("Number:"))
ui.tabWidget.SetTabText(ui.tabWidget.IndexOf(ui.tab_2), qt.QTabWidget_Tr("Tab 2"))
ui.menu_File.SetTitle(qt.QMenuBar_Tr("&File"))
ui.dockWidget.SetWindowTitle(qt.QMainWindow_Tr("Dock Title"))
}