diff --git a/identities.go b/identities.go deleted file mode 100644 index 8bb916f..0000000 --- a/identities.go +++ /dev/null @@ -1,138 +0,0 @@ -package main - -import ( - "github.com/therecipe/qt/core" - "fmt" -) - -func init() { QIdentityListModel_QmlRegisterType2("CustomQmlTypes", 1, 0, "QIdentityListModel") } -// TODO: register QObj of Item - -const ( - Name = int(core.Qt__UserRole) + 1<qml/ProfilesColumn.qml qml/main.qml assets/cwtch-logo.png + qml/AddIdentity.qml diff --git a/qml/AddIdentity.qml b/qml/AddIdentity.qml new file mode 100644 index 0000000..eb4ff92 --- /dev/null +++ b/qml/AddIdentity.qml @@ -0,0 +1,46 @@ +import QtQuick 2.0 +import QtQuick.Window 2.2 +import QtQuick.Controls 1.4 + +//import CustomQmlTypes 1.0 + +Window { + visible: false + id: addIdentityWindow + + width: 600 + //minimumWidth: 600 + height: 400 + //minimumHeight: 400 + title: "Add Identity" + + signal closed + onVisibleChanged: if (!visible) closed() + + Item { + + anchors.left: parent.left + anchors.leftMargin: 200 + + + Column { + Text { text: "Name:" } + TextField { id: nameText } + TextField { id: password; echoMode: TextInput.Password } + TextField { id: passconfirm; echoMode: TextInput.Password } + Text { id: passError; visible: false; text: "Passwords do not match"; color: "red" } + Button { text: "Create"; isDefault: true; + onClicked: { + if (password.text !== passconfirm.text) { + passError.visible = true + } else { + passError.visible = false + cwtchApp.identityCreate(nameText.text, password.text) + addIdentityWindow.visible = false + } + } + } + } + } + +} diff --git a/qml/MainWindow.qml b/qml/MainWindow.qml index ed6a3d0..3b57319 100644 --- a/qml/MainWindow.qml +++ b/qml/MainWindow.qml @@ -1,6 +1,5 @@ import QtQuick 2.9 import QtQuick.Window 2.2 -import CustomQmlTypes 1.0 Window { //visible: false @@ -9,11 +8,8 @@ Window { height: 800 title: qsTr("Bulletin") - property alias model: profilesColumn.model - ProfilesColumn { id: profilesColumn - model: identityList anchors.top: parent.top anchors.left: parent.left diff --git a/qml/ProfilesColumn.qml b/qml/ProfilesColumn.qml index 4acc3e3..bb1adc0 100644 --- a/qml/ProfilesColumn.qml +++ b/qml/ProfilesColumn.qml @@ -1,18 +1,22 @@ import QtQuick 2.0 -import CustomQmlTypes 1.0 Rectangle { color: "#381F47" - property alias model: list.model - ListView { id: list - //height: parent.height + //height: parent.height width: parent.width anchors.fill: parent + ListModel { + id: identitiesModel + ListElement { name: "unlock"; onion: ""; color: "#af921d"; buttonType: 1} + ListElement { name: "add"; onion: ""; color: "#e0e0e0"; buttonType: 2} + } + model: identitiesModel + highlight: Item { Rectangle { width: 4; height: 100; color: "white"; radius: 2} } //highlight: highlightBar @@ -20,7 +24,19 @@ Rectangle { delegate: profileDelegate + Connections { + target: cwtchApp + onIdentityAddList: function (name, onion, color, buttonType) { + console.log("on Identity-Add-List(" + name + "," + onion +","+ color+ "," + buttonType+")") + identitiesModel.insert(identitiesModel.count-2, { + "name": name, + "onion": onion, + "color": color, + "buttonType": buttonType + }) + } + } } Component { @@ -35,8 +51,8 @@ Rectangle { anchors.left: parent.left anchors.leftMargin: 10 - Rectangle { y: 10; width: 80; height: 80; color: model.Color } - Text { color: "#a0a0a0"; text: Name } + Rectangle { y: 10; width: 80; height: 80; color: model.color } + Text { color: "#a0a0a0"; text: name } } @@ -47,7 +63,18 @@ Rectangle { anchors.fill: parent onClicked: { list.currentIndex = index - list.model.clickIdentity(model.Name) + + // var addIWin = AddIdentity{ } + console.log("onClicked " + model.name + " type " + model.buttonType) + if (model.buttonType === cwtchApp.typeAdd) { + var component = Qt.createComponent("AddIdentity.qml") + var object = component.createObject(root) + object.show() + //object.closed.connect(function() { object.destroy() }) + } else + if (model.ButtonType === cwtchApp.typeIdentity) { + cwtchApp.identityClicked(model.name + " " + model.buttonType) + } } } } diff --git a/qml/main.qml b/qml/main.qml index 82a148c..c11f3b9 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -2,7 +2,6 @@ import QtQuick 2.0 import QtQuick.Controls 1.0 import QtQuick.Layouts 1.0 import QtQuick.Window 2.0 -import CustomQmlTypes 1.0 // Root non-graphical object providing window management and other logic. QtObject { @@ -12,8 +11,6 @@ QtObject { onVisibleChanged: if (!visible) Qt.quit() } - property QIdentityListModel model: identityList - property LoadingWindow loadingWindow: LoadingWindow { visible: true } property Timer timer: Timer {