diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/backend.go | 5 | ||||
-rw-r--r-- | gui/handlers.cpp | 12 | ||||
-rw-r--r-- | gui/handlers.h | 1 | ||||
-rw-r--r-- | gui/qml/LoginDialog.qml | 5 | ||||
-rw-r--r-- | gui/qml/main.qml | 4 |
5 files changed, 24 insertions, 3 deletions
diff --git a/gui/backend.go b/gui/backend.go index 536ade3..a5cb3ab 100644 --- a/gui/backend.go +++ b/gui/backend.go @@ -22,6 +22,11 @@ func GetAppName() *C.char { return (*C.char)(backend.GetAppName()) } +//export Login +func Login(username, password *C.char) { + backend.Login(C.GoString(username), C.GoString(password)) +} + //export SwitchOn func SwitchOn() { backend.SwitchOn() diff --git a/gui/handlers.cpp b/gui/handlers.cpp index ab64afb..3959964 100644 --- a/gui/handlers.cpp +++ b/gui/handlers.cpp @@ -35,6 +35,18 @@ void Backend::donateAccepted() DonateAccepted(); } +void Backend::login(QString username, QString password) +{ + // TODO: there has to be a cleaner way to do the conversion + char * u = new char [username.length()+1]; + char * p = new char [password.length()+1]; + strcpy(u, username.toStdString().c_str()); + strcpy(p, password.toStdString().c_str()); + Login(u, p); + delete [] u; + delete [] p; +} + void Backend::quit() { Quit(); diff --git a/gui/handlers.h b/gui/handlers.h index 62a733d..656a451 100644 --- a/gui/handlers.h +++ b/gui/handlers.h @@ -35,6 +35,7 @@ public slots: void switchOn(); void switchOff(); void donateAccepted(); + void login(QString username, QString password); void quit(); }; diff --git a/gui/qml/LoginDialog.qml b/gui/qml/LoginDialog.qml index 0c0f18e..1724769 100644 --- a/gui/qml/LoginDialog.qml +++ b/gui/qml/LoginDialog.qml @@ -22,7 +22,6 @@ Dialog { } visible: false - //visible: ctx.showLogin == true - //onAccepted: backend.login(username.text, password.text) - onRejected: backend.quit() // TODO: it doesn't close + onAccepted: backend.login(username.text, password.text) + onRejected: backend.quit() } diff --git a/gui/qml/main.qml b/gui/qml/main.qml index 09bbab5..0242493 100644 --- a/gui/qml/main.qml +++ b/gui/qml/main.qml @@ -19,6 +19,10 @@ ApplicationWindow { console.debug(jsonModel.getJson()) donate.visible = true } + if (ctx.loginDialog == 'true') { + console.debug(jsonModel.getJson()) + login.visible = true + } if (ctx.errors ) { if ( ctx.errors == "nohelpers" ) { showInitFailure(qsTr("Could not find helpers. Check your installation")) |