mirror of
https://github.com/mappu/miqt.git
synced 2025-01-02 21:58:38 +00:00
examples/mdoutliner: initial work on tab closing
This commit is contained in:
parent
04692b78f8
commit
9a23c644c1
@ -22,8 +22,7 @@ type AppWindow struct {
|
||||
w *qt.QMainWindow
|
||||
cw *qt.QWidget
|
||||
|
||||
tabs *qt.QTabWidget
|
||||
tabData []AppTab
|
||||
tabs *qt.QTabWidget
|
||||
}
|
||||
|
||||
type AppTab struct {
|
||||
@ -100,6 +99,11 @@ func NewAppWindow() *AppWindow {
|
||||
// Main widgets
|
||||
|
||||
ret.tabs = qt.NewQTabWidget2(ret.w.QWidget)
|
||||
ret.tabs.SetTabsClosable(true)
|
||||
ret.tabs.OnTabCloseRequested(func() {
|
||||
ret.handleTabClose(ret.tabs.CurrentIndex()) // FIXME need to get this from the signal
|
||||
})
|
||||
|
||||
ret.w.SetCentralWidget(ret.tabs.QWidget)
|
||||
|
||||
// Add initial tab
|
||||
@ -113,6 +117,10 @@ func NewAppWindow() *AppWindow {
|
||||
return &ret
|
||||
}
|
||||
|
||||
func (a *AppWindow) handleTabClose(tabIndex int) {
|
||||
a.tabs.RemoveTab(tabIndex)
|
||||
}
|
||||
|
||||
func (a *AppWindow) handleFileOpen() {
|
||||
fname := qt.QFileDialog_GetOpenFileName4(a.w.QWidget, "Open markdown file...", "", "Markdown files (*.md *.txt);;All Files (*)")
|
||||
if fname == "" {
|
||||
|
Loading…
Reference in New Issue
Block a user