profile delete. profile version tagging. minor qml refactor (less importing widgets directly into qml namespace)

This commit is contained in:
Dan Ballard 2019-12-10 15:44:35 -08:00
parent fbecb20e05
commit d77851a835
21 changed files with 204 additions and 243 deletions

View File

@ -4,3 +4,6 @@ const Nick = "nick"
const LastRead = "last-read" const LastRead = "last-read"
const Picture = "picture" const Picture = "picture"
const DefaultPassword = "default-password" const DefaultPassword = "default-password"
const ProfileTypeV1DefaultPassword = "v1-defaultPassword"
const ProfileTypeV1Password = "v1-userPassword"

View File

@ -1,6 +1,7 @@
package handlers package handlers
import ( import (
"cwtch.im/cwtch/app"
"cwtch.im/cwtch/app/plugins" "cwtch.im/cwtch/app/plugins"
"cwtch.im/cwtch/event" "cwtch.im/cwtch/event"
"cwtch.im/ui/go/constants" "cwtch.im/ui/go/constants"
@ -12,7 +13,7 @@ import (
"time" "time"
) )
func App(gcd *ui.GrandCentralDispatcher, subscribed chan bool, reloadingFirst bool) { func App(gcd *ui.GrandCentralDispatcher, subscribed chan bool, reloadingAccounts bool) {
q := event.NewQueue() q := event.NewQueue()
the.AppBus.Subscribe(event.NewPeer, q) the.AppBus.Subscribe(event.NewPeer, q)
the.AppBus.Subscribe(event.PeerError, q) the.AppBus.Subscribe(event.PeerError, q)
@ -21,7 +22,6 @@ func App(gcd *ui.GrandCentralDispatcher, subscribed chan bool, reloadingFirst bo
the.AppBus.Subscribe(event.NetworkStatus, q) the.AppBus.Subscribe(event.NetworkStatus, q)
the.AppBus.Subscribe(event.ReloadDone, q) the.AppBus.Subscribe(event.ReloadDone, q)
subscribed <- true subscribed <- true
loadingV1Accounts := !reloadingFirst
networkOffline := false networkOffline := false
timeSinceLastSuccess := time.Unix(0, 0) timeSinceLastSuccess := time.Unix(0, 0)
@ -77,35 +77,24 @@ func App(gcd *ui.GrandCentralDispatcher, subscribed chan bool, reloadingFirst bo
case event.AppError: case event.AppError:
if e.Data[event.Error] == event.AppErrLoaded0 { if e.Data[event.Error] == event.AppErrLoaded0 {
if reloadingAccounts {
if loadingV1Accounts { reloadingAccounts = false
loadingV1Accounts = false
// TODO: only an error if other profiles are not loaded
if len(the.CwtchApp.ListPeers()) == 0 {
log.Infoln("couldn't load your config file. attempting to create one now")
if gcd.Version() == "development" {
the.CwtchApp.CreatePeer("tester", the.AppPassword)
} else {
the.CwtchApp.CreatePeer("alice", the.AppPassword)
}
}
} else { } else {
gcd.ErrorLoaded0() gcd.ErrorLoaded0()
} }
} }
case event.ReloadDone: case event.ReloadDone:
if the.Peer == nil { reloadingAccounts = false
loadingV1Accounts = true if len(the.CwtchApp.ListPeers()) == 0 {
the.CwtchApp.LoadProfiles(the.AppPassword) the.CwtchApp.LoadProfiles(the.AppPassword)
} }
case event.NewPeer: case event.NewPeer:
onion := e.Data[event.Identity] onion := e.Data[event.Identity]
peer := the.CwtchApp.GetPeer(onion) peer := the.CwtchApp.GetPeer(onion)
if loadingV1Accounts { if tag, exists := peer.GetAttribute(app.AttributeTag); !exists || tag == "" {
the.CwtchApp.GetPeer(onion).SetAttribute(constants.DefaultPassword, "true") peer.SetAttribute(app.AttributeTag, constants.ProfileTypeV1DefaultPassword)
loadingV1Accounts = false
} }
log.Infof("NewPeer for %v\n", onion) log.Infof("NewPeer for %v\n", onion)

View File

@ -9,6 +9,8 @@ import (
"time" "time"
) )
const ExitPeerHandlerEvent = 10000
func PeerHandler(onion string, uiManager ui.Manager, subscribed chan bool) { func PeerHandler(onion string, uiManager ui.Manager, subscribed chan bool) {
peer := the.CwtchApp.GetPeer(onion) peer := the.CwtchApp.GetPeer(onion)
eventBus := the.CwtchApp.GetEventBus(onion) eventBus := the.CwtchApp.GetEventBus(onion)
@ -105,6 +107,10 @@ func PeerHandler(onion string, uiManager ui.Manager, subscribed chan bool) {
log.Errorf("found group that is nil :/") log.Errorf("found group that is nil :/")
} }
} }
case event.DeletePeer:
log.Infof("PeerHandler got DeletePeer, SHUTTING down!\n")
uiManager.ReloadProfiles()
return
} }
} }
} }

View File

@ -37,12 +37,11 @@ type GrandCentralDispatcher struct {
_ string `property:"selectedConversation,auto"` _ string `property:"selectedConversation,auto"`
// profile management stuff // profile management stuff
_ func() `signal:"Loaded"` _ func() `signal:"Loaded"`
_ func(handle, displayname, image string) `signal:"AddProfile"` _ func(handle, displayname, image, tag string) `signal:"AddProfile"`
_ func() `signal:"ErrorLoaded0"` _ func() `signal:"ErrorLoaded0"`
_ func() `signal:"ResetProfile"` _ func() `signal:"ResetProfile"`
_ func() `signal:"ResetProfileList"` _ func() `signal:"ResetProfileList"`
_ func(onion string) `signal:"deleteProfile"`
// contact list stuff // contact list stuff
_ func(handle, displayName, image, server string, badge, status int, blocked bool, loading bool, lastMsgTime int) `signal:"AddContact"` _ func(handle, displayName, image, server string, badge, status int, blocked bool, loading bool, lastMsgTime int) `signal:"AddContact"`
@ -78,11 +77,12 @@ type GrandCentralDispatcher struct {
_ func() `signal:"onActivate,auto"` _ func() `signal:"onActivate,auto"`
_ func(locale string) `signal:"setLocale,auto"` _ func(locale string) `signal:"setLocale,auto"`
// profile managemenet // profile managemenet
_ func(onion, nick string) `signal:"updateNick,auto"` _ func(onion, nick string) `signal:"updateNick,auto"`
_ func(handle string) `signal:"loadProfile,auto"` _ func(handle string) `signal:"loadProfile,auto"`
_ func(nick, password string) `signal:"createProfile,auto"` _ func(nick string, defaultPass bool, password string) `signal:"createProfile,auto"`
_ func(password string) `signal:"unlockProfiles,auto"` _ func(password string) `signal:"unlockProfiles,auto"`
_ func() `signal:"reloadProfileList,auto"` _ func() `signal:"reloadProfileList,auto"`
_ func(onion string) `signal:"deleteProfile,auto"`
// operating a profile // operating a profile
_ func(message string, mid string) `signal:"sendMessage,auto"` _ func(message string, mid string) `signal:"sendMessage,auto"`
_ func(onion string) `signal:"blockPeer,auto"` _ func(onion string) `signal:"blockPeer,auto"`
@ -619,8 +619,12 @@ func (this *GrandCentralDispatcher) loadProfile(onion string) {
} }
} }
func (this *GrandCentralDispatcher) createProfile(nick, password string) { func (this *GrandCentralDispatcher) createProfile(nick string, defaultPass bool, password string) {
the.CwtchApp.CreatePeer(nick, password) if defaultPass {
the.CwtchApp.CreateTaggedPeer(nick, the.AppPassword, constants.ProfileTypeV1DefaultPassword)
} else {
the.CwtchApp.CreateTaggedPeer(nick, password, constants.ProfileTypeV1Password)
}
} }
func (this *GrandCentralDispatcher) reloadProfileList() { func (this *GrandCentralDispatcher) reloadProfileList() {
@ -632,5 +636,6 @@ func (this *GrandCentralDispatcher) reloadProfileList() {
} }
func (this *GrandCentralDispatcher) deleteProfile(onion string) { func (this *GrandCentralDispatcher) deleteProfile(onion string) {
//the.CwtchApp. log.Infof("deleteProfile %v\n", onion)
the.CwtchApp.DeletePeer(onion)
} }

View File

@ -1,6 +1,7 @@
package ui package ui
import ( import (
"cwtch.im/cwtch/app"
"cwtch.im/cwtch/model" "cwtch.im/cwtch/model"
"cwtch.im/cwtch/protocol/connections" "cwtch.im/cwtch/protocol/connections"
"cwtch.im/ui/go/constants" "cwtch.im/ui/go/constants"
@ -122,8 +123,10 @@ func AddProfile(gcd *GrandCentralDispatcher, handle string) {
pic = RandomProfileImage(handle) pic = RandomProfileImage(handle)
peer.SetAttribute(constants.Picture, pic) peer.SetAttribute(constants.Picture, pic)
} }
log.Infof("AddProfile %v %v %v\n", handle, nick, pic)
gcd.AddProfile(handle, nick, pic) tag, _ := peer.GetAttribute(app.AttributeTag)
log.Infof("AddProfile %v %v %v %v\n", handle, nick, pic, tag)
gcd.AddProfile(handle, nick, pic, tag)
} }
} }
@ -143,6 +146,8 @@ type Manager interface {
AddSendMessageError(peer string, signature string, err string) AddSendMessageError(peer string, signature string, err string)
AddMessage(handle string, from string, message string, fromMe bool, messageID string, timestamp time.Time, Acknowledged bool) AddMessage(handle string, from string, message string, fromMe bool, messageID string, timestamp time.Time, Acknowledged bool)
ReloadProfiles()
UpdateContactDisplayName(handle string, name string) UpdateContactDisplayName(handle string, name string)
UpdateContactStatus(handle string, status int, loading bool) UpdateContactStatus(handle string, status int, loading bool)
UpdateContactAttribute(handle, key, value string) UpdateContactAttribute(handle, key, value string)
@ -244,6 +249,10 @@ func (this *manager) AddMessage(handle string, from string, message string, from
}) })
} }
func (this *manager) ReloadProfiles() {
this.gcd.reloadProfileList()
}
// UpdateContactDisplayName updates a contact's display name in the contact list and conversations // UpdateContactDisplayName updates a contact's display name in the contact list and conversations
func (this *manager) UpdateContactDisplayName(handle string, name string) { func (this *manager) UpdateContactDisplayName(handle string, name string) {
this.gcd.DoIfProfile(this.profile, func() { this.gcd.DoIfProfile(this.profile, func() {

View File

@ -29,9 +29,7 @@
<file>qml/widgets/ScalingLabel.qml</file> <file>qml/widgets/ScalingLabel.qml</file>
<file>qml/widgets/SimpleButton.qml</file> <file>qml/widgets/SimpleButton.qml</file>
<file>qml/widgets/StackToolbar.qml</file> <file>qml/widgets/StackToolbar.qml</file>
<file>qml/widgets/controls/Button.qml</file>
<file>qml/widgets/controls/Loader.qml</file> <file>qml/widgets/controls/Loader.qml</file>
<file>qml/widgets/controls/Text.qml</file>
<file>qml/widgets/controls/Variables.qml</file> <file>qml/widgets/controls/Variables.qml</file>
<file>i18n/translation_de.qm</file> <file>i18n/translation_de.qm</file>
<file>i18n/translation_en.qm</file> <file>i18n/translation_en.qm</file>

View File

@ -6,8 +6,7 @@ import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import "../widgets" import "../widgets" as Widgets
import "../widgets/controls" as Awesome
import "../fonts/Twemoji.js" as T import "../fonts/Twemoji.js" as T
import "../utils.js" as Utils import "../utils.js" as Utils
import "../styles" import "../styles"
@ -176,7 +175,7 @@ ColumnLayout {
width: parent.width - 50 width: parent.width - 50
} }
SimpleButton { Widgets.SimpleButton {
id: replybtn id: replybtn
visible: selected visible: selected
text: "reply" text: "reply"
@ -231,7 +230,7 @@ ColumnLayout {
} }
SimpleButton { // SEND MESSAGE BUTTON Widgets.SimpleButton { // SEND MESSAGE BUTTON
id: btnSend id: btnSend
icon: "regular/paper-plane" icon: "regular/paper-plane"
text: "post" text: "post"

View File

@ -5,7 +5,7 @@ import QtQuick.Controls.Material 2.0
import QtQuick.Controls 1.4 import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import "../widgets" import "../widgets" as Widgets
import "../widgets/controls" as Awesome import "../widgets/controls" as Awesome
import "../fonts/Twemoji.js" as T import "../fonts/Twemoji.js" as T
import "../utils.js" as Utils import "../utils.js" as Utils
@ -204,7 +204,7 @@ ColumnLayout {
style: CwtchTextFieldStyle{} style: CwtchTextFieldStyle{}
} }
SimpleButton { // SEND MESSAGE BUTTON Widgets.SimpleButton { // SEND MESSAGE BUTTON
id: btnSend id: btnSend
icon: "regular/paper-plane" icon: "regular/paper-plane"
text: "add" text: "add"

View File

@ -6,7 +6,7 @@ import QtQuick.Layouts 1.3
import QtQuick.Window 2.11 import QtQuick.Window 2.11
import QtQuick.Controls 1.4 import QtQuick.Controls 1.4
import "../widgets" import "../widgets" as Widgets
import "../styles" import "../styles"
ColumnLayout { // settingsPane ColumnLayout { // settingsPane
@ -14,7 +14,7 @@ ColumnLayout { // settingsPane
anchors.fill: parent anchors.fill: parent
StackToolbar { Widgets.StackToolbar {
id: stb id: stb
text: qsTr("create-group-title") text: qsTr("create-group-title")
aux.visible: false aux.visible: false
@ -37,7 +37,7 @@ ColumnLayout { // settingsPane
spacing: 5 spacing: 5
width: root.width width: root.width
ScalingLabel { Widgets.ScalingLabel {
//: Server label //: Server label
text: qsTr("server-label") + ":" text: qsTr("server-label") + ":"
} }
@ -48,7 +48,7 @@ ColumnLayout { // settingsPane
text: "2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd" text: "2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd"
} }
ScalingLabel{ Widgets.ScalingLabel{
//: Group name label //: Group name label
text: qsTr("group-name-label") + ":" text: qsTr("group-name-label") + ":"
} }
@ -60,7 +60,7 @@ ColumnLayout { // settingsPane
text: qsTr("default-group-name") text: qsTr("default-group-name")
} }
SimpleButton { Widgets.SimpleButton {
//: create group button //: create group button
text: qsTr("create-group-btn") text: qsTr("create-group-btn")

View File

@ -6,7 +6,7 @@ import QtQuick.Layouts 1.3
import QtQuick.Window 2.11 import QtQuick.Window 2.11
import QtQuick.Controls 1.4 import QtQuick.Controls 1.4
import "../widgets" import "../widgets" as Widgets
import "../styles" import "../styles"
import "../utils.js" as Utils import "../utils.js" as Utils
@ -16,7 +16,7 @@ ColumnLayout { // groupSettingsPane
property string groupID property string groupID
property variant addrbook property variant addrbook
StackToolbar { Widgets.StackToolbar {
id: toolbar id: toolbar
aux.visible: false aux.visible: false
back.onClicked: theStack.pane = theStack.messagePane back.onClicked: theStack.pane = theStack.messagePane
@ -38,7 +38,7 @@ ColumnLayout { // groupSettingsPane
leftPadding: 10 leftPadding: 10
spacing: 5 spacing: 5
ScalingLabel { Widgets.ScalingLabel {
text: qsTr("server-label") + ":" text: qsTr("server-label") + ":"
} }
@ -48,7 +48,7 @@ ColumnLayout { // groupSettingsPane
readOnly: true readOnly: true
} }
SimpleButton { Widgets.SimpleButton {
icon: "regular/clipboard" icon: "regular/clipboard"
text: qsTr("copy-btn") text: qsTr("copy-btn")
@ -59,7 +59,7 @@ ColumnLayout { // groupSettingsPane
} }
} }
ScalingLabel { Widgets.ScalingLabel {
text: qsTr("invitation-label") + ":" text: qsTr("invitation-label") + ":"
} }
@ -69,7 +69,7 @@ ColumnLayout { // groupSettingsPane
readOnly: true readOnly: true
} }
SimpleButton { Widgets.SimpleButton {
icon: "regular/clipboard" icon: "regular/clipboard"
text: qsTr("copy-btn") text: qsTr("copy-btn")
@ -80,7 +80,7 @@ ColumnLayout { // groupSettingsPane
} }
} }
ScalingLabel{ Widgets.ScalingLabel{
text: qsTr("group-name-label") + ":" text: qsTr("group-name-label") + ":"
} }
@ -89,7 +89,7 @@ ColumnLayout { // groupSettingsPane
style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 } style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
} }
SimpleButton { Widgets.SimpleButton {
text: qsTr("save-btn") text: qsTr("save-btn")
onClicked: { onClicked: {
@ -100,7 +100,7 @@ ColumnLayout { // groupSettingsPane
} }
//: Invite someone to the group //: Invite someone to the group
ScalingLabel { text: qsTr("invite-to-group-label") } Widgets.ScalingLabel { text: qsTr("invite-to-group-label") }
ComboBox { ComboBox {
id: cbInvite id: cbInvite
@ -110,7 +110,7 @@ ColumnLayout { // groupSettingsPane
style: CwtchComboBoxStyle{} style: CwtchComboBoxStyle{}
} }
SimpleButton { Widgets.SimpleButton {
text: qsTr("invite-btn") text: qsTr("invite-btn")
onClicked: { onClicked: {
@ -118,7 +118,7 @@ ColumnLayout { // groupSettingsPane
} }
} }
SimpleButton { Widgets.SimpleButton {
icon: "regular/trash-alt" icon: "regular/trash-alt"
text: qsTr("delete-btn") text: qsTr("delete-btn")

View File

@ -6,7 +6,7 @@ import QtQuick.Layouts 1.3
import QtQuick.Window 2.11 import QtQuick.Window 2.11
import QtQuick.Controls 1.4 import QtQuick.Controls 1.4
import "../widgets" import "../widgets" as Widgets
import "../styles" import "../styles"
ColumnLayout { // peerSettingsPane ColumnLayout { // peerSettingsPane
@ -14,7 +14,7 @@ ColumnLayout { // peerSettingsPane
anchors.fill: parent anchors.fill: parent
property bool blocked property bool blocked
StackToolbar { Widgets.StackToolbar {
id: toolbar id: toolbar
aux.visible: false aux.visible: false
@ -38,7 +38,7 @@ ColumnLayout { // peerSettingsPane
leftPadding: 10 leftPadding: 10
spacing: 5 spacing: 5
ScalingLabel { Widgets.ScalingLabel {
text: qsTr("address-label") text: qsTr("address-label")
} }
@ -48,7 +48,7 @@ ColumnLayout { // peerSettingsPane
readOnly: true readOnly: true
} }
SimpleButton { Widgets.SimpleButton {
icon: "regular/clipboard" icon: "regular/clipboard"
text: qsTr("copy-btn") text: qsTr("copy-btn")
@ -60,7 +60,7 @@ ColumnLayout { // peerSettingsPane
} }
} }
ScalingLabel{ Widgets.ScalingLabel{
text: qsTr("display-name-label") text: qsTr("display-name-label")
} }
@ -69,7 +69,7 @@ ColumnLayout { // peerSettingsPane
style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 } style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
} }
SimpleButton { Widgets.SimpleButton {
text: qsTr("save-btn") text: qsTr("save-btn")
onClicked: { onClicked: {
@ -80,7 +80,7 @@ ColumnLayout { // peerSettingsPane
} }
SimpleButton { Widgets.SimpleButton {
icon: "solid/hand-paper" icon: "solid/hand-paper"
text: root.blocked ? qsTr("unblock-btn") : qsTr("block-btn") text: root.blocked ? qsTr("unblock-btn") : qsTr("block-btn")
@ -94,7 +94,7 @@ ColumnLayout { // peerSettingsPane
} }
} }
SimpleButton { Widgets.SimpleButton {
icon: "regular/trash-alt" icon: "regular/trash-alt"
text: qsTr("delete-btn") text: qsTr("delete-btn")

View File

@ -1,13 +1,13 @@
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Controls 2.4 import QtQuick.Controls 2.13
import QtQuick.Controls.Material 2.0 import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import QtQuick.Window 2.11 import QtQuick.Window 2.11
import QtQuick.Controls 1.4
import "../widgets"
import "../styles" import "../widgets" as Widgets
// import "../styles"
ColumnLayout { // Add Profile Pane ColumnLayout { // Add Profile Pane
id: profileAddEditPane id: profileAddEditPane
@ -15,7 +15,7 @@ ColumnLayout { // Add Profile Pane
property string mode // edit or add property string mode // edit or add
StackToolbar { Widgets.StackToolbar {
id: stb id: stb
text: mode == "add" ? qsTr("add-profile-title") : qsTr("edit-profile-title") text: mode == "add" ? qsTr("add-profile-title") : qsTr("edit-profile-title")
aux.visible: false aux.visible: false
@ -28,6 +28,7 @@ ColumnLayout { // Add Profile Pane
txtPassword1.text = "" txtPassword1.text = ""
txtPassword2.text = "" txtPassword2.text = ""
deleteReset() deleteReset()
radioUsePassword.checked = true
} }
function load(onion, name, pass) { function load(onion, name, pass) {
@ -64,59 +65,90 @@ ColumnLayout { // Add Profile Pane
spacing: 5 spacing: 5
width: profileAddEditPane.width width: profileAddEditPane.width
ScalingLabel { Widgets.ScalingLabel {
//: Onion //: Onion
text: qsTr("profile-onion-label") + ":" text: qsTr("profile-onion-label") + ":"
visible: mode == "edit" visible: mode == "edit"
} }
ScalingLabel { Widgets.ScalingLabel {
id: onionLabel id: onionLabel
visible: mode == "edit" visible: mode == "edit"
} }
ScalingLabel { Widgets.ScalingLabel {
//: Display name //: Display name
text: qsTr("profile-name") + ":" text: qsTr("profile-name") + ":"
} }
TextField { Widgets.TextField {
id: txtProfileName id: txtProfileName
Layout.fillWidth: true Layout.fillWidth: true
style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 } //style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
//: default suggested profile name //: default suggested profile name
text: qsTr("default-profile-name") text: qsTr("default-profile-name")
} }
ScalingLabel { RowLayout {
//id: radioButtons
Widgets.RadioButton {
id: radioUsePassword
checked: true
//: Password
text: qsTr("radio-use-password")
}
Widgets.RadioButton {
id: radioNoPassword
//: Unencrypted (No password)
text: qsTr("radio-no-password")
}
}
Widgets.ScalingLabel {
id: noPasswordLabel
//: Not using a password on this account means that all data stored locally will not be encrypted
text: qsTr("no-password-warning")
visible: radioNoPassword.checked
}
Widgets.ScalingLabel {
id: passwordLabel
//: Password //: Password
text: qsTr("password1-label") + ":" text: qsTr("password1-label") + ":"
visible: radioUsePassword.checked
} }
TextField { Widgets.TextField {
id: txtPassword1 id: txtPassword1
Layout.fillWidth: true Layout.fillWidth: true
style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 } //style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
echoMode: TextInput.Password echoMode: TextInput.Password
readOnly: mode == "edit" readOnly: mode == "edit"
visible: radioUsePassword.checked
} }
ScalingLabel { Widgets.ScalingLabel {
id: passwordReLabel
//: Reenter password //: Reenter password
text: qsTr("password2-label") + ":" text: qsTr("password2-label") + ":"
visible: radioUsePassword.checked
} }
TextField { Widgets.TextField {
id: txtPassword2 id: txtPassword2
Layout.fillWidth: true Layout.fillWidth: true
style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 } //style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
echoMode: TextInput.Password echoMode: TextInput.Password
readOnly: mode == "edit" readOnly: mode == "edit"
visible: radioUsePassword.checked
} }
SimpleButton { Widgets.SimpleButton {
//: Create Profile || Save Profile //: Create Profile || Save Profile
text: mode == "add" ? qsTr("create-profile-btn") : qsTr("save-profile-btn") text: mode == "add" ? qsTr("create-profile-btn") : qsTr("save-profile-btn")
@ -125,7 +157,7 @@ ColumnLayout { // Add Profile Pane
passwordErrorLabel.visible = true passwordErrorLabel.visible = true
} else { } else {
if (mode == "add") { if (mode == "add") {
gcd.createProfile(txtProfileName.text, txtPassword1.text) gcd.createProfile(txtProfileName.text, radioNoPassword .checked, txtPassword1.text)
} else { } else {
gcd.updateNick(onionLabel.text, txtProfileName.text) gcd.updateNick(onionLabel.text, txtProfileName.text)
} }
@ -135,7 +167,7 @@ ColumnLayout { // Add Profile Pane
} }
} }
ScalingLabel { Widgets.ScalingLabel {
id: passwordErrorLabel id: passwordErrorLabel
//: Passwords do not match //: Passwords do not match
text: qsTr("password-error-match") text: qsTr("password-error-match")
@ -143,7 +175,7 @@ ColumnLayout { // Add Profile Pane
color: "red" color: "red"
} }
SimpleButton { Widgets.SimpleButton {
//: Delete Profile //: Delete Profile
text: qsTr("delete-profile-btn") text: qsTr("delete-profile-btn")
icon: "regular/trash-alt" icon: "regular/trash-alt"
@ -158,21 +190,21 @@ ColumnLayout { // Add Profile Pane
} }
} }
ScalingLabel { Widgets.ScalingLabel {
id: deleteConfirmLabel id: deleteConfirmLabel
//: Type DELETE to confirm //: Type DELETE to confirm
text: qsTr("delete-confirm-label")+ ":" text: qsTr("delete-confirm-label")+ ":"
visible: false visible: false
} }
TextField { Widgets.TextField {
id: confirmDeleteTxt id: confirmDeleteTxt
Layout.fillWidth: true Layout.fillWidth: true
style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 } //style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
visible: false visible: false
} }
SimpleButton { Widgets.SimpleButton {
id: confirmDeleteBtn id: confirmDeleteBtn
icon: "regular/trash-alt" icon: "regular/trash-alt"

View File

@ -8,7 +8,7 @@ import QtQuick.Window 2.11
import QtQuick.Controls 1.4 import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4 import QtQuick.Controls.Styles 1.4
import "../widgets" import "../widgets" as Widgets
import "../widgets/controls" import "../widgets/controls"
import "../styles" import "../styles"
@ -19,7 +19,7 @@ ColumnLayout {
//leftPadding: 10 //leftPadding: 10
//spacing: 5 //spacing: 5
ScalingLabel { Widgets.ScalingLabel {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
wrapMode: TextEdit.Wrap wrapMode: TextEdit.Wrap
//: Please enter password: //: Please enter password:
@ -33,7 +33,7 @@ ColumnLayout {
echoMode: TextInput.Password echoMode: TextInput.Password
} }
ScalingLabel { Widgets.ScalingLabel {
id: error id: error
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
color: "red" color: "red"
@ -42,7 +42,7 @@ ColumnLayout {
visible: false visible: false
} }
SimpleButton { Widgets.SimpleButton {
id: "button" id: "button"
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@ -75,7 +75,7 @@ ColumnLayout {
Layout.minimumWidth: Layout.maximumWidth Layout.minimumWidth: Layout.maximumWidth
//Layout.maximumWidth: theStack.pane == theStack.emptyPane ? parent.width : 450 //Layout.maximumWidth: theStack.pane == theStack.emptyPane ? parent.width : 450
ProfileList { Widgets.ProfileList {
anchors.fill: parent anchors.fill: parent
} }
} }

View File

@ -25,6 +25,7 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
property bool isHover property bool isHover
property bool background: true property bool background: true
property string type // profile or contact or button property string type // profile or contact or button
property string tag // profile version/type
// Profile // Profile
property bool defaultPassword property bool defaultPassword
@ -114,6 +115,22 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
// Profile // Profile
Image {// Profle Type
id: profiletype
source: tag == "v1-userPassword" ? "qrc:/qml/images/fontawesome/solid/lock.svg" : "qrc:/qml/images/fontawesome/solid/lock-open.svg"
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 1 * gcd.themeScale
anchors.rightMargin: (20 * gcd.themeScale) + parent.height
height: parent.height * 0.5
width: height
visible: type == "profile"
}
// Contact // Contact

View File

@ -41,7 +41,7 @@ ColumnLayout {
Connections { // ADD/REMOVE CONTACT ENTRIES Connections { // ADD/REMOVE CONTACT ENTRIES
target: gcd target: gcd
onAddProfile: function(handle, displayName, image) { onAddProfile: function(handle, displayName, image, tag) {
console.log("ProfileList onAddProfile for: " + handle) console.log("ProfileList onAddProfile for: " + handle)
for (var i = 0; i < profilesModel.count; i++) { for (var i = 0; i < profilesModel.count; i++) {
@ -55,7 +55,8 @@ ColumnLayout {
"_handle": handle, "_handle": handle,
"_displayName": displayName, "_displayName": displayName,
"_image": image, "_image": image,
"_type": "profile" "_type": "profile",
"_tag": tag
}) })
} }
@ -77,6 +78,7 @@ ColumnLayout {
_displayName: qsTr("add-new-profile-btn"), _displayName: qsTr("add-new-profile-btn"),
_image: "qrc:/qml/images/fontawesome/solid/user-plus.svg", _image: "qrc:/qml/images/fontawesome/solid/user-plus.svg",
_type: "button", _type: "button",
_tag: ","
}) })
} }
} }
@ -89,6 +91,7 @@ ColumnLayout {
_displayName: qsTr("add-new-profile-btn") _displayName: qsTr("add-new-profile-btn")
_image: "qrc:/qml/images/fontawesome/solid/user-plus.svg" _image: "qrc:/qml/images/fontawesome/solid/user-plus.svg"
_type: "button" _type: "button"
_tag: ""
} }
} }
@ -104,6 +107,7 @@ ColumnLayout {
blocked: false blocked: false
loading: false loading: false
type: _type type: _type
tag: _tag
} }
} }
} }

View File

@ -0,0 +1,27 @@
import QtQuick 2.7
import QtQuick.Controls 2.13
RadioButton {
id: control
property real size: 12
spacing: 0
indicator: Rectangle {
width: 16 * gcd.themeScale
height: 16 * gcd.themeScale
anchors.verticalCenter: parent.verticalCenter
radius: 9
border.width: 1
Rectangle {
anchors.fill: parent
visible: control.checked
color: "black"
radius: 9
anchors.margins: 4
}
}
}

View File

@ -4,7 +4,6 @@ import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.0 import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import "controls" as Awesome
import "../fonts/Twemoji.js" as T import "../fonts/Twemoji.js" as T
Rectangle { Rectangle {

View File

@ -4,7 +4,6 @@ import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.0 import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import "controls" as Awesome
import "../fonts/Twemoji.js" as T import "../fonts/Twemoji.js" as T
Rectangle { // OVERHEAD BAR ON STACK PANE Rectangle { // OVERHEAD BAR ON STACK PANE

16
qml/widgets/TextField.qml Normal file
View File

@ -0,0 +1,16 @@
import QtQuick 2.7
import QtQuick.Controls 2.13
TextField {
color: "black"
font.pointSize: 10 * gcd.themeScale
width: 100
background: Rectangle {
radius: 2
color: windowItem.cwtch_background_color
border.color: windowItem.cwtch_color
}
}

View File

@ -1,81 +0,0 @@
/****************************************************************************
**
**
** Copyright (c) 2014 Ricardo do Valle Flores de Oliveira
**
** $BEGIN_LICENSE:MIT$
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
** SOFTWARE.
**
**
****************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 1.0
import QtQuick.Controls.Styles 1.0
import QtQuick.Layouts 1.0
Button {
id: button
property string icon
property color color: "black"
property font font
style: ButtonStyle {
id: buttonstyle
property font font: button.font
property color foregroundColor: button.color
background: Item {
Rectangle {
id: baserect
anchors.fill: parent
color: "transparent"
}
}
label: Item {
implicitWidth: row.implicitWidth
implicitHeight: row.implicitHeight
RowLayout {
id: row
anchors.centerIn: parent
spacing: 15
Text {
color: buttonstyle.foregroundColor
font.pointSize: buttonstyle.font.pointSize * 2
font.family: awesome.family
renderType: Text.NativeRendering
text: awesome.loaded ? icon : ""
visible: !(icon === "")
}
Text {
color: buttonstyle.foregroundColor
font: buttonstyle.font
renderType: Text.NativeRendering
text: control.text
visible: !(control.text === "")
Layout.alignment: Qt.AlignBottom
}
}
}
}
}

View File

@ -1,61 +0,0 @@
/****************************************************************************
**
** The MIT License (MIT)
**
** Copyright (c) 2014 Ricardo do Valle Flores de Oliveira
**
** $BEGIN_LICENSE:MIT$
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
** SOFTWARE.
**
** $END_LICENSE$
**
****************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
Text {
id: root
property alias spacing: row.spacing
property alias text: content.text
property color color: "black"
property font font
property string icon
RowLayout {
id: row
Text {
color: root.color
font.pointSize: root.font.pointSize
font.family: awesome.family
renderType: Text.NativeRendering
text: awesome.loaded ? icon : ""
}
Text {
id: content
color: root.color
font.pointSize: root.font.pointSize
renderType: Text.NativeRendering
}
}
}