loading screen, cwtch load and feedback from asaur. transition to mock main screen
This commit is contained in:
parent
5ff6790226
commit
2ab81679f8
|
@ -4,6 +4,8 @@
|
||||||
deploy/
|
deploy/
|
||||||
rcc.cpp
|
rcc.cpp
|
||||||
rcc_cgo_linux_linux_amd64.go
|
rcc_cgo_linux_linux_amd64.go
|
||||||
|
moc*
|
||||||
|
rcc.qrc
|
||||||
|
|
||||||
*~
|
*~
|
||||||
*.autosave
|
*.autosave
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
import QtQuick 2.0
|
|
||||||
|
|
||||||
|
|
||||||
Box {
|
|
||||||
color: "#157efb"
|
|
||||||
}
|
|
17
Box.qml
17
Box.qml
|
@ -1,17 +0,0 @@
|
||||||
import QtQuick 2.0
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: root
|
|
||||||
width: 64
|
|
||||||
height: 64
|
|
||||||
color: "#ffffff"
|
|
||||||
border.color: Qt.darker(color, 1.2)
|
|
||||||
property alias text: label.text
|
|
||||||
property color fontColor: '#1f1f1f'
|
|
||||||
Text {
|
|
||||||
id: label
|
|
||||||
anchors.centerIn: parent
|
|
||||||
font.pixelSize: 14
|
|
||||||
color: root.fontColor
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
# qt Cwtch Bulletin
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
You need Go, QT (plus dev tools) and the GO QT dev tools from https://github.com/therecipe/qt
|
||||||
|
|
||||||
|
qtdeploy
|
Binary file not shown.
After Width: | Height: | Size: 65 KiB |
79
main.go
79
main.go
|
@ -7,8 +7,72 @@ import (
|
||||||
"github.com/therecipe/qt/gui"
|
"github.com/therecipe/qt/gui"
|
||||||
"github.com/therecipe/qt/qml"
|
"github.com/therecipe/qt/qml"
|
||||||
"github.com/therecipe/qt/quickcontrols2"
|
"github.com/therecipe/qt/quickcontrols2"
|
||||||
|
"git.openprivacy.ca/openprivacy/asaur"
|
||||||
|
"cwtch.im/cwtch/app"
|
||||||
|
"os/exec"
|
||||||
|
"log"
|
||||||
|
"os/user"
|
||||||
|
"path"
|
||||||
|
"time"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type QmlCwtchApp struct {
|
||||||
|
core.QObject
|
||||||
|
|
||||||
|
_ int `property:"torStatusProgress"`
|
||||||
|
_ string `property:"torStatusSummary"`
|
||||||
|
|
||||||
|
_ func() `constructor:"init"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (qCwtchApp *QmlCwtchApp) init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var cwtchApp app.Application
|
||||||
|
|
||||||
|
func InitCwtch(engine *qml.QQmlApplicationEngine, qCwtchApp *QmlCwtchApp) error {
|
||||||
|
|
||||||
|
torPath, err := exec.LookPath("tor")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("tor could not be found on this system. Please install it in the system $PATH")
|
||||||
|
}
|
||||||
|
|
||||||
|
usr, err := user.Current()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("\nError: could not load current user: %v\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
doneChan := make(chan bool)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
status, _ := asaur.GetInfo("localhost:9051", "tcp4", "", "status/bootstrap-phase")
|
||||||
|
|
||||||
|
progress, _ := strconv.Atoi(status["PROGRESS"])
|
||||||
|
qCwtchApp.SetTorStatusProgress(progress)
|
||||||
|
|
||||||
|
qCwtchApp.SetTorStatusSummary(status["SUMMARY"])
|
||||||
|
|
||||||
|
if status["TAG"] == "done" {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
doneChan <- true
|
||||||
|
}()
|
||||||
|
|
||||||
|
cwtchApp, err = app.NewApp(path.Join(usr.HomeDir, ".cwtch"), torPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error initializing application: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
<-doneChan
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// enable high dpi scaling
|
// enable high dpi scaling
|
||||||
|
@ -24,21 +88,28 @@ func main() {
|
||||||
// Default, Fusion, Imagine, Universal
|
// Default, Fusion, Imagine, Universal
|
||||||
quickcontrols2.QQuickStyle_SetStyle("Material")
|
quickcontrols2.QQuickStyle_SetStyle("Material")
|
||||||
|
|
||||||
|
var qCwtchApp = NewQmlCwtchApp(nil)
|
||||||
// create the qml application engine
|
// create the qml application engine
|
||||||
engine := qml.NewQQmlApplicationEngine(nil)
|
engine := qml.NewQQmlApplicationEngine(nil)
|
||||||
|
|
||||||
|
engine.RootContext().SetContextProperty("cwtchApp", qCwtchApp)
|
||||||
|
|
||||||
// load the embeeded qml file
|
// load the embeeded qml file
|
||||||
// created by either qtrcc or qtdeploy
|
// created by either qtrcc or qtdeploy
|
||||||
//engine.Load(core.NewQUrl3("qrc:./Box.qml", 0))
|
//engine.Load(core.NewQUrl3("qrc:/qml/LoadingWindow.qml", 0))
|
||||||
//engine.Load(core.NewQUrl3("qrc:./BlueBox.qml", 0))
|
//engine.Load(core.NewQUrl3("qrc:/qml/MainWindow.qml", 0))
|
||||||
//engine.Load(core.NewQUrl3("qrc:./main.qml", 0))
|
|
||||||
engine.Load(core.NewQUrl3("qrc:/main.qml", 0))
|
|
||||||
// you can also load a local file like this instead:
|
// you can also load a local file like this instead:
|
||||||
//engine.Load(core.QUrl_FromLocalFile("./qml/main.qml"))
|
//engine.Load(core.QUrl_FromLocalFile("./qml/main.qml"))
|
||||||
|
engine.Load(core.NewQUrl3("qrc:/qml/main.qml", 0))
|
||||||
|
|
||||||
|
go InitCwtch(engine, qCwtchApp)
|
||||||
// start the main Qt event loop
|
// start the main Qt event loop
|
||||||
// and block until app.Exit() is called
|
// and block until app.Exit() is called
|
||||||
// or the window is closed by the user
|
// or the window is closed by the user
|
||||||
gui.QGuiApplication_Exec()
|
gui.QGuiApplication_Exec()
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
cwtchApp.Shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
qml.qrc
12
qml.qrc
|
@ -1,9 +1,11 @@
|
||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>main.qml</file>
|
<file>qml/GroupsColumn.qml</file>
|
||||||
<file>BlueBox.qml</file>
|
<file>qml/LoadingWindow.qml</file>
|
||||||
<file>Box.qml</file>
|
<file>qml/MainWindow.qml</file>
|
||||||
<file>ProfilesColumn.qml</file>
|
<file>qml/ProfilesColumn.qml</file>
|
||||||
<file>GroupsColumn.qml</file>
|
<file>assets/open_privacy_logo_white_bg.png</file>
|
||||||
|
<file>qml/main.qml</file>
|
||||||
|
<file>assets/cwtch-logo.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -15,6 +15,8 @@ Rectangle {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
|
highlight: Rectangle { color: "#ffffff"; radius: 5 }
|
||||||
|
|
||||||
delegate: Component {
|
delegate: Component {
|
||||||
id: groupsDelegate
|
id: groupsDelegate
|
||||||
|
|
||||||
|
@ -55,10 +57,6 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
highlight: Rectangle { color: "#ffffff"; radius: 5 }
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Window 2.2
|
||||||
|
import QtQuick.Controls 2.2
|
||||||
|
|
||||||
|
Window {
|
||||||
|
//id: loadingWindow
|
||||||
|
visible: true
|
||||||
|
title: "Cwtch Bulletin"
|
||||||
|
color: "#ffffff"
|
||||||
|
width: 349
|
||||||
|
height: 145
|
||||||
|
|
||||||
|
Column {
|
||||||
|
Image {
|
||||||
|
source: "../assets/cwtch-logo.png"
|
||||||
|
width: 349
|
||||||
|
height: 125
|
||||||
|
}
|
||||||
|
ProgressBar {
|
||||||
|
id: loadingProgressBar
|
||||||
|
width: parent.width
|
||||||
|
indeterminate: false
|
||||||
|
value: 0
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
id: loadingProgressText
|
||||||
|
text: ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: cwtchApp
|
||||||
|
|
||||||
|
onTorStatusProgressChanged: loadingProgressBar.value = cwtchApp.torStatusProgress/100
|
||||||
|
onTorStatusSummaryChanged: loadingProgressText.text = cwtchApp.torStatusSummary
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,8 @@ import QtQuick 2.9
|
||||||
import QtQuick.Window 2.2
|
import QtQuick.Window 2.2
|
||||||
|
|
||||||
Window {
|
Window {
|
||||||
visible: true
|
//visible: false
|
||||||
|
id: mainWindow
|
||||||
width: 1024
|
width: 1024
|
||||||
height: 800
|
height: 800
|
||||||
title: qsTr("Bulletin")
|
title: qsTr("Bulletin")
|
||||||
|
@ -24,7 +25,7 @@ Window {
|
||||||
ListElement {name: "alice"; onion: "710829b408e8b368273cbc20b07f1c0d"; pcolor: "#ff0000"}
|
ListElement {name: "alice"; onion: "710829b408e8b368273cbc20b07f1c0d"; pcolor: "#ff0000"}
|
||||||
ListElement {name: "bob"; onion: "a219b9740fc76367833cbc20b07d1cee"; pcolor: "#00ff00" }
|
ListElement {name: "bob"; onion: "a219b9740fc76367833cbc20b07d1cee"; pcolor: "#00ff00" }
|
||||||
ListElement {name: "carol"; onion: "930829b408e8b364563cbc20b07a6560"; pcolor: "#0000ff" }
|
ListElement {name: "carol"; onion: "930829b408e8b364563cbc20b07a6560"; pcolor: "#0000ff" }
|
||||||
|
ListElement {name: "+"; onion: "930829b408e8b364563cbc20b07a6560"; pcolor: "#a0a0a0" }
|
||||||
}
|
}
|
||||||
|
|
||||||
ListModel {
|
ListModel {
|
|
@ -15,8 +15,9 @@ Rectangle {
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: list
|
id: list
|
||||||
height: parent.height
|
//height: parent.height
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
//highlight: Rectangle { border-color: "white"; radius: 5 }
|
//highlight: Rectangle { border-color: "white"; radius: 5 }
|
||||||
|
|
||||||
|
@ -33,10 +34,6 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Controls 1.0
|
||||||
|
import QtQuick.Layouts 1.0
|
||||||
|
import QtQuick.Window 2.0
|
||||||
|
|
||||||
|
// Root non-graphical object providing window management and other logic.
|
||||||
|
QtObject {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property MainWindow mainWindow: MainWindow {
|
||||||
|
onVisibleChanged: if (!visible) Qt.quit()
|
||||||
|
}
|
||||||
|
|
||||||
|
property LoadingWindow loadingWindow: LoadingWindow { visible: true }
|
||||||
|
|
||||||
|
property Timer timer: Timer {
|
||||||
|
id: timer
|
||||||
|
}
|
||||||
|
|
||||||
|
function delay(delayTime, cb) {
|
||||||
|
timer.interval = delayTime;
|
||||||
|
timer.repeat = false;
|
||||||
|
timer.triggered.connect(cb);
|
||||||
|
timer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
property list<QtObject> commObjs: [
|
||||||
|
Connections {
|
||||||
|
target: cwtchApp
|
||||||
|
|
||||||
|
onTorStatusProgressChanged: { if (cwtchApp.torStatusProgress === 100) {
|
||||||
|
delay(1000, function() {
|
||||||
|
loadingWindow.visible = false
|
||||||
|
mainWindow.visible = true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue