reuse of flashcard elements and other fixes

This commit is contained in:
jorenchik
2024-09-10 12:50:15 +03:00
parent f154f1a255
commit cd1ef1bb44
6 changed files with 606 additions and 175 deletions

View File

@@ -0,0 +1,245 @@
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- [cap_est] What is the capital of Estonia? >
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin
- Tallin

View File

@@ -0,0 +1,110 @@
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga
- [cap_riga] What is the capital of Latvia? >
- Riga

23
src/mdemory-app-qt/.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
},
{
"name": "Debug Go Program",
"type": "go",
"request": "launch",
"mode": "exec",
"program": "${workspaceFolder}/mdemory_debug",
"args": []
}
]
}

View File

@@ -1,5 +1,8 @@
package main package main
// TODO: open flashcard with many answers and switch mdem file,
// it remains opens with the same options -> Rehide the answers.
import ( import (
"fmt" "fmt"
"os" "os"
@@ -12,31 +15,53 @@ import (
"github.com/therecipe/qt/widgets" "github.com/therecipe/qt/widgets"
) )
var mdems []*widgets.QWidget var hMdemScroll *widgets.QVBoxLayout
var hMdemScroll *widgets.QVBoxLayout var mdemSpacer *widgets.QSpacerItem
var mdemSpacer *widgets.QSpacerItem
var spacerInitialized bool = false var spacerInitialized bool = false
var workingPath string = "/home/jorenchik/Code/mdemory/memorybase" var workingPath string = "/home/jorenchik/Code/mdemory/memorybase"
func CreateMdem(frontText string, backTexts []string) *widgets.QWidget { type Mdem struct {
// frontText := "What is the capital of Latvia?" wMdem *widgets.QWidget;
wFrontText *widgets.QLabel;
wBack *widgets.QWidget;
backLabels []*widgets.QLabel;
showButton *widgets.QToolButton;
labelCount int;
}
// DefineMdem var mdems []*Mdem
wMdem := widgets.NewQWidget(nil, 0)
vMdem := widgets.NewQVBoxLayout()
wMdem.SetLayout(vMdem) func (mdem *Mdem) showBacklabels() {
id := fmt.Sprintf("mdem_%d", 1) for i := range(len(mdem.backLabels)) {
wMdem.SetObjectName(id) if i < mdem.labelCount {
if !mdem.backLabels[i].IsVisible() {
mdem.backLabels[i].Show()
}
} else {
if mdem.backLabels[i].IsVisible() {
mdem.backLabels[i].Hide()
}
}
}
}
// InitFront func CreateMdem() *Mdem {
wFront := widgets.NewQWidget(nil, 0)
hFront := widgets.NewQHBoxLayout() // DefineMdem
wFront.SetMinimumHeight(60) wMdem := widgets.NewQWidget(nil, 0)
// wFront.SetMaximumHeight(60) vMdem := widgets.NewQVBoxLayout()
wFront.SetLayout(hFront)
wFront.SetProperty("first", core.NewQVariant1(true)); wMdem.SetLayout(vMdem)
wMdem.SetStyleSheet(fmt.Sprintf(` id := fmt.Sprintf("mdem_%d", 1)
wMdem.SetObjectName(id)
// InitFront
wFront := widgets.NewQWidget(nil, 0)
hFront := widgets.NewQHBoxLayout()
wFront.SetMinimumHeight(60)
wFront.SetLayout(hFront)
wFront.SetProperty("first", core.NewQVariant1(true))
wMdem.SetStyleSheet(fmt.Sprintf(`
QWidget#%s > QWidget { QWidget#%s > QWidget {
border-right: 1px solid gray; border-right: 1px solid gray;
border-bottom: 1px solid gray; border-bottom: 1px solid gray;
@@ -47,174 +72,196 @@ func CreateMdem(frontText string, backTexts []string) *widgets.QWidget {
} }
`, id, id)) `, id, id))
// AddFrontContent // AddFrontContent
elFrontText := widgets.NewQLabel2(frontText, nil, 0) elFrontText := widgets.NewQLabel(nil, 0)
hFront.AddWidget(elFrontText, 0, 0) hFront.AddWidget(elFrontText, 0, 0)
hFront.AddStretch(1) hFront.AddStretch(1)
hideButton := widgets.NewQToolButton(nil) showAnswer := widgets.NewQToolButton(nil)
showAnswer := widgets.NewQToolButton(nil) showAnswer.SetText("Show")
hideButton.SetText("Hide") hFront.AddWidget(showAnswer, 0, 0)
showAnswer.SetText("Show")
hFront.AddWidget(hideButton, 0, 0)
hFront.AddWidget(showAnswer, 0, 0)
wBack := widgets.NewQWidget(nil, 0) wBack := widgets.NewQWidget(nil, 0)
hBack := widgets.NewQVBoxLayout() hBack := widgets.NewQVBoxLayout()
// wBack.SetMinimumHeight(60) wBack.SetLayout(hBack)
wBack.SetLayout(hBack) vMdem.AddWidget(wBack, 0, 0)
vMdem.AddWidget(wBack, 0, 0) // AddBackContent
// AddBackContent var backLabels []*widgets.QLabel
for i := range(backTexts) { for range(20) {
backText := strings.Trim(backTexts[i], " \t\n") elBackText := widgets.NewQLabel(nil, 0)
elBackText := widgets.NewQLabel2(
fmt.Sprintf("- %s", backText),
nil,
0,
)
hBack.AddWidget(elBackText, 0, 0) hBack.AddWidget(elBackText, 0, 0)
backLabels = append(backLabels, elBackText)
} }
hBack.AddStretch(1)
vMdem.AddWidget(wFront, 0, 0) vMdem.AddWidget(wFront, 0, 0)
vMdem.AddWidget(wBack, 0, 0) vMdem.AddWidget(wBack, 0, 0)
vMdem.SetContentsMargins(0,0,0,0) vMdem.SetContentsMargins(0, 0, 0, 0)
vMdem.SetSpacing(0) vMdem.SetSpacing(0)
wBack.Hide() wBack.Hide()
hideButton.ConnectClicked(func(checked bool) { wMdem.Hide()
if wBack.IsVisible() { mdem := Mdem{
wBack.Hide() wMdem,
} elFrontText,
}) wBack,
showAnswer.ConnectClicked(func(checked bool) { backLabels,
if !wBack.IsVisible() { showAnswer,
wBack.Show() 0,
}
mdem.showButton.ConnectClicked(func(checked bool) {
if mdem.wBack.IsVisible() {
mdem.wBack.Hide()
mdem.showButton.SetText("Show")
} else {
mdem.wBack.Show()
mdem.showButton.SetText("Hide")
} }
mdem.showBacklabels()
}) })
return wMdem return &mdem
} }
func CreateMdems(questions *[]parser.Question) { func CreateMdems(questions *[]parser.Question) {
if spacerInitialized { if spacerInitialized {
hMdemScroll.RemoveItem(mdemSpacer) hMdemScroll.RemoveItem(mdemSpacer)
} } else {
for i := range(mdems) { mdemSpacer = widgets.NewQSpacerItem(
hMdemScroll.RemoveWidget(mdems[i]) 0, 0, widgets.QSizePolicy__Maximum, widgets.QSizePolicy__Minimum,
mdems[i].Hide() )
mdems[i].DeleteLater() }
}
// destroy widgets for i := range mdems {
mdems = nil if mdems[i].wMdem.IsVisible() {
for i := range(*questions) { mdems[i].wMdem.Hide()
question := (*questions)[i] }
switch question.(type) { }
case parser.SingleAnswerQuestion:
mdems = append( if len(*questions) > len(mdems) {
mdems, for range(len(*questions) - len(mdems)) {
CreateMdem( mdem := CreateMdem()
question.(parser.SingleAnswerQuestion).Question, mdems = append(mdems, mdem)
[]string{ hMdemScroll.AddWidget(mdem.wMdem, 0, 0)
question.(parser.SingleAnswerQuestion).Answer,
},
),
)
case parser.MultipleChoiceQuestion:
var answers []string
choices := question.(parser.MultipleChoiceQuestion).Choices
for i := range(choices) {
answers = append(answers, choices[i].Answer)
}
mdems = append(
mdems,
CreateMdem(
question.(parser.MultipleChoiceQuestion).Question,
answers,
),
)
} }
} }
for i := 0; i < len(mdems); i++ {
hMdemScroll.AddWidget(mdems[i], 0, 0)
}
if !spacerInitialized { for i := range *questions {
mdemSpacer = widgets.NewQSpacerItem( question := (*questions)[i]
40, switch question.(type) {
40, case parser.SingleAnswerQuestion:
widgets.QSizePolicy__Minimum, mdems[i].wFrontText.SetText(
widgets.QSizePolicy__Expanding, question.(parser.SingleAnswerQuestion).Question,
) )
spacerInitialized = true answer := strings.Trim(
} question.(parser.SingleAnswerQuestion).Answer, " \t\n",
hMdemScroll.AddItem(mdemSpacer) )
mdems[i].backLabels[0].SetText(answer)
if mdems[i].wBack.IsVisible() {
mdems[i].wBack.Hide()
}
mdems[i].labelCount = 1
case parser.MultipleChoiceQuestion:
choices := question.(parser.MultipleChoiceQuestion).Choices
mdems[i].wFrontText.SetText(
question.(parser.MultipleChoiceQuestion).Question,
)
for k := range choices {
answer := strings.Trim(choices[k].Answer, " \t\n")
if k < len(mdems[i].backLabels) {
mdems[i].backLabels[k].SetText(answer)
} else {
label := widgets.NewQLabel2(answer, nil, 0)
mdems[i].backLabels = append(
mdems[i].backLabels,
label,
)
mdems[i].wBack.Layout().AddWidget(label)
}
}
mdems[i].labelCount = len(choices)
}
if !mdems[i].wMdem.IsVisible() {
mdems[i].wMdem.Show()
}
}
if !spacerInitialized {
mdemSpacer = widgets.NewQSpacerItem(
40,
40,
widgets.QSizePolicy__Minimum,
widgets.QSizePolicy__Expanding,
)
spacerInitialized = true
}
hMdemScroll.AddItem(mdemSpacer)
} }
func main() { func main() {
// InitApp // InitApp
app := widgets.NewQApplication(len(os.Args), os.Args) app := widgets.NewQApplication(len(os.Args), os.Args)
window := widgets.NewQMainWindow(nil, 0) window := widgets.NewQMainWindow(nil, 0)
hSplitter := widgets.NewQSplitter(nil) hSplitter := widgets.NewQSplitter(nil)
window.SetWindowTitle("MDemory") window.SetWindowTitle("MDemory")
window.SetMinimumSize2(400, 300) window.SetMinimumSize2(400, 300)
leftWidget := widgets.NewQWidget(nil, 0) leftWidget := widgets.NewQWidget(nil, 0)
leftLayout := widgets.NewQVBoxLayout() leftLayout := widgets.NewQVBoxLayout()
mdemLabel := widgets.NewQLabel2("Mdems", nil, 0) mdemLabel := widgets.NewQLabel2("Mdems", nil, 0)
model := widgets.NewQFileSystemModel(nil) model := widgets.NewQFileSystemModel(nil)
mdemList := widgets.NewQTreeView(nil) mdemList := widgets.NewQTreeView(nil)
leftWidget.SetLayout(leftLayout) leftWidget.SetLayout(leftLayout)
leftLayout.AddWidget(mdemLabel, 0, 0) leftLayout.AddWidget(mdemLabel, 0, 0)
model.SetRootPath(workingPath) model.SetRootPath(workingPath)
mdemList.SetModel(model) mdemList.SetModel(model)
rootIndex := model.Index2("/home/jorenchik/Code/mdemory/memorybase", 0) rootIndex := model.Index2("/home/jorenchik/Code/mdemory/memorybase", 0)
fmt.Printf("Root index: %s\n", model.FileName(rootIndex)) fmt.Printf("Root index: %s\n", model.FileName(rootIndex))
mdemList.SetRootIndex(rootIndex) mdemList.SetRootIndex(rootIndex)
mdemList.HideColumn(1) mdemList.HideColumn(1)
mdemList.HideColumn(2) mdemList.HideColumn(2)
mdemList.HideColumn(3) mdemList.HideColumn(3)
mdemList.ConnectDoubleClicked(func(index *core.QModelIndex) { mdemList.ConnectDoubleClicked(func(index *core.QModelIndex) {
if model.IsDir(index) { if model.IsDir(index) {
return return
} }
filePath := model.FilePath(index) filePath := model.FilePath(index)
fileContents, err := os.ReadFile(filePath) fileContents, err := os.ReadFile(filePath)
if (err != nil) { if err != nil {
widgets.QMessageBox_Critical( widgets.QMessageBox_Critical(
nil, nil,
"Compilation error", "Compilation error",
err.Error(), err.Error(),
widgets.QMessageBox__Ok, widgets.QMessageBox__Ok,
widgets.QMessageBox__Ok, widgets.QMessageBox__Ok,
) )
return return
} }
start := time.Now().UnixMicro() start := time.Now().UnixMicro()
questions, err := api.Compile(string(fileContents)) questions, err := api.Compile(string(fileContents))
if (err != nil) { if err != nil {
widgets.QMessageBox_Critical( widgets.QMessageBox_Critical(
nil, nil,
"Compilation error", "Compilation error",
err.Error(), err.Error(),
widgets.QMessageBox__Ok, widgets.QMessageBox__Ok,
widgets.QMessageBox__Ok, widgets.QMessageBox__Ok,
) )
return return
} }
duration := float32(time.Now().UnixMicro() - start) / 1000 duration := float32(time.Now().UnixMicro()-start) / 1000
fmt.Printf("Compilation took %.3fms", duration) fmt.Printf("Compilation took %.3fms", duration)
CreateMdems(&questions)
// Take a slice (mock pagination for now)
questions = questions[0:10]
CreateMdems(&questions)
}) })
deckLabel := widgets.NewQLabel2("Decks", nil, 0) deckLabel := widgets.NewQLabel2("Decks", nil, 0)
deckList := widgets.NewQListView(nil) deckList := widgets.NewQListView(nil)
leftLayout.AddWidget(mdemList, 1, 0) leftLayout.AddWidget(mdemList, 1, 0)
leftLayout.AddWidget(deckLabel, 0, 0) leftLayout.AddWidget(deckLabel, 0, 0)
leftLayout.AddWidget(deckList, 1, 0) leftLayout.AddWidget(deckList, 1, 0)
@@ -223,17 +270,17 @@ func main() {
rightLayout := widgets.NewQVBoxLayout() rightLayout := widgets.NewQVBoxLayout()
rightWidget.SetLayout(rightLayout) rightWidget.SetLayout(rightLayout)
top := widgets.NewQWidget(nil, 0) top := widgets.NewQWidget(nil, 0)
hTop := widgets.NewQHBoxLayout() hTop := widgets.NewQHBoxLayout()
deckListLabel := widgets.NewQLabel2("Mdem: file.mdem", nil, 0) deckListLabel := widgets.NewQLabel2("Mdem: file.mdem", nil, 0)
top.SetLayout(hTop) top.SetLayout(hTop)
rightLayout.AddWidget(top, 0, 0) rightLayout.AddWidget(top, 0, 0)
hTop.AddWidget(deckListLabel, 0, 0) hTop.AddWidget(deckListLabel, 0, 0)
hTop.AddStretch(1) hTop.AddStretch(1)
refresh := widgets.NewQToolButton(nil) refresh := widgets.NewQToolButton(nil)
practice := widgets.NewQToolButton(nil) practice := widgets.NewQToolButton(nil)
shuffle := widgets.NewQToolButton(nil) shuffle := widgets.NewQToolButton(nil)
hTop.AddWidget(refresh, 0, 0) hTop.AddWidget(refresh, 0, 0)
hTop.AddWidget(shuffle, 0, 0) hTop.AddWidget(shuffle, 0, 0)
hTop.AddWidget(practice, 0, 0) hTop.AddWidget(practice, 0, 0)
@@ -241,42 +288,48 @@ func main() {
shuffle.SetText("Shuffle") shuffle.SetText("Shuffle")
practice.SetText("Practice") practice.SetText("Practice")
mdemScroll := widgets.NewQScrollArea(nil) mdemScroll := widgets.NewQScrollArea(nil)
mdemContainer := widgets.NewQWidget(nil, 0) mdemContainer := widgets.NewQWidget(nil, 0)
hMdemScroll = widgets.NewQVBoxLayout() hMdemScroll = widgets.NewQVBoxLayout()
mdemScroll.SetWidget(mdemContainer) mdemScroll.SetWidget(mdemContainer)
mdemScroll.SetWidgetResizable(true) mdemScroll.SetWidgetResizable(true)
mdemContainer.SetLayout(hMdemScroll) mdemContainer.SetLayout(hMdemScroll)
// CreateMdems for i := 0; i < 40; i++ {
rightLayout.AddWidget(mdemScroll, 1, 0) mdem := CreateMdem()
// CreateMdems(nil, hMdemScroll) mdems = append(
mdems,
mdem,
)
hMdemScroll.AddWidget(mdem.wMdem, 0, 0)
}
// Pagination rightLayout.AddWidget(mdemScroll, 1, 0)
pagination := widgets.NewQWidget(nil, 0) // Pagination
pagination := widgets.NewQWidget(nil, 0)
hPagination := widgets.NewQHBoxLayout() hPagination := widgets.NewQHBoxLayout()
pagination.SetLayout(hPagination) pagination.SetLayout(hPagination)
// TEMP: mock pagination // TEMP: mock pagination
prevButton := widgets.NewQToolButton(nil) prevButton := widgets.NewQToolButton(nil)
prevButton.SetText("<") prevButton.SetText("<")
hPagination.AddWidget(prevButton, 0, 0) hPagination.AddWidget(prevButton, 0, 0)
for i := 0; i < 5; i++ { for i := 0; i < 5; i++ {
button := widgets.NewQToolButton(nil) button := widgets.NewQToolButton(nil)
button.SetText(fmt.Sprintf("%d", i+1)) button.SetText(fmt.Sprintf("%d", i+1))
hPagination.AddWidget(button, 0, 0) hPagination.AddWidget(button, 0, 0)
} }
nextButton := widgets.NewQToolButton(nil) nextButton := widgets.NewQToolButton(nil)
nextButton.SetText(">") nextButton.SetText(">")
hPagination.AddWidget(nextButton, 0, 0) hPagination.AddWidget(nextButton, 0, 0)
hPagination.AddStretch(1) hPagination.AddStretch(1)
rightLayout.AddWidget(pagination, 0, 0) rightLayout.AddWidget(pagination, 0, 0)
hSplitter.AddWidget(leftWidget) hSplitter.AddWidget(leftWidget)
hSplitter.AddWidget(rightWidget) hSplitter.AddWidget(rightWidget)
hSplitter.SetStretchFactor(0, 1) hSplitter.SetStretchFactor(0, 1)
hSplitter.SetStretchFactor(1, 3) hSplitter.SetStretchFactor(1, 3)
window.SetCentralWidget(hSplitter) window.SetCentralWidget(hSplitter)
window.Show() window.Show()

Binary file not shown.

BIN
src/mdemory-app-qt/mdemory_debug Executable file

Binary file not shown.