diff --git a/go.mod b/go.mod index b16ef9c7..ac957848 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.12 require ( cwtch.im/cwtch v0.3.11 - git.openprivacy.ca/openprivacy/connectivity v1.1.1 + git.openprivacy.ca/openprivacy/connectivity v1.1.4 git.openprivacy.ca/openprivacy/log v1.0.0 github.com/gopherjs/gopherjs v0.0.0-20200209183636-89e6cbcd0b6d // indirect github.com/therecipe/qt v0.0.0-20191101232336-18864661ae4f diff --git a/go.sum b/go.sum index 59d6ad7f..976949b9 100644 --- a/go.sum +++ b/go.sum @@ -6,11 +6,21 @@ cwtch.im/tapir v0.1.15 h1:XSCWOvjmNkzMT2IceFgTBXWGKtYfr3a8o+La1s10OhE= cwtch.im/tapir v0.1.15/go.mod h1:HzezugpEx+nZ3LdyDsl0w6n45IJYnOt8uqldkLWmaqs= cwtch.im/tapir v0.1.17 h1:2jVZUe1a88tMI4aJPvRTO4Id3NN3PsM62cT5lntEChk= cwtch.im/tapir v0.1.17/go.mod h1:HzezugpEx+nZ3LdyDsl0w6n45IJYnOt8uqldkLWmaqs= +cwtch.im/tapir v0.1.18 h1:Fs/jL9ZRyel/A1D/BYzIPEVQau8y5BJg44yA+GQDbSM= +cwtch.im/tapir v0.1.18/go.mod h1:/IrAI6CBHfgzsfgRT8WHVb1P9fCCz7+45hfsdkKn8Zg= git.openprivacy.ca/openprivacy/connectivity v1.1.0/go.mod h1:4P8mirZZslKbo2zBrXXVjgEdqGwHo/6qoFBwFQW6d6E= git.openprivacy.ca/openprivacy/connectivity v1.1.1 h1:hKxBOmxP7Jdu3K1BJ93mRtKNiWUoP6YHt/o2snE2Z0w= git.openprivacy.ca/openprivacy/connectivity v1.1.1/go.mod h1:4P8mirZZslKbo2zBrXXVjgEdqGwHo/6qoFBwFQW6d6E= +git.openprivacy.ca/openprivacy/connectivity v1.1.2 h1:Bk8ul3+4/awpQGvskfLpp7/K3Lj8OAxBwlmQqeZy3Ok= +git.openprivacy.ca/openprivacy/connectivity v1.1.2/go.mod h1:4P8mirZZslKbo2zBrXXVjgEdqGwHo/6qoFBwFQW6d6E= +git.openprivacy.ca/openprivacy/connectivity v1.1.3 h1:iRGHS8RB4SZ9cjYK/yXt4R8PqQDVwwYJZ3iqe+w3IPE= +git.openprivacy.ca/openprivacy/connectivity v1.1.3/go.mod h1:4P8mirZZslKbo2zBrXXVjgEdqGwHo/6qoFBwFQW6d6E= +git.openprivacy.ca/openprivacy/connectivity v1.1.4 h1:/I9epvNNjM8rR/q5y9Y63D9/aPXpBFvngwNGLD8mvUk= +git.openprivacy.ca/openprivacy/connectivity v1.1.4/go.mod h1:4P8mirZZslKbo2zBrXXVjgEdqGwHo/6qoFBwFQW6d6E= git.openprivacy.ca/openprivacy/libricochet-go v1.0.11 h1:C7QFFzG0p5XKu0zcOIdLGwEpA9uU0BceBM7CfVK5D40= git.openprivacy.ca/openprivacy/libricochet-go v1.0.11/go.mod h1:yTMps/ZpYS+BNBBvANsNAft28FXrBvFHQauMYNWPrwE= +git.openprivacy.ca/openprivacy/libricochet-go v1.0.13 h1:Z86uL9K47onznY1wP1P/wWfWMbbyvk6xnCp94R180os= +git.openprivacy.ca/openprivacy/libricochet-go v1.0.13/go.mod h1:ZUuX1SOrgV4K18IEcp0hQJNPKszRr2oGb3UeK2iYe5U= git.openprivacy.ca/openprivacy/log v1.0.0 h1:Rvqm1weUdR4AOnJ79b1upHCc9vC/QF1rhSD2Um7sr1Y= git.openprivacy.ca/openprivacy/log v1.0.0/go.mod h1:gGYK8xHtndRLDymFtmjkG26GaMQNgyhioNS82m812Iw= github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 h1:w1UutsfOrms1J05zt7ISrnJIXKzwaspym5BTKGx93EI= @@ -25,6 +35,9 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/gopherjs/gopherjs v0.0.0-20190411002643-bd77b112433e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de h1:F7WD09S8QB4LrkEpka0dFPLSotH11HRpCsLIbIcJ7sU= github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -43,10 +56,13 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= @@ -77,12 +93,14 @@ github.com/therecipe/qt/internal/binding/files/docs/5.13.0 v0.0.0-20191101232336 github.com/therecipe/qt/internal/binding/files/docs/5.13.0 v0.0.0-20191101232336-18864661ae4f/go.mod h1:mH55Ek7AZcdns5KPp99O0bg+78el64YCYWHiQKrOdt4= github.com/therecipe/qt/internal/binding/files/docs/5.13.0 v0.0.0-20200126204426-5074eb6d8c41 h1:jTzKrQ6EIPvKw1B9/wwoKJLrXF+ManMsXoUzufxAdsg= github.com/therecipe/qt/internal/binding/files/docs/5.13.0 v0.0.0-20200126204426-5074eb6d8c41/go.mod h1:mH55Ek7AZcdns5KPp99O0bg+78el64YCYWHiQKrOdt4= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg= go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72 h1:+ELyKg6m8UBf0nPFSqD0mi7zUfwPyXo23HNjMnXPz7w= golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200206161412-a0c6ece9d31a h1:aczoJ0HPNE92XKa7DrIzkNN6esOKO2TBwiiYoKcINhA= @@ -92,14 +110,24 @@ golang.org/x/crypto v0.0.0-20200210222208-86ce3cb69678 h1:wCWoJcFExDgyYx2m2hpHgw golang.org/x/crypto v0.0.0-20200210222208-86ce3cb69678/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200320181102-891825fb96df h1:lDWgvUvNnaTnNBc/dwOty86cFeKoKWbwy2wQj0gIxbU= golang.org/x/crypto v0.0.0-20200320181102-891825fb96df/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200420104511-884d27f42877 h1:IhZPbxNd1UjBCaD5AfpSSbJTRlp+ZSuyuH5uoksNS04= +golang.org/x/crypto v0.0.0-20200420104511-884d27f42877/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190420063019-afa5a82059c6/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200320181208-1c781a10960a h1:KaxWXSFrOaE2ptiOotI+zFdzHxBsg9MW6XfCv497IRo= golang.org/x/net v0.0.0-20200320181208-1c781a10960a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -110,13 +138,25 @@ golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a h1:XCr/YX7O0uxRkLq2k1ApNQMim golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200320181252-af34d8274f85 h1:fD99hd4ciR6T3oPhr2EkmuKe9oHixHx9Hj/hND89j3g= golang.org/x/sys v0.0.0-20200320181252-af34d8274f85/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d h1:nc5K6ox/4lTFbMVSL9WRR81ixkcwXThoiF6yf+R9scA= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190420181800-aa740d480789 h1:FF0rjo15h51+N6642mf5S3QuplmKo2aCrJUYkHTx85s= golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200420001825-978e26b7c37c/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/go/handlers/appHandler.go b/go/handlers/appHandler.go index c7d5cb9e..851f0fc3 100644 --- a/go/handlers/appHandler.go +++ b/go/handlers/appHandler.go @@ -10,7 +10,6 @@ import ( "git.openprivacy.ca/openprivacy/log" "os" "strconv" - "time" ) func App(gcd *ui.GrandCentralDispatcher, subscribed chan bool, reloadingAccounts bool) { @@ -19,55 +18,33 @@ func App(gcd *ui.GrandCentralDispatcher, subscribed chan bool, reloadingAccounts the.AppBus.Subscribe(event.PeerError, q) the.AppBus.Subscribe(event.AppError, q) the.AppBus.Subscribe(event.ACNStatus, q) - the.AppBus.Subscribe(event.NetworkStatus, q) the.AppBus.Subscribe(event.ReloadDone, q) subscribed <- true - networkOffline := false - timeSinceLastSuccess := time.Unix(0, 0) - gcd.Loaded() for { e := q.Next() switch e.EventType { - case event.NetworkStatus: - status := e.Data[event.Status] - if status == "Error" && !networkOffline { - networkOffline = true - // if it has been more that 5 minutes since we received any kind of success, then we should kill tor - // anything less that this i.e. transient networking failures, should allow us to reconnect without issue - if time.Now().Sub(timeSinceLastSuccess) > (time.Minute * 5) { - the.ACN.Restart() - } - } - - if status == "Success" && networkOffline { - timeSinceLastSuccess = time.Now() - networkOffline = false - } case event.ACNStatus: progStr := e.Data[event.Progreess] - percent, _ := strconv.Atoi(progStr) + progress, _ := strconv.Atoi(progStr) message := e.Data[event.Status] var statuscode int - if percent >= 0 && percent <= 25 { - statuscode = 1 - message = "Connecting to network" - } else if percent < 100 { - statuscode = 2 - message = "Establishing Tor circuit" - } else if percent == 100 { - statuscode = 3 - message = "tor appears to be running just fine!" - } else { + log.Debugf("ACNStatus: %d %v\n", progress, message) + if progress >= -2 && progress < 0 { statuscode = 0 - message = "can't find tor. is it running? is the controlport configured?" + } else if progress >= 0 && progress < 50 { + statuscode = 1 + } else if progress >= 50 && progress < 100 { + statuscode = 2 + } else { + statuscode = 3 } - gcd.TorStatus(statuscode, message) + gcd.TorStatus(statuscode) case event.PeerError: // current only case diff --git a/go/handlers/peerHandler.go b/go/handlers/peerHandler.go index 9909e745..537edc39 100644 --- a/go/handlers/peerHandler.go +++ b/go/handlers/peerHandler.go @@ -44,7 +44,6 @@ func PeerHandler(onion string, uiManager ui.Manager, subscribed chan bool) { switch e.EventType { case event.NetworkStatus: - the.AppBus.Publish(*e) if e.Data["Status"] == "Success" && networkOffline { networkOffline = false // TODO we may have to reinitialize the peer diff --git a/go/ui/gcd.go b/go/ui/gcd.go index 64bd1bbd..2aa034c0 100644 --- a/go/ui/gcd.go +++ b/go/ui/gcd.go @@ -69,7 +69,7 @@ type GrandCentralDispatcher struct { // profile-area stuff _ func(name, onion, image, tag string) `signal:"UpdateMyProfile"` - _ func(status int, str string) `signal:"TorStatus"` + _ func(status int) `signal:"TorStatus"` // settings helpers _ func(str string) `signal:"InvokePopup"` @@ -572,7 +572,7 @@ func (this *GrandCentralDispatcher) setLocale(locale string) { func (this *GrandCentralDispatcher) onActivate() { log.Debugln("onActivate") if the.CwtchApp != nil { - the.CwtchApp.QueryACNStatus() + go the.CwtchApp.QueryACNStatus() } } diff --git a/i18n/translation_de.qm b/i18n/translation_de.qm index 44296704..f961acc2 100644 Binary files a/i18n/translation_de.qm and b/i18n/translation_de.qm differ diff --git a/i18n/translation_de.ts b/i18n/translation_de.ts index f466ec97..0609c946 100644 --- a/i18n/translation_de.ts +++ b/i18n/translation_de.ts @@ -4,30 +4,29 @@ AddGroupPane - create-group-title - Gruppe Anlegen + Gruppe Anlegen - + server-label Server label Server - + group-name-label Group name label Gruppenname - + default-group-name default suggested group name Tolle Gruppe - + create-group-btn create group button Anlegen @@ -155,44 +154,44 @@ GroupSettingsPane - + server-label Server - - + + copy-btn Kopieren - + invitation-label Einladung - + group-name-label Gruppenname - + save-btn Speichern - + invite-to-group-label Invite someone to the group In die Gruppe einladen - + invite-btn Einladen - + delete-btn Löschen @@ -200,7 +199,7 @@ InplaceEditText - + Update @@ -244,18 +243,18 @@ Klicken, um DM zu senden - + could-not-send-msg-error Could not send this message Nachricht konnte nicht gesendet werden - + acknowledged-label bestätigt - + pending-label Bestätigung ausstehend @@ -263,25 +262,22 @@ MyProfile - copy-btn Button for copying profile onion address to clipboard - Kopieren + Kopieren - copied-clipboard-notification Copied to clipboard - in die Zwischenablage kopiert + in die Zwischenablage kopiert - new-group-btn create new group button - Neue Gruppe anlegen + Neue Gruppe anlegen - + paste-address-to-add-contact ex: "... paste an address here to add a contact ..." Adresse hier hinzufügen, um einen Kontakt aufzunehmen @@ -290,84 +286,78 @@ OverlayPane - + accept-group-invite-label Do you want to accept the invitation to $GROUP Möchtest Du die Einladung annehmen - + accept-group-btn Accept group invite button Annehmen - + reject-group-btn Reject Group invite button Ablehnen - + chat-btn Chat - + lists-btn Listen - + bulletins-btn Meldungen - puzzle-game-btn - Puzzlespiel + Puzzlespiel PeerSettingsPane - + address-label Adresse - + copy-btn Kopieren - + copied-to-clipboard-notification notification: copied to clipboard in die Zwischenablage kopiert - + display-name-label Angezeigter Name - + save-btn speichern - + delete-btn löschen - - unblock-btn - - - - + block-btn @@ -376,112 +366,102 @@ ProfileAddEditPane - add-profile-title - - - - - edit-profile-title - - - - - + default-profile-name default suggested profile name - + profile-onion-label Onion - + profile-name Display name - + radio-use-password Password - + radio-no-password Unencrypted (No password) - + no-password-warning Not using a password on this account means that all data stored locally will not be encrypted - + current-password-label Current Password - + password1-label Password - + password2-label Reenter password - + create-profile-btn Create Profile || Save Profile - + save-profile-btn - + password-error-match Passwords do not match - + password-change-error Error changing password: Supplied password rejected - + delete-profile-btn Delete Profile - + delete-confirm-label Type DELETE to confirm - + delete-profile-confirm-btn Really Delete Profile - + delete-confirm-text DELETE @@ -490,8 +470,7 @@ ProfileList - - + add-new-profile-btn @@ -499,19 +478,19 @@ ProfileManagerPane - + enter-profile-password Please enter password: - + error-0-profiles-loaded-for-password 0 profiles loaded with that password - + unlock Unlock @@ -520,51 +499,68 @@ SettingsPane - cwtch-settings-title Cwtch Settings title - Cwtch Einstellungen + Cwtch Einstellungen - + zoom-label Interface zoom (mostly affects text and button sizes) Benutzeroberflächen-Zoom (betriftt hauptsächlich Text- und Knopgrößen) - + large-text-label Groß - + default-scaling-text "Default size text (scale factor: " defaultmäßige Textgröße (Skalierungsfaktor: - + small-text-label Klein - + version %1 builddate %2 Version: %1 Built on: %2 - + block-unknown-label - StackToolbar + Statusbar - - view-group-membership-tooltip - View Group Membership + + network-status-disconnected + Disconnected from the internet, check your connection + + + + + network-status-attempting-tor + Attempting to connect to Tor network + + + + + network-status-connecting + Connecting... + + + + + network-status-online + Online diff --git a/i18n/translation_en.qm b/i18n/translation_en.qm index d08055d7..67a327df 100644 Binary files a/i18n/translation_en.qm and b/i18n/translation_en.qm differ diff --git a/i18n/translation_en.ts b/i18n/translation_en.ts index 092776c8..eb4d332c 100644 --- a/i18n/translation_en.ts +++ b/i18n/translation_en.ts @@ -4,30 +4,29 @@ AddGroupPane - create-group-title - Create Group + Create Group - + server-label Server label Server - + group-name-label Group name label Group name - + default-group-name default suggested group name Awesome Group - + create-group-btn create group button Create @@ -161,44 +160,44 @@ Right-click to reset. GroupSettingsPane - + server-label Server - - + + copy-btn Copy - + invitation-label Invitation - + group-name-label Group Name - + save-btn Save - + invite-to-group-label Invite someone to the group Invite to group - + invite-btn Invite - + delete-btn Delete @@ -206,7 +205,7 @@ Right-click to reset. InplaceEditText - + Update Update @@ -250,18 +249,18 @@ Right-click to reset. Click to DM - + could-not-send-msg-error Could not send this message Could not send this message - + acknowledged-label Acknowledged - + pending-label Pending @@ -269,25 +268,22 @@ Right-click to reset. MyProfile - copy-btn Button for copying profile onion address to clipboard - Copy + Copy - copied-clipboard-notification Copied to clipboard - Copied to clipboard + Copied to clipboard - new-group-btn create new group button - Create new group + Create new group - + paste-address-to-add-contact ex: "... paste an address here to add a contact ..." ... paste an address here to add a contact... @@ -296,84 +292,82 @@ Right-click to reset. OverlayPane - + accept-group-invite-label Do you want to accept the invitation to $GROUP Do you want to accept the invitation to - + accept-group-btn Accept group invite button Accept - + reject-group-btn Reject Group invite button Reject - + chat-btn Chat - + lists-btn Lists - + bulletins-btn Bulletins - puzzle-game-btn - Puzzle Game + Puzzle Game PeerSettingsPane - + address-label Address - + copy-btn Copy - + copied-to-clipboard-notification notification: copied to clipboard Copied to Clipboard - + display-name-label Display Name - + save-btn Save - + block-btn Block Peer - unblock-btn - Unblock Peer + Unblock Peer - + delete-btn Delete @@ -381,113 +375,111 @@ Right-click to reset. ProfileAddEditPane - add-profile-title - Add new profile + Add new profile - edit-profile-title - Edit Profile + Edit Profile - + profile-name Display name Display name - - + + default-profile-name default suggested profile name Alice - + profile-onion-label Onion Onion - + radio-use-password Password Password - + radio-no-password Unencrypted (No password) Unencrypted (No password) - + no-password-warning Not using a password on this account means that all data stored locally will not be encrypted Not using a password on this account means that all data stored locally will not be encrypted - + current-password-label Current Password Current Password - + password1-label Password Password - + password2-label Reenter password Reenter password - + create-profile-btn Create Profile || Save Profile Create Profile - + save-profile-btn Save Profile - + password-error-match Passwords do not match Passwords do not match - + password-change-error Error changing password: Supplied password rejected Error changing password: Supplied password rejected - + delete-profile-btn Delete Profile Delete Profile - + delete-confirm-label Type DELETE to confirm Type DELETE to confirm - + delete-profile-confirm-btn Really Delete Profile Really Delete Profile - + delete-confirm-text DELETE DELETE @@ -496,8 +488,7 @@ Right-click to reset. ProfileList - - + add-new-profile-btn Add new profile @@ -505,19 +496,19 @@ Right-click to reset. ProfileManagerPane - + enter-profile-password Please enter password: Please enter password - + error-0-profiles-loaded-for-password 0 profiles loaded with that password 0 profiles loaded with that password - + unlock Unlock Unlock @@ -526,41 +517,40 @@ Right-click to reset. SettingsPane - cwtch-settings-title Cwtch Settings title - Cwtch Settings + Cwtch Settings - + version %1 builddate %2 Version: %1 Built on: %2 Version: %1 Built on: %2 - + zoom-label Interface zoom (mostly affects text and button sizes) Interface zoom (mostly affects text and button sizes) - + block-unknown-label Block Unknown Peers - + large-text-label Large - + default-scaling-text "Default size text (scale factor: " Default size text (scale factor: - + small-text-label Small @@ -568,10 +558,36 @@ Right-click to reset. StackToolbar - view-group-membership-tooltip View Group Membership - View Group Membership + View Group Membership + + + + Statusbar + + + network-status-disconnected + Disconnected from the internet, check your connection + Disconnected from the internet, check your connection + + + + network-status-attempting-tor + Attempting to connect to Tor network + Attempting to connect to Tor network + + + + network-status-connecting + Connecting... + Connecting to network and peers... + + + + network-status-online + Online + Online diff --git a/i18n/translation_fr.qm b/i18n/translation_fr.qm index b97e1ede..269741c1 100644 Binary files a/i18n/translation_fr.qm and b/i18n/translation_fr.qm differ diff --git a/i18n/translation_fr.ts b/i18n/translation_fr.ts index 29507be6..ba33de5c 100644 --- a/i18n/translation_fr.ts +++ b/i18n/translation_fr.ts @@ -4,30 +4,29 @@ AddGroupPane - create-group-title - Créer un groupe + Créer un groupe - + server-label Server label Serveur - + group-name-label Group name label Groupe - + default-group-name default suggested group name Un super groupe - + create-group-btn create group button Créer @@ -155,44 +154,44 @@ GroupSettingsPane - + server-label Serveur - - + + copy-btn Copier - + invitation-label Invitation - + group-name-label Nom du groupe - + save-btn Sauvegarder - + invite-to-group-label Invite someone to the group Inviter quelqu'un - + invite-btn Invitation - + delete-btn Effacer @@ -200,7 +199,7 @@ InplaceEditText - + Update @@ -244,18 +243,18 @@ Envoyer un message privé - + could-not-send-msg-error Could not send this message Impossible d'envoyer ce message - + acknowledged-label Confirmé - + pending-label En attente @@ -263,25 +262,22 @@ MyProfile - copy-btn Button for copying profile onion address to clipboard - Copier + Copier - copied-clipboard-notification Copied to clipboard - Copié dans le presse-papier + Copié dans le presse-papier - new-group-btn create new group button - Créer un nouveau groupe + Créer un nouveau groupe - + paste-address-to-add-contact ex: "... paste an address here to add a contact ..." ... coller une adresse ici pour ajouter un contact... @@ -290,84 +286,78 @@ OverlayPane - + accept-group-invite-label Do you want to accept the invitation to $GROUP Voulez-vous accepter l'invitation au groupe - + accept-group-btn Accept group invite button Accepter - + reject-group-btn Reject Group invite button Refuser - + chat-btn Discuter - + lists-btn Listes - + bulletins-btn Bulletins - puzzle-game-btn - Puzzle + Puzzle PeerSettingsPane - + address-label Adresse - + copy-btn Copier - + copied-to-clipboard-notification notification: copied to clipboard Copié dans le presse-papier - + display-name-label Pseudo - + save-btn Sauvegarder - + delete-btn Effacer - - unblock-btn - - - - + block-btn @@ -376,112 +366,102 @@ ProfileAddEditPane - add-profile-title - - - - - edit-profile-title - - - - - + default-profile-name default suggested profile name - + profile-onion-label Onion - + profile-name Display name - + radio-use-password Password - + radio-no-password Unencrypted (No password) - + no-password-warning Not using a password on this account means that all data stored locally will not be encrypted - + current-password-label Current Password - + password1-label Password - + password2-label Reenter password - + create-profile-btn Create Profile || Save Profile - + save-profile-btn - + password-error-match Passwords do not match - + password-change-error Error changing password: Supplied password rejected - + delete-profile-btn Delete Profile - + delete-confirm-label Type DELETE to confirm - + delete-profile-confirm-btn Really Delete Profile - + delete-confirm-text DELETE @@ -490,8 +470,7 @@ ProfileList - - + add-new-profile-btn @@ -499,19 +478,19 @@ ProfileManagerPane - + enter-profile-password Please enter password: - + error-0-profiles-loaded-for-password 0 profiles loaded with that password - + unlock Unlock @@ -520,51 +499,68 @@ SettingsPane - cwtch-settings-title Cwtch Settings title - Préférences Cwtch + Préférences Cwtch - + zoom-label Interface zoom (mostly affects text and button sizes) Interface zoom (essentiellement la taille du texte et des composants de l'interface) - + large-text-label Large - + default-scaling-text "Default size text (scale factor: " Taille par défaut du texte (échelle: - + small-text-label Petit - + version %1 builddate %2 Version: %1 Built on: %2 - + block-unknown-label - StackToolbar + Statusbar - - view-group-membership-tooltip - View Group Membership + + network-status-disconnected + Disconnected from the internet, check your connection + + + + + network-status-attempting-tor + Attempting to connect to Tor network + + + + + network-status-connecting + Connecting... + + + + + network-status-online + Online diff --git a/i18n/translation_pt.qm b/i18n/translation_pt.qm index 659cade6..934c5293 100644 Binary files a/i18n/translation_pt.qm and b/i18n/translation_pt.qm differ diff --git a/i18n/translation_pt.ts b/i18n/translation_pt.ts index 6c8be065..fda57ebd 100644 --- a/i18n/translation_pt.ts +++ b/i18n/translation_pt.ts @@ -4,30 +4,29 @@ AddGroupPane - create-group-title - Criar Grupo + Criar Grupo - + server-label Server label Servidor - + group-name-label Group name label Nome do grupo - + default-group-name default suggested group name Grupo incrível - + create-group-btn create group button Criar @@ -155,44 +154,44 @@ GroupSettingsPane - + server-label Servidor - - + + copy-btn Copiar - + invitation-label Convite - + group-name-label Nome do Grupo - + save-btn Salvar - + invite-to-group-label Invite someone to the group Convidar ao grupo - + invite-btn Convidar - + delete-btn Deletar @@ -200,7 +199,7 @@ InplaceEditText - + Update @@ -244,18 +243,18 @@ Clique para DM - + could-not-send-msg-error Could not send this message Não deu para enviar esta mensagem - + acknowledged-label Confirmada - + pending-label Pendente @@ -263,25 +262,22 @@ MyProfile - copy-btn Button for copying profile onion address to clipboard - Copiar + Copiar - copied-clipboard-notification Copied to clipboard - Copiado + Copiado - new-group-btn create new group button - Criar novo grupo + Criar novo grupo - + paste-address-to-add-contact ex: "... paste an address here to add a contact ..." … cole um endereço aqui para adicionar um contato… @@ -290,84 +286,78 @@ OverlayPane - + accept-group-invite-label Do you want to accept the invitation to $GROUP Você quer aceitar o convite para - + accept-group-btn Accept group invite button Aceitar - + reject-group-btn Reject Group invite button Recusar - + chat-btn Chat - + lists-btn Listas - + bulletins-btn Boletins - puzzle-game-btn - Jogo de Adivinhação + Jogo de Adivinhação PeerSettingsPane - + address-label Endereço - + copy-btn Copiar - + copied-to-clipboard-notification notification: copied to clipboard Copiado - + display-name-label Nome de Exibição - + save-btn Salvar - + delete-btn Deletar - - unblock-btn - - - - + block-btn @@ -376,112 +366,102 @@ ProfileAddEditPane - add-profile-title - - - - - edit-profile-title - - - - - + default-profile-name default suggested profile name - + profile-onion-label Onion - + profile-name Display name - + radio-use-password Password - + radio-no-password Unencrypted (No password) - + no-password-warning Not using a password on this account means that all data stored locally will not be encrypted - + current-password-label Current Password - + password1-label Password - + password2-label Reenter password - + create-profile-btn Create Profile || Save Profile - + save-profile-btn - + password-error-match Passwords do not match - + password-change-error Error changing password: Supplied password rejected - + delete-profile-btn Delete Profile - + delete-confirm-label Type DELETE to confirm - + delete-profile-confirm-btn Really Delete Profile - + delete-confirm-text DELETE @@ -490,8 +470,7 @@ ProfileList - - + add-new-profile-btn @@ -499,19 +478,19 @@ ProfileManagerPane - + enter-profile-password Please enter password: - + error-0-profiles-loaded-for-password 0 profiles loaded with that password - + unlock Unlock @@ -520,51 +499,68 @@ SettingsPane - cwtch-settings-title Cwtch Settings title - Configurações do Cwtch + Configurações do Cwtch - + zoom-label Interface zoom (mostly affects text and button sizes) Zoom da interface (afeta principalmente tamanho de texto e botões) - + large-text-label Grande - + default-scaling-text "Default size text (scale factor: " Texto tamanho padrão (fator de escala: - + small-text-label Pequeno - + version %1 builddate %2 Version: %1 Built on: %2 - + block-unknown-label - StackToolbar + Statusbar - - view-group-membership-tooltip - View Group Membership + + network-status-disconnected + Disconnected from the internet, check your connection + + + + + network-status-attempting-tor + Attempting to connect to Tor network + + + + + network-status-connecting + Connecting... + + + + + network-status-online + Online diff --git a/main.go b/main.go index f11c373a..1d28ce20 100644 --- a/main.go +++ b/main.go @@ -238,6 +238,7 @@ func loadACN() { var err error the.ACN, err = tor.NewTorACN(the.CwtchDir, torpath) if err != nil { + // TODO: turn into UI error: status panel? log.Errorf("Could not start Tor: %v", err) os.Exit(1) } diff --git a/qml.qrc b/qml.qrc index b4983897..54cbc142 100644 --- a/qml.qrc +++ b/qml.qrc @@ -34,6 +34,8 @@ qml/widgets/RadioButton.qml qml/widgets/Button.qml qml/widgets/TextField.qml + qml/widgets/Toolbar.qml + qml/widgets/Statusbar.qml qml/widgets/controls/Loader.qml qml/widgets/controls/Variables.qml i18n/translation_de.qm diff --git a/qml/main.qml b/qml/main.qml index d10d34cc..d70ea472 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -101,7 +101,7 @@ ApplicationWindow { currentIndex: 1 anchors.right: parent.right anchors.left: parent.left - anchors.bottom: parent.bottom + anchors.bottom: statusbar.top anchors.top: toolbar.bottom readonly property int splashPane: 0 @@ -212,6 +212,8 @@ ApplicationWindow { } } + + focus: true Keys.onPressed: { if (event.key == Qt.Key_Back) { @@ -220,7 +222,7 @@ ApplicationWindow { } } - onCurrentIndexChanged : updateToolbar() + onCurrentIndexChanged : { updateToolbar(); statusbar.resetHeight() } @@ -252,6 +254,10 @@ ApplicationWindow { Component.onCompleted: updateToolbar() } + Statusbar { + id: statusbar + } + function backFn() { if (parentStack.currentIndex == parentStack.managementPane) { androidCwtchActivity.rootHomeButtonHandle() diff --git a/qml/panes/PeerSettingsPane.qml b/qml/panes/PeerSettingsPane.qml index db9d1724..fe753699 100644 --- a/qml/panes/PeerSettingsPane.qml +++ b/qml/panes/PeerSettingsPane.qml @@ -11,7 +11,7 @@ import "../widgets" as Widgets import "../styles" import "../theme" -Column { // peerSettingsPane +ColumnLayout { // peerSettingsPane id: root anchors.fill: parent property bool blocked diff --git a/qml/theme/CwtchDark.qml b/qml/theme/CwtchDark.qml index 7fb16037..3f42c772 100644 --- a/qml/theme/CwtchDark.qml +++ b/qml/theme/CwtchDark.qml @@ -37,4 +37,13 @@ ThemeType { toggleOffColor: mauvePurple toolbarIconColor: whitePurple + + statusbarDisconnectedInternetColor: whitePurple + statusbarDisconnectedInternetFontColor: deepPurple + statusbarDisconnectedTorColor: darkGrayPurple + statusbarDisconnectedTorFontColor: whitePurple + statusbarConnectingColor: deepPurple + statusbarConnectingFontColor: whitePurple + statusbarOnlineColor: mauvePurple + statusbarOnlineFontColor: whitePurple } diff --git a/qml/theme/CwtchLight.qml b/qml/theme/CwtchLight.qml index 5cf71657..f12b31ea 100644 --- a/qml/theme/CwtchLight.qml +++ b/qml/theme/CwtchLight.qml @@ -37,4 +37,13 @@ ThemeType { toggleOffColor: purple toolbarIconColor: darkPurple + + statusbarDisconnectedInternetColor: softPurple + statusbarDisconnectedInternetFontColor: darkPurple + statusbarDisconnectedTorColor: purple + statusbarDisconnectedTorFontColor: darkPurple + statusbarConnectingColor: greyPurple + statusbarConnectingFontColor: whitePurple + statusbarOnlineColor: darkPurple + statusbarOnlineFontColor: whitePurple } diff --git a/qml/theme/Theme.qml b/qml/theme/Theme.qml index 535a0dde..53d6650e 100644 --- a/qml/theme/Theme.qml +++ b/qml/theme/Theme.qml @@ -33,6 +33,15 @@ Item { readonly property color toolbarIconColor: theme.toolbarIconColor + readonly property color statusbarDisconnectedInternetColor: theme.statusbarDisconnectedInternetColor + readonly property color statusbarDisconnectedInternetFontColor: theme.statusbarDisconnectedInternetFontColor + readonly property color statusbarDisconnectedTorFontColor: theme.statusbarDisconnectedTorFontColor + readonly property color statusbarDisconnectedTorColor: theme.statusbarDisconnectedTorColor + readonly property color statusbarConnectingColor: theme.statusbarConnectingColor + readonly property color statusbarConnectingFontColor: theme.statusbarConnectingFontColor + readonly property color statusbarOnlineColor: theme.statusbarOnlineColor + readonly property color statusbarOnlineFontColor: theme.statusbarOnlineFontColor + readonly property int headerSize: 50 readonly property int usernameSize: 30 readonly property int tabSize: 25 @@ -40,6 +49,7 @@ Item { readonly property int secondaryTextSize: 20 // address readonly property int chatMetaTextSize: 15 readonly property int badgeTextSize: 12 + readonly property int statusTextSize: 12 readonly property int sidePaneMinSize: 700 readonly property int doublePaneMinSize: 1000 diff --git a/qml/theme/ThemeType.qml b/qml/theme/ThemeType.qml index efe4adaf..a71cc84b 100644 --- a/qml/theme/ThemeType.qml +++ b/qml/theme/ThemeType.qml @@ -29,6 +29,15 @@ QtObject { property color toolbarIconColor: "red" + property color statusbarDisconnectedInternetColor: "red" + property color statusbarDisconnectedInternetFontColor: "red" + property color statusbarDisconnectedTorFontColor: "red" + property color statusbarDisconnectedTorColor: "red" + property color statusbarConnectingColor: "red" + property color statusbarConnectingFontColor: "red" + property color statusbarOnlineColor: "red" + property color statusbarOnlineFontColor: "red" + // ... more to come diff --git a/qml/widgets/MyProfile.qml b/qml/widgets/MyProfile.qml index 455ec66d..c0436f94 100644 --- a/qml/widgets/MyProfile.qml +++ b/qml/widgets/MyProfile.qml @@ -170,10 +170,5 @@ Item { } onResetProfile: { realignProfile() } - - /*onTorStatus: function(code, str) { - rectTorStatus.code = code - rectTorStatus.message = str - }*/ } } diff --git a/qml/widgets/Statusbar.qml b/qml/widgets/Statusbar.qml new file mode 100644 index 00000000..38e4aaf8 --- /dev/null +++ b/qml/widgets/Statusbar.qml @@ -0,0 +1,186 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.4 + +import "." as Widgets +import "../theme" + +// Statusbar is a app wide 10-25 tall bar that should be place at the bottom of the app that gives network health information +// it changes color and text/icon message based on network health. when netowrk is not healthy it is always in fullsized mode +// when network is health it reduces to a minimal color strip unless mouse overed / clicked to reveal the text/icons +Rectangle { + id: statusbar + + property int status: statusDisconnectedInternet + + readonly property int statusDisconnectedInternet: 0 + readonly property int statusDisconnectedTor: 1 + readonly property int statusConnecting: 2 + readonly property int statusOnline: 3 + + readonly property int openHeight: 25 + readonly property int hideHeight: 10 + + property bool isHover: false + + height: openHeight + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + + Text { + id: statusMessage + opacity: 0 + anchors.right: networkStatus.left + anchors.verticalCenter: parent.verticalCenter + anchors.rightMargin: 5 * gcd.themeScale + + font.pixelSize: Theme.statusTextSize * gcd.themeScale + } + + Icon { + id: networkStatus + opacity: 0 + anchors.right: connectionStatus.left + anchors.verticalCenter: parent.verticalCenter + anchors.rightMargin: 5 * gcd.themeScale + height: 18 + width: 18 + + } + + Icon { + id: connectionStatus + opacity: 0 + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.rightMargin: 10 * gcd.themeScale + height: 18 * gcd.themeScale + width: 18 * gcd.themeScale + } + + function changeStatus() { + if (status == statusDisconnectedInternet) { + statusbar.color = Theme.statusbarDisconnectedInternetColor + statusMessage.color = Theme.statusbarDisconnectedInternetFontColor + networkStatus.iconColor = Theme.statusbarDisconnectedInternetFontColor + networkStatus.source = gcd.assetPath + "core/signal_cellular_off-24px.svg" + connectionStatus.iconColor = Theme.statusbarDisconnectedInternetFontColor + connectionStatus.source = gcd.assetPath + "core/syncing-03.svg" + //: Disconnected from the internet, check your connection + statusMessage.text = qsTr("network-status-disconnected") + show() + } else if (status == statusDisconnectedTor) { + statusbar.color = Theme.statusbarDisconnectedTorColor + statusMessage.color = Theme.statusbarDisconnectedTorFontColor + networkStatus.iconColor = Theme.statusbarDisconnectedTorFontColor + networkStatus.source = gcd.assetPath + "core/signal_cellular_connected_no_internet_4_bar-24px.svg" + connectionStatus.iconColor = Theme.statusbarDisconnectedTorFontColor + connectionStatus.source = gcd.assetPath + "core/syncing-03.svg" + //: Attempting to connect to Tor network + statusMessage.text = qsTr("network-status-attempting-tor") + show() + } else if (status == statusConnecting) { + statusbar.color = Theme.statusbarConnectingColor + statusMessage.color = Theme.statusbarConnectingFontColor + networkStatus.iconColor = Theme.statusbarConnectingFontColor + networkStatus.source = gcd.assetPath + "core/signal_cellular_connected_no_internet_4_bar-24px.svg" + connectionStatus.iconColor = Theme.statusbarConnectingFontColor + connectionStatus.source = gcd.assetPath + "core/syncing-02.svg" + //: Connecting... + statusMessage.text = qsTr("network-status-connecting") + show() + } else { + statusbar.color = Theme.statusbarOnlineColor + statusMessage.color = Theme.statusbarOnlineFontColor + networkStatus.iconColor = Theme.statusbarOnlineFontColor + networkStatus.source = gcd.assetPath + "core/signal_cellular_4_bar-24px.svg" + connectionStatus.iconColor = Theme.statusbarOnlineFontColor + connectionStatus.source = gcd.assetPath + "core/syncing-01.svg" + //: Online + statusMessage.text = qsTr("network-status-online") + hide() + } + } + + MouseArea { + id: ma + anchors.fill: parent + hoverEnabled: true + + SequentialAnimation { + id: showAnim + PropertyAnimation { id: openStatus; target: statusbar; property: "height"; to: openHeight} + ParallelAnimation { + PropertyAnimation { id: showStatus; target: statusMessage; property: "opacity"; to: 1} + PropertyAnimation { id: showNetIcon; target: networkStatus; property: "opacity"; to: 1} + PropertyAnimation { id: showConnIcon; target: connectionStatus; property: "opacity"; to: 1} + } + } + + SequentialAnimation { + id: hideAnim + ParallelAnimation { + PropertyAnimation { id: hideStatus; target: statusMessage; property: "opacity"; to: 0} + PropertyAnimation { id: hideNetIcon; target: networkStatus; property: "opacity"; to: 0} + PropertyAnimation { id: hideConnIcon; target: connectionStatus; property: "opacity"; to: 0} + } + PropertyAnimation { id: closeStatus; target: statusbar; property: "height"; to: hideHeight; duration: 200 } + } + + onEntered: { + isHover = true + show() + } + + + onExited: { + isHover = false + hide() + } + + onPressed: { + isHover = true + show() + } + + onReleased: { + isHover = false + hide() + } + } + + function resetHeight() { + if (isHover || status != statusOnline) { + height = openHeight + } else { + height = hideHeight + } + } + + function show() { + if (isHover || status != statusOnline) { + hideAnim.stop() + showAnim.start() + } + } + + function hide() { + if (!isHover && status == statusOnline) { + showAnim.stop() + hideAnim.start() + } + } + + onStatusChanged: { changeStatus() } + + Component.onCompleted: { resetHeight() } + + Connections { + target: gcd + + onTorStatus: function(code) { + status = code + } + } + +} diff --git a/qml/widgets/ToggleSwitch.qml b/qml/widgets/ToggleSwitch.qml index 06abf801..4c151aae 100644 --- a/qml/widgets/ToggleSwitch.qml +++ b/qml/widgets/ToggleSwitch.qml @@ -7,7 +7,7 @@ import "../theme" // perform any additional operations needed to define the behavior of the toggle switch Switch { property bool isToggled -property var onToggled: function () { console.log("In Superclass") }; + property var onToggled: function () { console.log("In Superclass") }; style: SwitchStyle { handle: Rectangle {