replace model loader with placeholder data and update some paths and fix the theme switcher
This commit is contained in:
parent
4aa9af3e5b
commit
32d5e14afc
53
model.go
53
model.go
|
@ -7,7 +7,6 @@ import (
|
||||||
"github.com/therecipe/qt/core"
|
"github.com/therecipe/qt/core"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -181,47 +180,25 @@ func FormEntryDirectoryName(cwd, api, formName string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BuildFormModel(fdm *FormDataModel, datadir string) {
|
func BuildFormModel(fdm *FormDataModel, datadir string) {
|
||||||
if _, err := os.Stat(datadir); os.IsNotExist(err) {
|
fdm.addFormEntry(LoadFormEntry("wip1"))
|
||||||
err := os.Mkdir(datadir, 0700)
|
fdm.addFormEntry(LoadFormEntry("wip2"))
|
||||||
if err != nil {
|
fdm.addFormEntry(LoadFormEntry("wip3"))
|
||||||
fdm.SetError(err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cwd, _ := filepath.Abs(datadir)
|
|
||||||
fdm.SetCwd(cwd)
|
|
||||||
|
|
||||||
folders, err := ioutil.ReadDir(datadir)
|
|
||||||
if err != nil {
|
|
||||||
fdm.SetError(err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, folder := range folders {
|
|
||||||
fdm.addFormEntry(LoadFormEntry(datadir + string(os.PathSeparator) + folder.Name()))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadFormEntry(path string) *FormEntry {
|
func LoadFormEntry(path string) *FormEntry {
|
||||||
bytes, err := ioutil.ReadFile(path + string(os.PathSeparator) + "config.json")
|
fe := &FormEntry{
|
||||||
if err != nil {
|
API: "api1",
|
||||||
return FormEntryError(path, err.Error())
|
FormID: "fid1",
|
||||||
|
FormName: "fn1",
|
||||||
|
User: "user1",
|
||||||
|
FolderName: "fn1",
|
||||||
|
Token: "token1",
|
||||||
|
RemotePubKey: "pubkey1",
|
||||||
|
LocalPubKey: "localkey2",
|
||||||
|
Error: "error1",
|
||||||
|
LastDownload: time.Now(),
|
||||||
|
Submissions: 123,
|
||||||
}
|
}
|
||||||
|
|
||||||
fe := &FormEntry{}
|
|
||||||
err = json.Unmarshal(bytes, fe)
|
|
||||||
if err != nil {
|
|
||||||
return FormEntryError(path, err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
fe.FolderName = path
|
|
||||||
|
|
||||||
bytes, err = ioutil.ReadFile(path + string(os.PathSeparator) + "keys" + string(os.PathSeparator) + "public.key")
|
|
||||||
if err == nil {
|
|
||||||
fe.LocalPubKey = string(bytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
return fe
|
return fe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ import QtQuick.Dialogs 1.3
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
import QtQuick.Controls.Styles 1.4
|
import QtQuick.Controls.Styles 1.4
|
||||||
|
|
||||||
import "qml-theme"
|
import "opaque/theme"
|
||||||
import "qml-widgets" as Widgets
|
import "opaque" as Widgets
|
||||||
import "qml-widgets/fonts"
|
import "opaque/fonts"
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
spacing: 24
|
spacing: 24
|
||||||
|
|
|
@ -8,9 +8,9 @@ import QtQuick.Layouts 1.12
|
||||||
import QtQuick.Controls.Styles 1.4
|
import QtQuick.Controls.Styles 1.4
|
||||||
import QtQuick.Controls 1.4 as C
|
import QtQuick.Controls 1.4 as C
|
||||||
|
|
||||||
import "qml-theme"
|
import "opaque/theme"
|
||||||
import "qml-widgets" as Widgets
|
import "opaque" as Widgets
|
||||||
import "qml-widgets/fonts"
|
import "opaque/fonts"
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
spacing: 24
|
spacing: 24
|
||||||
|
|
|
@ -42,7 +42,9 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widgets.ToggleSwitch {
|
Widgets.ToggleSwitch {
|
||||||
//?
|
onToggled: function(){
|
||||||
|
Theme.theme = isToggled ? Theme.light : Theme.dark;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 176274e648252d37a0aa53f24778c297dc42992c
|
Subproject commit 913796b2889369e9701d315a3f178ca87663e71c
|
Loading…
Reference in New Issue