Compare commits
645 Commits
v2.6.2-rc1
...
v2.7.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03cddabfd0 | ||
|
|
8c2d77c68f | ||
|
|
d3cd422b46 | ||
|
|
482ab9ad14 | ||
|
|
835cd2ac80 | ||
|
|
36e2813169 | ||
|
|
35f8103b40 | ||
|
|
f4febe04bc | ||
|
|
c2f5f156f0 | ||
|
|
7136d92011 | ||
|
|
a35aa58943 | ||
|
|
e7f7ad7eb3 | ||
|
|
c0863ede02 | ||
|
|
45b39cdbc1 | ||
|
|
9447a10716 | ||
|
|
2039872ee5 | ||
|
|
016a90d7b0 | ||
|
|
9b5bb1365c | ||
|
|
b0dfdca76f | ||
|
|
de74057cc8 | ||
|
|
e2188b109a | ||
|
|
3ae55c2555 | ||
|
|
b47adb7aeb | ||
|
|
889cb636d3 | ||
|
|
c9719f44dc | ||
|
|
599dae0486 | ||
|
|
1c5cdc4d36 | ||
|
|
0156edf320 | ||
|
|
f425dfdfea | ||
|
|
7ea2f3fa59 | ||
|
|
1c22070a74 | ||
|
|
21f3cb8f7d | ||
|
|
9abc1eb921 | ||
|
|
94325359d7 | ||
|
|
585094a719 | ||
|
|
4b79c597dc | ||
|
|
1bc8ec59aa | ||
|
|
b9a350e201 | ||
|
|
cd80c749d6 | ||
|
|
06fdde8f1e | ||
|
|
9f259bda27 | ||
|
|
d7a9940973 | ||
|
|
db92d5bfff | ||
|
|
246f7e9395 | ||
|
|
b5549bf00c | ||
|
|
7fe138330e | ||
|
|
3488fd7c7f | ||
|
|
a3aab00ca9 | ||
|
|
d10bc1bb14 | ||
|
|
18a88fcecf | ||
|
|
c92f520423 | ||
|
|
00d73a9389 | ||
|
|
ddf67ff948 | ||
|
|
9b32ebdae4 | ||
|
|
0ec2291bd7 | ||
|
|
026bf02c85 | ||
|
|
42ebc7e995 | ||
|
|
b4b6366ba8 | ||
|
|
7b740f5e9a | ||
|
|
cb328d6cea | ||
|
|
b57b8cfb66 | ||
|
|
cb1c68a36e | ||
|
|
29138cc533 | ||
|
|
c09dd9287c | ||
|
|
65b47d4613 | ||
|
|
aab2d01a7c | ||
|
|
f748a4bb50 | ||
|
|
e4b19d0cb5 | ||
|
|
eeefbe57af | ||
|
|
84066634e7 | ||
|
|
9e82ba60b4 | ||
|
|
96a74d9ef0 | ||
|
|
1ebcd3a0fb | ||
|
|
7565c547ae | ||
|
|
8f9101773c | ||
|
|
17fcfd4e41 | ||
|
|
9e6df7a4dc | ||
|
|
9319210c4c | ||
|
|
43fa27887d | ||
|
|
58f1c3234d | ||
|
|
715924cac6 | ||
|
|
163ca3b58a | ||
|
|
1c2916052d | ||
|
|
b76da25ef1 | ||
|
|
7f35178c70 | ||
|
|
212e1f80f5 | ||
|
|
a2c9e369c3 | ||
|
|
78f12de997 | ||
|
|
8ec7cfa700 | ||
|
|
bc8f64bb98 | ||
|
|
c7cc716e57 | ||
|
|
578a3b4ef4 | ||
|
|
cc671dfad3 | ||
|
|
86b915d42e | ||
|
|
738127525f | ||
|
|
6485ef480b | ||
|
|
9af7d4ad06 | ||
|
|
32741162d9 | ||
|
|
3da982f073 | ||
|
|
a021f62e96 | ||
|
|
80e21560eb | ||
|
|
e38b98c81a | ||
|
|
9c0221a0fa | ||
|
|
afbed7dbd7 | ||
|
|
05083e32c9 | ||
|
|
c6bd8c1221 | ||
|
|
63c7844a27 | ||
|
|
762032ebbc | ||
|
|
4a64e8da83 | ||
|
|
5c6af99f11 | ||
|
|
6ac1a4a353 | ||
|
|
330ff96ee2 | ||
|
|
a90995cf15 | ||
|
|
84693b95ec | ||
|
|
aa9921c6f5 | ||
|
|
d653618b0a | ||
|
|
dc9744448c | ||
|
|
ed9c06583a | ||
|
|
ff92adf3e0 | ||
|
|
bf95c03847 | ||
|
|
e0641df727 | ||
|
|
f01c47e0ec | ||
|
|
faf46fcf60 | ||
|
|
687a99279d | ||
|
|
25e09815be | ||
|
|
02cb43180c | ||
|
|
b32310b8a6 | ||
|
|
556a1a5ef2 | ||
|
|
36467c1e3a | ||
|
|
d4b334636e | ||
|
|
7653c5fa60 | ||
|
|
bd61cd3142 | ||
|
|
1a0f7221d9 | ||
|
|
7303c726f9 | ||
|
|
44bfc79caa | ||
|
|
6f8ffc0357 | ||
|
|
bb45a5f67e | ||
|
|
baa0a5b8af | ||
|
|
9081556e1d | ||
|
|
1b14f55c3c | ||
|
|
89a5e34414 | ||
|
|
e2bc7d1307 | ||
|
|
768cf7e1ae | ||
|
|
d87a88e39f | ||
|
|
314c00a8b7 | ||
|
|
16ed62d548 | ||
|
|
2b2810511d | ||
|
|
e07859fb3c | ||
|
|
9b034a2eb0 | ||
|
|
bd9652b24c | ||
|
|
8b5f09305c | ||
|
|
6d033f2964 | ||
|
|
0bcac1882a | ||
|
|
b6b04aeff8 | ||
|
|
a69aed80e6 | ||
|
|
e81f972270 | ||
|
|
542590db7c | ||
|
|
e04aae94bc | ||
|
|
aa18667905 | ||
|
|
addb27a085 | ||
|
|
be10d5200f | ||
|
|
e8348612b4 | ||
|
|
3a160a4dce | ||
|
|
ccd20f0172 | ||
|
|
c03bc8540c | ||
|
|
003acb7254 | ||
|
|
b961b683d6 | ||
|
|
f82ef95866 | ||
|
|
ed9000bb07 | ||
|
|
6afe2b124d | ||
|
|
629d23d832 | ||
|
|
d837feca71 | ||
|
|
a7dade979c | ||
|
|
3a2caf61e5 | ||
|
|
b5ed16088a | ||
|
|
e4a20b9e72 | ||
|
|
37e5fe786f | ||
|
|
643995528b | ||
|
|
ecd17f2ea2 | ||
|
|
bf0bf2c1b6 | ||
|
|
acedf362b6 | ||
|
|
3b580eeca7 | ||
|
|
6adfff1f13 | ||
|
|
7d542d7989 | ||
|
|
b6a8195cb0 | ||
|
|
cc21d175f1 | ||
|
|
ade4b198cf | ||
|
|
32b65f576f | ||
|
|
f2bbb90d52 | ||
|
|
ffbf06755f | ||
|
|
58716bb406 | ||
|
|
782d68afa8 | ||
|
|
1c1f291778 | ||
|
|
b754eacd74 | ||
|
|
7ce8a6a201 | ||
|
|
789a2a7ae3 | ||
|
|
be4fc6b887 | ||
|
|
2dae31486a | ||
|
|
71f66c6229 | ||
|
|
b4f926ded7 | ||
|
|
438a445353 | ||
|
|
6a04fe8ab6 | ||
|
|
ca7bdf245e | ||
|
|
c45d2212a5 | ||
|
|
66bfccc738 | ||
|
|
ae7eddf7c9 | ||
|
|
36a59f09ac | ||
|
|
5869b93acb | ||
|
|
b15eb27aa9 | ||
|
|
336b64a569 | ||
|
|
6a49e787bb | ||
|
|
0c5f4a1525 | ||
|
|
6ef9f3cc26 | ||
|
|
72be80cbd9 | ||
|
|
99a27d19b9 | ||
|
|
877fd7abb9 | ||
|
|
363e62f8fa | ||
|
|
9a3aa55b29 | ||
|
|
ab9897b397 | ||
|
|
30829d0669 | ||
|
|
c18611d4af | ||
|
|
5eff8608fe | ||
|
|
c25a56b2be | ||
|
|
3a4ca5e190 | ||
|
|
d1d1f9bb58 | ||
|
|
0c81d25e96 | ||
|
|
90ace3fedc | ||
|
|
3a0ccf3697 | ||
|
|
ea1e42cb83 | ||
|
|
4e0997dbdf | ||
|
|
50b4fdc03d | ||
|
|
57084fbd3e | ||
|
|
4478399282 | ||
|
|
53abf5a316 | ||
|
|
9ce2491d67 | ||
|
|
ec637217f2 | ||
|
|
91a5395e1a | ||
|
|
dac1c9b413 | ||
|
|
c21e4f5982 | ||
|
|
478281d853 | ||
|
|
08d4c56886 | ||
|
|
4987add452 | ||
|
|
6a9f155856 | ||
|
|
407864c40e | ||
|
|
03c0d8ba5a | ||
|
|
76c7ab499f | ||
|
|
dcc84d3508 | ||
|
|
8ae18d9935 | ||
|
|
013e08f80a | ||
|
|
33dd60107d | ||
|
|
2fc76c2b24 | ||
|
|
923abd8d0b | ||
|
|
dc6c638f34 | ||
|
|
2081a265b1 | ||
|
|
a72c3ba8f0 | ||
|
|
363a865263 | ||
|
|
b40e753696 | ||
|
|
58e99184bb | ||
|
|
79ba95ce04 | ||
|
|
93319a6a61 | ||
|
|
7fb0a82e69 | ||
|
|
e9e6b85bd9 | ||
|
|
3b5966bba0 | ||
|
|
7fc592cb22 | ||
|
|
c7299dec78 | ||
|
|
fce0a50e37 | ||
|
|
c047232c3b | ||
|
|
a846f0276d | ||
|
|
e2cb3aa078 | ||
|
|
801098f546 | ||
|
|
4fc8936553 | ||
|
|
dd0135ce2e | ||
|
|
d830a1c5f7 | ||
|
|
403df7cebc | ||
|
|
45bc034261 | ||
|
|
bbbead5769 | ||
|
|
fca7b32405 | ||
|
|
d558af31c9 | ||
|
|
5131463644 | ||
|
|
9e8498ad4e | ||
|
|
3777ae4624 | ||
|
|
e896c41ef9 | ||
|
|
9d8b8be8d2 | ||
|
|
1c15b97b11 | ||
|
|
8017ee45f5 | ||
|
|
8c1e3cabe0 | ||
|
|
0c6279f86a | ||
|
|
1cffa3b731 | ||
|
|
549acb0785 | ||
|
|
a143b42c2a | ||
|
|
e85ad9de6a | ||
|
|
0ab5bbb08e | ||
|
|
4efa282f80 | ||
|
|
d53cfbd9fb | ||
|
|
94986877d8 | ||
|
|
f3bc2f5e87 | ||
|
|
a5365a6cce | ||
|
|
b9ad82ceeb | ||
|
|
fe959fe0d5 | ||
|
|
6421397083 | ||
|
|
52ae354ca2 | ||
|
|
c6ff66be79 | ||
|
|
73af9b1cac | ||
|
|
cdaee7b933 | ||
|
|
6adbd9bd50 | ||
|
|
6acf3871e4 | ||
|
|
ead2131ba2 | ||
|
|
cf1532acf1 | ||
|
|
17ca7ab5db | ||
|
|
c42332a5ee | ||
|
|
c736f48ac9 | ||
|
|
06b251063e | ||
|
|
cb7b2a3dc6 | ||
|
|
5ac203ebd8 | ||
|
|
6135eb26ad | ||
|
|
d18e2ba339 | ||
|
|
7ed03f1f29 | ||
|
|
5301477747 | ||
|
|
73667a5367 | ||
|
|
09c282d9ea | ||
|
|
f9f1b49298 | ||
|
|
f5ff69f8b3 | ||
|
|
1e43c29484 | ||
|
|
a15cad0088 | ||
|
|
8e8858178b | ||
|
|
528352ba82 | ||
|
|
e54f127a06 | ||
|
|
d9fd9cfef2 | ||
|
|
9618500975 | ||
|
|
25076f2ddc | ||
|
|
66912071a8 | ||
|
|
e9438549f4 | ||
|
|
eff75a2059 | ||
|
|
d001d9d1a3 | ||
|
|
5c3f71c097 | ||
|
|
7f764f8108 | ||
|
|
2dcf594fc6 | ||
|
|
076469f385 | ||
|
|
e178eeb7f5 | ||
|
|
a8cf6e0443 | ||
|
|
725458b63c | ||
|
|
9a11bef263 | ||
|
|
b184cba953 | ||
|
|
8b393ce792 | ||
|
|
f801ffe4f7 | ||
|
|
b293a5b818 | ||
|
|
beffd726bd | ||
|
|
41f6c9e52d | ||
|
|
ce71673824 | ||
|
|
e05f187fcf | ||
|
|
04b5754653 | ||
|
|
44bc3692fd | ||
|
|
3a310f93e0 | ||
|
|
706769026d | ||
|
|
704e34fa99 | ||
|
|
a6fae36cb2 | ||
|
|
4c791abafc | ||
|
|
11e14f1726 | ||
|
|
0273689ca9 | ||
|
|
05a56c2e8e | ||
|
|
325dd8732e | ||
|
|
4d5dd0f49c | ||
|
|
39d85fd008 | ||
|
|
a12164ad53 | ||
|
|
805b85a4d7 | ||
|
|
cacb300ffd | ||
|
|
15e36c535f | ||
|
|
b5e51c7e34 | ||
|
|
e4482ef675 | ||
|
|
09b3be25fc | ||
|
|
7235db2793 | ||
|
|
35005e46b4 | ||
|
|
abd50022d1 | ||
|
|
e9c12c32d2 | ||
|
|
8950417d37 | ||
|
|
8c6e2f84c1 | ||
|
|
d0aec7696a | ||
|
|
a9da2a2277 | ||
|
|
4f1e4e149f | ||
|
|
bd25144390 | ||
|
|
3d1fc20d01 | ||
|
|
921b144d06 | ||
|
|
12d306fa85 | ||
|
|
3b750895b4 | ||
|
|
8c334a1f43 | ||
|
|
6db3b2fb78 | ||
|
|
5775ec1ff1 | ||
|
|
32bb31a417 | ||
|
|
87844f5ff4 | ||
|
|
19491ff85f | ||
|
|
8546d53b05 | ||
|
|
dfb20586ce | ||
|
|
5783c406a2 | ||
|
|
6c56811636 | ||
|
|
08c7be5350 | ||
|
|
ade9c6ce72 | ||
|
|
fdefb19bdb | ||
|
|
ade50d0b92 | ||
|
|
09bae4d6e1 | ||
|
|
0c30d9cfe8 | ||
|
|
94dae8d535 | ||
|
|
e8fc3ecf28 | ||
|
|
b3a03e9c58 | ||
|
|
097b923871 | ||
|
|
f422a63200 | ||
|
|
eec460a32d | ||
|
|
5ccea62ba6 | ||
|
|
529beb328a | ||
|
|
796cc8cd28 | ||
|
|
c8b4145214 | ||
|
|
04a9f0313a | ||
|
|
6166961804 | ||
|
|
4ddc606361 | ||
|
|
836c748cd9 | ||
|
|
3bee0bcf04 | ||
|
|
0d349d54b4 | ||
|
|
29123f4d9d | ||
|
|
a16c1a8957 | ||
|
|
c1cd308940 | ||
|
|
4bba498229 | ||
|
|
40b2fc8848 | ||
|
|
6bc13fcab1 | ||
|
|
c3cb7dfadd | ||
|
|
7750d2198d | ||
|
|
3ced2a6ea3 | ||
|
|
f993e7c555 | ||
|
|
35df5691f2 | ||
|
|
6b71e4ec6f | ||
|
|
9c199cc753 | ||
|
|
57f9b8159f | ||
|
|
a94e116926 | ||
|
|
75444e44b9 | ||
|
|
dbfa5dc786 | ||
|
|
17f39bd09d | ||
|
|
7c8e650c5a | ||
|
|
eaddc55267 | ||
|
|
f6b6765424 | ||
|
|
f3ab9d5fef | ||
|
|
998354b5ab | ||
|
|
852d39e271 | ||
|
|
7deb74cc22 | ||
|
|
ba6d1ab886 | ||
|
|
c72aa457b3 | ||
|
|
6ed6a5e8ea | ||
|
|
fd7ba861a1 | ||
|
|
b25aa99de7 | ||
|
|
dddb233f16 | ||
|
|
04dd02c295 | ||
|
|
3f495a30e0 | ||
|
|
37f74291b5 | ||
|
|
361c5a5a54 | ||
|
|
4114fe68c9 | ||
|
|
4dddf88569 | ||
|
|
7f19d5669b | ||
|
|
c6705ecd9c | ||
|
|
28da954aad | ||
|
|
a8fbbc65c1 | ||
|
|
47ffcfd561 | ||
|
|
481d8d3a0b | ||
|
|
ace142bb23 | ||
|
|
ea14baff6c | ||
|
|
0c4c5c5f8b | ||
|
|
0a407a39b0 | ||
|
|
3ad1c0e7a8 | ||
|
|
a140720901 | ||
|
|
141d31c546 | ||
|
|
f293dbfeeb | ||
|
|
3f533edba6 | ||
|
|
10a5e75cd8 | ||
|
|
58349fae02 | ||
|
|
3269402f48 | ||
|
|
26f7848821 | ||
|
|
08efb40599 | ||
|
|
f81e5be119 | ||
|
|
cf4fcebc53 | ||
|
|
00db94a73c | ||
|
|
a8ecf486d1 | ||
|
|
83918619cf | ||
|
|
f52c330c22 | ||
|
|
67ed54671b | ||
|
|
fc6b895f52 | ||
|
|
6f9256f290 | ||
|
|
f6b03f0186 | ||
|
|
555c513acb | ||
|
|
96da4674f9 | ||
|
|
e5f0ee3b92 | ||
|
|
570041e3b4 | ||
|
|
c0e7120b12 | ||
|
|
82a73e443c | ||
|
|
5d3a8e3725 | ||
|
|
8f616969ab | ||
|
|
cb60e8aa90 | ||
|
|
b9f0e444e8 | ||
|
|
cd89efc24b | ||
|
|
8ebacae846 | ||
|
|
7a033395f2 | ||
|
|
dd90ed9643 | ||
|
|
d392843c12 | ||
|
|
e944aa6f2d | ||
|
|
08c76f5997 | ||
|
|
4c2895c92f | ||
|
|
d8dca83dd5 | ||
|
|
0ff91574d2 | ||
|
|
30cff4e4f8 | ||
|
|
1138118d8e | ||
|
|
be2c1fdb89 | ||
|
|
030e85c06c | ||
|
|
b493f03d42 | ||
|
|
4bfd2a5d77 | ||
|
|
4945dd126a | ||
|
|
8caa997181 | ||
|
|
2b88ea390c | ||
|
|
31f3b322c8 | ||
|
|
55ebd5154c | ||
|
|
dcc33f3417 | ||
|
|
eab8c1eb7e | ||
|
|
5a9fc02f07 | ||
|
|
9d6780d6c1 | ||
|
|
811c3c995a | ||
|
|
44ed5744f1 | ||
|
|
179bbffd76 | ||
|
|
207de071f4 | ||
|
|
0845f25f70 | ||
|
|
916d414543 | ||
|
|
b93fbddf05 | ||
|
|
b40e3e7b4e | ||
|
|
c46ca5c256 | ||
|
|
44d954ade9 | ||
|
|
cdc939ae97 | ||
|
|
a2a753a34b | ||
|
|
d0e25c230a | ||
|
|
82a67a44c4 | ||
|
|
233a423e8c | ||
|
|
5e099adb2f | ||
|
|
a35b346e62 | ||
|
|
7d4406254a | ||
|
|
70091726c9 | ||
|
|
564088680a | ||
|
|
1eb61b7949 | ||
|
|
f6bac6cfdd | ||
|
|
e8c8fe4223 | ||
|
|
3659bca0ec | ||
|
|
ace3da841c | ||
|
|
457b0c3ab1 | ||
|
|
544229d1e8 | ||
|
|
af05db895c | ||
|
|
2958cf2180 | ||
|
|
32c114bd17 | ||
|
|
1d96b102c0 | ||
|
|
d6fce49162 | ||
|
|
ff5bf8634f | ||
|
|
f49cd1850c | ||
|
|
d420242fcb | ||
|
|
c873da75e4 | ||
|
|
9b60573d7e | ||
|
|
907f36bfcb | ||
|
|
04fedf83b4 | ||
|
|
f3d774e2e5 | ||
|
|
8f40161fa2 | ||
|
|
febc035063 | ||
|
|
4902751d02 | ||
|
|
45bd869a15 | ||
|
|
905c1532fe | ||
|
|
c3d8657619 | ||
|
|
51ff031de5 | ||
|
|
6b9395a3c5 | ||
|
|
b1db012094 | ||
|
|
556e8d39aa | ||
|
|
cd5ff96904 | ||
|
|
24a20ec758 | ||
|
|
4edab98b58 | ||
|
|
dd130ede8f | ||
|
|
81bcb46ef2 | ||
|
|
37f532c1f0 | ||
|
|
04f2bd4baa | ||
|
|
07df659a3f | ||
|
|
e89ff9ae61 | ||
|
|
c662ff1902 | ||
|
|
a3825080db | ||
|
|
a237493def | ||
|
|
3a0cd45782 | ||
|
|
f08cc08eb2 | ||
|
|
e3685b951c | ||
|
|
6b04e2f77b | ||
|
|
2e8b7771b0 | ||
|
|
26e98d35e6 | ||
|
|
ab3d0141ec | ||
|
|
39df36c247 | ||
|
|
7473cdf184 | ||
|
|
4f7d7e3601 | ||
|
|
49a6dc311e | ||
|
|
c585e81530 | ||
|
|
c779098772 | ||
|
|
cc07ed1ee8 | ||
|
|
222b2d8645 | ||
|
|
f41eeaf6ec | ||
|
|
48097801e8 | ||
|
|
dca83aad45 | ||
|
|
be7a524557 | ||
|
|
0827ff0995 | ||
|
|
503b9de2a0 | ||
|
|
a2d47cdec4 | ||
|
|
ba74c24d8f | ||
|
|
d60a216982 | ||
|
|
d6af025a46 | ||
|
|
82fa10c227 | ||
|
|
13b2b5253e | ||
|
|
46e0a05078 | ||
|
|
8329de4cee | ||
|
|
b4dee67bf5 | ||
|
|
5ae3435fe6 | ||
|
|
9a256fcbfe | ||
|
|
112d2bfe11 | ||
|
|
69a11a7ec1 | ||
|
|
3960ffea3f | ||
|
|
78543deee4 | ||
|
|
4dd49327e4 | ||
|
|
2121e7116e | ||
|
|
67107a4f5d | ||
|
|
0557d53f5f | ||
|
|
819a006a17 | ||
|
|
65ee5915af | ||
|
|
8ad3b18932 | ||
|
|
c835c39491 | ||
|
|
4cb45d5d6a | ||
|
|
b28ae98d58 | ||
|
|
c389985c2e | ||
|
|
ac24874585 | ||
|
|
a9bea53c89 | ||
|
|
0f7c10a2d6 | ||
|
|
18f51e47d7 | ||
|
|
aba4b722af | ||
|
|
654049d4fd | ||
|
|
cea0d519a4 | ||
|
|
ff7b0aace9 | ||
|
|
9b476a5caa | ||
|
|
2c58bee151 | ||
|
|
c4ffd844f3 | ||
|
|
cbc19e86fb | ||
|
|
10073c1f10 | ||
|
|
8a35bfdc13 | ||
|
|
ddf1ac04e5 | ||
|
|
aa388b86c0 | ||
|
|
f9c6449c05 | ||
|
|
3c00c09ea8 |
37
.drone.yml
@@ -22,11 +22,11 @@ steps:
|
||||
source /opt/qt57/bin/qt57-env.sh &&
|
||||
mkdir build &&
|
||||
cd build &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 ../ &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
|
||||
make &&
|
||||
useradd -m -s /bin/bash test &&
|
||||
chown -R test:test . &&
|
||||
su -c 'ctest --output-on-failure' test"
|
||||
su -c 'ASAN_OPTIONS=detect_leaks=0 ctest --output-on-failure' test"
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
@@ -59,11 +59,11 @@ steps:
|
||||
source /opt/qt58/bin/qt58-env.sh &&
|
||||
mkdir build &&
|
||||
cd build &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 ../ &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
|
||||
make &&
|
||||
useradd -m -s /bin/bash test &&
|
||||
chown -R test:test . &&
|
||||
su -c 'ctest --output-on-failure' test"
|
||||
su -c 'ASAN_OPTIONS=detect_leaks=0 ctest --output-on-failure' test"
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
@@ -96,11 +96,11 @@ steps:
|
||||
source /opt/qt59/bin/qt59-env.sh &&
|
||||
mkdir build &&
|
||||
cd build &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 ../ &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
|
||||
make &&
|
||||
useradd -m -s /bin/bash test &&
|
||||
chown -R test:test . &&
|
||||
su -c 'ctest --output-on-failure' test"
|
||||
su -c 'ASAN_OPTIONS=detect_leaks=0 ctest --output-on-failure' test"
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
@@ -137,11 +137,11 @@ steps:
|
||||
source /opt/qt510/bin/qt510-env.sh &&
|
||||
mkdir build &&
|
||||
cd build &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 ../ &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
|
||||
make &&
|
||||
useradd -m -s /bin/bash test &&
|
||||
chown -R test:test . &&
|
||||
su -c 'ctest --output-on-failure' test"
|
||||
su -c 'ASAN_OPTIONS=detect_leaks=0 ctest --output-on-failure' test"
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
@@ -178,11 +178,11 @@ steps:
|
||||
source /opt/qt511/bin/qt511-env.sh &&
|
||||
mkdir build &&
|
||||
cd build &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 ../ &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
|
||||
make &&
|
||||
useradd -m -s /bin/bash test &&
|
||||
chown -R test:test . &&
|
||||
su -c 'ctest --output-on-failure' test"
|
||||
su -c 'ASAN_OPTIONS=detect_leaks=0 ctest --output-on-failure' test"
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
@@ -219,11 +219,11 @@ steps:
|
||||
source /opt/qt511/bin/qt511-env.sh &&
|
||||
mkdir build &&
|
||||
cd build &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 ../ &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
|
||||
make &&
|
||||
useradd -m -s /bin/bash test &&
|
||||
chown -R test:test . &&
|
||||
su -c 'ctest --output-on-failure' test"
|
||||
su -c 'ASAN_OPTIONS=detect_leaks=0 ctest --output-on-failure' test"
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
@@ -268,11 +268,11 @@ steps:
|
||||
export PKG_CONFIG_PATH=\$QT_BASE_DIR/lib/pkgconfig:\$PKG_CONFIG_PATH &&
|
||||
mkdir build &&
|
||||
cd build &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 ../ &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
|
||||
make &&
|
||||
useradd -m -s /bin/bash test &&
|
||||
chown -R test:test . &&
|
||||
su -c 'ctest --output-on-failure' test"
|
||||
su -c 'ASAN_OPTIONS=detect_leaks=0 ctest --output-on-failure' test"
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
@@ -317,11 +317,11 @@ steps:
|
||||
export PKG_CONFIG_PATH=\$QT_BASE_DIR/lib/pkgconfig:\$PKG_CONFIG_PATH &&
|
||||
mkdir build &&
|
||||
cd build &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 ../ &&
|
||||
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
|
||||
make &&
|
||||
useradd -m -s /bin/bash test &&
|
||||
chown -R test:test . &&
|
||||
su -c 'ctest --output-on-failure' test"
|
||||
su -c 'ASAN_OPTIONS=detect_leaks=0 ctest --output-on-failure' test"
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
@@ -361,9 +361,10 @@ steps:
|
||||
from_secret: DEBIAN_SECRET_IV
|
||||
trigger:
|
||||
branch:
|
||||
- stable-2.6
|
||||
- master
|
||||
event:
|
||||
- tag
|
||||
- pull_request
|
||||
- push
|
||||
---
|
||||
kind: pipeline
|
||||
name: Documentation
|
||||
|
||||
3
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
# You can add one username per supported platform and one custom link
|
||||
custom: https://www.bountysource.com/teams/nextcloud/issues?tracker_ids=74294474
|
||||
67
.github/stale.yml
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 28
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 14
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- 1. to develop
|
||||
- 2. to review
|
||||
- 3. to release
|
||||
- 4. to test
|
||||
- accessibility
|
||||
- backport-request
|
||||
- bug
|
||||
- design
|
||||
- enhancement
|
||||
- epic
|
||||
- discussion
|
||||
- documentation
|
||||
- overview
|
||||
- good first issue
|
||||
- feature-request
|
||||
- feature: :arrows_counterclockwise: sync engine
|
||||
- feature: :busts_in_silhouette: sharing
|
||||
- feature: :cloud: system tray
|
||||
- feature: :gear: settings
|
||||
- feature: :inbox_tray: install and update
|
||||
- feature: :key: authentication
|
||||
- feature: :lock: end to end encryption
|
||||
- feature: :memo: versions
|
||||
- feature: :minidisc: external storage
|
||||
- feature: :minidisc: virtual drive
|
||||
- feature: :new: versions
|
||||
- feature: :tongue: language l10n and translations
|
||||
- feature: :wheelchair: accessibility
|
||||
- feature: :white_square_button: nextcloudcmd
|
||||
- feature: :zap: activity and :bell: notification
|
||||
- good first issue
|
||||
- help wanted
|
||||
- high
|
||||
- integration
|
||||
- low
|
||||
- medium
|
||||
- needs info
|
||||
- os: :apple: macOS
|
||||
- os: :door: Windows
|
||||
- os: :penguin: Linux
|
||||
- os: :smiling_imp: FreeBSD
|
||||
- overview
|
||||
- package: appimage
|
||||
- package: debian
|
||||
- package: snap
|
||||
- papercut
|
||||
- regression
|
||||
- security
|
||||
- server
|
||||
- spec
|
||||
- technical debt
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This request did not receive an update in the last 4 weeks.
|
||||
Please take a look again and update the issue with new details,
|
||||
otherwise the issue will be automatically closed in 2 weeks. Thank you!
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
||||
@@ -198,7 +198,7 @@ X-GNOME-Autostart-Delay=3
|
||||
|
||||
|
||||
# Translations
|
||||
Icon[cs_CZ]=@NAZEV_IKONY_APLIKACE@
|
||||
Icon[cs_CZ]=@APPLICATION_ICON_NAME@
|
||||
Name[cs_CZ]=@APPLICATION_NAME@ synchronizační klient pro desktop
|
||||
Comment[cs_CZ]=@APPLICATION_NAME@ synchronizační klient pro desktop
|
||||
GenericName[cs_CZ]=Synchronizace složek
|
||||
|
||||
@@ -198,7 +198,7 @@ X-GNOME-Autostart-Delay=3
|
||||
|
||||
|
||||
# Translations
|
||||
Icon[de]=@APPLICATION_ICON_NAME@
|
||||
Name[de]=@APPLICATION_NAME@ Client zur Desktop-Synchronisation
|
||||
Comment[de]=@APPLICATION_NAME@ Client zur Desktop-Synchronisation
|
||||
GenericName[de]=Synchronisationsordner
|
||||
Icon[de_DE]=@APPLICATION_ICON_NAME@
|
||||
Name[de_DE]=@APPLICATION_NAME@ Client zur Desktop-Synchronisation
|
||||
Comment[de_DE]=@APPLICATION_NAME@ Client zur Desktop-Synchronisation
|
||||
GenericName[de_DE]=Synchronisationsordner
|
||||
|
||||
@@ -198,4 +198,7 @@ X-GNOME-Autostart-Delay=3
|
||||
|
||||
|
||||
# Translations
|
||||
Icon[el]=@APPLICATION_ICON_NAME@
|
||||
Name[el]=@APPLICATION_NAME@ πρόγραμμα συγχρονισμού
|
||||
Comment[el]=@APPLICATION_NAME@ πρόγραμμα συγχρονισμού
|
||||
GenericName[el]=Συγχρονισμός φακέλου
|
||||
|
||||
204
.tx/nextcloud.client-desktop/es_AR_translation
Normal file
@@ -0,0 +1,204 @@
|
||||
[Desktop Entry]
|
||||
Categories=Utility;X-SuSE-SyncUtility;
|
||||
Type=Application
|
||||
Exec=@APPLICATION_EXECUTABLE@
|
||||
Name=@APPLICATION_NAME@ desktop sync client
|
||||
Comment=@APPLICATION_NAME@ desktop synchronization client
|
||||
GenericName=Folder Sync
|
||||
Icon=@APPLICATION_ICON_NAME@
|
||||
Keywords=@APPLICATION_NAME@;syncing;file;sharing;
|
||||
X-GNOME-Autostart-Delay=3
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
Icon[es_AR]=@APPLICATION_ICON_NAME@
|
||||
Name[es_AR]=@APPLICATION_NAME@ cliente de sincronización de escritorio
|
||||
Comment[es_AR]=@APPLICATION_NAME@ cliente de sincronización de escritorio
|
||||
GenericName[es_AR]=Sincronización de carpetas
|
||||
@@ -199,4 +199,6 @@ X-GNOME-Autostart-Delay=3
|
||||
|
||||
# Translations
|
||||
Icon[sv]=@APPLICATION_ICON_NAME@
|
||||
Name[sv]=@APPLICATION_NAME@ desktopssynkklient
|
||||
Comment[sv]=@APPLICATION_NAME@ desktopssynkroniseringsklient
|
||||
GenericName[sv]=Mappsynkronisering
|
||||
|
||||
@@ -219,6 +219,12 @@ if (APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
endif()
|
||||
|
||||
option(SANITIZE_ADDRESS "Enable address sanitizer in tests" OFF)
|
||||
if (SANITIZE_ADDRESS)
|
||||
include(SanitizerFlags)
|
||||
enable_sanitizer()
|
||||
endif ()
|
||||
|
||||
# Handle Translations, pick all client_* files from trans directory.
|
||||
file( GLOB TRANS_FILES ${CMAKE_SOURCE_DIR}/translations/client_*.ts)
|
||||
set(TRANSLATIONS ${TRANS_FILES})
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
Will be tracked going forward here:
|
||||
https://github.com/nextcloud/desktop/releases
|
||||
|
||||
2.5 Series ChangeLog
|
||||
====================
|
||||
|
||||
|
||||
@@ -7,11 +7,12 @@ set( APPLICATION_UPDATE_URL "https://updates.nextcloud.org/client/" CACHE STRING
|
||||
set( APPLICATION_HELP_URL "" CACHE STRING "URL for the help menu" )
|
||||
set( APPLICATION_ICON_NAME "Nextcloud" )
|
||||
set( APPLICATION_SERVER_URL "" CACHE STRING "URL for the server to use. If entered the server can only connect to this instance" )
|
||||
set( APPLICATION_REV_DOMAIN "com.nextcloud.desktopclient" )
|
||||
|
||||
set( LINUX_PACKAGE_SHORTNAME "nextcloud" )
|
||||
set( LINUX_APPLICATION_ID "${APPLICATION_REV_DOMAIN}.${LINUX_PACKAGE_SHORTNAME}")
|
||||
|
||||
set( THEME_CLASS "NextcloudTheme" )
|
||||
set( APPLICATION_REV_DOMAIN "com.nextcloud.desktopclient" )
|
||||
set( WIN_SETUP_BITMAP_PATH "${CMAKE_SOURCE_DIR}/admin/win/nsi" )
|
||||
|
||||
set( MAC_INSTALLER_BACKGROUND_FILE "${CMAKE_SOURCE_DIR}/admin/osx/installer-background.png" CACHE STRING "The MacOSX installer background image")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
set( MIRALL_VERSION_MAJOR 2 )
|
||||
set( MIRALL_VERSION_MINOR 6 )
|
||||
set( MIRALL_VERSION_PATCH 2 )
|
||||
set( MIRALL_VERSION_YEAR 2019 )
|
||||
set( MIRALL_VERSION_MINOR 7 )
|
||||
set( MIRALL_VERSION_PATCH 0 )
|
||||
set( MIRALL_VERSION_YEAR 2020 )
|
||||
set( MIRALL_SOVERSION 0 )
|
||||
|
||||
if ( NOT DEFINED MIRALL_VERSION_SUFFIX )
|
||||
|
||||
@@ -12,17 +12,20 @@ export PATH=$QT_BASE_DIR/bin:$PATH
|
||||
export LD_LIBRARY_PATH=$QT_BASE_DIR/lib/x86_64-linux-gnu:$QT_BASE_DIR/lib:$LD_LIBRARY_PATH
|
||||
export PKG_CONFIG_PATH=$QT_BASE_DIR/lib/pkgconfig:$PKG_CONFIG_PATH
|
||||
|
||||
#Set APPID for .desktop file processing
|
||||
export LINUX_APPLICATION_ID=com.nextcloud.desktopclient.nextcloud
|
||||
|
||||
#set defaults
|
||||
export SUFFIX=${DRONE_PULL_REQUEST:=master}
|
||||
if [ $SUFFIX != "master" ]; then
|
||||
SUFFIX="PR-$SUFFIX"
|
||||
fi
|
||||
|
||||
#QtKeyChain 0.9.1
|
||||
#QtKeyChain master
|
||||
cd /build
|
||||
git clone https://github.com/frankosterfeld/qtkeychain.git
|
||||
cd qtkeychain
|
||||
git checkout v0.9.1
|
||||
git checkout master
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -D CMAKE_INSTALL_PREFIX=/usr ../
|
||||
@@ -62,7 +65,7 @@ rm -rf ./usr/share/caja-python/
|
||||
rm -rf ./usr/share/nautilus-python/
|
||||
rm -rf ./usr/share/nemo-python/
|
||||
|
||||
# Move sync exlucde to right location
|
||||
# Move sync exclude to right location
|
||||
mv ./etc/Nextcloud/sync-exclude.lst ./usr/bin/
|
||||
rm -rf ./etc
|
||||
|
||||
@@ -88,7 +91,7 @@ chmod a+x linuxdeployqt*.AppImage
|
||||
rm ./linuxdeployqt-continuous-x86_64.AppImage
|
||||
unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=/app/usr/lib/
|
||||
./squashfs-root/AppRun ${DESKTOP_FILE} -bundle-non-qt-libs
|
||||
./squashfs-root/AppRun ${DESKTOP_FILE} -bundle-non-qt-libs -qmldir=$DRONE_WORKSPACE/src/gui
|
||||
|
||||
# Set origin
|
||||
./squashfs-root/usr/bin/patchelf --set-rpath '$ORIGIN/' /app/usr/lib/libnextcloudsync.so.0
|
||||
|
||||
19
client.qrc
@@ -1,16 +1,8 @@
|
||||
<RCC>
|
||||
<qresource prefix="/client">
|
||||
<file>resources/dialog-close.png</file>
|
||||
<file>resources/dialog-ok.png</file>
|
||||
<file>resources/dialog-cancel.png</file>
|
||||
<file>resources/folder-sync.png</file>
|
||||
<file>resources/folder-sync@2x.png</file>
|
||||
<file>resources/task-ongoing.png</file>
|
||||
<file>resources/view-refresh.png</file>
|
||||
<file>resources/warning.png</file>
|
||||
<file>resources/warning@2x.png</file>
|
||||
<file>resources/settings.png</file>
|
||||
<file>resources/settings@2x.png</file>
|
||||
<file>resources/activity.svg</file>
|
||||
<file>resources/activity.png</file>
|
||||
<file>resources/activity@2x.png</file>
|
||||
<file>resources/network.png</file>
|
||||
@@ -20,13 +12,13 @@
|
||||
<file>resources/lock-https.png</file>
|
||||
<file>resources/lock-https@2x.png</file>
|
||||
<file>resources/account.png</file>
|
||||
<file>resources/account.svg</file>
|
||||
<file>resources/more.svg</file>
|
||||
<file>resources/delete.png</file>
|
||||
<file>resources/close.svg</file>
|
||||
<file>resources/bell.svg</file>
|
||||
<file>resources/link.svg</file>
|
||||
<file>resources/files.svg</file>
|
||||
<file>resources/folder-grey.png</file>
|
||||
<file>resources/state-error.svg</file>
|
||||
<file>resources/state-warning.svg</file>
|
||||
<file>resources/folder.svg</file>
|
||||
@@ -38,7 +30,14 @@
|
||||
<file>resources/copy.svg</file>
|
||||
<file>resources/state-sync.svg</file>
|
||||
<file>resources/add.png</file>
|
||||
<file>resources/add-color.svg</file>
|
||||
<file>resources/state-info.svg</file>
|
||||
<file>resources/change.svg</file>
|
||||
<file>resources/delete-color.svg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/"/>
|
||||
<qresource prefix="/qml">
|
||||
<file>src/gui/tray/Window.qml</file>
|
||||
<file>src/gui/tray/UserLine.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>@MIRALL_VERSION_STRING@</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>(C) 2014-2019 @APPLICATION_VENDOR@</string>
|
||||
<string>(C) 2014-2020 @APPLICATION_VENDOR@</string>
|
||||
<key>NSSupportsAutomaticGraphicsSwitching</key>
|
||||
<true/>
|
||||
<key>SUShowReleaseNotes</key>
|
||||
|
||||
17
cmake/modules/SanitizerFlags.cmake
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
# Enable address sanitizer (gcc/clang only)
|
||||
macro(ENABLE_SANITIZER)
|
||||
|
||||
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
message(FATAL_ERROR "Sanitizer supported only for gcc/clang")
|
||||
endif()
|
||||
|
||||
set(SANITIZER_FLAGS "-fsanitize=address -fsanitize=leak -g")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}")
|
||||
|
||||
set(LINKER_FLAGS "-fsanitize=address,undefined -fuse-ld=gold")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}")
|
||||
|
||||
endmacro()
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
#cmakedefine CRASHREPORTER_EXECUTABLE "@CRASHREPORTER_EXECUTABLE@"
|
||||
#define SOCKETAPI_TEAM_IDENTIFIER_PREFIX "@SOCKETAPI_TEAM_IDENTIFIER_PREFIX@"
|
||||
|
||||
#cmakedefine APPLICATION_DOMAIN @APPLICATION_DOMAIN@
|
||||
#cmakedefine THEME_CLASS @THEME_CLASS@
|
||||
#cmakedefine THEME_INCLUDE @THEME_INCLUDE@
|
||||
|
||||
#cmakedefine APPLICATION_NAME "@APPLICATION_NAME@"
|
||||
#cmakedefine APPLICATION_VENDOR "@APPLICATION_VENDOR@"
|
||||
#cmakedefine APPLICATION_DOMAIN "@APPLICATION_DOMAIN@"
|
||||
#cmakedefine APPLICATION_REV_DOMAIN "@APPLICATION_REV_DOMAIN@"
|
||||
#cmakedefine APPLICATION_SHORTNAME "@APPLICATION_SHORTNAME@"
|
||||
#cmakedefine APPLICATION_EXECUTABLE "@APPLICATION_EXECUTABLE@"
|
||||
@@ -21,6 +21,7 @@
|
||||
#cmakedefine APPLICATION_HELP_URL "@APPLICATION_HELP_URL@"
|
||||
#cmakedefine APPLICATION_ICON_NAME "@APPLICATION_ICON_NAME@"
|
||||
#cmakedefine APPLICATION_SERVER_URL "@APPLICATION_SERVER_URL@"
|
||||
#cmakedefine LINUX_APPLICATION_ID "@LINUX_APPLICATION_ID@"
|
||||
#cmakedefine APPLICATION_WIZARD_HEADER_BACKGROUND_COLOR "@APPLICATION_WIZARD_HEADER_BACKGROUND_COLOR@"
|
||||
#cmakedefine APPLICATION_WIZARD_HEADER_TITLE_COLOR "@APPLICATION_WIZARD_HEADER_TITLE_COLOR@"
|
||||
#cmakedefine APPLICATION_WIZARD_USE_CUSTOM_LOGO "@APPLICATION_WIZARD_USE_CUSTOM_LOGO@"
|
||||
|
||||
@@ -13,11 +13,19 @@ desktop client.
|
||||
|
||||
These instructions are updated to work with version |version| of the Nextcloud Client.
|
||||
|
||||
Getting Source Code
|
||||
-------------------
|
||||
You have two possibilities to clone the repo.
|
||||
|
||||
The :ref:`generic-build-instructions` pull the latest code directly from
|
||||
GitHub, and work on Linux, macOS, and Windows.
|
||||
First option is As [remote URL](https://help.github.com/en/articles/which-remote-url-should-i-use) you can choose between cloning with HTTPS URL's, which is recommended or cloning with SSH URL's.
|
||||
|
||||
[https://github.com/nextcloud/desktop.git](https://github.com/nextcloud/desktop.git)
|
||||
|
||||
When you don't have SSH key added to your GitHub account, than use HTTPS.
|
||||
|
||||
When you no part of the nextcloud organisation, clone with HTTPS:
|
||||
|
||||
```
|
||||
$ git clone git@github.com:nextcloud/desktop.git
|
||||
```
|
||||
|
||||
macOS
|
||||
-----
|
||||
@@ -47,7 +55,7 @@ To set up your build environment for development using HomeBrew_:
|
||||
|
||||
5. Install a Qt5 version with qtwebkit support::
|
||||
|
||||
brew install qt5 --with-qtwebkit
|
||||
brew install qt5
|
||||
|
||||
6. Install any missing dependencies::
|
||||
|
||||
@@ -67,10 +75,23 @@ To set up your build environment for development using HomeBrew_:
|
||||
|
||||
10. Install the Packages_ package creation tool.
|
||||
|
||||
11. In the build directory, run ``admin/osx/create_mac.sh <build_dir> <install_dir>``.
|
||||
If you have a developer signing certificate, you can specify
|
||||
its Common Name as a third parameter (use quotes) to have the package
|
||||
signed automatically.
|
||||
11. Enable git submodules:
|
||||
```
|
||||
$ cd desktop
|
||||
$ git submodule init
|
||||
$ git submodule update
|
||||
```
|
||||
|
||||
12. Generate the build files:
|
||||
```
|
||||
$ cd build
|
||||
$ cmake .. -DCMAKE_INSTALL_PREFIX=~/nextcloud-desktop-client -DCMAKE_BUILD_TYPE=Debug -DNO_SHIBBOLETH=1
|
||||
```
|
||||
|
||||
13. Compile and install:
|
||||
```
|
||||
$ make install
|
||||
```
|
||||
|
||||
.. note:: Contrary to earlier versions, Nextcloud 1.7 and later are packaged
|
||||
as a ``pkg`` installer. Do not call "make package" at any time when
|
||||
|
||||
@@ -27,7 +27,7 @@ download page.
|
||||
System Requirements
|
||||
----------------------------------
|
||||
|
||||
- Windows 7+
|
||||
- Windows 8.1+
|
||||
- macOS 10.7+ (**64-bit only**)
|
||||
- CentOS 6 & 7 (64-bit only)
|
||||
- Debian 8.0 & 9.0
|
||||
|
||||
1
resources/add-color.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.1" viewbox="0 0 16 16"><path fill="#00d400" d="M9.02 13.98h-2v-5h-5v-2h5v-5h2v5l5-.028V8.98h-5z"/></svg>
|
||||
|
After Width: | Height: | Size: 179 B |
1
resources/change.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" version="1.1" height="16"><path d="m8 2c-2.142 0-4.125 1.145-5.196 3l1.948 1.125c0.671-1.162 1.906-1.875 3.2476-1.875 1.1906 0 2.297 0.56157 3 1.5l-1.5 1.5h4.5v-4.5l-1.406 1.406c-1.129-1.348-2.802-2.1563-4.594-2.1563z"/><path d="m2 8.75v4.5l1.408-1.41c1.116 1.334 2.817 2.145 4.592 2.16 2.16 0.01827 4.116-1.132 5.196-3.002l-1.948-1.125c-0.677 1.171-1.9005 1.886-3.248 1.875-1.18-0.01-2.3047-0.572-3-1.5l1.5-1.5z"/></svg>
|
||||
|
After Width: | Height: | Size: 493 B |
1
resources/delete-color.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.1" viewBox="0 0 16 16"><path d="m3.0503 4.4645 3.5355 3.5355-3.5355 3.536 1.4142 1.414 3.5355-3.5358 3.536 3.5358 1.414-1.414-3.5358-3.536 3.5358-3.5355-1.414-1.4142-3.536 3.5355-3.5355-3.5355-1.4142 1.4142z" fill="#d40000"/></svg>
|
||||
|
After Width: | Height: | Size: 306 B |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 668 B |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 596 B |
|
Before Width: | Height: | Size: 1.3 KiB |
@@ -499,7 +499,7 @@ restart_sync:
|
||||
}
|
||||
|
||||
Cmd cmd;
|
||||
QString dbPath = options.source_dir + SyncJournalDb::makeDbName(options.source_dir, credentialFreeUrl, folder, user);
|
||||
QString dbPath = options.source_dir + SyncJournalDb::makeDbName(credentialFreeUrl, folder, user);
|
||||
SyncJournalDb db(dbPath);
|
||||
|
||||
if (!selectiveSyncList.empty()) {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <QElapsedTimer>
|
||||
#include <QUrl>
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
#include <sqlite3.h>
|
||||
|
||||
#include "common/syncjournaldb.h"
|
||||
@@ -102,11 +103,15 @@ SyncJournalDb::SyncJournalDb(const QString &dbFilePath, QObject *parent)
|
||||
}
|
||||
}
|
||||
|
||||
QString SyncJournalDb::makeDbName(const QString &localPath,
|
||||
const QUrl &remoteUrl,
|
||||
QString SyncJournalDb::makeDbName(const QUrl &remoteUrl,
|
||||
const QString &remotePath,
|
||||
const QString &user)
|
||||
{
|
||||
const QString dbPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||
if (!QDir(dbPath).exists()) {
|
||||
QDir().mkdir(dbPath);
|
||||
}
|
||||
|
||||
QString journalPath = QLatin1String("._sync_");
|
||||
|
||||
QString key = QString::fromUtf8("%1@%2:%3").arg(user, remoteUrl.toString(), remotePath);
|
||||
@@ -115,17 +120,16 @@ QString SyncJournalDb::makeDbName(const QString &localPath,
|
||||
journalPath.append(ba.left(6).toHex());
|
||||
journalPath.append(".db");
|
||||
|
||||
journalPath = dbPath + QLatin1Char('/') + journalPath;
|
||||
|
||||
// If the journal doesn't exist and we can't create a file
|
||||
// at that location, try again with a journal name that doesn't
|
||||
// have the ._ prefix.
|
||||
//
|
||||
// The disadvantage of that filename is that it will only be ignored
|
||||
// by client versions >2.3.2.
|
||||
//
|
||||
// See #5633: "._*" is often forbidden on samba shared folders.
|
||||
|
||||
// If it exists already, the path is clearly usable
|
||||
QFile file(QDir(localPath).filePath(journalPath));
|
||||
QFile file(QDir(dbPath).filePath(journalPath));
|
||||
if (file.exists()) {
|
||||
return journalPath;
|
||||
}
|
||||
@@ -140,7 +144,7 @@ QString SyncJournalDb::makeDbName(const QString &localPath,
|
||||
|
||||
// Can we create it if we drop the underscore?
|
||||
QString alternateJournalPath = journalPath.mid(2).prepend(".");
|
||||
QFile file2(QDir(localPath).filePath(alternateJournalPath));
|
||||
QFile file2(QDir(dbPath).filePath(alternateJournalPath));
|
||||
if (file2.open(QIODevice::ReadWrite)) {
|
||||
// The alternative worked, use it
|
||||
qCInfo(lcDb) << "Using alternate database path" << alternateJournalPath;
|
||||
|
||||
@@ -46,8 +46,7 @@ public:
|
||||
virtual ~SyncJournalDb();
|
||||
|
||||
/// Create a journal path for a specific configuration
|
||||
static QString makeDbName(const QString &localPath,
|
||||
const QUrl &remoteUrl,
|
||||
static QString makeDbName(const QUrl &remoteUrl,
|
||||
const QString &remotePath,
|
||||
const QString &user);
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ void Utility::usleep(int usec)
|
||||
}
|
||||
|
||||
// This can be overriden from the tests
|
||||
OCSYNC_EXPORT bool fsCasePreserving_override = []()-> bool {
|
||||
OCSYNC_EXPORT bool fsCasePreserving_override = []() -> bool {
|
||||
QByteArray env = qgetenv("OWNCLOUD_TEST_CASE_PRESERVING");
|
||||
if (!env.isEmpty())
|
||||
return env.toInt();
|
||||
@@ -362,12 +362,12 @@ QString Utility::fileNameForGuiUse(const QString &fName)
|
||||
QByteArray Utility::normalizeEtag(QByteArray etag)
|
||||
{
|
||||
/* strip "XXXX-gzip" */
|
||||
if(etag.startsWith('"') && etag.endsWith("-gzip\"")) {
|
||||
if (etag.startsWith('"') && etag.endsWith("-gzip\"")) {
|
||||
etag.chop(6);
|
||||
etag.remove(0, 1);
|
||||
}
|
||||
/* strip trailing -gzip */
|
||||
if(etag.endsWith("-gzip")) {
|
||||
if (etag.endsWith("-gzip")) {
|
||||
etag.chop(5);
|
||||
}
|
||||
/* strip normal quotes */
|
||||
@@ -400,7 +400,7 @@ void Utility::crash()
|
||||
// without compiler warnings about possible truncation
|
||||
uint Utility::convertSizeToUint(size_t &convertVar)
|
||||
{
|
||||
if( convertVar > UINT_MAX ) {
|
||||
if (convertVar > UINT_MAX) {
|
||||
//throw std::bad_cast();
|
||||
convertVar = UINT_MAX; // intentionally default to wrong value here to not crash: exception handling TBD
|
||||
}
|
||||
@@ -409,7 +409,7 @@ uint Utility::convertSizeToUint(size_t &convertVar)
|
||||
|
||||
uint Utility::convertSizeToInt(size_t &convertVar)
|
||||
{
|
||||
if( convertVar > INT_MAX ) {
|
||||
if (convertVar > INT_MAX) {
|
||||
//throw std::bad_cast();
|
||||
convertVar = INT_MAX; // intentionally default to wrong value here to not crash: exception handling TBD
|
||||
}
|
||||
@@ -465,7 +465,7 @@ QString Utility::timeAgoInWords(const QDateTime &dt, const QDateTime &from)
|
||||
|
||||
if (floor(secs / 3600.0) > 0) {
|
||||
int hours = floor(secs / 3600.0);
|
||||
if(hours == 1){
|
||||
if (hours == 1) {
|
||||
return (QObject::tr("%n hour ago", "", hours));
|
||||
} else {
|
||||
return (QObject::tr("%n hours ago", "", hours));
|
||||
@@ -480,7 +480,7 @@ QString Utility::timeAgoInWords(const QDateTime &dt, const QDateTime &from)
|
||||
return QObject::tr("Less than a minute ago");
|
||||
}
|
||||
|
||||
} else if(minutes == 1){
|
||||
} else if (minutes == 1) {
|
||||
return (QObject::tr("%n minute ago", "", minutes));
|
||||
} else {
|
||||
return (QObject::tr("%n minutes ago", "", minutes));
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#ifndef UTILITY_H
|
||||
#define UTILITY_H
|
||||
|
||||
|
||||
#include "ocsynclib.h"
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
@@ -29,6 +30,7 @@
|
||||
#include <QMap>
|
||||
#include <QUrl>
|
||||
#include <QUrlQuery>
|
||||
#include <QtQuick/QQuickImageProvider>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
|
||||
@@ -47,14 +47,18 @@ QString getUserAutostartDir_private()
|
||||
|
||||
bool hasLaunchOnStartup_private(const QString &appName)
|
||||
{
|
||||
QString desktopFileLocation = getUserAutostartDir_private() + appName + QLatin1String(".desktop");
|
||||
QString desktopFileLocation = getUserAutostartDir_private()
|
||||
+ QLatin1String(LINUX_APPLICATION_ID)
|
||||
+ QLatin1String(".desktop");
|
||||
return QFile::exists(desktopFileLocation);
|
||||
}
|
||||
|
||||
void setLaunchOnStartup_private(const QString &appName, const QString &guiName, bool enable)
|
||||
{
|
||||
QString userAutoStartPath = getUserAutostartDir_private();
|
||||
QString desktopFileLocation = userAutoStartPath + appName + QLatin1String(".desktop");
|
||||
QString desktopFileLocation = userAutoStartPath
|
||||
+ QLatin1String(LINUX_APPLICATION_ID)
|
||||
+ QLatin1String(".desktop");
|
||||
if (enable) {
|
||||
if (!QDir().exists(userAutoStartPath) && !QDir().mkpath(userAutoStartPath)) {
|
||||
qCWarning(lcUtility) << "Could not create autostart folder" << userAutoStartPath;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
project(gui)
|
||||
find_package(Qt5 REQUIRED COMPONENTS Widgets)
|
||||
find_package(Qt5 REQUIRED COMPONENTS Widgets Svg)
|
||||
set(CMAKE_AUTOMOC TRUE)
|
||||
set(CMAKE_AUTOUIC TRUE)
|
||||
set(CMAKE_AUTORCC TRUE)
|
||||
@@ -24,7 +24,6 @@ set(client_UI_SRCS
|
||||
ignorelisteditor.ui
|
||||
ignorelisttablewidget.ui
|
||||
networksettings.ui
|
||||
activitywidget.ui
|
||||
synclogdialog.ui
|
||||
settingsdialog.ui
|
||||
sharedialog.ui
|
||||
@@ -35,12 +34,13 @@ set(client_UI_SRCS
|
||||
addcertificatedialog.ui
|
||||
proxyauthdialog.ui
|
||||
mnemonicdialog.ui
|
||||
tray/Window.qml
|
||||
tray/UserLine.qml
|
||||
wizard/flow2authwidget.ui
|
||||
wizard/owncloudadvancedsetuppage.ui
|
||||
wizard/owncloudconnectionmethoddialog.ui
|
||||
wizard/owncloudhttpcredspage.ui
|
||||
wizard/owncloudoauthcredspage.ui
|
||||
wizard/flow2authcredspage.ui
|
||||
wizard/flow2authwidget.ui
|
||||
wizard/owncloudsetupnocredspage.ui
|
||||
wizard/owncloudwizardresultpage.ui
|
||||
wizard/webview.ui
|
||||
@@ -74,10 +74,6 @@ set(client_SRCS
|
||||
openfilemanager.cpp
|
||||
owncloudgui.cpp
|
||||
owncloudsetupwizard.cpp
|
||||
activitydata.cpp
|
||||
activitylistmodel.cpp
|
||||
activitywidget.cpp
|
||||
activityitemdelegate.cpp
|
||||
selectivesyncdialog.cpp
|
||||
settingsdialog.cpp
|
||||
sharedialog.cpp
|
||||
@@ -100,15 +96,20 @@ set(client_SRCS
|
||||
synclogdialog.cpp
|
||||
tooltipupdater.cpp
|
||||
notificationconfirmjob.cpp
|
||||
servernotificationhandler.cpp
|
||||
guiutility.cpp
|
||||
elidedlabel.cpp
|
||||
headerbanner.cpp
|
||||
iconjob.cpp
|
||||
remotewipe.cpp
|
||||
tray/ActivityData.cpp
|
||||
tray/ActivityListModel.cpp
|
||||
tray/UserModel.cpp
|
||||
tray/NotificationHandler.cpp
|
||||
creds/credentialsfactory.cpp
|
||||
creds/httpcredentialsgui.cpp
|
||||
creds/oauth.cpp
|
||||
creds/flow2auth.cpp
|
||||
creds/keychainchunk.cpp
|
||||
creds/webflowcredentials.cpp
|
||||
creds/webflowcredentialsdialog.cpp
|
||||
wizard/postfixlineedit.cpp
|
||||
@@ -297,7 +298,7 @@ else()
|
||||
endif()
|
||||
|
||||
add_library(updater STATIC ${updater_SRCS})
|
||||
target_link_libraries(updater ${synclib_NAME} Qt5::Widgets Qt5::Network Qt5::Xml Qt5::WebEngineWidgets)
|
||||
target_link_libraries(updater ${synclib_NAME} Qt5::Widgets Qt5::Svg Qt5::Network Qt5::Xml Qt5::WebEngineWidgets)
|
||||
target_include_directories(updater PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
|
||||
@@ -307,7 +308,7 @@ set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
|
||||
set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
|
||||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/${APPLICATION_EXECUTABLE};${CMAKE_INSTALL_RPATH}" )
|
||||
|
||||
target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::Widgets Qt5::Network Qt5::Xml)
|
||||
target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::Widgets Qt5::Svg Qt5::Network Qt5::Xml)
|
||||
target_link_libraries( ${APPLICATION_EXECUTABLE} ${synclib_NAME} )
|
||||
target_link_libraries( ${APPLICATION_EXECUTABLE} updater )
|
||||
target_link_libraries( ${APPLICATION_EXECUTABLE} ${OS_SPECIFIC_LINK_LIBRARIES} )
|
||||
@@ -387,7 +388,7 @@ endif()
|
||||
|
||||
if(NOT BUILD_OWNCLOUD_OSX_BUNDLE AND NOT WIN32)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/mirall.desktop.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_EXECUTABLE}.desktop)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_EXECUTABLE}.desktop DESTINATION ${DATADIR}/applications )
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${LINUX_APPLICATION_ID}.desktop)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LINUX_APPLICATION_ID}.desktop DESTINATION ${DATADIR}/applications )
|
||||
endif()
|
||||
|
||||
|
||||
@@ -89,6 +89,9 @@ private:
|
||||
// Adds an account to the tracked list, emitting accountAdded()
|
||||
void addAccountState(AccountState *accountState);
|
||||
|
||||
AccountManager() {}
|
||||
QList<AccountStatePtr> _accounts;
|
||||
|
||||
public slots:
|
||||
/// Saves account data, not including the credentials
|
||||
void saveAccount(Account *a);
|
||||
@@ -104,9 +107,5 @@ Q_SIGNALS:
|
||||
void accountAdded(AccountState *account);
|
||||
void accountRemoved(AccountState *account);
|
||||
void removeAccountFolders(AccountState *account);
|
||||
|
||||
private:
|
||||
AccountManager() {}
|
||||
QList<AccountStatePtr> _accounts;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -109,13 +109,13 @@ protected:
|
||||
|
||||
AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::AccountSettings)
|
||||
, _ui(new Ui::AccountSettings)
|
||||
, _wasDisabledBefore(false)
|
||||
, _accountState(accountState)
|
||||
, _quotaInfo(accountState)
|
||||
, _menuShown(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
_ui->setupUi(this);
|
||||
|
||||
_model = new FolderStatusModel;
|
||||
_model->setAccountState(_accountState);
|
||||
@@ -123,37 +123,37 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
|
||||
FolderStatusDelegate *delegate = new FolderStatusDelegate;
|
||||
delegate->setParent(this);
|
||||
|
||||
ui->_folderList->header()->hide();
|
||||
ui->_folderList->setItemDelegate(delegate);
|
||||
ui->_folderList->setModel(_model);
|
||||
// Connect styleChanged events to our widgets, so they can adapt (Dark-/Light-Mode switching)
|
||||
connect(this, &AccountSettings::styleChanged, delegate, &FolderStatusDelegate::slotStyleChanged);
|
||||
|
||||
_ui->_folderList->header()->hide();
|
||||
_ui->_folderList->setItemDelegate(delegate);
|
||||
_ui->_folderList->setModel(_model);
|
||||
#if defined(Q_OS_MAC)
|
||||
ui->_folderList->setMinimumWidth(400);
|
||||
_ui->_folderList->setMinimumWidth(400);
|
||||
#else
|
||||
ui->_folderList->setMinimumWidth(300);
|
||||
_ui->_folderList->setMinimumWidth(300);
|
||||
#endif
|
||||
new ToolTipUpdater(ui->_folderList);
|
||||
new ToolTipUpdater(_ui->_folderList);
|
||||
|
||||
auto mouseCursorChanger = new MouseCursorChanger(this);
|
||||
mouseCursorChanger->folderList = ui->_folderList;
|
||||
mouseCursorChanger->folderList = _ui->_folderList;
|
||||
mouseCursorChanger->model = _model;
|
||||
ui->_folderList->setMouseTracking(true);
|
||||
ui->_folderList->setAttribute(Qt::WA_Hover, true);
|
||||
ui->_folderList->installEventFilter(mouseCursorChanger);
|
||||
_ui->_folderList->setMouseTracking(true);
|
||||
_ui->_folderList->setAttribute(Qt::WA_Hover, true);
|
||||
_ui->_folderList->installEventFilter(mouseCursorChanger);
|
||||
|
||||
createAccountToolbox();
|
||||
connect(AccountManager::instance(), &AccountManager::accountAdded,
|
||||
this, &AccountSettings::slotAccountAdded);
|
||||
connect(this, &AccountSettings::removeAccountFolders,
|
||||
AccountManager::instance(), &AccountManager::removeAccountFolders);
|
||||
connect(ui->_folderList, &QWidget::customContextMenuRequested,
|
||||
connect(_ui->_folderList, &QWidget::customContextMenuRequested,
|
||||
this, &AccountSettings::slotCustomContextMenuRequested);
|
||||
connect(ui->_folderList, &QAbstractItemView::clicked,
|
||||
connect(_ui->_folderList, &QAbstractItemView::clicked,
|
||||
this, &AccountSettings::slotFolderListClicked);
|
||||
connect(ui->_folderList, &QTreeView::expanded, this, &AccountSettings::refreshSelectiveSyncStatus);
|
||||
connect(ui->_folderList, &QTreeView::collapsed, this, &AccountSettings::refreshSelectiveSyncStatus);
|
||||
connect(ui->selectiveSyncNotification, &QLabel::linkActivated,
|
||||
connect(_ui->_folderList, &QTreeView::expanded, this, &AccountSettings::refreshSelectiveSyncStatus);
|
||||
connect(_ui->_folderList, &QTreeView::collapsed, this, &AccountSettings::refreshSelectiveSyncStatus);
|
||||
connect(_ui->selectiveSyncNotification, &QLabel::linkActivated,
|
||||
this, &AccountSettings::slotLinkActivated);
|
||||
connect(_model, &FolderStatusModel::suggestExpand, ui->_folderList, &QTreeView::expand);
|
||||
connect(_model, &FolderStatusModel::suggestExpand, _ui->_folderList, &QTreeView::expand);
|
||||
connect(_model, &FolderStatusModel::dirtyChanged, this, &AccountSettings::refreshSelectiveSyncStatus);
|
||||
refreshSelectiveSyncStatus();
|
||||
connect(_model, &QAbstractItemModel::rowsInserted,
|
||||
@@ -170,20 +170,21 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
|
||||
addAction(syncNowWithRemoteDiscovery);
|
||||
|
||||
|
||||
connect(ui->selectiveSyncApply, &QAbstractButton::clicked, _model, &FolderStatusModel::slotApplySelectiveSync);
|
||||
connect(ui->selectiveSyncCancel, &QAbstractButton::clicked, _model, &FolderStatusModel::resetFolders);
|
||||
connect(ui->bigFolderApply, &QAbstractButton::clicked, _model, &FolderStatusModel::slotApplySelectiveSync);
|
||||
connect(ui->bigFolderSyncAll, &QAbstractButton::clicked, _model, &FolderStatusModel::slotSyncAllPendingBigFolders);
|
||||
connect(ui->bigFolderSyncNone, &QAbstractButton::clicked, _model, &FolderStatusModel::slotSyncNoPendingBigFolders);
|
||||
connect(_ui->selectiveSyncApply, &QAbstractButton::clicked, _model, &FolderStatusModel::slotApplySelectiveSync);
|
||||
connect(_ui->selectiveSyncCancel, &QAbstractButton::clicked, _model, &FolderStatusModel::resetFolders);
|
||||
connect(_ui->bigFolderApply, &QAbstractButton::clicked, _model, &FolderStatusModel::slotApplySelectiveSync);
|
||||
connect(_ui->bigFolderSyncAll, &QAbstractButton::clicked, _model, &FolderStatusModel::slotSyncAllPendingBigFolders);
|
||||
connect(_ui->bigFolderSyncNone, &QAbstractButton::clicked, _model, &FolderStatusModel::slotSyncNoPendingBigFolders);
|
||||
|
||||
connect(FolderMan::instance(), &FolderMan::folderListChanged, _model, &FolderStatusModel::resetFolders);
|
||||
connect(this, &AccountSettings::folderChanged, _model, &FolderStatusModel::resetFolders);
|
||||
|
||||
|
||||
QColor color = palette().highlight().color();
|
||||
ui->quotaProgressBar->setStyleSheet(QString::fromLatin1(progressBarStyleC).arg(color.name()));
|
||||
// quotaProgressBar style now set in customizeStyle()
|
||||
/*QColor color = palette().highlight().color();
|
||||
_ui->quotaProgressBar->setStyleSheet(QString::fromLatin1(progressBarStyleC).arg(color.name()));*/
|
||||
|
||||
ui->connectLabel->setText(tr("No account configured."));
|
||||
_ui->connectLabel->setText(tr("No account configured."));
|
||||
|
||||
connect(_accountState, &AccountState::stateChanged, this, &AccountSettings::slotAccountStateChanged);
|
||||
slotAccountStateChanged();
|
||||
@@ -200,72 +201,31 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
|
||||
{
|
||||
slotNewMnemonicGenerated();
|
||||
} else {
|
||||
ui->encryptionMessage->hide();
|
||||
_ui->encryptionMessage->hide();
|
||||
}
|
||||
|
||||
connect(UserModel::instance(), &UserModel::addAccount,
|
||||
this, &AccountSettings::slotOpenAccountWizard);
|
||||
|
||||
customizeStyle();
|
||||
}
|
||||
|
||||
|
||||
void AccountSettings::createAccountToolbox()
|
||||
{
|
||||
QMenu *menu = new QMenu();
|
||||
|
||||
connect(menu, &QMenu::aboutToShow, this, &AccountSettings::slotMenuBeforeShow);
|
||||
|
||||
_addAccountAction = new QAction(tr("Add new"), this);
|
||||
menu->addAction(_addAccountAction);
|
||||
connect(_addAccountAction, &QAction::triggered, this, &AccountSettings::slotOpenAccountWizard);
|
||||
|
||||
_toggleSignInOutAction = new QAction(tr("Log out"), this);
|
||||
connect(_toggleSignInOutAction, &QAction::triggered, this, &AccountSettings::slotToggleSignInState);
|
||||
menu->addAction(_toggleSignInOutAction);
|
||||
|
||||
QAction *action = new QAction(tr("Remove"), this);
|
||||
menu->addAction(action);
|
||||
connect(action, &QAction::triggered, this, &AccountSettings::slotDeleteAccount);
|
||||
|
||||
ui->_accountToolbox->setText(tr("Account") + QLatin1Char(' '));
|
||||
ui->_accountToolbox->setMenu(menu);
|
||||
ui->_accountToolbox->setPopupMode(QToolButton::InstantPopup);
|
||||
|
||||
slotAccountAdded(_accountState);
|
||||
}
|
||||
|
||||
|
||||
void AccountSettings::slotNewMnemonicGenerated()
|
||||
{
|
||||
ui->encryptionMessage->setText(tr("This account supports end-to-end encryption"));
|
||||
_ui->encryptionMessage->setText(tr("This account supports end-to-end encryption"));
|
||||
|
||||
QAction *mnemonic = new QAction(tr("Enable encryption"), this);
|
||||
connect(mnemonic, &QAction::triggered, this, &AccountSettings::requesetMnemonic);
|
||||
connect(mnemonic, &QAction::triggered, ui->encryptionMessage, &KMessageWidget::hide);
|
||||
connect(mnemonic, &QAction::triggered, _ui->encryptionMessage, &KMessageWidget::hide);
|
||||
|
||||
ui->encryptionMessage->addAction(mnemonic);
|
||||
ui->encryptionMessage->show();
|
||||
_ui->encryptionMessage->addAction(mnemonic);
|
||||
_ui->encryptionMessage->show();
|
||||
}
|
||||
|
||||
void AccountSettings::slotMenuBeforeShow() {
|
||||
if (_menuShown) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto menu = ui->_accountToolbox->menu();
|
||||
|
||||
// We can't check this during the initial creation as there is no account yet then
|
||||
if (_accountState->account()->capabilities().clientSideEncryptionAvaliable()) {
|
||||
QAction *mnemonic = new QAction(tr("Show E2E mnemonic"), this);
|
||||
connect(mnemonic, &QAction::triggered, this, &AccountSettings::requesetMnemonic);
|
||||
menu->addAction(mnemonic);
|
||||
}
|
||||
|
||||
_menuShown = true;
|
||||
}
|
||||
|
||||
|
||||
QString AccountSettings::selectedFolderAlias() const
|
||||
{
|
||||
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
||||
QModelIndex selected = _ui->_folderList->selectionModel()->currentIndex();
|
||||
if (!selected.isValid())
|
||||
return "";
|
||||
return _model->data(selected, FolderStatusDelegate::FolderAliasRole).toString();
|
||||
@@ -294,7 +254,7 @@ void AccountSettings::slotToggleSignInState()
|
||||
|
||||
void AccountSettings::doExpand()
|
||||
{
|
||||
ui->_folderList->expandToDepth(0);
|
||||
_ui->_folderList->expandToDepth(0);
|
||||
}
|
||||
|
||||
void AccountSettings::slotShowMnemonic(const QString &mnemonic) {
|
||||
@@ -542,7 +502,7 @@ void AccountSettings::slotEditCurrentIgnoredFiles()
|
||||
|
||||
void AccountSettings::slotEditCurrentLocalIgnoredFiles()
|
||||
{
|
||||
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
||||
QModelIndex selected = _ui->_folderList->selectionModel()->currentIndex();
|
||||
if (!selected.isValid() || _model->classify(selected) != FolderStatusModel::SubFolder)
|
||||
return;
|
||||
QString fileName = _model->data(selected, FolderStatusDelegate::FolderPathRole).toString();
|
||||
@@ -614,7 +574,7 @@ void AccountSettings::slotSubfolderContextMenuRequested(const QModelIndex& index
|
||||
|
||||
void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
|
||||
{
|
||||
QTreeView *tv = ui->_folderList;
|
||||
QTreeView *tv = _ui->_folderList;
|
||||
QModelIndex index = tv->indexAt(pos);
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
@@ -645,7 +605,7 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
|
||||
ac = menu->addAction(tr("Edit Ignored Files"));
|
||||
connect(ac, &QAction::triggered, this, &AccountSettings::slotEditCurrentIgnoredFiles);
|
||||
|
||||
if (!ui->_folderList->isExpanded(index)) {
|
||||
if (!_ui->_folderList->isExpanded(index)) {
|
||||
ac = menu->addAction(tr("Choose what to sync"));
|
||||
ac->setEnabled(folderConnected);
|
||||
connect(ac, &QAction::triggered, this, &AccountSettings::doExpand);
|
||||
@@ -684,7 +644,7 @@ void AccountSettings::slotFolderListClicked(const QModelIndex &indx)
|
||||
}
|
||||
if (_model->classify(indx) == FolderStatusModel::RootFolder) {
|
||||
// tries to find if we clicked on the '...' button.
|
||||
QTreeView *tv = ui->_folderList;
|
||||
QTreeView *tv = _ui->_folderList;
|
||||
auto pos = tv->mapFromGlobal(QCursor::pos());
|
||||
if (FolderStatusDelegate::optionsButtonRect(tv->visualRect(indx), layoutDirection()).contains(pos)) {
|
||||
slotCustomContextMenuRequested(pos);
|
||||
@@ -697,8 +657,8 @@ void AccountSettings::slotFolderListClicked(const QModelIndex &indx)
|
||||
|
||||
// Expand root items on single click
|
||||
if (_accountState && _accountState->state() == AccountState::Connected) {
|
||||
bool expanded = !(ui->_folderList->isExpanded(indx));
|
||||
ui->_folderList->setExpanded(indx, expanded);
|
||||
bool expanded = !(_ui->_folderList->isExpanded(indx));
|
||||
_ui->_folderList->setExpanded(indx, expanded);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -780,7 +740,7 @@ void AccountSettings::slotRemoveCurrentFolder()
|
||||
{
|
||||
FolderMan *folderMan = FolderMan::instance();
|
||||
auto folder = folderMan->folder(selectedFolderAlias());
|
||||
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
||||
QModelIndex selected = _ui->_folderList->selectionModel()->currentIndex();
|
||||
if (selected.isValid() && folder) {
|
||||
int row = selected.row();
|
||||
|
||||
@@ -822,7 +782,7 @@ void AccountSettings::slotOpenCurrentFolder()
|
||||
|
||||
void AccountSettings::slotOpenCurrentLocalSubFolder()
|
||||
{
|
||||
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
||||
QModelIndex selected = _ui->_folderList->selectionModel()->currentIndex();
|
||||
if (!selected.isValid() || _model->classify(selected) != FolderStatusModel::SubFolder)
|
||||
return;
|
||||
QString fileName = _model->data(selected, FolderStatusDelegate::FolderPathRole).toString();
|
||||
@@ -838,19 +798,19 @@ void AccountSettings::showConnectionLabel(const QString &message, QStringList er
|
||||
if (errors.isEmpty()) {
|
||||
QString msg = message;
|
||||
Theme::replaceLinkColorStringBackgroundAware(msg);
|
||||
ui->connectLabel->setText(msg);
|
||||
ui->connectLabel->setToolTip(QString());
|
||||
ui->connectLabel->setStyleSheet(QString());
|
||||
_ui->connectLabel->setText(msg);
|
||||
_ui->connectLabel->setToolTip(QString());
|
||||
_ui->connectLabel->setStyleSheet(QString());
|
||||
} else {
|
||||
errors.prepend(message);
|
||||
QString msg = errors.join(QLatin1String("\n"));
|
||||
qCDebug(lcAccountSettings) << msg;
|
||||
Theme::replaceLinkColorStringBackgroundAware(msg, QColor("#bb4d4d"));
|
||||
ui->connectLabel->setText(msg);
|
||||
ui->connectLabel->setToolTip(QString());
|
||||
ui->connectLabel->setStyleSheet(errStyle);
|
||||
Theme::replaceLinkColorString(msg, QColor("#c1c8e6"));
|
||||
_ui->connectLabel->setText(msg);
|
||||
_ui->connectLabel->setToolTip(QString());
|
||||
_ui->connectLabel->setStyleSheet(errStyle);
|
||||
}
|
||||
ui->accountStatus->setVisible(!message.isEmpty());
|
||||
_ui->accountStatus->setVisible(!message.isEmpty());
|
||||
}
|
||||
|
||||
void AccountSettings::slotEnableCurrentFolder()
|
||||
@@ -948,29 +908,29 @@ void AccountSettings::slotOpenOC()
|
||||
void AccountSettings::slotUpdateQuota(qint64 total, qint64 used)
|
||||
{
|
||||
if (total > 0) {
|
||||
ui->quotaProgressBar->setVisible(true);
|
||||
ui->quotaProgressBar->setEnabled(true);
|
||||
_ui->quotaProgressBar->setVisible(true);
|
||||
_ui->quotaProgressBar->setEnabled(true);
|
||||
// workaround the label only accepting ints (which may be only 32 bit wide)
|
||||
const double percent = used / (double)total * 100;
|
||||
const int percentInt = qMin(qRound(percent), 100);
|
||||
ui->quotaProgressBar->setValue(percentInt);
|
||||
_ui->quotaProgressBar->setValue(percentInt);
|
||||
QString usedStr = Utility::octetsToString(used);
|
||||
QString totalStr = Utility::octetsToString(total);
|
||||
QString percentStr = Utility::compactFormatDouble(percent, 1);
|
||||
QString toolTip = tr("%1 (%3%) of %2 in use. Some folders, including network mounted or shared folders, might have different limits.").arg(usedStr, totalStr, percentStr);
|
||||
ui->quotaInfoLabel->setText(tr("%1 of %2 in use").arg(usedStr, totalStr));
|
||||
ui->quotaInfoLabel->setToolTip(toolTip);
|
||||
ui->quotaProgressBar->setToolTip(toolTip);
|
||||
_ui->quotaInfoLabel->setText(tr("%1 of %2 in use").arg(usedStr, totalStr));
|
||||
_ui->quotaInfoLabel->setToolTip(toolTip);
|
||||
_ui->quotaProgressBar->setToolTip(toolTip);
|
||||
} else {
|
||||
ui->quotaProgressBar->setVisible(false);
|
||||
ui->quotaInfoLabel->setToolTip(QString());
|
||||
_ui->quotaProgressBar->setVisible(false);
|
||||
_ui->quotaInfoLabel->setToolTip(QString());
|
||||
|
||||
/* -1 means not computed; -2 means unknown; -3 means unlimited (#3940)*/
|
||||
if (total == 0 || total == -1) {
|
||||
ui->quotaInfoLabel->setText(tr("Currently there is no storage usage information available."));
|
||||
_ui->quotaInfoLabel->setText(tr("Currently there is no storage usage information available."));
|
||||
} else {
|
||||
QString usedStr = Utility::octetsToString(used);
|
||||
ui->quotaInfoLabel->setText(tr("%1 in use").arg(usedStr));
|
||||
_ui->quotaInfoLabel->setText(tr("%1 in use").arg(usedStr));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -979,7 +939,7 @@ void AccountSettings::slotAccountStateChanged()
|
||||
{
|
||||
int state = _accountState ? _accountState->state() : AccountState::Disconnected;
|
||||
if (_accountState) {
|
||||
ui->sslButton->updateAccountState(_accountState);
|
||||
_ui->sslButton->updateAccountState(_accountState);
|
||||
AccountPtr account = _accountState->account();
|
||||
QUrl safeUrl(account->url());
|
||||
safeUrl.setPassword(QString()); // Remove the password from the URL to avoid showing it in the UI
|
||||
@@ -1038,14 +998,14 @@ void AccountSettings::slotAccountStateChanged()
|
||||
}
|
||||
|
||||
/* Allow to expand the item if the account is connected. */
|
||||
ui->_folderList->setItemsExpandable(state == AccountState::Connected);
|
||||
_ui->_folderList->setItemsExpandable(state == AccountState::Connected);
|
||||
|
||||
if (state != AccountState::Connected) {
|
||||
/* check if there are expanded root items, if so, close them */
|
||||
int i;
|
||||
for (i = 0; i < _model->rowCount(); ++i) {
|
||||
if (ui->_folderList->isExpanded(_model->index(i)))
|
||||
ui->_folderList->setExpanded(_model->index(i), false);
|
||||
if (_ui->_folderList->isExpanded(_model->index(i)))
|
||||
_ui->_folderList->setExpanded(_model->index(i), false);
|
||||
}
|
||||
} else if (_model->isDirty()) {
|
||||
// If we connect and have pending changes, show the list.
|
||||
@@ -1056,21 +1016,12 @@ void AccountSettings::slotAccountStateChanged()
|
||||
// sync user interface buttons.
|
||||
refreshSelectiveSyncStatus();
|
||||
|
||||
/* set the correct label for the Account toolbox button */
|
||||
if (_accountState) {
|
||||
if (_accountState->isSignedOut()) {
|
||||
_toggleSignInOutAction->setText(tr("Log in"));
|
||||
} else {
|
||||
_toggleSignInOutAction->setText(tr("Log out"));
|
||||
}
|
||||
}
|
||||
|
||||
if (state == AccountState::State::Connected) {
|
||||
/* TODO: We should probably do something better here.
|
||||
* Verify if the user has a private key already uploaded to the server,
|
||||
* if it has, do not offer to create one.
|
||||
*/
|
||||
qCInfo(lcAccountSettings) << "Accout" << accountsState()->account()->displayName()
|
||||
qCInfo(lcAccountSettings) << "Account" << accountsState()->account()->displayName()
|
||||
<< "Client Side Encryption" << accountsState()->account()->capabilities().clientSideEncryptionAvaliable();
|
||||
}
|
||||
}
|
||||
@@ -1089,21 +1040,21 @@ void AccountSettings::slotLinkActivated(const QString &link)
|
||||
// Make sure the folder itself is expanded
|
||||
Folder *f = FolderMan::instance()->folder(alias);
|
||||
QModelIndex folderIndx = _model->indexForPath(f, QString());
|
||||
if (!ui->_folderList->isExpanded(folderIndx)) {
|
||||
ui->_folderList->setExpanded(folderIndx, true);
|
||||
if (!_ui->_folderList->isExpanded(folderIndx)) {
|
||||
_ui->_folderList->setExpanded(folderIndx, true);
|
||||
}
|
||||
|
||||
QModelIndex indx = _model->indexForPath(f, myFolder);
|
||||
if (indx.isValid()) {
|
||||
// make sure all the parents are expanded
|
||||
for (auto i = indx.parent(); i.isValid(); i = i.parent()) {
|
||||
if (!ui->_folderList->isExpanded(i)) {
|
||||
ui->_folderList->setExpanded(i, true);
|
||||
if (!_ui->_folderList->isExpanded(i)) {
|
||||
_ui->_folderList->setExpanded(i, true);
|
||||
}
|
||||
}
|
||||
ui->_folderList->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
ui->_folderList->setCurrentIndex(indx);
|
||||
ui->_folderList->scrollTo(indx);
|
||||
_ui->_folderList->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
_ui->_folderList->setCurrentIndex(indx);
|
||||
_ui->_folderList->scrollTo(indx);
|
||||
} else {
|
||||
qCWarning(lcAccountSettings) << "Unable to find a valid index for " << myFolder;
|
||||
}
|
||||
@@ -1112,7 +1063,7 @@ void AccountSettings::slotLinkActivated(const QString &link)
|
||||
|
||||
AccountSettings::~AccountSettings()
|
||||
{
|
||||
delete ui;
|
||||
delete _ui;
|
||||
}
|
||||
|
||||
void AccountSettings::refreshSelectiveSyncStatus()
|
||||
@@ -1150,8 +1101,8 @@ void AccountSettings::refreshSelectiveSyncStatus()
|
||||
}
|
||||
|
||||
if (msg.isEmpty()) {
|
||||
ui->selectiveSyncButtons->setVisible(true);
|
||||
ui->bigFolderUi->setVisible(false);
|
||||
_ui->selectiveSyncButtons->setVisible(true);
|
||||
_ui->bigFolderUi->setVisible(false);
|
||||
} else {
|
||||
ConfigFile cfg;
|
||||
QString info = !cfg.confirmExternalStorage()
|
||||
@@ -1160,44 +1111,32 @@ void AccountSettings::refreshSelectiveSyncStatus()
|
||||
? tr("There are folders that were not synchronized because they are external storages: ")
|
||||
: tr("There are folders that were not synchronized because they are too big or external storages: ");
|
||||
|
||||
ui->selectiveSyncNotification->setText(info + msg);
|
||||
ui->selectiveSyncButtons->setVisible(false);
|
||||
ui->bigFolderUi->setVisible(true);
|
||||
_ui->selectiveSyncNotification->setText(info + msg);
|
||||
_ui->selectiveSyncButtons->setVisible(false);
|
||||
_ui->bigFolderUi->setVisible(true);
|
||||
shouldBeVisible = true;
|
||||
}
|
||||
|
||||
ui->selectiveSyncApply->setEnabled(_model->isDirty() || !msg.isEmpty());
|
||||
bool wasVisible = !ui->selectiveSyncStatus->isHidden();
|
||||
_ui->selectiveSyncApply->setEnabled(_model->isDirty() || !msg.isEmpty());
|
||||
bool wasVisible = !_ui->selectiveSyncStatus->isHidden();
|
||||
if (wasVisible != shouldBeVisible) {
|
||||
QSize hint = ui->selectiveSyncStatus->sizeHint();
|
||||
QSize hint = _ui->selectiveSyncStatus->sizeHint();
|
||||
if (shouldBeVisible) {
|
||||
ui->selectiveSyncStatus->setMaximumHeight(0);
|
||||
ui->selectiveSyncStatus->setVisible(true);
|
||||
_ui->selectiveSyncStatus->setMaximumHeight(0);
|
||||
_ui->selectiveSyncStatus->setVisible(true);
|
||||
}
|
||||
auto anim = new QPropertyAnimation(ui->selectiveSyncStatus, "maximumHeight", ui->selectiveSyncStatus);
|
||||
auto anim = new QPropertyAnimation(_ui->selectiveSyncStatus, "maximumHeight", _ui->selectiveSyncStatus);
|
||||
anim->setEndValue(shouldBeVisible ? hint.height() : 0);
|
||||
anim->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
connect(anim, &QPropertyAnimation::finished, [this, shouldBeVisible]() {
|
||||
ui->selectiveSyncStatus->setMaximumHeight(QWIDGETSIZE_MAX);
|
||||
_ui->selectiveSyncStatus->setMaximumHeight(QWIDGETSIZE_MAX);
|
||||
if (!shouldBeVisible) {
|
||||
ui->selectiveSyncStatus->hide();
|
||||
_ui->selectiveSyncStatus->hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void AccountSettings::slotAccountAdded(AccountState *)
|
||||
{
|
||||
// if the theme is limited to single account, the button must hide if
|
||||
// there is already one account.
|
||||
int s = AccountManager::instance()->accounts().size();
|
||||
if (s > 0 && !Theme::instance()->multiAccount()) {
|
||||
_addAccountAction->setVisible(false);
|
||||
} else {
|
||||
_addAccountAction->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void AccountSettings::slotDeleteAccount()
|
||||
{
|
||||
// Deleting the account potentially deletes 'this', so
|
||||
@@ -1240,7 +1179,7 @@ bool AccountSettings::event(QEvent *e)
|
||||
// Expand the folder automatically only if there's only one, see #4283
|
||||
// The 2 is 1 folder + 1 'add folder' button
|
||||
if (_model->rowCount() <= 2) {
|
||||
ui->_folderList->setExpanded(_model->index(0, 0), true);
|
||||
_ui->_folderList->setExpanded(_model->index(0, 0), true);
|
||||
}
|
||||
}
|
||||
return QWidget::event(e);
|
||||
@@ -1249,13 +1188,19 @@ bool AccountSettings::event(QEvent *e)
|
||||
void AccountSettings::slotStyleChanged()
|
||||
{
|
||||
customizeStyle();
|
||||
|
||||
// Notify the other widgets (Dark-/Light-Mode switching)
|
||||
emit styleChanged();
|
||||
}
|
||||
|
||||
void AccountSettings::customizeStyle()
|
||||
{
|
||||
QString msg = ui->connectLabel->text();
|
||||
QString msg = _ui->connectLabel->text();
|
||||
Theme::replaceLinkColorStringBackgroundAware(msg);
|
||||
ui->connectLabel->setText(msg);
|
||||
_ui->connectLabel->setText(msg);
|
||||
|
||||
QColor color = palette().highlight().color();
|
||||
_ui->quotaProgressBar->setStyleSheet(QString::fromLatin1(progressBarStyleC).arg(color.name()));
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
@@ -64,6 +64,7 @@ signals:
|
||||
void showIssuesList(AccountState *account);
|
||||
void requesetMnemonic();
|
||||
void removeAccountFolders(AccountState *account);
|
||||
void styleChanged();
|
||||
|
||||
public slots:
|
||||
void slotOpenOC();
|
||||
@@ -89,7 +90,6 @@ protected slots:
|
||||
void slotDeleteAccount();
|
||||
void slotToggleSignInState();
|
||||
void slotOpenAccountWizard();
|
||||
void slotAccountAdded(AccountState *);
|
||||
void refreshSelectiveSyncStatus();
|
||||
void slotMarkSubfolderEncrypted(const FolderStatusModel::SubFolderInfo* folderInfo);
|
||||
void slotMarkSubfolderDecrypted(const FolderStatusModel::SubFolderInfo* folderInfo);
|
||||
@@ -99,8 +99,6 @@ protected slots:
|
||||
void doExpand();
|
||||
void slotLinkActivated(const QString &link);
|
||||
|
||||
void slotMenuBeforeShow();
|
||||
|
||||
// Encryption Related Stuff.
|
||||
void slotShowMnemonic(const QString &mnemonic);
|
||||
void slotNewMnemonicGenerated();
|
||||
@@ -135,7 +133,7 @@ private:
|
||||
/// Returns the alias of the selected folder, empty string if none
|
||||
QString selectedFolderAlias() const;
|
||||
|
||||
Ui::AccountSettings *ui;
|
||||
Ui::AccountSettings *_ui;
|
||||
|
||||
FolderStatusModel *_model;
|
||||
QUrl _OCUrl;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>582</width>
|
||||
<width>581</width>
|
||||
<height>557</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -184,13 +184,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="_accountToolbox">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "creds/httpcredentials.h"
|
||||
#include "logger.h"
|
||||
#include "configfile.h"
|
||||
#include "ocsnavigationappsjob.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QTimer>
|
||||
@@ -27,6 +28,7 @@
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QNetworkRequest>
|
||||
#include <QBuffer>
|
||||
|
||||
@@ -40,9 +42,9 @@ AccountState::AccountState(AccountPtr account)
|
||||
, _state(AccountState::Disconnected)
|
||||
, _connectionStatus(ConnectionValidator::Undefined)
|
||||
, _waitingForNewCredentials(false)
|
||||
, _notificationsEtagResponseHeader("*")
|
||||
, _maintenanceToConnectedDelay(60000 + (qrand() % (4 * 60000))) // 1-5min delay
|
||||
, _remoteWipe(new RemoteWipe(_account))
|
||||
, _hasTalk(false)
|
||||
{
|
||||
qRegisterMetaType<AccountState *>("AccountState*");
|
||||
|
||||
@@ -74,6 +76,11 @@ AccountPtr AccountState::account() const
|
||||
return _account;
|
||||
}
|
||||
|
||||
bool AccountState::hasTalk() const
|
||||
{
|
||||
return _hasTalk;
|
||||
}
|
||||
|
||||
AccountState::ConnectionStatus AccountState::connectionStatus() const
|
||||
{
|
||||
return _connectionStatus;
|
||||
@@ -237,6 +244,9 @@ void AccountState::checkConnectivity()
|
||||
// Use a small authed propfind as a minimal ping when we're
|
||||
// already connected.
|
||||
conValidator->checkAuthentication();
|
||||
|
||||
// Get the Apps available on the server.
|
||||
fetchNavigationApps();
|
||||
} else {
|
||||
// Check the server and then the auth.
|
||||
|
||||
@@ -267,7 +277,7 @@ void AccountState::slotConnectionValidatorResult(ConnectionValidator::Status sta
|
||||
// Come online gradually from 503 or maintenance mode
|
||||
if (status == ConnectionValidator::Connected
|
||||
&& (_connectionStatus == ConnectionValidator::ServiceUnavailable
|
||||
|| _connectionStatus == ConnectionValidator::MaintenanceMode)) {
|
||||
|| _connectionStatus == ConnectionValidator::MaintenanceMode)) {
|
||||
if (!_timeSinceMaintenanceOver.isValid()) {
|
||||
qCInfo(lcAccountState) << "AccountState reconnection: delaying for"
|
||||
<< _maintenanceToConnectedDelay << "ms";
|
||||
@@ -293,6 +303,9 @@ void AccountState::slotConnectionValidatorResult(ConnectionValidator::Status sta
|
||||
case ConnectionValidator::Connected:
|
||||
if (_state != Connected) {
|
||||
setState(Connected);
|
||||
|
||||
// Get the Apps available on the server.
|
||||
fetchNavigationApps();
|
||||
}
|
||||
break;
|
||||
case ConnectionValidator::Undefined:
|
||||
@@ -405,4 +418,110 @@ std::unique_ptr<QSettings> AccountState::settings()
|
||||
return s;
|
||||
}
|
||||
|
||||
void AccountState::fetchNavigationApps(){
|
||||
OcsNavigationAppsJob *job = new OcsNavigationAppsJob(_account);
|
||||
job->addRawHeader("If-None-Match", navigationAppsEtagResponseHeader());
|
||||
connect(job, &OcsNavigationAppsJob::appsJobFinished, this, &AccountState::slotNavigationAppsFetched);
|
||||
connect(job, &OcsNavigationAppsJob::etagResponseHeaderReceived, this, &AccountState::slotEtagResponseHeaderReceived);
|
||||
connect(job, &OcsNavigationAppsJob::ocsError, this, &AccountState::slotOcsError);
|
||||
job->getNavigationApps();
|
||||
}
|
||||
|
||||
void AccountState::slotEtagResponseHeaderReceived(const QByteArray &value, int statusCode){
|
||||
if(statusCode == 200){
|
||||
qCDebug(lcAccountState) << "New navigation apps ETag Response Header received " << value;
|
||||
setNavigationAppsEtagResponseHeader(value);
|
||||
}
|
||||
}
|
||||
|
||||
void AccountState::slotOcsError(int statusCode, const QString &message)
|
||||
{
|
||||
qCDebug(lcAccountState) << "Error " << statusCode << " while fetching new navigation apps: " << message;
|
||||
}
|
||||
|
||||
void AccountState::slotNavigationAppsFetched(const QJsonDocument &reply, int statusCode)
|
||||
{
|
||||
if(_account){
|
||||
if (statusCode == 304) {
|
||||
qCWarning(lcAccountState) << "Status code " << statusCode << " Not Modified - No new navigation apps.";
|
||||
} else {
|
||||
_apps.clear();
|
||||
_hasTalk = false;
|
||||
|
||||
if(!reply.isEmpty()){
|
||||
auto element = reply.object().value("ocs").toObject().value("data");
|
||||
auto navLinks = element.toArray();
|
||||
|
||||
if(navLinks.size() > 0){
|
||||
foreach (const QJsonValue &value, navLinks) {
|
||||
auto navLink = value.toObject();
|
||||
|
||||
AccountApp *app = new AccountApp(navLink.value("name").toString(), QUrl(navLink.value("href").toString()),
|
||||
navLink.value("id").toString(), QUrl(navLink.value("icon").toString()));
|
||||
|
||||
_apps << app;
|
||||
|
||||
if(app->id() == QLatin1String("spreed"))
|
||||
_hasTalk = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emit hasFetchedNavigationApps();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AccountAppList AccountState::appList() const
|
||||
{
|
||||
return _apps;
|
||||
}
|
||||
|
||||
AccountApp* AccountState::findApp(const QString &appId) const
|
||||
{
|
||||
if(!appId.isEmpty()) {
|
||||
foreach(AccountApp *app, appList()) {
|
||||
if(app->id() == appId)
|
||||
return app;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
|
||||
AccountApp::AccountApp(const QString &name, const QUrl &url,
|
||||
const QString &id, const QUrl &iconUrl,
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
, _name(name)
|
||||
, _url(url)
|
||||
, _id(id)
|
||||
, _iconUrl(iconUrl)
|
||||
{
|
||||
}
|
||||
|
||||
QString AccountApp::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
QUrl AccountApp::url() const
|
||||
{
|
||||
return _url;
|
||||
}
|
||||
|
||||
QString AccountApp::id() const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
QUrl AccountApp::iconUrl() const
|
||||
{
|
||||
return _iconUrl;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
@@ -29,9 +29,11 @@ namespace OCC {
|
||||
|
||||
class AccountState;
|
||||
class Account;
|
||||
class AccountApp;
|
||||
class RemoteWipe;
|
||||
|
||||
typedef QExplicitlySharedDataPointer<AccountState> AccountStatePtr;
|
||||
typedef QList<AccountApp*> AccountAppList;
|
||||
|
||||
/**
|
||||
* @brief Extra info about an ownCloud server account.
|
||||
@@ -101,6 +103,11 @@ public:
|
||||
|
||||
bool isSignedOut() const;
|
||||
|
||||
bool hasTalk() const;
|
||||
|
||||
AccountAppList appList() const;
|
||||
AccountApp* findApp(const QString &appId) const;
|
||||
|
||||
/** A user-triggered sign out which disconnects, stops syncs
|
||||
* for the account and forgets the password. */
|
||||
void signOutByUi();
|
||||
@@ -161,10 +168,12 @@ public slots:
|
||||
|
||||
private:
|
||||
void setState(State state);
|
||||
void fetchNavigationApps();
|
||||
|
||||
signals:
|
||||
void stateChanged(int state);
|
||||
void isConnectedChanged();
|
||||
void hasFetchedNavigationApps();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void slotConnectionValidatorResult(ConnectionValidator::Status status, const QStringList &errors);
|
||||
@@ -176,12 +185,17 @@ protected Q_SLOTS:
|
||||
void slotCredentialsFetched(AbstractCredentials *creds);
|
||||
void slotCredentialsAsked(AbstractCredentials *creds);
|
||||
|
||||
void slotNavigationAppsFetched(const QJsonDocument &reply, int statusCode);
|
||||
void slotEtagResponseHeaderReceived(const QByteArray &value, int statusCode);
|
||||
void slotOcsError(int statusCode, const QString &message);
|
||||
|
||||
private:
|
||||
AccountPtr _account;
|
||||
State _state;
|
||||
ConnectionStatus _connectionStatus;
|
||||
QStringList _connectionErrors;
|
||||
bool _waitingForNewCredentials;
|
||||
bool _hasTalk;
|
||||
QElapsedTimer _timeSinceLastETagCheck;
|
||||
QPointer<ConnectionValidator> _connectionValidator;
|
||||
QByteArray _notificationsEtagResponseHeader;
|
||||
@@ -205,7 +219,34 @@ private:
|
||||
*/
|
||||
RemoteWipe *_remoteWipe;
|
||||
|
||||
/**
|
||||
* Holds the App names and URLs available on the server
|
||||
*/
|
||||
AccountAppList _apps;
|
||||
|
||||
};
|
||||
|
||||
class AccountApp : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AccountApp(const QString &name, const QUrl &url,
|
||||
const QString &id, const QUrl &iconUrl,
|
||||
QObject* parent = 0);
|
||||
|
||||
QString name() const;
|
||||
QUrl url() const;
|
||||
QString id() const;
|
||||
QUrl iconUrl() const;
|
||||
|
||||
private:
|
||||
QString _name;
|
||||
QUrl _url;
|
||||
|
||||
QString _id;
|
||||
QUrl _iconUrl;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(OCC::AccountState *)
|
||||
|
||||
@@ -1,336 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
||||
* Copyright (C) by Olivier Goffart <ogoffart@woboq.com>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "activityitemdelegate.h"
|
||||
#include "folderstatusmodel.h"
|
||||
#include "folderman.h"
|
||||
#include "accountstate.h"
|
||||
#include "activitydata.h"
|
||||
#include <theme.h>
|
||||
#include <account.h>
|
||||
|
||||
#include <QFileIconProvider>
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
|
||||
#define HASQT5_11 (QT_VERSION >= QT_VERSION_CHECK(5,11,0))
|
||||
|
||||
namespace OCC {
|
||||
|
||||
int ActivityItemDelegate::_iconHeight = 0;
|
||||
int ActivityItemDelegate::_margin = 0;
|
||||
int ActivityItemDelegate::_primaryButtonWidth = 0;
|
||||
int ActivityItemDelegate::_secondaryButtonWidth = 0;
|
||||
int ActivityItemDelegate::_spaceBetweenButtons = 0;
|
||||
int ActivityItemDelegate::_timeWidth = 0;
|
||||
int ActivityItemDelegate::_buttonHeight = 0;
|
||||
const QString ActivityItemDelegate::_remote_share("remote_share");
|
||||
const QString ActivityItemDelegate::_call("call");
|
||||
|
||||
int ActivityItemDelegate::iconHeight()
|
||||
{
|
||||
if (_iconHeight == 0) {
|
||||
QStyleOptionViewItem option;
|
||||
QFont font = option.font;
|
||||
|
||||
QFontMetrics fm(font);
|
||||
|
||||
_iconHeight = qRound(fm.height() / 5.0 * 8.0);
|
||||
}
|
||||
return _iconHeight;
|
||||
}
|
||||
|
||||
int ActivityItemDelegate::rowHeight()
|
||||
{
|
||||
if (_margin == 0) {
|
||||
QStyleOptionViewItem opt;
|
||||
|
||||
QFont f = opt.font;
|
||||
QFontMetrics fm(f);
|
||||
|
||||
_margin = fm.height() / 2;
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
_margin += 5;
|
||||
#endif
|
||||
}
|
||||
return iconHeight() + 5 * _margin;
|
||||
}
|
||||
|
||||
QSize ActivityItemDelegate::sizeHint(const QStyleOptionViewItem &option,
|
||||
const QModelIndex & /* index */) const
|
||||
{
|
||||
QFont font = option.font;
|
||||
|
||||
return QSize(0, rowHeight());
|
||||
}
|
||||
|
||||
void ActivityItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
QFont font = option.font;
|
||||
QFontMetrics fm(font);
|
||||
int margin = fm.height() / 2.5;
|
||||
painter->save();
|
||||
int iconSize = 16;
|
||||
int iconOffset = qRound(fm.height() / 4.0 * 7.0);
|
||||
int offset = 4;
|
||||
|
||||
// get the data
|
||||
Activity::Type activityType = qvariant_cast<Activity::Type>(index.data(ActionRole));
|
||||
QIcon actionIcon = qvariant_cast<QIcon>(index.data(ActionIconRole));
|
||||
QString objectType = qvariant_cast<QString>(index.data(ObjectTypeRole));
|
||||
QString actionText = qvariant_cast<QString>(index.data(ActionTextRole));
|
||||
QString messageText = qvariant_cast<QString>(index.data(MessageRole));
|
||||
QList<QVariant> customList = index.data(ActionsLinksRole).toList();
|
||||
QString timeText = qvariant_cast<QString>(index.data(PointInTimeRole));
|
||||
bool accountOnline = qvariant_cast<bool>(index.data(AccountConnectedRole));
|
||||
|
||||
// activity/notification icons
|
||||
QRect actionIconRect = option.rect;
|
||||
actionIconRect.setLeft(option.rect.left() + iconOffset/3);
|
||||
actionIconRect.setRight(option.rect.left() + iconOffset);
|
||||
actionIconRect.setTop(option.rect.top() + qRound((option.rect.height() - 16)/3.0));
|
||||
|
||||
// subject text rect
|
||||
QRect actionTextBox = actionIconRect;
|
||||
#if (HASQT5_11)
|
||||
int actionTextBoxWidth = fm.horizontalAdvance(actionText);
|
||||
#else
|
||||
int actionTextBoxWidth = fm.width(actionText);
|
||||
#endif
|
||||
actionTextBox.setTop(option.rect.top() + margin + offset/2);
|
||||
actionTextBox.setHeight(fm.height());
|
||||
actionTextBox.setLeft(actionIconRect.right() + margin);
|
||||
actionTextBox.setRight(actionTextBox.left() + actionTextBoxWidth + margin);
|
||||
|
||||
// message text rect
|
||||
QRect messageTextBox = actionTextBox;
|
||||
#if (HASQT5_11)
|
||||
int messageTextWidth = fm.horizontalAdvance(messageText);
|
||||
#else
|
||||
int messageTextWidth = fm.width(messageText);
|
||||
#endif
|
||||
int messageTextTop = option.rect.top() + fm.height() + margin;
|
||||
if(actionText.isEmpty()) messageTextTop = option.rect.top() + margin + offset/2;
|
||||
messageTextBox.setTop(messageTextTop);
|
||||
messageTextBox.setHeight(fm.height());
|
||||
messageTextBox.setBottom(messageTextBox.top() + fm.height());
|
||||
messageTextBox.setRight(messageTextBox.left() + messageTextWidth + margin);
|
||||
if(messageText.isEmpty()){
|
||||
messageTextBox.setHeight(0);
|
||||
messageTextBox.setBottom(messageTextBox.top());
|
||||
}
|
||||
|
||||
// time box rect
|
||||
QRect timeBox = messageTextBox;
|
||||
QString timeStr = tr("%1").arg(timeText);
|
||||
#if (HASQT5_11)
|
||||
int timeTextWidth = fm.horizontalAdvance(timeStr);
|
||||
#else
|
||||
int timeTextWidth = fm.width(timeStr);
|
||||
#endif
|
||||
int timeTop = option.rect.top() + fm.height() + fm.height() + margin + offset/2;
|
||||
if(messageText.isEmpty() || actionText.isEmpty())
|
||||
timeTop = option.rect.top() + fm.height() + margin;
|
||||
timeBox.setTop(timeTop);
|
||||
timeBox.setHeight(fm.height());
|
||||
timeBox.setBottom(timeBox.top() + fm.height());
|
||||
timeBox.setRight(timeBox.left() + timeTextWidth + margin);
|
||||
|
||||
// buttons - default values
|
||||
int rightMargin = margin;
|
||||
int leftMargin = margin * offset;
|
||||
int top = option.rect.top() + margin;
|
||||
int buttonSize = option.rect.height()/2;
|
||||
int right = option.rect.right() - rightMargin;
|
||||
int left = right - buttonSize;
|
||||
|
||||
QStyleOptionButton secondaryButton;
|
||||
secondaryButton.rect = option.rect;
|
||||
secondaryButton.features |= QStyleOptionButton::Flat;
|
||||
secondaryButton.state |= QStyle::State_None;
|
||||
secondaryButton.rect.setLeft(left);
|
||||
secondaryButton.rect.setRight(right);
|
||||
secondaryButton.rect.setTop(top + margin);
|
||||
secondaryButton.rect.setHeight(iconSize);
|
||||
|
||||
QStyleOptionButton primaryButton;
|
||||
primaryButton.rect = option.rect;
|
||||
primaryButton.features |= QStyleOptionButton::DefaultButton;
|
||||
primaryButton.state |= QStyle::State_Raised;
|
||||
primaryButton.rect.setTop(top);
|
||||
primaryButton.rect.setHeight(buttonSize);
|
||||
|
||||
right = secondaryButton.rect.left() - rightMargin;
|
||||
left = secondaryButton.rect.left() - leftMargin;
|
||||
|
||||
primaryButton.rect.setRight(right);
|
||||
|
||||
if(activityType == Activity::Type::NotificationType){
|
||||
|
||||
// Secondary will be 'Dismiss' or '...' multiple options button
|
||||
secondaryButton.icon = QIcon(QLatin1String(":/client/resources/close.svg"));
|
||||
if(customList.size() > 1)
|
||||
secondaryButton.icon = QIcon(QLatin1String(":/client/resources/more.svg"));
|
||||
secondaryButton.iconSize = QSize(iconSize, iconSize);
|
||||
|
||||
// Primary button will be 'More Information' or 'Accept'
|
||||
primaryButton.text = tr("More information");
|
||||
if(objectType == _remote_share) primaryButton.text = tr("Accept");
|
||||
if(objectType == _call) primaryButton.text = tr("Join");
|
||||
|
||||
#if (HASQT5_11)
|
||||
primaryButton.rect.setLeft(left - margin * 2 - fm.horizontalAdvance(primaryButton.text));
|
||||
#else
|
||||
primaryButton.rect.setLeft(left - margin * 2 - fm.width(primaryButton.text));
|
||||
#endif
|
||||
|
||||
// save info to be able to filter mouse clicks
|
||||
_buttonHeight = buttonSize;
|
||||
_primaryButtonWidth = primaryButton.rect.size().width();
|
||||
_secondaryButtonWidth = secondaryButton.rect.size().width();
|
||||
_spaceBetweenButtons = secondaryButton.rect.left() - primaryButton.rect.right();
|
||||
|
||||
} else if(activityType == Activity::SyncResultType){
|
||||
|
||||
// Secondary will be 'open file manager' with the folder icon
|
||||
secondaryButton.icon = QIcon(QLatin1String(":/client/resources/folder.svg"));
|
||||
secondaryButton.iconSize = QSize(iconSize, iconSize);
|
||||
|
||||
// Primary button will be 'open browser'
|
||||
primaryButton.text = tr("Open Browser");
|
||||
|
||||
#if (HASQT5_11)
|
||||
primaryButton.rect.setLeft(left - margin * 2 - fm.horizontalAdvance(primaryButton.text));
|
||||
#else
|
||||
primaryButton.rect.setLeft(left - margin * 2 - fm.width(primaryButton.text));
|
||||
#endif
|
||||
|
||||
// save info to be able to filter mouse clicks
|
||||
_buttonHeight = buttonSize;
|
||||
_primaryButtonWidth = primaryButton.rect.size().width();
|
||||
_secondaryButtonWidth = secondaryButton.rect.size().width();
|
||||
_spaceBetweenButtons = secondaryButton.rect.left() - primaryButton.rect.right();
|
||||
|
||||
} else if(activityType == Activity::SyncFileItemType){
|
||||
|
||||
// Secondary will be 'open file manager' with the folder icon
|
||||
secondaryButton.icon = QIcon(QLatin1String(":/client/resources/folder.svg"));
|
||||
secondaryButton.iconSize = QSize(iconSize, iconSize);
|
||||
|
||||
// No primary button on this case
|
||||
// Whatever error we have at this case it is local, there is no point on opening the browser
|
||||
_primaryButtonWidth = 0;
|
||||
_secondaryButtonWidth = secondaryButton.rect.size().width();
|
||||
_spaceBetweenButtons = secondaryButton.rect.left() - primaryButton.rect.right();
|
||||
|
||||
} else {
|
||||
_spaceBetweenButtons = leftMargin;
|
||||
_primaryButtonWidth = 0;
|
||||
_secondaryButtonWidth = 0;
|
||||
}
|
||||
|
||||
// draw the icon
|
||||
QPixmap pm = actionIcon.pixmap(iconSize, iconSize, QIcon::Normal);
|
||||
painter->drawPixmap(QPoint(actionIconRect.left(), actionIconRect.top()), pm);
|
||||
|
||||
// change pen color if use is not online
|
||||
QPalette p = option.palette;
|
||||
if(!accountOnline)
|
||||
p.setCurrentColorGroup(QPalette::Disabled);
|
||||
|
||||
// change pen color if the line is selected
|
||||
if (option.state & QStyle::State_Selected)
|
||||
painter->setPen(p.color(QPalette::HighlightedText));
|
||||
else
|
||||
painter->setPen(p.color(QPalette::Text));
|
||||
|
||||
// calculate space for text - use the max possible before using the elipses
|
||||
int spaceLeftForText = option.rect.width() - (actionIconRect.width() + margin + rightMargin + leftMargin) -
|
||||
(_primaryButtonWidth + _secondaryButtonWidth + _spaceBetweenButtons);
|
||||
|
||||
// draw the subject
|
||||
const QString elidedAction = fm.elidedText(actionText, Qt::ElideRight, spaceLeftForText);
|
||||
painter->drawText(actionTextBox, elidedAction);
|
||||
|
||||
// draw the buttons
|
||||
if(activityType == Activity::Type::NotificationType || activityType == Activity::Type::SyncResultType)
|
||||
QApplication::style()->drawControl(QStyle::CE_PushButton, &primaryButton, painter);
|
||||
|
||||
// Since they are errors on local syncing, there is nothing to do in the server
|
||||
if(activityType != Activity::Type::ActivityType)
|
||||
QApplication::style()->drawControl(QStyle::CE_PushButton, &secondaryButton, painter);
|
||||
|
||||
// draw the message
|
||||
// change pen color for the message
|
||||
if(!messageText.isEmpty()){
|
||||
const QString elidedMessage = fm.elidedText(messageText, Qt::ElideRight, spaceLeftForText);
|
||||
painter->drawText(messageTextBox, elidedMessage);
|
||||
}
|
||||
|
||||
// change pen color for the time
|
||||
if (option.state & QStyle::State_Selected)
|
||||
painter->setPen(p.color(QPalette::Disabled, QPalette::HighlightedText));
|
||||
else
|
||||
painter->setPen(p.color(QPalette::Disabled, QPalette::Text));
|
||||
|
||||
// draw the time
|
||||
const QString elidedTime = fm.elidedText(timeStr, Qt::ElideRight, spaceLeftForText);
|
||||
painter->drawText(timeBox, elidedTime);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
bool ActivityItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
|
||||
const QStyleOptionViewItem &option, const QModelIndex &index)
|
||||
{
|
||||
Activity::Type activityType = qvariant_cast<Activity::Type>(index.data(ActionRole));
|
||||
if(activityType != Activity::Type::ActivityType){
|
||||
if (event->type() == QEvent::MouseButtonRelease){
|
||||
QMouseEvent *mouseEvent = (QMouseEvent*)event;
|
||||
if(mouseEvent){
|
||||
int mouseEventX = mouseEvent->x();
|
||||
int mouseEventY = mouseEvent->y();
|
||||
int buttonsWidth = _primaryButtonWidth + _spaceBetweenButtons + _secondaryButtonWidth;
|
||||
int x = option.rect.left() + option.rect.width() - buttonsWidth - _timeWidth;
|
||||
int y = option.rect.top();
|
||||
|
||||
// clickable area for ...
|
||||
if (mouseEventX > x && mouseEventX < x + buttonsWidth){
|
||||
if(mouseEventY > y && mouseEventY < y + _buttonHeight){
|
||||
|
||||
// ...primary button ('more information' or 'accept' on notifications or 'open browser' on errors)
|
||||
if (mouseEventX > x && mouseEventX < x + _primaryButtonWidth){
|
||||
emit primaryButtonClickedOnItemView(index);
|
||||
|
||||
// ...secondary button ('dismiss' on notifications or 'open file manager' on errors)
|
||||
} else {
|
||||
x += _primaryButtonWidth + _spaceBetweenButtons;
|
||||
if (mouseEventX > x && mouseEventX < x + _secondaryButtonWidth)
|
||||
emit secondaryButtonClickedOnItemView(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QStyledItemDelegate::editorEvent(event, model, option, index);
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Klaas Freitag <freitag@kde.org>
|
||||
* Copyright (C) by Olivier Goffart <ogoffart@woboq.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QMouseEvent>
|
||||
|
||||
class QMouseEvent;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
/**
|
||||
* @brief The ActivityItemDelegate class
|
||||
* @ingroup gui
|
||||
*/
|
||||
class ActivityItemDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum datarole { ActionIconRole = Qt::UserRole + 1,
|
||||
UserIconRole,
|
||||
AccountRole,
|
||||
ObjectTypeRole,
|
||||
ActionsLinksRole,
|
||||
ActionTextRole,
|
||||
ActionRole,
|
||||
MessageRole,
|
||||
PathRole,
|
||||
LinkRole,
|
||||
PointInTimeRole,
|
||||
AccountConnectedRole,
|
||||
SyncFileStatusRole };
|
||||
|
||||
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override;
|
||||
QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const override;
|
||||
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) override;
|
||||
|
||||
static int rowHeight();
|
||||
static int iconHeight();
|
||||
|
||||
signals:
|
||||
void primaryButtonClickedOnItemView(const QModelIndex &index);
|
||||
void secondaryButtonClickedOnItemView(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
static int _margin;
|
||||
static int _iconHeight;
|
||||
static int _primaryButtonWidth;
|
||||
static int _secondaryButtonWidth;
|
||||
static int _spaceBetweenButtons;
|
||||
static int _timeWidth;
|
||||
static int _buttonHeight;
|
||||
static const QString _remote_share;
|
||||
static const QString _call;
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
@@ -1,355 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include <QtCore>
|
||||
#include <QAbstractListModel>
|
||||
#include <QWidget>
|
||||
#include <QIcon>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
|
||||
#include "account.h"
|
||||
#include "accountstate.h"
|
||||
#include "accountmanager.h"
|
||||
#include "folderman.h"
|
||||
#include "accessmanager.h"
|
||||
#include "activityitemdelegate.h"
|
||||
|
||||
#include "activitydata.h"
|
||||
#include "activitylistmodel.h"
|
||||
|
||||
#include "theme.h"
|
||||
|
||||
#include "servernotificationhandler.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
Q_LOGGING_CATEGORY(lcActivity, "nextcloud.gui.activity", QtInfoMsg)
|
||||
|
||||
ActivityListModel::ActivityListModel(AccountState *accountState, QWidget *parent)
|
||||
: QAbstractListModel(parent)
|
||||
, _accountState(accountState)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant ActivityListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
Activity a;
|
||||
|
||||
// filter the get action here
|
||||
// send only the text of the get action
|
||||
// if there is more than one send the icon? the ...
|
||||
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
a = _finalList.at(index.row());
|
||||
AccountStatePtr ast = AccountManager::instance()->account(a._accName);
|
||||
if (!ast && _accountState != ast.data())
|
||||
return QVariant();
|
||||
QStringList list;
|
||||
|
||||
switch (role) {
|
||||
case ActivityItemDelegate::PathRole:
|
||||
if(!a._file.isEmpty()){
|
||||
auto folder = FolderMan::instance()->folder(a._folder);
|
||||
list = FolderMan::instance()->findFileInLocalFolders(folder->remotePath(), ast->account());
|
||||
if (list.count() > 0) {
|
||||
return QVariant(list.at(0));
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
case ActivityItemDelegate::ActionsLinksRole:{
|
||||
QList<QVariant> customList;
|
||||
foreach (ActivityLink customItem, a._links) {
|
||||
QVariant customVariant;
|
||||
customVariant.setValue(customItem);
|
||||
customList << customVariant;
|
||||
}
|
||||
return customList;
|
||||
}
|
||||
case ActivityItemDelegate::ActionIconRole:
|
||||
if(a._type == Activity::NotificationType){
|
||||
QIcon cachedIcon = ServerNotificationHandler::iconCache.value(a._id);
|
||||
if(!cachedIcon.isNull())
|
||||
return cachedIcon;
|
||||
else return QIcon(QLatin1String(":/client/resources/bell.svg"));
|
||||
} else if(a._type == Activity::SyncResultType){
|
||||
return QIcon(QLatin1String(":/client/resources/state-error.svg"));
|
||||
} else if(a._type == Activity::SyncFileItemType){
|
||||
if(a._status == SyncFileItem::NormalError
|
||||
|| a._status == SyncFileItem::FatalError
|
||||
|| a._status == SyncFileItem::DetailError
|
||||
|| a._status == SyncFileItem::BlacklistedError) {
|
||||
return QIcon(QLatin1String(":/client/resources/state-error.svg"));
|
||||
} else if(a._status == SyncFileItem::SoftError
|
||||
|| a._status == SyncFileItem::Conflict
|
||||
|| a._status == SyncFileItem::Restoration
|
||||
|| a._status == SyncFileItem::FileLocked){
|
||||
return QIcon(QLatin1String(":/client/resources/state-warning.svg"));
|
||||
} else if(a._status == SyncFileItem::FileIgnored){
|
||||
return QIcon(QLatin1String(":/client/resources/state-info.svg"));
|
||||
}
|
||||
return QIcon(QLatin1String(":/client/resources/state-sync.svg"));
|
||||
}
|
||||
return QIcon(QLatin1String(":/client/resources/activity.png"));
|
||||
break;
|
||||
case ActivityItemDelegate::ObjectTypeRole:
|
||||
return a._objectType;
|
||||
break;
|
||||
case ActivityItemDelegate::ActionRole:{
|
||||
QVariant type;
|
||||
type.setValue(a._type);
|
||||
return type;
|
||||
break;
|
||||
}
|
||||
case ActivityItemDelegate::ActionTextRole:
|
||||
return a._subject;
|
||||
break;
|
||||
case ActivityItemDelegate::MessageRole:
|
||||
return a._message;
|
||||
break;
|
||||
case ActivityItemDelegate::LinkRole:
|
||||
return a._link;
|
||||
break;
|
||||
case ActivityItemDelegate::AccountRole:
|
||||
return a._accName;
|
||||
break;
|
||||
case ActivityItemDelegate::PointInTimeRole:
|
||||
return Utility::timeAgoInWords(a._dateTime);
|
||||
break;
|
||||
case ActivityItemDelegate::AccountConnectedRole:
|
||||
return (ast && ast->isConnected());
|
||||
break;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int ActivityListModel::rowCount(const QModelIndex &) const
|
||||
{
|
||||
return _finalList.count();
|
||||
}
|
||||
|
||||
bool ActivityListModel::canFetchMore(const QModelIndex &) const
|
||||
{
|
||||
// We need to be connected to be able to fetch more
|
||||
if (_accountState && _accountState->isConnected()) {
|
||||
// If the fetching is reported to be done or we are currently fetching we can't fetch more
|
||||
if (!_doneFetching && !_currentlyFetching) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ActivityListModel::startFetchJob()
|
||||
{
|
||||
if (!_accountState->isConnected()) {
|
||||
return;
|
||||
}
|
||||
JsonApiJob *job = new JsonApiJob(_accountState->account(), QLatin1String("ocs/v2.php/cloud/activity"), this);
|
||||
QObject::connect(job, &JsonApiJob::jsonReceived,
|
||||
this, &ActivityListModel::slotActivitiesReceived);
|
||||
|
||||
QUrlQuery params;
|
||||
params.addQueryItem(QLatin1String("start"), QString::number(_currentItem));
|
||||
params.addQueryItem(QLatin1String("count"), QString::number(100));
|
||||
job->addQueryParams(params);
|
||||
|
||||
_currentlyFetching = true;
|
||||
qCInfo(lcActivity) << "Start fetching activities for " << _accountState->account()->displayName();
|
||||
job->start();
|
||||
}
|
||||
|
||||
void ActivityListModel::slotActivitiesReceived(const QJsonDocument &json, int statusCode)
|
||||
{
|
||||
auto activities = json.object().value("ocs").toObject().value("data").toArray();
|
||||
|
||||
ActivityList list;
|
||||
auto ast = _accountState;
|
||||
if (!ast) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (activities.size() == 0) {
|
||||
_doneFetching = true;
|
||||
}
|
||||
|
||||
_currentlyFetching = false;
|
||||
_currentItem += activities.size();
|
||||
|
||||
foreach (auto activ, activities) {
|
||||
auto json = activ.toObject();
|
||||
|
||||
Activity a;
|
||||
a._type = Activity::ActivityType;
|
||||
a._accName = ast->account()->displayName();
|
||||
a._id = json.value("id").toInt();
|
||||
a._subject = json.value("subject").toString();
|
||||
a._message = json.value("message").toString();
|
||||
a._file = json.value("file").toString();
|
||||
a._link = QUrl(json.value("link").toString());
|
||||
a._dateTime = QDateTime::fromString(json.value("date").toString(), Qt::ISODate);
|
||||
list.append(a);
|
||||
}
|
||||
|
||||
_activityLists.append(list);
|
||||
|
||||
emit activityJobStatusCode(statusCode);
|
||||
|
||||
combineActivityLists();
|
||||
}
|
||||
|
||||
void ActivityListModel::addErrorToActivityList(Activity activity) {
|
||||
qCInfo(lcActivity) << "Error successfully added to the notification list: " << activity._subject;
|
||||
_notificationErrorsLists.prepend(activity);
|
||||
combineActivityLists();
|
||||
}
|
||||
|
||||
void ActivityListModel::addIgnoredFileToList(Activity newActivity) {
|
||||
qCInfo(lcActivity) << "First checking for duplicates then add file to the notification list of ignored files: " << newActivity._file;
|
||||
|
||||
bool duplicate = false;
|
||||
if(_listOfIgnoredFiles.size() == 0){
|
||||
_notificationIgnoredFiles = newActivity;
|
||||
_notificationIgnoredFiles._subject = tr("Files from the ignore list as well as symbolic links are not synced. This includes:");
|
||||
_listOfIgnoredFiles.append(newActivity);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(Activity activity, _listOfIgnoredFiles){
|
||||
if(activity._file == newActivity._file){
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!duplicate){
|
||||
_notificationIgnoredFiles._message.append(", " + newActivity._file);
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityListModel::addNotificationToActivityList(Activity activity) {
|
||||
qCInfo(lcActivity) << "Notification successfully added to the notification list: " << activity._subject;
|
||||
_notificationLists.prepend(activity);
|
||||
combineActivityLists();
|
||||
}
|
||||
|
||||
void ActivityListModel::clearNotifications() {
|
||||
qCInfo(lcActivity) << "Clear the notifications";
|
||||
_notificationLists.clear();
|
||||
combineActivityLists();
|
||||
}
|
||||
|
||||
void ActivityListModel::removeActivityFromActivityList(int row) {
|
||||
Activity activity = _finalList.at(row);
|
||||
removeActivityFromActivityList(activity);
|
||||
combineActivityLists();
|
||||
}
|
||||
|
||||
void ActivityListModel::addSyncFileItemToActivityList(Activity activity) {
|
||||
qCInfo(lcActivity) << "Successfully added to the activity list: " << activity._subject;
|
||||
_syncFileItemLists.prepend(activity);
|
||||
combineActivityLists();
|
||||
}
|
||||
|
||||
void ActivityListModel::removeActivityFromActivityList(Activity activity) {
|
||||
qCInfo(lcActivity) << "Activity/Notification/Error successfully dismissed: " << activity._subject;
|
||||
qCInfo(lcActivity) << "Trying to remove Activity/Notification/Error from view... ";
|
||||
|
||||
int index = -1;
|
||||
if(activity._type == Activity::ActivityType){
|
||||
index = _activityLists.indexOf(activity);
|
||||
if(index != -1) _activityLists.removeAt(index);
|
||||
} else if(activity._type == Activity::NotificationType){
|
||||
index = _notificationLists.indexOf(activity);
|
||||
if(index != -1) _notificationLists.removeAt(index);
|
||||
} else {
|
||||
index = _notificationErrorsLists.indexOf(activity);
|
||||
if(index != -1) _notificationErrorsLists.removeAt(index);
|
||||
}
|
||||
|
||||
if(index != -1){
|
||||
qCInfo(lcActivity) << "Activity/Notification/Error successfully removed from the list.";
|
||||
qCInfo(lcActivity) << "Updating Activity/Notification/Error view.";
|
||||
combineActivityLists();
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityListModel::combineActivityLists()
|
||||
{
|
||||
ActivityList resultList;
|
||||
|
||||
std::sort(_notificationErrorsLists.begin(), _notificationErrorsLists.end());
|
||||
resultList.append(_notificationErrorsLists);
|
||||
resultList.append(_notificationIgnoredFiles);
|
||||
|
||||
std::sort(_notificationLists.begin(), _notificationLists.end());
|
||||
resultList.append(_notificationLists);
|
||||
|
||||
std::sort(_syncFileItemLists.begin(), _syncFileItemLists.end());
|
||||
resultList.append(_syncFileItemLists);
|
||||
|
||||
std::sort(_activityLists.begin(), _activityLists.end());
|
||||
resultList.append(_activityLists);
|
||||
|
||||
beginResetModel();
|
||||
_finalList.clear();
|
||||
endResetModel();
|
||||
|
||||
beginInsertRows(QModelIndex(), 0, resultList.count());
|
||||
_finalList = resultList;
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
bool ActivityListModel::canFetchActivities() const {
|
||||
return _accountState->isConnected() && _accountState->account()->capabilities().hasActivities();
|
||||
}
|
||||
|
||||
void ActivityListModel::fetchMore(const QModelIndex &)
|
||||
{
|
||||
if (canFetchActivities()) {
|
||||
startFetchJob();
|
||||
} else {
|
||||
_doneFetching = true;
|
||||
combineActivityLists();
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityListModel::slotRefreshActivity()
|
||||
{
|
||||
_activityLists.clear();
|
||||
_doneFetching = false;
|
||||
_currentItem = 0;
|
||||
|
||||
if (canFetchActivities()) {
|
||||
startFetchJob();
|
||||
} else {
|
||||
_doneFetching = true;
|
||||
combineActivityLists();
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityListModel::slotRemoveAccount()
|
||||
{
|
||||
_finalList.clear();
|
||||
_activityLists.clear();
|
||||
_currentlyFetching = false;
|
||||
_doneFetching = false;
|
||||
_currentItem = 0;
|
||||
}
|
||||
}
|
||||
@@ -1,631 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include <QtGui>
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "activitylistmodel.h"
|
||||
#include "activitywidget.h"
|
||||
#include "syncresult.h"
|
||||
#include "logger.h"
|
||||
#include "theme.h"
|
||||
#include "folderman.h"
|
||||
#include "syncfileitem.h"
|
||||
#include "folder.h"
|
||||
#include "openfilemanager.h"
|
||||
#include "owncloudpropagator.h"
|
||||
#include "account.h"
|
||||
#include "accountstate.h"
|
||||
#include "accountmanager.h"
|
||||
#include "activityitemdelegate.h"
|
||||
#include "QProgressIndicator.h"
|
||||
#include "notificationconfirmjob.h"
|
||||
#include "servernotificationhandler.h"
|
||||
#include "theme.h"
|
||||
#include "ocsjob.h"
|
||||
#include "configfile.h"
|
||||
#include "guiutility.h"
|
||||
#include "socketapi.h"
|
||||
#include "ui_activitywidget.h"
|
||||
#include "syncengine.h"
|
||||
|
||||
#include <climits>
|
||||
|
||||
// time span in milliseconds which has to be between two
|
||||
// refreshes of the notifications
|
||||
#define NOTIFICATION_REQUEST_FREE_PERIOD 15000
|
||||
|
||||
namespace OCC {
|
||||
|
||||
ActivityWidget::ActivityWidget(AccountState *accountState, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, _ui(new Ui::ActivityWidget)
|
||||
, _notificationRequestsRunning(0)
|
||||
, _accountState(accountState)
|
||||
, _accept(tr("Accept"))
|
||||
, _remote_share("remote_share")
|
||||
{
|
||||
_ui->setupUi(this);
|
||||
|
||||
// Adjust copyToClipboard() when making changes here!
|
||||
#if defined(Q_OS_MAC)
|
||||
_ui->_activityList->setMinimumWidth(400);
|
||||
#endif
|
||||
|
||||
_model = new ActivityListModel(accountState, this);
|
||||
ActivityItemDelegate *delegate = new ActivityItemDelegate;
|
||||
delegate->setParent(this);
|
||||
_ui->_activityList->setItemDelegate(delegate);
|
||||
_ui->_activityList->setAlternatingRowColors(true);
|
||||
_ui->_activityList->setModel(_model);
|
||||
|
||||
showLabels();
|
||||
|
||||
connect(_model, &ActivityListModel::activityJobStatusCode,
|
||||
this, &ActivityWidget::slotAccountActivityStatus);
|
||||
|
||||
connect(_model, &QAbstractItemModel::rowsInserted, this, &ActivityWidget::rowsInserted);
|
||||
|
||||
connect(delegate, &ActivityItemDelegate::primaryButtonClickedOnItemView, this, &ActivityWidget::slotPrimaryButtonClickedOnListView);
|
||||
connect(delegate, &ActivityItemDelegate::secondaryButtonClickedOnItemView, this, &ActivityWidget::slotSecondaryButtonClickedOnListView);
|
||||
connect(_ui->_activityList, &QListView::activated, this, &ActivityWidget::slotOpenFile);
|
||||
|
||||
connect(ProgressDispatcher::instance(), &ProgressDispatcher::progressInfo,
|
||||
this, &ActivityWidget::slotProgressInfo);
|
||||
connect(ProgressDispatcher::instance(), &ProgressDispatcher::itemCompleted,
|
||||
this, &ActivityWidget::slotItemCompleted);
|
||||
connect(ProgressDispatcher::instance(), &ProgressDispatcher::syncError,
|
||||
this, &ActivityWidget::addError);
|
||||
|
||||
_removeTimer.setInterval(1000);
|
||||
}
|
||||
|
||||
ActivityWidget::~ActivityWidget()
|
||||
{
|
||||
delete _ui;
|
||||
}
|
||||
|
||||
void ActivityWidget::slotProgressInfo(const QString &folder, const ProgressInfo &progress)
|
||||
{
|
||||
if (progress.status() == ProgressInfo::Reconcile) {
|
||||
// Wipe all non-persistent entries - as well as the persistent ones
|
||||
// in cases where a local discovery was done.
|
||||
auto f = FolderMan::instance()->folder(folder);
|
||||
if (!f)
|
||||
return;
|
||||
const auto &engine = f->syncEngine();
|
||||
const auto style = engine.lastLocalDiscoveryStyle();
|
||||
foreach (Activity activity, _model->errorsList()) {
|
||||
if (activity._folder != folder){
|
||||
continue;
|
||||
}
|
||||
|
||||
if (style == LocalDiscoveryStyle::FilesystemOnly){
|
||||
_model->removeActivityFromActivityList(activity);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(activity._status == SyncFileItem::Conflict && !QFileInfo(f->path() + activity._file).exists()){
|
||||
_model->removeActivityFromActivityList(activity);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(activity._status == SyncFileItem::FileLocked && !QFileInfo(f->path() + activity._file).exists()){
|
||||
_model->removeActivityFromActivityList(activity);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(activity._status == SyncFileItem::FileIgnored && !QFileInfo(f->path() + activity._file).exists()) {
|
||||
_model->removeActivityFromActivityList(activity);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(!QFileInfo(f->path() + activity._file).exists()){
|
||||
_model->removeActivityFromActivityList(activity);
|
||||
continue;
|
||||
}
|
||||
|
||||
auto path = QFileInfo(activity._file).dir().path().toUtf8();
|
||||
if (path == ".")
|
||||
path.clear();
|
||||
|
||||
if(engine.shouldDiscoverLocally(path))
|
||||
_model->removeActivityFromActivityList(activity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (progress.status() == ProgressInfo::Done) {
|
||||
// We keep track very well of pending conflicts.
|
||||
// Inform other components about them.
|
||||
QStringList conflicts;
|
||||
foreach (Activity activity, _model->errorsList()) {
|
||||
if (activity._folder == folder
|
||||
&& activity._status == SyncFileItem::Conflict) {
|
||||
conflicts.append(activity._file);
|
||||
}
|
||||
}
|
||||
|
||||
emit ProgressDispatcher::instance()->folderConflicts(folder, conflicts);
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::slotItemCompleted(const QString &folder, const SyncFileItemPtr &item){
|
||||
auto folderInstance = FolderMan::instance()->folder(folder);
|
||||
|
||||
if (!folderInstance)
|
||||
return;
|
||||
|
||||
// check if we are adding it to the right account and if it is useful information (protocol errors)
|
||||
if(folderInstance->accountState() == _accountState){
|
||||
qCWarning(lcActivity) << "Item " << item->_file << " retrieved resulted in " << item->_errorString;
|
||||
|
||||
Activity activity;
|
||||
activity._type = Activity::SyncFileItemType; //client activity
|
||||
activity._status = item->_status;
|
||||
activity._dateTime = QDateTime::fromString(QDateTime::currentDateTime().toString(), Qt::ISODate);
|
||||
activity._message = item->_originalFile;
|
||||
activity._link = folderInstance->accountState()->account()->url();
|
||||
activity._accName = folderInstance->accountState()->account()->displayName();
|
||||
activity._file = item->_file;
|
||||
activity._folder = folder;
|
||||
|
||||
if(item->_status == SyncFileItem::NoStatus || item->_status == SyncFileItem::Success){
|
||||
qCWarning(lcActivity) << "Item " << item->_file << " retrieved successfully.";
|
||||
activity._message.prepend(" ");
|
||||
activity._message.prepend(tr("Synced"));
|
||||
_model->addSyncFileItemToActivityList(activity);
|
||||
} else {
|
||||
qCWarning(lcActivity) << "Item " << item->_file << " retrieved resulted in error " << item->_errorString;
|
||||
activity._subject = item->_errorString;
|
||||
|
||||
if(item->_status == SyncFileItem::Status::FileIgnored) {
|
||||
_model->addIgnoredFileToList(activity);
|
||||
} else {
|
||||
// add 'protocol error' to activity list
|
||||
_model->addErrorToActivityList(activity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::addError(const QString &folderAlias, const QString &message,
|
||||
ErrorCategory category)
|
||||
{
|
||||
auto folderInstance = FolderMan::instance()->folder(folderAlias);
|
||||
if (!folderInstance)
|
||||
return;
|
||||
|
||||
if(folderInstance->accountState() == _accountState){
|
||||
qCWarning(lcActivity) << "Item " << folderInstance->shortGuiLocalPath() << " retrieved resulted in " << message;
|
||||
|
||||
Activity activity;
|
||||
activity._type = Activity::SyncResultType;
|
||||
activity._status = SyncResult::Error;
|
||||
activity._dateTime = QDateTime::fromString(QDateTime::currentDateTime().toString(), Qt::ISODate);
|
||||
activity._subject = message;
|
||||
activity._message = folderInstance->shortGuiLocalPath();
|
||||
activity._link = folderInstance->shortGuiLocalPath();
|
||||
activity._accName = folderInstance->accountState()->account()->displayName();
|
||||
activity._folder = folderAlias;
|
||||
|
||||
|
||||
if (category == ErrorCategory::InsufficientRemoteStorage) {
|
||||
ActivityLink link;
|
||||
link._label = tr("Retry all uploads");
|
||||
link._link = folderInstance->path();
|
||||
link._verb = "";
|
||||
link._isPrimary = true;
|
||||
activity._links.append(link);
|
||||
}
|
||||
|
||||
// add 'other errors' to activity list
|
||||
_model->addErrorToActivityList(activity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ActivityWidget::slotPrimaryButtonClickedOnListView(const QModelIndex &index){
|
||||
QUrl link = qvariant_cast<QString>(index.data(ActivityItemDelegate::LinkRole));
|
||||
QString objectType = index.data(ActivityItemDelegate::ObjectTypeRole).toString();
|
||||
if(!link.isEmpty()){
|
||||
qCWarning(lcActivity) << "Opening" << link.toString() << "in browser for Notification/Activity" << qvariant_cast<QString>(index.data(ActivityItemDelegate::ActionTextRole));
|
||||
Utility::openBrowser(link, this);
|
||||
} else if(objectType == _remote_share){
|
||||
QVariant customItem = index.data(ActivityItemDelegate::ActionsLinksRole).toList().first();
|
||||
ActivityLink actionLink = qvariant_cast<ActivityLink>(customItem);
|
||||
if(actionLink._label == _accept){
|
||||
qCWarning(lcActivity) << objectType << "action" << actionLink._label << "for" << qvariant_cast<QString>(index.data(ActivityItemDelegate::ActionTextRole));
|
||||
const QString accountName = index.data(ActivityItemDelegate::AccountRole).toString();
|
||||
slotSendNotificationRequest(accountName, actionLink._link, actionLink._verb, index.row());
|
||||
} else {
|
||||
qCWarning(lcActivity) << "Failed: " << objectType << "action" << actionLink._label << "for" << qvariant_cast<QString>(index.data(ActivityItemDelegate::ActionTextRole));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::slotSecondaryButtonClickedOnListView(const QModelIndex &index){
|
||||
QList<QVariant> customList = index.data(ActivityItemDelegate::ActionsLinksRole).toList();
|
||||
QString objectType = index.data(ActivityItemDelegate::ObjectTypeRole).toString();
|
||||
|
||||
QList<ActivityLink> actionLinks;
|
||||
foreach(QVariant customItem, customList){
|
||||
actionLinks << qvariant_cast<ActivityLink>(customItem);
|
||||
}
|
||||
|
||||
if(objectType == _remote_share && actionLinks.first()._label == _accept)
|
||||
actionLinks.removeFirst();
|
||||
|
||||
if(qvariant_cast<Activity::Type>(index.data(ActivityItemDelegate::ActionRole)) == Activity::Type::NotificationType){
|
||||
const QString accountName = index.data(ActivityItemDelegate::AccountRole).toString();
|
||||
if(actionLinks.size() == 1){
|
||||
if(actionLinks.at(0)._verb == "DELETE"){
|
||||
qCWarning(lcActivity) << "Dismissing Notification/Activity" << qvariant_cast<QString>(index.data(ActivityItemDelegate::ActionTextRole));
|
||||
slotSendNotificationRequest(index.data(ActivityItemDelegate::AccountRole).toString(), actionLinks.at(0)._link, actionLinks.at(0)._verb, index.row());
|
||||
}
|
||||
} else if(actionLinks.size() > 1){
|
||||
QMenu menu;
|
||||
qCWarning(lcActivity) << "Displaying menu for Notification/Activity" << qvariant_cast<QString>(index.data(ActivityItemDelegate::ActionTextRole));
|
||||
foreach (ActivityLink actionLink, actionLinks) {
|
||||
QAction *menuAction = new QAction(actionLink._label, &menu);
|
||||
connect(menuAction, &QAction::triggered, this, [this, index, accountName, actionLink] {
|
||||
this->slotSendNotificationRequest(accountName, actionLink._link, actionLink._verb, index.row());
|
||||
});
|
||||
menu.addAction(menuAction);
|
||||
}
|
||||
menu.exec(QCursor::pos());
|
||||
}
|
||||
}
|
||||
|
||||
Activity::Type activityType = qvariant_cast<Activity::Type>(index.data(ActivityItemDelegate::ActionRole));
|
||||
if(activityType == Activity::Type::SyncFileItemType || activityType == Activity::Type::SyncResultType)
|
||||
slotOpenFile(index);
|
||||
}
|
||||
|
||||
void ActivityWidget::slotNotificationRequestFinished(int statusCode)
|
||||
{
|
||||
int row = sender()->property("activityRow").toInt();
|
||||
|
||||
// the ocs API returns stat code 100 or 200 inside the xml if it succeeded.
|
||||
if (statusCode != OCS_SUCCESS_STATUS_CODE && statusCode != OCS_SUCCESS_STATUS_CODE_V2) {
|
||||
qCWarning(lcActivity) << "Notification Request to Server failed, leave notification visible.";
|
||||
} else {
|
||||
// to do use the model to rebuild the list or remove the item
|
||||
qCWarning(lcActivity) << "Notification Request to Server successed, rebuilding list.";
|
||||
_model->removeActivityFromActivityList(row);
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::slotRefreshActivities()
|
||||
{
|
||||
_model->slotRefreshActivity();
|
||||
}
|
||||
|
||||
void ActivityWidget::slotRefreshNotifications()
|
||||
{
|
||||
// start a server notification handler if no notification requests
|
||||
// are running
|
||||
if (_notificationRequestsRunning == 0) {
|
||||
ServerNotificationHandler *snh = new ServerNotificationHandler(_accountState);
|
||||
connect(snh, &ServerNotificationHandler::newNotificationList,
|
||||
this, &ActivityWidget::slotBuildNotificationDisplay);
|
||||
|
||||
snh->slotFetchNotifications();
|
||||
} else {
|
||||
qCWarning(lcActivity) << "Notification request counter not zero.";
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::slotRemoveAccount()
|
||||
{
|
||||
_model->slotRemoveAccount();
|
||||
}
|
||||
|
||||
void ActivityWidget::showLabels()
|
||||
{
|
||||
_ui->_bottomLabel->hide(); // hide whatever was there before
|
||||
QString t("");
|
||||
QSetIterator<QString> i(_accountsWithoutActivities);
|
||||
while (i.hasNext()) {
|
||||
t.append(tr("<br/>Account %1 does not have activities enabled.").arg(i.next()));
|
||||
}
|
||||
if(!t.isEmpty()){
|
||||
_ui->_bottomLabel->setTextFormat(Qt::RichText);
|
||||
_ui->_bottomLabel->setText(t);
|
||||
_ui->_bottomLabel->show();
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::slotAccountActivityStatus(int statusCode)
|
||||
{
|
||||
if (!(_accountState && _accountState->account())) {
|
||||
return;
|
||||
}
|
||||
if (statusCode == 999) {
|
||||
_accountsWithoutActivities.insert(_accountState->account()->displayName());
|
||||
} else {
|
||||
_accountsWithoutActivities.remove(_accountState->account()->displayName());
|
||||
}
|
||||
|
||||
checkActivityWidgetVisibility();
|
||||
showLabels();
|
||||
}
|
||||
|
||||
// FIXME: Reused from protocol widget. Move over to utilities.
|
||||
QString ActivityWidget::timeString(QDateTime dt, QLocale::FormatType format) const
|
||||
{
|
||||
const QLocale loc = QLocale::system();
|
||||
QString dtFormat = loc.dateTimeFormat(format);
|
||||
static const QRegExp re("(HH|H|hh|h):mm(?!:s)");
|
||||
dtFormat.replace(re, "\\1:mm:ss");
|
||||
return loc.toString(dt, dtFormat);
|
||||
}
|
||||
|
||||
void ActivityWidget::storeActivityList(QTextStream &ts)
|
||||
{
|
||||
ActivityList activities = _model->activityList();
|
||||
|
||||
foreach (Activity activity, activities) {
|
||||
ts << right
|
||||
// account name
|
||||
<< qSetFieldWidth(activity._accName.length())
|
||||
<< activity._accName
|
||||
// separator
|
||||
<< qSetFieldWidth(2) << " - "
|
||||
|
||||
// date and time
|
||||
<< qSetFieldWidth(activity._dateTime.toString().length())
|
||||
<< activity._dateTime.toString()
|
||||
// separator
|
||||
<< qSetFieldWidth(2) << " - "
|
||||
|
||||
// fileq
|
||||
<< qSetFieldWidth(activity._file.length())
|
||||
<< activity._file
|
||||
// separator
|
||||
<< qSetFieldWidth(2) << " - "
|
||||
|
||||
// subject
|
||||
<< qSetFieldWidth(activity._subject.length())
|
||||
<< activity._subject
|
||||
// separator
|
||||
<< qSetFieldWidth(2) << " - "
|
||||
|
||||
// message
|
||||
<< qSetFieldWidth(activity._message.length())
|
||||
<< activity._message
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::checkActivityWidgetVisibility()
|
||||
{
|
||||
int accountCount = AccountManager::instance()->accounts().count();
|
||||
bool hasAccountsWithActivity =
|
||||
_accountsWithoutActivities.count() != accountCount;
|
||||
|
||||
_ui->_activityList->setVisible(hasAccountsWithActivity);
|
||||
|
||||
emit hideActivityTab(!hasAccountsWithActivity);
|
||||
}
|
||||
|
||||
void ActivityWidget::slotOpenFile(QModelIndex indx)
|
||||
{
|
||||
qCDebug(lcActivity) << indx.isValid() << indx.data(ActivityItemDelegate::PathRole).toString() << QFile::exists(indx.data(ActivityItemDelegate::PathRole).toString());
|
||||
if (indx.isValid()) {
|
||||
QString fullPath = indx.data(ActivityItemDelegate::PathRole).toString();
|
||||
if(!fullPath.isEmpty()){
|
||||
if (QFile::exists(fullPath)) {
|
||||
showInFileManager(fullPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GUI: Display the notifications.
|
||||
// All notifications in list are coming from the same account
|
||||
// but in the _widgetForNotifId hash widgets for all accounts are
|
||||
// collected.
|
||||
void ActivityWidget::slotBuildNotificationDisplay(const ActivityList &list)
|
||||
{
|
||||
// Whether a new notification was added to the list
|
||||
bool newNotificationShown = false;
|
||||
|
||||
_model->clearNotifications();
|
||||
|
||||
foreach (auto activity, list) {
|
||||
if (_blacklistedNotifications.contains(activity)) {
|
||||
qCInfo(lcActivity) << "Activity in blacklist, skip";
|
||||
continue;
|
||||
}
|
||||
|
||||
// handle gui logs. In order to NOT annoy the user with every fetching of the
|
||||
// notifications the notification id is stored in a Set. Only if an id
|
||||
// is not in the set, it qualifies for guiLog.
|
||||
// Important: The _guiLoggedNotifications set must be wiped regularly which
|
||||
// will repeat the gui log.
|
||||
|
||||
// after one hour, clear the gui log notification store
|
||||
if (_guiLogTimer.elapsed() > 60 * 60 * 1000) {
|
||||
_guiLoggedNotifications.clear();
|
||||
}
|
||||
|
||||
if (!_guiLoggedNotifications.contains(activity._id)) {
|
||||
newNotificationShown = true;
|
||||
_guiLoggedNotifications.insert(activity._id);
|
||||
|
||||
// Assemble a tray notification for the NEW notification
|
||||
ConfigFile cfg;
|
||||
if(cfg.optionalServerNotifications()){
|
||||
if(AccountManager::instance()->accounts().count() == 1){
|
||||
emit guiLog(activity._subject, "");
|
||||
} else {
|
||||
emit guiLog(activity._subject, activity._accName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_model->addNotificationToActivityList(activity);
|
||||
}
|
||||
|
||||
// restart the gui log timer now that we show a new notification
|
||||
if(newNotificationShown) {
|
||||
_guiLogTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::slotSendNotificationRequest(const QString &accountName, const QString &link, const QByteArray &verb, int row)
|
||||
{
|
||||
qCInfo(lcActivity) << "Server Notification Request " << verb << link << "on account" << accountName;
|
||||
|
||||
const QStringList validVerbs = QStringList() << "GET"
|
||||
<< "PUT"
|
||||
<< "POST"
|
||||
<< "DELETE";
|
||||
|
||||
if (validVerbs.contains(verb)) {
|
||||
AccountStatePtr acc = AccountManager::instance()->account(accountName);
|
||||
if (acc) {
|
||||
NotificationConfirmJob *job = new NotificationConfirmJob(acc->account());
|
||||
QUrl l(link);
|
||||
job->setLinkAndVerb(l, verb);
|
||||
job->setProperty("activityRow", QVariant::fromValue(row));
|
||||
connect(job, &AbstractNetworkJob::networkError,
|
||||
this, &ActivityWidget::slotNotifyNetworkError);
|
||||
connect(job, &NotificationConfirmJob::jobFinished,
|
||||
this, &ActivityWidget::slotNotifyServerFinished);
|
||||
job->start();
|
||||
|
||||
// count the number of running notification requests. If this member var
|
||||
// is larger than zero, no new fetching of notifications is started
|
||||
_notificationRequestsRunning++;
|
||||
}
|
||||
} else {
|
||||
qCWarning(lcActivity) << "Notification Links: Invalid verb:" << verb;
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::endNotificationRequest(int replyCode)
|
||||
{
|
||||
_notificationRequestsRunning--;
|
||||
slotNotificationRequestFinished(replyCode);
|
||||
}
|
||||
|
||||
void ActivityWidget::slotNotifyNetworkError(QNetworkReply *reply)
|
||||
{
|
||||
NotificationConfirmJob *job = qobject_cast<NotificationConfirmJob *>(sender());
|
||||
if (!job) {
|
||||
return;
|
||||
}
|
||||
|
||||
int resultCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
|
||||
endNotificationRequest(resultCode);
|
||||
qCWarning(lcActivity) << "Server notify job failed with code " << resultCode;
|
||||
}
|
||||
|
||||
void ActivityWidget::slotNotifyServerFinished(const QString &reply, int replyCode)
|
||||
{
|
||||
NotificationConfirmJob *job = qobject_cast<NotificationConfirmJob *>(sender());
|
||||
if (!job) {
|
||||
return;
|
||||
}
|
||||
|
||||
endNotificationRequest(replyCode);
|
||||
qCInfo(lcActivity) << "Server Notification reply code" << replyCode << reply;
|
||||
}
|
||||
|
||||
/* ==================================================================== */
|
||||
|
||||
ActivitySettings::ActivitySettings(AccountState *accountState, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, _accountState(accountState)
|
||||
{
|
||||
_vbox = new QVBoxLayout(this);
|
||||
setLayout(_vbox);
|
||||
|
||||
_activityWidget = new ActivityWidget(_accountState, this);
|
||||
|
||||
_vbox->insertWidget(1, _activityWidget);
|
||||
connect(_activityWidget, &ActivityWidget::guiLog, this, &ActivitySettings::guiLog);
|
||||
connect(&_notificationCheckTimer, &QTimer::timeout,
|
||||
this, &ActivitySettings::slotRegularNotificationCheck);
|
||||
|
||||
// Add a progress indicator to spin if the acitivity list is updated.
|
||||
_progressIndicator = new QProgressIndicator(this);
|
||||
|
||||
// connect a model signal to stop the animation
|
||||
connect(_activityWidget, &ActivityWidget::rowsInserted, _progressIndicator, &QProgressIndicator::stopAnimation);
|
||||
connect(_activityWidget, &ActivityWidget::rowsInserted, this, &ActivitySettings::slotDisplayActivities);
|
||||
}
|
||||
|
||||
void ActivitySettings::slotDisplayActivities(){
|
||||
_vbox->removeWidget(_progressIndicator);
|
||||
}
|
||||
|
||||
void ActivitySettings::setNotificationRefreshInterval(std::chrono::milliseconds interval)
|
||||
{
|
||||
qCDebug(lcActivity) << "Starting Notification refresh timer with " << interval.count() / 1000 << " sec interval";
|
||||
_notificationCheckTimer.start(interval.count());
|
||||
}
|
||||
|
||||
void ActivitySettings::slotRemoveAccount()
|
||||
{
|
||||
_activityWidget->slotRemoveAccount();
|
||||
}
|
||||
|
||||
void ActivitySettings::slotRefresh()
|
||||
{
|
||||
// QElapsedTimer isn't actually constructed as invalid.
|
||||
if (!_timeSinceLastCheck.contains(_accountState)) {
|
||||
_timeSinceLastCheck[_accountState].invalidate();
|
||||
}
|
||||
QElapsedTimer &timer = _timeSinceLastCheck[_accountState];
|
||||
|
||||
// Fetch Activities only if visible and if last check is longer than 15 secs ago
|
||||
if (timer.isValid() && timer.elapsed() < NOTIFICATION_REQUEST_FREE_PERIOD) {
|
||||
qCDebug(lcActivity) << "Do not check as last check is only secs ago: " << timer.elapsed() / 1000;
|
||||
return;
|
||||
}
|
||||
if (_accountState && _accountState->isConnected()) {
|
||||
if (isVisible() || !timer.isValid()) {
|
||||
_vbox->insertWidget(0, _progressIndicator);
|
||||
_vbox->setAlignment(_progressIndicator, Qt::AlignHCenter);
|
||||
_progressIndicator->startAnimation();
|
||||
_activityWidget->slotRefreshActivities();
|
||||
}
|
||||
_activityWidget->slotRefreshNotifications();
|
||||
timer.start();
|
||||
}
|
||||
}
|
||||
|
||||
void ActivitySettings::slotRegularNotificationCheck()
|
||||
{
|
||||
slotRefresh();
|
||||
}
|
||||
|
||||
bool ActivitySettings::event(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::Show) {
|
||||
slotRefresh();
|
||||
}
|
||||
return QWidget::event(e);
|
||||
}
|
||||
|
||||
ActivitySettings::~ActivitySettings()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef ACTIVITYWIDGET_H
|
||||
#define ACTIVITYWIDGET_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDateTime>
|
||||
#include <QLocale>
|
||||
#include <QAbstractListModel>
|
||||
#include <chrono>
|
||||
|
||||
#include "progressdispatcher.h"
|
||||
#include "owncloudgui.h"
|
||||
#include "account.h"
|
||||
#include "activitydata.h"
|
||||
#include "accountmanager.h"
|
||||
|
||||
#include "ui_activitywidget.h"
|
||||
|
||||
class QPushButton;
|
||||
class QProgressIndicator;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class Account;
|
||||
class AccountStatusPtr;
|
||||
class JsonApiJob;
|
||||
class ActivityListModel;
|
||||
|
||||
namespace Ui {
|
||||
class ActivityWidget;
|
||||
}
|
||||
class Application;
|
||||
|
||||
/**
|
||||
* @brief The ActivityWidget class
|
||||
* @ingroup gui
|
||||
*
|
||||
* The list widget to display the activities, contained in the
|
||||
* subsequent ActivitySettings widget.
|
||||
*/
|
||||
|
||||
class ActivityWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ActivityWidget(AccountState *accountState, QWidget *parent = nullptr);
|
||||
~ActivityWidget();
|
||||
QSize sizeHint() const override { return ownCloudGui::settingsDialogSize(); }
|
||||
void storeActivityList(QTextStream &ts);
|
||||
|
||||
/**
|
||||
* Adjusts the activity tab's and some widgets' visibility
|
||||
*
|
||||
* Based on whether activities are enabled and whether notifications are
|
||||
* available.
|
||||
*/
|
||||
void checkActivityWidgetVisibility();
|
||||
|
||||
public slots:
|
||||
void slotOpenFile(QModelIndex indx);
|
||||
void slotRefreshActivities();
|
||||
void slotRefreshNotifications();
|
||||
void slotRemoveAccount();
|
||||
void slotAccountActivityStatus(int statusCode);
|
||||
void addError(const QString &folderAlias, const QString &message, ErrorCategory category);
|
||||
void slotProgressInfo(const QString &folder, const ProgressInfo &progress);
|
||||
void slotItemCompleted(const QString &folder, const SyncFileItemPtr &item);
|
||||
|
||||
signals:
|
||||
void guiLog(const QString &, const QString &);
|
||||
void rowsInserted();
|
||||
void hideActivityTab(bool);
|
||||
void sendNotificationRequest(const QString &accountName, const QString &link, const QByteArray &verb, int row);
|
||||
|
||||
private slots:
|
||||
void slotBuildNotificationDisplay(const ActivityList &list);
|
||||
void slotSendNotificationRequest(const QString &accountName, const QString &link, const QByteArray &verb, int row);
|
||||
void slotNotifyNetworkError(QNetworkReply *);
|
||||
void slotNotifyServerFinished(const QString &reply, int replyCode);
|
||||
void endNotificationRequest(int replyCode);
|
||||
void slotNotificationRequestFinished(int statusCode);
|
||||
void slotPrimaryButtonClickedOnListView(const QModelIndex &index);
|
||||
void slotSecondaryButtonClickedOnListView(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
void showLabels();
|
||||
QString timeString(QDateTime dt, QLocale::FormatType format) const;
|
||||
Ui::ActivityWidget *_ui;
|
||||
QSet<QString> _accountsWithoutActivities;
|
||||
QElapsedTimer _guiLogTimer;
|
||||
QSet<int> _guiLoggedNotifications;
|
||||
ActivityList _blacklistedNotifications;
|
||||
|
||||
QTimer _removeTimer;
|
||||
|
||||
// number of currently running notification requests. If non zero,
|
||||
// no query for notifications is started.
|
||||
int _notificationRequestsRunning;
|
||||
|
||||
ActivityListModel *_model;
|
||||
AccountState *_accountState;
|
||||
const QString _accept;
|
||||
const QString _remote_share;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief The ActivitySettings class
|
||||
* @ingroup gui
|
||||
*
|
||||
* Implements a tab for the settings dialog, displaying the three activity
|
||||
* lists.
|
||||
*/
|
||||
class ActivitySettings : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ActivitySettings(AccountState *accountState, QWidget *parent = nullptr);
|
||||
|
||||
~ActivitySettings();
|
||||
QSize sizeHint() const override { return ownCloudGui::settingsDialogSize(); }
|
||||
|
||||
public slots:
|
||||
void slotRefresh();
|
||||
void slotRemoveAccount();
|
||||
void setNotificationRefreshInterval(std::chrono::milliseconds interval);
|
||||
|
||||
private slots:
|
||||
void slotRegularNotificationCheck();
|
||||
void slotDisplayActivities();
|
||||
|
||||
signals:
|
||||
void guiLog(const QString &, const QString &);
|
||||
|
||||
private:
|
||||
bool event(QEvent *e) override;
|
||||
|
||||
ActivityWidget *_activityWidget;
|
||||
QProgressIndicator *_progressIndicator;
|
||||
QVBoxLayout *_vbox;
|
||||
QTimer _notificationCheckTimer;
|
||||
QHash<AccountState *, QElapsedTimer> _timeSinceLastCheck;
|
||||
|
||||
AccountState *_accountState;
|
||||
};
|
||||
}
|
||||
#endif // ActivityWIDGET_H
|
||||
@@ -1,98 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OCC::ActivityWidget</class>
|
||||
<widget class="QWidget" name="OCC::ActivityWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>652</width>
|
||||
<height>556</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QListView" name="_activityList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="defaultDropAction">
|
||||
<enum>Qt::IgnoreAction</enum>
|
||||
</property>
|
||||
<property name="resizeMode">
|
||||
<enum>QListView::Adjust</enum>
|
||||
</property>
|
||||
<property name="viewMode">
|
||||
<enum>QListView::ListMode</enum>
|
||||
</property>
|
||||
<property name="modelColumn">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="_bottomLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>_activityList</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -52,6 +52,7 @@
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QGuiApplication>
|
||||
|
||||
class QSocket;
|
||||
|
||||
@@ -108,7 +109,6 @@ Application::Application(int &argc, char **argv)
|
||||
, _userTriggeredConnect(false)
|
||||
, _debugMode(false)
|
||||
, _backgroundMode(false)
|
||||
, _isQuitting(false)
|
||||
{
|
||||
_startedAt.start();
|
||||
|
||||
@@ -123,6 +123,15 @@ Application::Application(int &argc, char **argv)
|
||||
// TODO: Can't set this without breaking current config paths
|
||||
// setOrganizationName(QLatin1String(APPLICATION_VENDOR));
|
||||
setOrganizationDomain(QLatin1String(APPLICATION_REV_DOMAIN));
|
||||
|
||||
// setDesktopFilename to provide wayland compatibility (in general: conformance with naming standards)
|
||||
// but only on Qt >= 5.7, where setDesktopFilename was introduced
|
||||
#if (QT_VERSION >= 0x050700)
|
||||
QString desktopFileName = QString(QLatin1String(LINUX_APPLICATION_ID)
|
||||
+ QLatin1String(".desktop"));
|
||||
setDesktopFileName(desktopFileName);
|
||||
#endif
|
||||
|
||||
setApplicationName(_theme->appName());
|
||||
setWindowIcon(_theme->applicationIcon());
|
||||
setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
||||
@@ -254,6 +263,11 @@ Application::Application(int &argc, char **argv)
|
||||
|
||||
// Cleanup at Quit.
|
||||
connect(this, &QCoreApplication::aboutToQuit, this, &Application::slotCleanup);
|
||||
|
||||
// Allow other classes to hook into isShowingSettingsDialog() signals (re-auth widgets, for example)
|
||||
connect(_gui.data(), &ownCloudGui::isShowingSettingsDialog, this, &Application::slotGuiIsShowingSettings);
|
||||
|
||||
_gui->createTray();
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
@@ -286,7 +300,7 @@ void Application::slotAccountStateRemoved(AccountState *accountState)
|
||||
}
|
||||
|
||||
// if there is no more account, show the wizard.
|
||||
if (!_isQuitting && AccountManager::instance()->accounts().isEmpty()) {
|
||||
if (AccountManager::instance()->accounts().isEmpty()) {
|
||||
// allow to add a new account if there is non any more. Always think
|
||||
// about single account theming!
|
||||
OwncloudSetupWizard::runWizard(this, SLOT(slotownCloudWizardDone(int)));
|
||||
@@ -309,8 +323,6 @@ void Application::slotAccountStateAdded(AccountState *accountState)
|
||||
|
||||
void Application::slotCleanup()
|
||||
{
|
||||
_isQuitting = true;
|
||||
|
||||
AccountManager::instance()->save();
|
||||
FolderMan::instance()->unloadAndDeleteAllFolders();
|
||||
|
||||
@@ -380,7 +392,7 @@ void Application::slotownCloudWizardDone(int res)
|
||||
Utility::setLaunchOnStartup(_theme->appName(), _theme->appNameGUI(), true);
|
||||
}
|
||||
|
||||
_gui->slotShowSettings();
|
||||
Systray::instance()->showWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -648,5 +660,9 @@ void Application::showSettingsDialog()
|
||||
_gui->slotShowSettings();
|
||||
}
|
||||
|
||||
void Application::slotGuiIsShowingSettings()
|
||||
{
|
||||
emit isShowingSettingsDialog();
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
@@ -82,6 +82,7 @@ protected:
|
||||
signals:
|
||||
void folderRemoved();
|
||||
void folderStateChanged(Folder *);
|
||||
void isShowingSettingsDialog();
|
||||
|
||||
protected slots:
|
||||
void slotParseMessage(const QString &, QObject *);
|
||||
@@ -91,6 +92,7 @@ protected slots:
|
||||
void slotAccountStateAdded(AccountState *accountState);
|
||||
void slotAccountStateRemoved(AccountState *accountState);
|
||||
void slotSystemOnlineConfigurationChanged(QNetworkConfiguration);
|
||||
void slotGuiIsShowingSettings();
|
||||
|
||||
private:
|
||||
void setHelp();
|
||||
@@ -114,7 +116,6 @@ private:
|
||||
bool _userTriggeredConnect;
|
||||
bool _debugMode;
|
||||
bool _backgroundMode;
|
||||
bool _isQuitting;
|
||||
|
||||
ClientProxy _proxy;
|
||||
|
||||
|
||||
@@ -249,6 +249,11 @@ void ConnectionValidator::slotCapabilitiesRecieved(const QJsonDocument &json)
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for the directEditing capability
|
||||
QUrl directEditingURL = QUrl(caps["files"].toObject()["directEditing"].toObject()["url"].toString());
|
||||
QString directEditingETag = caps["files"].toObject()["directEditing"].toObject()["etag"].toString();
|
||||
_account->fetchDirectEditors(directEditingURL, directEditingETag);
|
||||
|
||||
fetchUser();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,12 @@
|
||||
*/
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QTimer>
|
||||
#include <QBuffer>
|
||||
#include "account.h"
|
||||
#include "creds/flow2auth.h"
|
||||
#include "flow2auth.h"
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include "theme.h"
|
||||
@@ -28,6 +30,17 @@ namespace OCC {
|
||||
|
||||
Q_LOGGING_CATEGORY(lcFlow2auth, "nextcloud.sync.credentials.flow2auth", QtInfoMsg)
|
||||
|
||||
|
||||
Flow2Auth::Flow2Auth(Account *account, QObject *parent)
|
||||
: QObject(parent)
|
||||
, _account(account)
|
||||
, _isBusy(false)
|
||||
, _hasToken(false)
|
||||
{
|
||||
_pollTimer.setInterval(1000);
|
||||
QObject::connect(&_pollTimer, &QTimer::timeout, this, &Flow2Auth::slotPollTimerTimeout);
|
||||
}
|
||||
|
||||
Flow2Auth::~Flow2Auth()
|
||||
{
|
||||
}
|
||||
@@ -47,7 +60,23 @@ QUrl Flow2Auth::authorisationLink() const
|
||||
|
||||
void Flow2Auth::openBrowser()
|
||||
{
|
||||
_pollTimer.stop();
|
||||
fetchNewToken(TokenAction::actionOpenBrowser);
|
||||
}
|
||||
|
||||
void Flow2Auth::copyLinkToClipboard()
|
||||
{
|
||||
fetchNewToken(TokenAction::actionCopyLinkToClipboard);
|
||||
}
|
||||
|
||||
void Flow2Auth::fetchNewToken(const TokenAction action)
|
||||
{
|
||||
if(_isBusy)
|
||||
return;
|
||||
|
||||
_isBusy = true;
|
||||
_hasToken = false;
|
||||
|
||||
emit statusChanged(PollStatus::statusFetchToken, 0);
|
||||
|
||||
// Step 1: Initiate a login, do an anonymous POST request
|
||||
QUrl url = Utility::concatUrlPath(_account->url().toString(), QLatin1String("/index.php/login/v2"));
|
||||
@@ -59,14 +88,18 @@ void Flow2Auth::openBrowser()
|
||||
auto job = _account->sendRequest("POST", url, req);
|
||||
job->setTimeout(qMin(30 * 1000ll, job->timeoutMsec()));
|
||||
|
||||
QObject::connect(job, &SimpleNetworkJob::finishedSignal, this, [this](QNetworkReply *reply) {
|
||||
QObject::connect(job, &SimpleNetworkJob::finishedSignal, this, [this, action](QNetworkReply *reply) {
|
||||
auto jsonData = reply->readAll();
|
||||
QJsonParseError jsonParseError;
|
||||
QJsonObject json = QJsonDocument::fromJson(jsonData, &jsonParseError).object();
|
||||
QString pollToken, pollEndpoint, loginUrl;
|
||||
|
||||
QString pollToken = json.value("poll").toObject().value("token").toString();
|
||||
QString pollEndpoint = json.value("poll").toObject().value("endpoint").toString();
|
||||
QUrl loginUrl = json["login"].toString();
|
||||
if (reply->error() == QNetworkReply::NoError && jsonParseError.error == QJsonParseError::NoError
|
||||
&& !json.isEmpty()) {
|
||||
pollToken = json.value("poll").toObject().value("token").toString();
|
||||
pollEndpoint = json.value("poll").toObject().value("endpoint").toString();
|
||||
loginUrl = json["login"].toString();
|
||||
}
|
||||
|
||||
if (reply->error() != QNetworkReply::NoError || jsonParseError.error != QJsonParseError::NoError
|
||||
|| json.isEmpty() || pollToken.isEmpty() || pollEndpoint.isEmpty() || loginUrl.isEmpty()) {
|
||||
@@ -85,7 +118,9 @@ void Flow2Auth::openBrowser()
|
||||
errorReason = tr("The reply from the server did not contain all expected fields");
|
||||
}
|
||||
qCWarning(lcFlow2auth) << "Error when getting the loginUrl" << json << errorReason;
|
||||
emit result(Error);
|
||||
emit result(Error, errorReason);
|
||||
_pollTimer.stop();
|
||||
_isBusy = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,23 +134,50 @@ void Flow2Auth::openBrowser()
|
||||
ConfigFile cfg;
|
||||
std::chrono::milliseconds polltime = cfg.remotePollInterval();
|
||||
qCInfo(lcFlow2auth) << "setting remote poll timer interval to" << polltime.count() << "msec";
|
||||
_pollTimer.setInterval(polltime.count());
|
||||
QObject::connect(&_pollTimer, &QTimer::timeout, this, &Flow2Auth::slotPollTimerTimeout);
|
||||
_pollTimer.start();
|
||||
_secondsInterval = (polltime.count() / 1000);
|
||||
_secondsLeft = _secondsInterval;
|
||||
emit statusChanged(PollStatus::statusPollCountdown, _secondsLeft);
|
||||
|
||||
|
||||
// Try to open Browser
|
||||
if (!QDesktopServices::openUrl(authorisationLink())) {
|
||||
// We cannot open the browser, then we claim we don't support Flow2Auth.
|
||||
// Our UI callee should ask the user to copy and open the link.
|
||||
emit result(NotSupported, QString());
|
||||
if(!_pollTimer.isActive()) {
|
||||
_pollTimer.start();
|
||||
}
|
||||
|
||||
|
||||
switch(action)
|
||||
{
|
||||
case actionOpenBrowser:
|
||||
// Try to open Browser
|
||||
if (!QDesktopServices::openUrl(authorisationLink())) {
|
||||
// We cannot open the browser, then we claim we don't support Flow2Auth.
|
||||
// Our UI callee will ask the user to copy and open the link.
|
||||
emit result(NotSupported);
|
||||
}
|
||||
break;
|
||||
case actionCopyLinkToClipboard:
|
||||
QApplication::clipboard()->setText(authorisationLink().toString(QUrl::FullyEncoded));
|
||||
emit statusChanged(PollStatus::statusCopyLinkToClipboard, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
_isBusy = false;
|
||||
_hasToken = true;
|
||||
});
|
||||
}
|
||||
|
||||
void Flow2Auth::slotPollTimerTimeout()
|
||||
{
|
||||
_pollTimer.stop();
|
||||
if(_isBusy || !_hasToken)
|
||||
return;
|
||||
|
||||
_isBusy = true;
|
||||
|
||||
_secondsLeft--;
|
||||
if(_secondsLeft > 0) {
|
||||
emit statusChanged(PollStatus::statusPollCountdown, _secondsLeft);
|
||||
_isBusy = false;
|
||||
return;
|
||||
}
|
||||
emit statusChanged(PollStatus::statusPollNow, 0);
|
||||
|
||||
// Step 2: Poll
|
||||
QNetworkRequest req;
|
||||
@@ -132,10 +194,15 @@ void Flow2Auth::slotPollTimerTimeout()
|
||||
auto jsonData = reply->readAll();
|
||||
QJsonParseError jsonParseError;
|
||||
QJsonObject json = QJsonDocument::fromJson(jsonData, &jsonParseError).object();
|
||||
QUrl serverUrl;
|
||||
QString loginName, appPassword;
|
||||
|
||||
QUrl serverUrl = json["server"].toString();
|
||||
QString loginName = json["loginName"].toString();
|
||||
QString appPassword = json["appPassword"].toString();
|
||||
if (reply->error() == QNetworkReply::NoError && jsonParseError.error == QJsonParseError::NoError
|
||||
&& !json.isEmpty()) {
|
||||
serverUrl = json["server"].toString();
|
||||
loginName = json["loginName"].toString();
|
||||
appPassword = json["appPassword"].toString();
|
||||
}
|
||||
|
||||
if (reply->error() != QNetworkReply::NoError || jsonParseError.error != QJsonParseError::NoError
|
||||
|| json.isEmpty() || serverUrl.isEmpty() || loginName.isEmpty() || appPassword.isEmpty()) {
|
||||
@@ -155,26 +222,50 @@ void Flow2Auth::slotPollTimerTimeout()
|
||||
}
|
||||
qCDebug(lcFlow2auth) << "Error when polling for the appPassword" << json << errorReason;
|
||||
|
||||
// We get a 404 until authentication is done, so don't show this error in the GUI.
|
||||
if(reply->error() != QNetworkReply::ContentNotFoundError)
|
||||
emit result(Error, errorReason);
|
||||
|
||||
// Forget sensitive data
|
||||
appPassword.clear();
|
||||
loginName.clear();
|
||||
|
||||
// Failed: poll again
|
||||
_pollTimer.start();
|
||||
_secondsLeft = _secondsInterval;
|
||||
_isBusy = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_pollTimer.stop();
|
||||
|
||||
// Success
|
||||
qCInfo(lcFlow2auth) << "Success getting the appPassword for user: " << loginName << ", server: " << serverUrl.toString();
|
||||
|
||||
_account->setUrl(serverUrl);
|
||||
|
||||
emit result(LoggedIn, loginName, appPassword);
|
||||
emit result(LoggedIn, QString(), loginName, appPassword);
|
||||
|
||||
// Forget sensitive data
|
||||
appPassword.clear();
|
||||
loginName.clear();
|
||||
|
||||
_loginUrl.clear();
|
||||
_pollToken.clear();
|
||||
_pollEndpoint.clear();
|
||||
|
||||
_isBusy = false;
|
||||
_hasToken = false;
|
||||
});
|
||||
}
|
||||
|
||||
void Flow2Auth::slotPollNow()
|
||||
{
|
||||
// poll now if we're not already doing so
|
||||
if(_isBusy || !_hasToken)
|
||||
return;
|
||||
|
||||
_secondsLeft = 1;
|
||||
slotPollTimerTimeout();
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
@@ -25,17 +25,23 @@ namespace OCC {
|
||||
* Job that does the authorization, grants and fetches the access token via Login Flow v2
|
||||
*
|
||||
* See: https://docs.nextcloud.com/server/latest/developer_manual/client_apis/LoginFlow/index.html#login-flow-v2
|
||||
*
|
||||
*/
|
||||
class Flow2Auth : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Flow2Auth(Account *account, QObject *parent)
|
||||
: QObject(parent)
|
||||
, _account(account)
|
||||
{
|
||||
}
|
||||
enum TokenAction {
|
||||
actionOpenBrowser = 1,
|
||||
actionCopyLinkToClipboard
|
||||
};
|
||||
enum PollStatus {
|
||||
statusPollCountdown = 1,
|
||||
statusPollNow,
|
||||
statusFetchToken,
|
||||
statusCopyLinkToClipboard
|
||||
};
|
||||
|
||||
Flow2Auth(Account *account, QObject *parent);
|
||||
~Flow2Auth();
|
||||
|
||||
enum Result { NotSupported,
|
||||
@@ -44,6 +50,7 @@ public:
|
||||
Q_ENUM(Result);
|
||||
void start();
|
||||
void openBrowser();
|
||||
void copyLinkToClipboard();
|
||||
QUrl authorisationLink() const;
|
||||
|
||||
signals:
|
||||
@@ -51,18 +58,29 @@ signals:
|
||||
* The state has changed.
|
||||
* when logged in, appPassword has the value of the app password.
|
||||
*/
|
||||
void result(Flow2Auth::Result result, const QString &user = QString(), const QString &appPassword = QString());
|
||||
void result(Flow2Auth::Result result, const QString &errorString = QString(),
|
||||
const QString &user = QString(), const QString &appPassword = QString());
|
||||
|
||||
void statusChanged(const PollStatus status, int secondsLeft);
|
||||
|
||||
public slots:
|
||||
void slotPollNow();
|
||||
|
||||
private slots:
|
||||
void slotPollTimerTimeout();
|
||||
|
||||
private:
|
||||
void fetchNewToken(const TokenAction action);
|
||||
|
||||
Account *_account;
|
||||
QUrl _loginUrl;
|
||||
QString _pollToken;
|
||||
QString _pollEndpoint;
|
||||
QTimer _pollTimer;
|
||||
int _secondsLeft;
|
||||
int _secondsInterval;
|
||||
bool _isBusy;
|
||||
bool _hasToken;
|
||||
};
|
||||
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
221
src/gui/creds/keychainchunk.cpp
Normal file
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* Copyright (C) by Michael Schuster <michael@nextcloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "account.h"
|
||||
#include "keychainchunk.h"
|
||||
#include "theme.h"
|
||||
#include "networkjobs.h"
|
||||
#include "configfile.h"
|
||||
#include "creds/abstractcredentials.h"
|
||||
|
||||
using namespace QKeychain;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
Q_LOGGING_CATEGORY(lcKeychainChunk, "nextcloud.sync.credentials.keychainchunk", QtInfoMsg)
|
||||
|
||||
namespace KeychainChunk {
|
||||
|
||||
#if defined(KEYCHAINCHUNK_ENABLE_INSECURE_FALLBACK)
|
||||
static void addSettingsToJob(Account *account, QKeychain::Job *job)
|
||||
{
|
||||
Q_UNUSED(account)
|
||||
auto settings = ConfigFile::settingsWithGroup(Theme::instance()->appName());
|
||||
settings->setParent(job); // make the job parent to make setting deleted properly
|
||||
job->setSettings(settings.release());
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Job
|
||||
*/
|
||||
Job::Job(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
_serviceName = Theme::instance()->appName();
|
||||
}
|
||||
|
||||
/*
|
||||
* WriteJob
|
||||
*/
|
||||
WriteJob::WriteJob(Account *account, const QString &key, const QByteArray &data, QObject *parent)
|
||||
: Job(parent)
|
||||
{
|
||||
_account = account;
|
||||
_key = key;
|
||||
|
||||
// Windows workaround: Split the private key into chunks of 2048 bytes,
|
||||
// to allow 4k (4096 bit) keys to be saved (obey Windows's limits)
|
||||
_chunkBuffer = data;
|
||||
_chunkCount = 0;
|
||||
}
|
||||
|
||||
void WriteJob::start()
|
||||
{
|
||||
slotWriteJobDone(nullptr);
|
||||
}
|
||||
|
||||
void WriteJob::slotWriteJobDone(QKeychain::Job *incomingJob)
|
||||
{
|
||||
QKeychain::WritePasswordJob *writeJob = static_cast<QKeychain::WritePasswordJob *>(incomingJob);
|
||||
|
||||
// errors?
|
||||
if (writeJob) {
|
||||
_error = writeJob->error();
|
||||
_errorString = writeJob->errorString();
|
||||
|
||||
if (writeJob->error() != NoError) {
|
||||
qCWarning(lcKeychainChunk) << "Error while writing" << writeJob->key() << "chunk" << writeJob->errorString();
|
||||
_chunkBuffer.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// write a chunk if there is any in the buffer
|
||||
if (!_chunkBuffer.isEmpty()) {
|
||||
#if defined(Q_OS_WIN)
|
||||
// Windows workaround: Split the data into chunks of 2048 bytes,
|
||||
// to allow 4k (4096 bit) keys to be saved (obey Windows's limits)
|
||||
auto chunk = _chunkBuffer.left(KeychainChunk::ChunkSize);
|
||||
|
||||
_chunkBuffer = _chunkBuffer.right(_chunkBuffer.size() - chunk.size());
|
||||
#else
|
||||
// write full data in one chunk on non-Windows, as usual
|
||||
auto chunk = _chunkBuffer;
|
||||
|
||||
_chunkBuffer.clear();
|
||||
#endif
|
||||
auto index = (_chunkCount++);
|
||||
|
||||
// keep the limit
|
||||
if (_chunkCount > KeychainChunk::MaxChunks) {
|
||||
qCWarning(lcKeychainChunk) << "Maximum chunk count exceeded while writing" << writeJob->key() << "chunk" << QString::number(index) << "cutting off after" << QString::number(KeychainChunk::MaxChunks) << "chunks";
|
||||
|
||||
writeJob->deleteLater();
|
||||
|
||||
_chunkBuffer.clear();
|
||||
|
||||
emit finished(this);
|
||||
return;
|
||||
}
|
||||
|
||||
const QString kck = AbstractCredentials::keychainKey(
|
||||
_account->url().toString(),
|
||||
_key + (index > 0 ? (QString(".") + QString::number(index)) : QString()),
|
||||
_account->id());
|
||||
|
||||
QKeychain::WritePasswordJob *job = new QKeychain::WritePasswordJob(_serviceName);
|
||||
#if defined(KEYCHAINCHUNK_ENABLE_INSECURE_FALLBACK)
|
||||
addSettingsToJob(_account, job);
|
||||
#endif
|
||||
job->setInsecureFallback(_insecureFallback);
|
||||
connect(job, &QKeychain::Job::finished, this, &KeychainChunk::WriteJob::slotWriteJobDone);
|
||||
// only add the key's (sub)"index" after the first element, to stay compatible with older versions and non-Windows
|
||||
job->setKey(kck);
|
||||
job->setBinaryData(chunk);
|
||||
job->start();
|
||||
|
||||
chunk.clear();
|
||||
} else {
|
||||
emit finished(this);
|
||||
}
|
||||
|
||||
writeJob->deleteLater();
|
||||
}
|
||||
|
||||
/*
|
||||
* ReadJob
|
||||
*/
|
||||
ReadJob::ReadJob(Account *account, const QString &key, const bool &keychainMigration, QObject *parent)
|
||||
: Job(parent)
|
||||
{
|
||||
_account = account;
|
||||
_key = key;
|
||||
|
||||
_keychainMigration = keychainMigration;
|
||||
|
||||
_chunkCount = 0;
|
||||
_chunkBuffer.clear();
|
||||
}
|
||||
|
||||
void ReadJob::start()
|
||||
{
|
||||
_chunkCount = 0;
|
||||
_chunkBuffer.clear();
|
||||
|
||||
const QString kck = AbstractCredentials::keychainKey(
|
||||
_account->url().toString(),
|
||||
_key,
|
||||
_keychainMigration ? QString() : _account->id());
|
||||
|
||||
QKeychain::ReadPasswordJob *job = new QKeychain::ReadPasswordJob(_serviceName);
|
||||
#if defined(KEYCHAINCHUNK_ENABLE_INSECURE_FALLBACK)
|
||||
addSettingsToJob(_account, job);
|
||||
#endif
|
||||
job->setInsecureFallback(_insecureFallback);
|
||||
job->setKey(kck);
|
||||
connect(job, &QKeychain::Job::finished, this, &KeychainChunk::ReadJob::slotReadJobDone);
|
||||
job->start();
|
||||
}
|
||||
|
||||
void ReadJob::slotReadJobDone(QKeychain::Job *incomingJob)
|
||||
{
|
||||
// Errors or next chunk?
|
||||
QKeychain::ReadPasswordJob *readJob = static_cast<QKeychain::ReadPasswordJob *>(incomingJob);
|
||||
|
||||
if (readJob) {
|
||||
if (readJob->error() == NoError && readJob->binaryData().length() > 0) {
|
||||
_chunkBuffer.append(readJob->binaryData());
|
||||
_chunkCount++;
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
// try to fetch next chunk
|
||||
if (_chunkCount < KeychainChunk::MaxChunks) {
|
||||
const QString kck = AbstractCredentials::keychainKey(
|
||||
_account->url().toString(),
|
||||
_key + QString(".") + QString::number(_chunkCount),
|
||||
_keychainMigration ? QString() : _account->id());
|
||||
|
||||
QKeychain::ReadPasswordJob *job = new QKeychain::ReadPasswordJob(_serviceName);
|
||||
#if defined(KEYCHAINCHUNK_ENABLE_INSECURE_FALLBACK)
|
||||
addSettingsToJob(_account, job);
|
||||
#endif
|
||||
job->setInsecureFallback(_insecureFallback);
|
||||
job->setKey(kck);
|
||||
connect(job, &QKeychain::Job::finished, this, &KeychainChunk::ReadJob::slotReadJobDone);
|
||||
job->start();
|
||||
|
||||
readJob->deleteLater();
|
||||
return;
|
||||
} else {
|
||||
qCWarning(lcKeychainChunk) << "Maximum chunk count for" << readJob->key() << "reached, ignoring after" << KeychainChunk::MaxChunks;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (readJob->error() != QKeychain::Error::EntryNotFound ||
|
||||
((readJob->error() == QKeychain::Error::EntryNotFound) && _chunkCount == 0)) {
|
||||
_error = readJob->error();
|
||||
_errorString = readJob->errorString();
|
||||
qCWarning(lcKeychainChunk) << "Unable to read" << readJob->key() << "chunk" << QString::number(_chunkCount) << readJob->errorString();
|
||||
}
|
||||
}
|
||||
|
||||
readJob->deleteLater();
|
||||
}
|
||||
|
||||
emit finished(this);
|
||||
}
|
||||
|
||||
} // namespace KeychainChunk
|
||||
|
||||
} // namespace OCC
|
||||
120
src/gui/creds/keychainchunk.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (C) by Michael Schuster <michael@nextcloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef KEYCHAINCHUNK_H
|
||||
#define KEYCHAINCHUNK_H
|
||||
|
||||
#include <QObject>
|
||||
#include <keychain.h>
|
||||
#include "accountfwd.h"
|
||||
|
||||
// We don't support insecure fallback
|
||||
// #define KEYCHAINCHUNK_ENABLE_INSECURE_FALLBACK
|
||||
|
||||
namespace OCC {
|
||||
|
||||
namespace KeychainChunk {
|
||||
|
||||
/*
|
||||
* Workaround for Windows:
|
||||
*
|
||||
* Split the keychain entry's data into chunks of 2048 bytes,
|
||||
* to allow 4k (4096 bit) keys / large certs to be saved (see limits in webflowcredentials.h)
|
||||
*/
|
||||
static constexpr int ChunkSize = 2048;
|
||||
static constexpr int MaxChunks = 10;
|
||||
|
||||
/*
|
||||
* @brief: Abstract base class for KeychainChunk jobs.
|
||||
*/
|
||||
class Job : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Job(QObject *parent = nullptr);
|
||||
|
||||
const QKeychain::Error error() const {
|
||||
return _error;
|
||||
}
|
||||
const QString errorString() const {
|
||||
return _errorString;
|
||||
}
|
||||
|
||||
QByteArray binaryData() const {
|
||||
return _chunkBuffer;
|
||||
}
|
||||
|
||||
const bool insecureFallback() const {
|
||||
return _insecureFallback;
|
||||
}
|
||||
|
||||
// If we use it but don't support insecure fallback, give us nice compilation errors ;p
|
||||
#if defined(KEYCHAINCHUNK_ENABLE_INSECURE_FALLBACK)
|
||||
void setInsecureFallback(const bool &insecureFallback)
|
||||
{
|
||||
_insecureFallback = insecureFallback;
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
QString _serviceName;
|
||||
Account *_account;
|
||||
QString _key;
|
||||
bool _insecureFallback = false;
|
||||
bool _keychainMigration = false;
|
||||
|
||||
QKeychain::Error _error = QKeychain::NoError;
|
||||
QString _errorString;
|
||||
|
||||
int _chunkCount = 0;
|
||||
QByteArray _chunkBuffer;
|
||||
}; // class Job
|
||||
|
||||
/*
|
||||
* @brief: Simple wrapper class for QKeychain::WritePasswordJob, splits too large keychain entry's data into chunks on Windows
|
||||
*/
|
||||
class WriteJob : public KeychainChunk::Job {
|
||||
Q_OBJECT
|
||||
public:
|
||||
WriteJob(Account *account, const QString &key, const QByteArray &data, QObject *parent = nullptr);
|
||||
void start();
|
||||
|
||||
signals:
|
||||
void finished(KeychainChunk::WriteJob *incomingJob);
|
||||
|
||||
private slots:
|
||||
void slotWriteJobDone(QKeychain::Job *incomingJob);
|
||||
}; // class WriteJob
|
||||
|
||||
/*
|
||||
* @brief: Simple wrapper class for QKeychain::ReadPasswordJob, splits too large keychain entry's data into chunks on Windows
|
||||
*/
|
||||
class ReadJob : public KeychainChunk::Job {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ReadJob(Account *account, const QString &key, const bool &keychainMigration, QObject *parent = nullptr);
|
||||
void start();
|
||||
|
||||
signals:
|
||||
void finished(KeychainChunk::ReadJob *incomingJob);
|
||||
|
||||
private slots:
|
||||
void slotReadJobDone(QKeychain::Job *incomingJob);
|
||||
}; // class ReadJob
|
||||
|
||||
} // namespace KeychainChunk
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
#endif // KEYCHAINCHUNK_H
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "theme.h"
|
||||
#include "wizard/webview.h"
|
||||
#include "webflowcredentialsdialog.h"
|
||||
#include "keychainchunk.h"
|
||||
|
||||
using namespace QKeychain;
|
||||
|
||||
@@ -75,6 +76,7 @@ private:
|
||||
QPointer<const WebFlowCredentials> _cred;
|
||||
};
|
||||
|
||||
#if defined(KEYCHAINCHUNK_ENABLE_INSECURE_FALLBACK)
|
||||
static void addSettingsToJob(Account *account, QKeychain::Job *job)
|
||||
{
|
||||
Q_UNUSED(account)
|
||||
@@ -82,6 +84,7 @@ static void addSettingsToJob(Account *account, QKeychain::Job *job)
|
||||
settings->setParent(job); // make the job parent to make setting deleted properly
|
||||
job->setSettings(settings.release());
|
||||
}
|
||||
#endif
|
||||
|
||||
WebFlowCredentials::WebFlowCredentials()
|
||||
: _ready(false)
|
||||
@@ -170,6 +173,7 @@ void WebFlowCredentials::askFromUser() {
|
||||
_askDialog->show();
|
||||
|
||||
connect(_askDialog, &WebFlowCredentialsDialog::urlCatched, this, &WebFlowCredentials::slotAskFromUserCredentialsProvided);
|
||||
connect(_askDialog, &WebFlowCredentialsDialog::onClose, this, &WebFlowCredentials::slotAskFromUserCancelled);
|
||||
});
|
||||
job->start();
|
||||
|
||||
@@ -205,10 +209,18 @@ void WebFlowCredentials::slotAskFromUserCredentialsProvided(const QString &user,
|
||||
emit asked();
|
||||
|
||||
_askDialog->close();
|
||||
delete _askDialog;
|
||||
_askDialog->deleteLater();
|
||||
_askDialog = nullptr;
|
||||
}
|
||||
|
||||
void WebFlowCredentials::slotAskFromUserCancelled() {
|
||||
qCDebug(lcWebFlowCredentials()) << "User cancelled reauth!";
|
||||
|
||||
emit asked();
|
||||
|
||||
_askDialog->deleteLater();
|
||||
_askDialog = nullptr;
|
||||
}
|
||||
|
||||
bool WebFlowCredentials::stillValid(QNetworkReply *reply) {
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
@@ -229,86 +241,32 @@ void WebFlowCredentials::persist() {
|
||||
|
||||
// write cert if there is one
|
||||
if (!_clientSslCertificate.isNull()) {
|
||||
WritePasswordJob *job = new WritePasswordJob(Theme::instance()->appName());
|
||||
addSettingsToJob(_account, job);
|
||||
job->setInsecureFallback(false);
|
||||
connect(job, &Job::finished, this, &WebFlowCredentials::slotWriteClientCertPEMJobDone);
|
||||
job->setKey(keychainKey(_account->url().toString(), _user + clientCertificatePEMC, _account->id()));
|
||||
job->setBinaryData(_clientSslCertificate.toPem());
|
||||
auto *job = new KeychainChunk::WriteJob(_account,
|
||||
_user + clientCertificatePEMC,
|
||||
_clientSslCertificate.toPem());
|
||||
connect(job, &KeychainChunk::WriteJob::finished, this, &WebFlowCredentials::slotWriteClientCertPEMJobDone);
|
||||
job->start();
|
||||
} else {
|
||||
// no cert, just write credentials
|
||||
slotWriteClientCertPEMJobDone();
|
||||
slotWriteClientCertPEMJobDone(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void WebFlowCredentials::slotWriteClientCertPEMJobDone()
|
||||
void WebFlowCredentials::slotWriteClientCertPEMJobDone(KeychainChunk::WriteJob *writeJob)
|
||||
{
|
||||
if(writeJob)
|
||||
writeJob->deleteLater();
|
||||
|
||||
// write ssl key if there is one
|
||||
if (!_clientSslKey.isNull()) {
|
||||
// Windows workaround: Split the private key into chunks of 2048 bytes,
|
||||
// to allow 4k (4096 bit) keys to be saved (obey Windows's limits)
|
||||
_clientSslKeyChunkBufferPEM = _clientSslKey.toPem();
|
||||
_clientSslKeyChunkCount = 0;
|
||||
|
||||
writeSingleClientKeyChunkPEM(nullptr);
|
||||
auto *job = new KeychainChunk::WriteJob(_account,
|
||||
_user + clientKeyPEMC,
|
||||
_clientSslKey.toPem());
|
||||
connect(job, &KeychainChunk::WriteJob::finished, this, &WebFlowCredentials::slotWriteClientKeyPEMJobDone);
|
||||
job->start();
|
||||
} else {
|
||||
// no key, just write credentials
|
||||
slotWriteClientKeyPEMJobDone();
|
||||
}
|
||||
}
|
||||
|
||||
void WebFlowCredentials::writeSingleClientKeyChunkPEM(QKeychain::Job *incomingJob)
|
||||
{
|
||||
// errors?
|
||||
if (incomingJob) {
|
||||
WritePasswordJob *writeJob = static_cast<WritePasswordJob *>(incomingJob);
|
||||
|
||||
if (writeJob->error() != NoError) {
|
||||
qCWarning(lcWebFlowCredentials) << "Error while writing client CA key chunk" << writeJob->errorString();
|
||||
|
||||
_clientSslKeyChunkBufferPEM.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// write a key chunk if there is any in the buffer
|
||||
if (!_clientSslKeyChunkBufferPEM.isEmpty()) {
|
||||
#if defined(Q_OS_WIN)
|
||||
// Windows workaround: Split the private key into chunks of 2048 bytes,
|
||||
// to allow 4k (4096 bit) keys to be saved (obey Windows's limits)
|
||||
auto chunk = _clientSslKeyChunkBufferPEM.left(_clientSslKeyChunkSize);
|
||||
|
||||
_clientSslKeyChunkBufferPEM = _clientSslKeyChunkBufferPEM.right(_clientSslKeyChunkBufferPEM.size() - chunk.size());
|
||||
#else
|
||||
// write full key in one slot on non-Windows, as usual
|
||||
auto chunk = _clientSslKeyChunkBufferPEM;
|
||||
|
||||
_clientSslKeyChunkBufferPEM.clear();
|
||||
#endif
|
||||
auto index = (_clientSslKeyChunkCount++);
|
||||
|
||||
// keep the limit
|
||||
if (_clientSslKeyChunkCount > _clientSslKeyMaxChunks) {
|
||||
qCWarning(lcWebFlowCredentials) << "Maximum client key chunk count exceeded while writing slot" << QString::number(index) << "cutting off after" << QString::number(_clientSslKeyMaxChunks) << "chunks";
|
||||
|
||||
_clientSslKeyChunkBufferPEM.clear();
|
||||
|
||||
slotWriteClientKeyPEMJobDone();
|
||||
return;
|
||||
}
|
||||
|
||||
WritePasswordJob *job = new WritePasswordJob(Theme::instance()->appName());
|
||||
addSettingsToJob(_account, job);
|
||||
job->setInsecureFallback(false);
|
||||
connect(job, &Job::finished, this, &WebFlowCredentials::writeSingleClientKeyChunkPEM);
|
||||
// only add the key's (sub)"index" after the first element, to stay compatible with older versions and non-Windows
|
||||
job->setKey(keychainKey(_account->url().toString(), _user + clientKeyPEMC + (index > 0 ? (QString(".") + QString::number(index)) : QString()), _account->id()));
|
||||
job->setBinaryData(chunk);
|
||||
job->start();
|
||||
|
||||
chunk.clear();
|
||||
} else {
|
||||
slotWriteClientKeyPEMJobDone();
|
||||
slotWriteClientKeyPEMJobDone(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,20 +289,21 @@ void WebFlowCredentials::writeSingleClientCaCertPEM()
|
||||
return;
|
||||
}
|
||||
|
||||
WritePasswordJob *job = new WritePasswordJob(Theme::instance()->appName());
|
||||
addSettingsToJob(_account, job);
|
||||
job->setInsecureFallback(false);
|
||||
connect(job, &Job::finished, this, &WebFlowCredentials::slotWriteClientCaCertsPEMJobDone);
|
||||
job->setKey(keychainKey(_account->url().toString(), _user + clientCaCertificatePEMC + QString::number(index), _account->id()));
|
||||
job->setBinaryData(cert.toPem());
|
||||
auto *job = new KeychainChunk::WriteJob(_account,
|
||||
_user + clientCaCertificatePEMC + QString::number(index),
|
||||
cert.toPem());
|
||||
connect(job, &KeychainChunk::WriteJob::finished, this, &WebFlowCredentials::slotWriteClientCaCertsPEMJobDone);
|
||||
job->start();
|
||||
} else {
|
||||
slotWriteClientCaCertsPEMJobDone(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void WebFlowCredentials::slotWriteClientKeyPEMJobDone()
|
||||
void WebFlowCredentials::slotWriteClientKeyPEMJobDone(KeychainChunk::WriteJob *writeJob)
|
||||
{
|
||||
if(writeJob)
|
||||
writeJob->deleteLater();
|
||||
|
||||
_clientSslCaCertificatesWriteQueue.clear();
|
||||
|
||||
// write ca certs if there are any
|
||||
@@ -359,16 +318,16 @@ void WebFlowCredentials::slotWriteClientKeyPEMJobDone()
|
||||
}
|
||||
}
|
||||
|
||||
void WebFlowCredentials::slotWriteClientCaCertsPEMJobDone(QKeychain::Job *incomingJob)
|
||||
void WebFlowCredentials::slotWriteClientCaCertsPEMJobDone(KeychainChunk::WriteJob *writeJob)
|
||||
{
|
||||
// errors / next ca cert?
|
||||
if (incomingJob && !_clientSslCaCertificates.isEmpty()) {
|
||||
WritePasswordJob *writeJob = static_cast<WritePasswordJob *>(incomingJob);
|
||||
|
||||
if (writeJob && !_clientSslCaCertificates.isEmpty()) {
|
||||
if (writeJob->error() != NoError) {
|
||||
qCWarning(lcWebFlowCredentials) << "Error while writing client CA cert" << writeJob->errorString();
|
||||
}
|
||||
|
||||
writeJob->deleteLater();
|
||||
|
||||
if (!_clientSslCaCertificatesWriteQueue.isEmpty()) {
|
||||
// next ca cert
|
||||
writeSingleClientCaCertPEM();
|
||||
@@ -378,7 +337,9 @@ void WebFlowCredentials::slotWriteClientCaCertsPEMJobDone(QKeychain::Job *incomi
|
||||
|
||||
// done storing ca certs, time for the password
|
||||
WritePasswordJob *job = new WritePasswordJob(Theme::instance()->appName());
|
||||
#if defined(KEYCHAINCHUNK_ENABLE_INSECURE_FALLBACK)
|
||||
addSettingsToJob(_account, job);
|
||||
#endif
|
||||
job->setInsecureFallback(false);
|
||||
connect(job, &Job::finished, this, &WebFlowCredentials::slotWriteJobDone);
|
||||
job->setKey(keychainKey(_account->url().toString(), _user, _account->id()));
|
||||
@@ -428,6 +389,10 @@ void WebFlowCredentials::forgetSensitiveData() {
|
||||
DeletePasswordJob *job = new DeletePasswordJob(Theme::instance()->appName());
|
||||
job->setInsecureFallback(false);
|
||||
job->setKey(kck);
|
||||
connect(job, &Job::finished, this, [](QKeychain::Job *job) {
|
||||
DeletePasswordJob *djob = qobject_cast<DeletePasswordJob *>(job);
|
||||
djob->deleteLater();
|
||||
});
|
||||
job->start();
|
||||
|
||||
invalidateToken();
|
||||
@@ -478,29 +443,23 @@ void WebFlowCredentials::slotFinished(QNetworkReply *reply) {
|
||||
|
||||
void WebFlowCredentials::fetchFromKeychainHelper() {
|
||||
// Read client cert from keychain
|
||||
const QString kck = keychainKey(
|
||||
_account->url().toString(),
|
||||
_user + clientCertificatePEMC,
|
||||
_keychainMigration ? QString() : _account->id());
|
||||
|
||||
ReadPasswordJob *job = new ReadPasswordJob(Theme::instance()->appName());
|
||||
addSettingsToJob(_account, job);
|
||||
job->setInsecureFallback(false);
|
||||
job->setKey(kck);
|
||||
connect(job, &Job::finished, this, &WebFlowCredentials::slotReadClientCertPEMJobDone);
|
||||
auto *job = new KeychainChunk::ReadJob(_account,
|
||||
_user + clientCertificatePEMC,
|
||||
_keychainMigration);
|
||||
connect(job, &KeychainChunk::ReadJob::finished, this, &WebFlowCredentials::slotReadClientCertPEMJobDone);
|
||||
job->start();
|
||||
}
|
||||
|
||||
void WebFlowCredentials::slotReadClientCertPEMJobDone(QKeychain::Job *incomingJob)
|
||||
void WebFlowCredentials::slotReadClientCertPEMJobDone(KeychainChunk::ReadJob *readJob)
|
||||
{
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
||||
Q_ASSERT(!incomingJob->insecureFallback()); // If insecureFallback is set, the next test would be pointless
|
||||
if (_retryOnKeyChainError && (incomingJob->error() == QKeychain::NoBackendAvailable
|
||||
|| incomingJob->error() == QKeychain::OtherError)) {
|
||||
Q_ASSERT(!readJob->insecureFallback()); // If insecureFallback is set, the next test would be pointless
|
||||
if (_retryOnKeyChainError && (readJob->error() == QKeychain::NoBackendAvailable
|
||||
|| readJob->error() == QKeychain::OtherError)) {
|
||||
// Could be that the backend was not yet available. Wait some extra seconds.
|
||||
// (Issues #4274 and #6522)
|
||||
// (For kwallet, the error is OtherError instead of NoBackendAvailable, maybe a bug in QtKeychain)
|
||||
qCInfo(lcWebFlowCredentials) << "Backend unavailable (yet?) Retrying in a few seconds." << incomingJob->errorString();
|
||||
qCInfo(lcWebFlowCredentials) << "Backend unavailable (yet?) Retrying in a few seconds." << readJob->errorString();
|
||||
QTimer::singleShot(10000, this, &WebFlowCredentials::fetchFromKeychainHelper);
|
||||
_retryOnKeyChainError = false;
|
||||
return;
|
||||
@@ -509,7 +468,6 @@ void WebFlowCredentials::slotReadClientCertPEMJobDone(QKeychain::Job *incomingJo
|
||||
#endif
|
||||
|
||||
// Store PEM in memory
|
||||
ReadPasswordJob *readJob = static_cast<ReadPasswordJob *>(incomingJob);
|
||||
if (readJob->error() == NoError && readJob->binaryData().length() > 0) {
|
||||
QList<QSslCertificate> sslCertificateList = QSslCertificate::fromData(readJob->binaryData(), QSsl::Pem);
|
||||
if (sslCertificateList.length() >= 1) {
|
||||
@@ -517,79 +475,40 @@ void WebFlowCredentials::slotReadClientCertPEMJobDone(QKeychain::Job *incomingJo
|
||||
}
|
||||
}
|
||||
|
||||
readJob->deleteLater();
|
||||
|
||||
// Load key too
|
||||
_clientSslKeyChunkCount = 0;
|
||||
_clientSslKeyChunkBufferPEM.clear();
|
||||
|
||||
const QString kck = keychainKey(
|
||||
_account->url().toString(),
|
||||
_user + clientKeyPEMC,
|
||||
_keychainMigration ? QString() : _account->id());
|
||||
|
||||
ReadPasswordJob *job = new ReadPasswordJob(Theme::instance()->appName());
|
||||
addSettingsToJob(_account, job);
|
||||
job->setInsecureFallback(false);
|
||||
job->setKey(kck);
|
||||
connect(job, &Job::finished, this, &WebFlowCredentials::slotReadClientKeyPEMJobDone);
|
||||
auto *job = new KeychainChunk::ReadJob(_account,
|
||||
_user + clientKeyPEMC,
|
||||
_keychainMigration);
|
||||
connect(job, &KeychainChunk::ReadJob::finished, this, &WebFlowCredentials::slotReadClientKeyPEMJobDone);
|
||||
job->start();
|
||||
}
|
||||
|
||||
void WebFlowCredentials::slotReadClientKeyPEMJobDone(QKeychain::Job *incomingJob)
|
||||
void WebFlowCredentials::slotReadClientKeyPEMJobDone(KeychainChunk::ReadJob *readJob)
|
||||
{
|
||||
// Errors or next key chunk?
|
||||
ReadPasswordJob *readJob = static_cast<ReadPasswordJob *>(incomingJob);
|
||||
|
||||
if (readJob) {
|
||||
if (readJob->error() == NoError && readJob->binaryData().length() > 0) {
|
||||
_clientSslKeyChunkBufferPEM.append(readJob->binaryData());
|
||||
_clientSslKeyChunkCount++;
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
// try to fetch next chunk
|
||||
if (_clientSslKeyChunkCount < _clientSslKeyMaxChunks) {
|
||||
const QString kck = keychainKey(
|
||||
_account->url().toString(),
|
||||
_user + clientKeyPEMC + QString(".") + QString::number(_clientSslKeyChunkCount),
|
||||
_keychainMigration ? QString() : _account->id());
|
||||
|
||||
ReadPasswordJob *job = new ReadPasswordJob(Theme::instance()->appName());
|
||||
addSettingsToJob(_account, job);
|
||||
job->setInsecureFallback(false);
|
||||
job->setKey(kck);
|
||||
connect(job, &Job::finished, this, &WebFlowCredentials::slotReadClientKeyPEMJobDone);
|
||||
job->start();
|
||||
|
||||
return;
|
||||
} else {
|
||||
qCWarning(lcWebFlowCredentials) << "Maximum client key chunk count reached, ignoring after" << _clientSslKeyMaxChunks;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (readJob->error() != QKeychain::Error::EntryNotFound ||
|
||||
((readJob->error() == QKeychain::Error::EntryNotFound) && _clientSslKeyChunkCount == 0)) {
|
||||
qCWarning(lcWebFlowCredentials) << "Unable to read client key chunk slot" << QString::number(_clientSslKeyChunkCount) << readJob->errorString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Store key in memory
|
||||
if (_clientSslKeyChunkBufferPEM.size() > 0) {
|
||||
if (readJob->error() == NoError && readJob->binaryData().length() > 0) {
|
||||
QByteArray clientKeyPEM = readJob->binaryData();
|
||||
// FIXME Unfortunately Qt has a bug and we can't just use QSsl::Opaque to let it
|
||||
// load whatever we have. So we try until it works.
|
||||
_clientSslKey = QSslKey(_clientSslKeyChunkBufferPEM, QSsl::Rsa);
|
||||
_clientSslKey = QSslKey(clientKeyPEM, QSsl::Rsa);
|
||||
if (_clientSslKey.isNull()) {
|
||||
_clientSslKey = QSslKey(_clientSslKeyChunkBufferPEM, QSsl::Dsa);
|
||||
_clientSslKey = QSslKey(clientKeyPEM, QSsl::Dsa);
|
||||
}
|
||||
if (_clientSslKey.isNull()) {
|
||||
_clientSslKey = QSslKey(_clientSslKeyChunkBufferPEM, QSsl::Ec);
|
||||
_clientSslKey = QSslKey(clientKeyPEM, QSsl::Ec);
|
||||
}
|
||||
if (_clientSslKey.isNull()) {
|
||||
qCWarning(lcWebFlowCredentials) << "Could not load SSL key into Qt!";
|
||||
}
|
||||
// clear key chunk buffer, but don't set _clientSslKeyChunkCount to zero because we need it for deleteKeychainEntries
|
||||
_clientSslKeyChunkBufferPEM.clear();
|
||||
clientKeyPEM.clear();
|
||||
} else {
|
||||
qCWarning(lcWebFlowCredentials) << "Unable to read client key" << readJob->errorString();
|
||||
}
|
||||
|
||||
readJob->deleteLater();
|
||||
|
||||
// Start fetching client CA certs
|
||||
_clientSslCaCertificates.clear();
|
||||
|
||||
@@ -600,16 +519,10 @@ void WebFlowCredentials::readSingleClientCaCertPEM()
|
||||
{
|
||||
// try to fetch a client ca cert
|
||||
if (_clientSslCaCertificates.count() < _clientSslCaCertificatesMaxCount) {
|
||||
const QString kck = keychainKey(
|
||||
_account->url().toString(),
|
||||
_user + clientCaCertificatePEMC + QString::number(_clientSslCaCertificates.count()),
|
||||
_keychainMigration ? QString() : _account->id());
|
||||
|
||||
ReadPasswordJob *job = new ReadPasswordJob(Theme::instance()->appName());
|
||||
addSettingsToJob(_account, job);
|
||||
job->setInsecureFallback(false);
|
||||
job->setKey(kck);
|
||||
connect(job, &Job::finished, this, &WebFlowCredentials::slotReadClientCaCertsPEMJobDone);
|
||||
auto *job = new KeychainChunk::ReadJob(_account,
|
||||
_user + clientCaCertificatePEMC + QString::number(_clientSslCaCertificates.count()),
|
||||
_keychainMigration);
|
||||
connect(job, &KeychainChunk::ReadJob::finished, this, &WebFlowCredentials::slotReadClientCaCertsPEMJobDone);
|
||||
job->start();
|
||||
} else {
|
||||
qCWarning(lcWebFlowCredentials) << "Maximum client CA cert count exceeded while reading, ignoring after" << _clientSslCaCertificatesMaxCount;
|
||||
@@ -618,10 +531,8 @@ void WebFlowCredentials::readSingleClientCaCertPEM()
|
||||
}
|
||||
}
|
||||
|
||||
void WebFlowCredentials::slotReadClientCaCertsPEMJobDone(QKeychain::Job *incomingJob) {
|
||||
// Store key in memory
|
||||
ReadPasswordJob *readJob = static_cast<ReadPasswordJob *>(incomingJob);
|
||||
|
||||
void WebFlowCredentials::slotReadClientCaCertsPEMJobDone(KeychainChunk::ReadJob *readJob) {
|
||||
// Store cert in memory
|
||||
if (readJob) {
|
||||
if (readJob->error() == NoError && readJob->binaryData().length() > 0) {
|
||||
QList<QSslCertificate> sslCertificateList = QSslCertificate::fromData(readJob->binaryData(), QSsl::Pem);
|
||||
@@ -629,6 +540,8 @@ void WebFlowCredentials::slotReadClientCaCertsPEMJobDone(QKeychain::Job *incomin
|
||||
_clientSslCaCertificates.append(sslCertificateList.at(0));
|
||||
}
|
||||
|
||||
readJob->deleteLater();
|
||||
|
||||
// try next cert
|
||||
readSingleClientCaCertPEM();
|
||||
return;
|
||||
@@ -638,6 +551,8 @@ void WebFlowCredentials::slotReadClientCaCertsPEMJobDone(QKeychain::Job *incomin
|
||||
qCWarning(lcWebFlowCredentials) << "Unable to read client CA cert slot" << QString::number(_clientSslCaCertificates.count()) << readJob->errorString();
|
||||
}
|
||||
}
|
||||
|
||||
readJob->deleteLater();
|
||||
}
|
||||
|
||||
// Now fetch the actual server password
|
||||
@@ -647,7 +562,9 @@ void WebFlowCredentials::slotReadClientCaCertsPEMJobDone(QKeychain::Job *incomin
|
||||
_keychainMigration ? QString() : _account->id());
|
||||
|
||||
ReadPasswordJob *job = new ReadPasswordJob(Theme::instance()->appName());
|
||||
#if defined(KEYCHAINCHUNK_ENABLE_INSECURE_FALLBACK)
|
||||
addSettingsToJob(_account, job);
|
||||
#endif
|
||||
job->setInsecureFallback(false);
|
||||
job->setKey(kck);
|
||||
connect(job, &Job::finished, this, &WebFlowCredentials::slotReadPasswordJobDone);
|
||||
@@ -655,7 +572,7 @@ void WebFlowCredentials::slotReadClientCaCertsPEMJobDone(QKeychain::Job *incomin
|
||||
}
|
||||
|
||||
void WebFlowCredentials::slotReadPasswordJobDone(Job *incomingJob) {
|
||||
QKeychain::ReadPasswordJob *job = static_cast<ReadPasswordJob *>(incomingJob);
|
||||
QKeychain::ReadPasswordJob *job = qobject_cast<ReadPasswordJob *>(incomingJob);
|
||||
QKeychain::Error error = job->error();
|
||||
|
||||
// If we could not find the entry try the old entries
|
||||
@@ -678,6 +595,8 @@ void WebFlowCredentials::slotReadPasswordJobDone(Job *incomingJob) {
|
||||
}
|
||||
emit fetched();
|
||||
|
||||
job->deleteLater();
|
||||
|
||||
// If keychain data was read from legacy location, wipe these entries and store new ones
|
||||
if (_keychainMigration && _ready) {
|
||||
_keychainMigration = false;
|
||||
@@ -688,13 +607,20 @@ void WebFlowCredentials::slotReadPasswordJobDone(Job *incomingJob) {
|
||||
}
|
||||
|
||||
void WebFlowCredentials::deleteKeychainEntries(bool oldKeychainEntries) {
|
||||
auto startDeleteJob = [this, oldKeychainEntries](QString user) {
|
||||
auto startDeleteJob = [this, oldKeychainEntries](QString key) {
|
||||
DeletePasswordJob *job = new DeletePasswordJob(Theme::instance()->appName());
|
||||
#if defined(KEYCHAINCHUNK_ENABLE_INSECURE_FALLBACK)
|
||||
addSettingsToJob(_account, job);
|
||||
#endif
|
||||
job->setInsecureFallback(false);
|
||||
job->setKey(keychainKey(_account->url().toString(),
|
||||
user,
|
||||
key,
|
||||
oldKeychainEntries ? QString() : _account->id()));
|
||||
|
||||
connect(job, &Job::finished, this, [](QKeychain::Job *job) {
|
||||
DeletePasswordJob *djob = qobject_cast<DeletePasswordJob *>(job);
|
||||
djob->deleteLater();
|
||||
});
|
||||
job->start();
|
||||
};
|
||||
|
||||
@@ -719,9 +645,17 @@ void WebFlowCredentials::deleteKeychainEntries(bool oldKeychainEntries) {
|
||||
}
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
// also delete key sub-chunks (Windows workaround)
|
||||
for (auto i = 1; i < _clientSslKeyChunkCount; i++) {
|
||||
startDeleteJob(_user + clientKeyPEMC + QString(".") + QString::number(i));
|
||||
// Also delete key / cert sub-chunks (Windows workaround)
|
||||
// The first chunk (0) has no suffix, to stay compatible with older versions and non-Windows
|
||||
for (auto chunk = 1; chunk < KeychainChunk::MaxChunks; chunk++) {
|
||||
const QString strChunkSuffix = QString(".") + QString::number(chunk);
|
||||
|
||||
startDeleteJob(_user + clientKeyPEMC + strChunkSuffix);
|
||||
startDeleteJob(_user + clientCertificatePEMC + strChunkSuffix);
|
||||
|
||||
for (auto i = 0; i < _clientSslCaCertificates.count(); i++) {
|
||||
startDeleteJob(_user + clientCaCertificatePEMC + QString::number(i));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// FIXME MS@2019-12-07 -->
|
||||
@@ -729,4 +663,4 @@ void WebFlowCredentials::deleteKeychainEntries(bool oldKeychainEntries) {
|
||||
// <-- FIXME MS@2019-12-07
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace OCC
|
||||
|
||||
@@ -19,6 +19,11 @@ namespace QKeychain {
|
||||
|
||||
namespace OCC {
|
||||
|
||||
namespace KeychainChunk {
|
||||
class ReadJob;
|
||||
class WriteJob;
|
||||
}
|
||||
|
||||
class WebFlowCredentialsDialog;
|
||||
|
||||
class WebFlowCredentials : public AbstractCredentials
|
||||
@@ -61,15 +66,16 @@ private slots:
|
||||
void slotFinished(QNetworkReply *reply);
|
||||
|
||||
void slotAskFromUserCredentialsProvided(const QString &user, const QString &pass, const QString &host);
|
||||
void slotAskFromUserCancelled();
|
||||
|
||||
void slotReadClientCertPEMJobDone(QKeychain::Job *incomingJob);
|
||||
void slotReadClientKeyPEMJobDone(QKeychain::Job *incomingJob);
|
||||
void slotReadClientCaCertsPEMJobDone(QKeychain::Job *incommingJob);
|
||||
void slotReadClientCertPEMJobDone(KeychainChunk::ReadJob *readJob);
|
||||
void slotReadClientKeyPEMJobDone(KeychainChunk::ReadJob *readJob);
|
||||
void slotReadClientCaCertsPEMJobDone(KeychainChunk::ReadJob *readJob);
|
||||
void slotReadPasswordJobDone(QKeychain::Job *incomingJob);
|
||||
|
||||
void slotWriteClientCertPEMJobDone();
|
||||
void slotWriteClientKeyPEMJobDone();
|
||||
void slotWriteClientCaCertsPEMJobDone(QKeychain::Job *incomingJob);
|
||||
void slotWriteClientCertPEMJobDone(KeychainChunk::WriteJob *writeJob);
|
||||
void slotWriteClientKeyPEMJobDone(KeychainChunk::WriteJob *writeJob);
|
||||
void slotWriteClientCaCertsPEMJobDone(KeychainChunk::WriteJob *writeJob);
|
||||
void slotWriteJobDone(QKeychain::Job *);
|
||||
|
||||
private:
|
||||
@@ -91,19 +97,6 @@ private:
|
||||
static constexpr int _clientSslCaCertificatesMaxCount = 10;
|
||||
QQueue<QSslCertificate> _clientSslCaCertificatesWriteQueue;
|
||||
|
||||
/*
|
||||
* Workaround: ...and this time only on Windows:
|
||||
*
|
||||
* Split the private key into chunks of 2048 bytes,
|
||||
* to allow 4k (4096 bit) keys to be saved (see limits above)
|
||||
*/
|
||||
void writeSingleClientKeyChunkPEM(QKeychain::Job *incomingJob);
|
||||
|
||||
static constexpr int _clientSslKeyChunkSize = 2048;
|
||||
static constexpr int _clientSslKeyMaxChunks = 10;
|
||||
int _clientSslKeyChunkCount = 0;
|
||||
QByteArray _clientSslKeyChunkBufferPEM;
|
||||
|
||||
protected:
|
||||
/** Reads data from keychain locations
|
||||
*
|
||||
@@ -134,6 +127,6 @@ protected:
|
||||
WebFlowCredentialsDialog *_askDialog;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace OCC
|
||||
|
||||
#endif // WEBFLOWCREDENTIALS_H
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
#include <QLabel>
|
||||
|
||||
#include "theme.h"
|
||||
#include "application.h"
|
||||
#include "owncloudgui.h"
|
||||
#include "headerbanner.h"
|
||||
#include "wizard/owncloudwizardcommon.h"
|
||||
#include "wizard/webview.h"
|
||||
#include "wizard/flow2authwidget.h"
|
||||
@@ -19,31 +22,59 @@ WebFlowCredentialsDialog::WebFlowCredentialsDialog(Account *account, bool useFlo
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
_layout = new QVBoxLayout(this);
|
||||
int spacing = _layout->spacing();
|
||||
int margin = _layout->margin();
|
||||
_layout->setSpacing(0);
|
||||
_layout->setMargin(0);
|
||||
|
||||
if(_useFlow2) {
|
||||
_headerBanner = new HeaderBanner(this);
|
||||
_layout->addWidget(_headerBanner);
|
||||
Theme *theme = Theme::instance();
|
||||
_headerBanner->setup(tr("Log in"), theme->wizardHeaderLogo(), theme->wizardHeaderBanner(),
|
||||
Qt::AutoText, QString::fromLatin1("color:#fff;"));
|
||||
}
|
||||
|
||||
_containerLayout = new QVBoxLayout(this);
|
||||
_containerLayout->setSpacing(spacing);
|
||||
_containerLayout->setMargin(margin);
|
||||
|
||||
//QString msg = tr("You have been logged out of %1 as user %2, please login again")
|
||||
// .arg(_account->displayName(), _user);
|
||||
_infoLabel = new QLabel();
|
||||
_layout->addWidget(_infoLabel);
|
||||
_containerLayout->addWidget(_infoLabel);
|
||||
|
||||
if (_useFlow2) {
|
||||
_flow2AuthWidget = new Flow2AuthWidget(account);
|
||||
_layout->addWidget(_flow2AuthWidget);
|
||||
_flow2AuthWidget = new Flow2AuthWidget();
|
||||
_containerLayout->addWidget(_flow2AuthWidget);
|
||||
|
||||
connect(_flow2AuthWidget, &Flow2AuthWidget::urlCatched, this, &WebFlowCredentialsDialog::urlCatched);
|
||||
connect(_flow2AuthWidget, &Flow2AuthWidget::authResult, this, &WebFlowCredentialsDialog::slotFlow2AuthResult);
|
||||
|
||||
// Connect styleChanged events to our widgets, so they can adapt (Dark-/Light-Mode switching)
|
||||
connect(this, &WebFlowCredentialsDialog::styleChanged, _flow2AuthWidget, &Flow2AuthWidget::slotStyleChanged);
|
||||
|
||||
// allow Flow2 page to poll on window activation
|
||||
connect(this, &WebFlowCredentialsDialog::onActivate, _flow2AuthWidget, &Flow2AuthWidget::slotPollNow);
|
||||
|
||||
_flow2AuthWidget->startAuth(account);
|
||||
} else {
|
||||
_webView = new WebView();
|
||||
_layout->addWidget(_webView);
|
||||
_containerLayout->addWidget(_webView);
|
||||
|
||||
connect(_webView, &WebView::urlCatched, this, &WebFlowCredentialsDialog::urlCatched);
|
||||
}
|
||||
|
||||
auto app = static_cast<Application *>(qApp);
|
||||
connect(app, &Application::isShowingSettingsDialog, this, &WebFlowCredentialsDialog::slotShowSettingsDialog);
|
||||
|
||||
_errorLabel = new QLabel();
|
||||
_errorLabel->hide();
|
||||
_layout->addWidget(_errorLabel);
|
||||
_containerLayout->addWidget(_errorLabel);
|
||||
|
||||
WizardCommon::initErrorLabel(_errorLabel);
|
||||
|
||||
_layout->addLayout(_containerLayout);
|
||||
setLayout(_layout);
|
||||
|
||||
customizeStyle();
|
||||
}
|
||||
|
||||
void WebFlowCredentialsDialog::closeEvent(QCloseEvent* e) {
|
||||
@@ -52,11 +83,17 @@ void WebFlowCredentialsDialog::closeEvent(QCloseEvent* e) {
|
||||
if (_webView) {
|
||||
// Force calling WebView::~WebView() earlier so that _profile and _page are
|
||||
// deleted in the correct order.
|
||||
delete _webView;
|
||||
_webView->deleteLater();
|
||||
_webView = nullptr;
|
||||
}
|
||||
|
||||
if (_flow2AuthWidget)
|
||||
delete _flow2AuthWidget;
|
||||
if (_flow2AuthWidget) {
|
||||
_flow2AuthWidget->resetAuth();
|
||||
_flow2AuthWidget->deleteLater();
|
||||
_flow2AuthWidget = nullptr;
|
||||
}
|
||||
|
||||
emit onClose();
|
||||
}
|
||||
|
||||
void WebFlowCredentialsDialog::setUrl(const QUrl &url) {
|
||||
@@ -69,6 +106,9 @@ void WebFlowCredentialsDialog::setInfo(const QString &msg) {
|
||||
}
|
||||
|
||||
void WebFlowCredentialsDialog::setError(const QString &error) {
|
||||
// bring window to top
|
||||
slotShowSettingsDialog();
|
||||
|
||||
if (_useFlow2 && _flow2AuthWidget) {
|
||||
_flow2AuthWidget->setError(error);
|
||||
return;
|
||||
@@ -82,4 +122,49 @@ void WebFlowCredentialsDialog::setError(const QString &error) {
|
||||
}
|
||||
}
|
||||
|
||||
void WebFlowCredentialsDialog::changeEvent(QEvent *e)
|
||||
{
|
||||
switch (e->type()) {
|
||||
case QEvent::StyleChange:
|
||||
case QEvent::PaletteChange:
|
||||
case QEvent::ThemeChange:
|
||||
customizeStyle();
|
||||
|
||||
// Notify the other widgets (Dark-/Light-Mode switching)
|
||||
emit styleChanged();
|
||||
break;
|
||||
case QEvent::ActivationChange:
|
||||
if(isActiveWindow())
|
||||
emit onActivate();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
QDialog::changeEvent(e);
|
||||
}
|
||||
|
||||
void WebFlowCredentialsDialog::customizeStyle()
|
||||
{
|
||||
// HINT: Customize dialog's own style here, if necessary in the future (Dark-/Light-Mode switching)
|
||||
}
|
||||
|
||||
void WebFlowCredentialsDialog::slotShowSettingsDialog()
|
||||
{
|
||||
// bring window to top but slightly delay, to avoid being hidden behind the SettingsDialog
|
||||
QTimer::singleShot(100, this, [this] {
|
||||
ownCloudGui::raiseDialog(this);
|
||||
});
|
||||
}
|
||||
|
||||
void WebFlowCredentialsDialog::slotFlow2AuthResult(Flow2Auth::Result r, const QString &errorString, const QString &user, const QString &appPassword)
|
||||
{
|
||||
if(r == Flow2Auth::LoggedIn) {
|
||||
emit urlCatched(user, appPassword, QString());
|
||||
} else {
|
||||
// bring window to top
|
||||
slotShowSettingsDialog();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
#include <QUrl>
|
||||
|
||||
#include "accountfwd.h"
|
||||
#include "creds/flow2auth.h"
|
||||
|
||||
class QLabel;
|
||||
class QVBoxLayout;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class HeaderBanner;
|
||||
class WebView;
|
||||
class Flow2AuthWidget;
|
||||
|
||||
@@ -30,11 +32,21 @@ public:
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent * e) override;
|
||||
void changeEvent(QEvent *) override;
|
||||
|
||||
public slots:
|
||||
void slotFlow2AuthResult(Flow2Auth::Result, const QString &errorString, const QString &user, const QString &appPassword);
|
||||
void slotShowSettingsDialog();
|
||||
|
||||
signals:
|
||||
void urlCatched(const QString user, const QString pass, const QString host);
|
||||
void styleChanged();
|
||||
void onActivate();
|
||||
void onClose();
|
||||
|
||||
private:
|
||||
void customizeStyle();
|
||||
|
||||
bool _useFlow2;
|
||||
|
||||
Flow2AuthWidget *_flow2AuthWidget;
|
||||
@@ -43,8 +55,10 @@ private:
|
||||
QLabel *_errorLabel;
|
||||
QLabel *_infoLabel;
|
||||
QVBoxLayout *_layout;
|
||||
QVBoxLayout *_containerLayout;
|
||||
HeaderBanner *_headerBanner;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace OCC
|
||||
|
||||
#endif // WEBFLOWCREDENTIALSDIALOG_H
|
||||
|
||||
@@ -914,6 +914,8 @@ void Folder::slotItemCompleted(const SyncFileItemPtr &item)
|
||||
_folderWatcher->removePath(path() + item->_file);
|
||||
_folderWatcher->addPath(path() + item->destination());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1204,7 +1206,7 @@ QString FolderDefinition::absoluteJournalPath() const
|
||||
|
||||
QString FolderDefinition::defaultJournalPath(AccountPtr account)
|
||||
{
|
||||
return SyncJournalDb::makeDbName(localPath, account->url(), targetPath, account->credentials()->user());
|
||||
return SyncJournalDb::makeDbName(account->url(), targetPath, account->credentials()->user());
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
QString alias;
|
||||
/// path on local machine
|
||||
QString localPath;
|
||||
/// path to the journal, usually relative to localPath
|
||||
/// path to the journal, usually in QStandardPaths::AppDataLocation
|
||||
QString journalPath;
|
||||
/// path on remote
|
||||
QString targetPath;
|
||||
|
||||
@@ -210,6 +210,27 @@ void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account,
|
||||
folderDefinition.journalPath = defaultJournalPath;
|
||||
}
|
||||
|
||||
// Migration #2: journalPath now in DataAppDir, not root of local tree (cross-platform persistent user roaming files)
|
||||
if (folderDefinition.journalPath.at(0) == QChar('.')) {
|
||||
QFile oldJournal(folderDefinition.localPath + "/" + folderDefinition.journalPath);
|
||||
QFile oldJournalShm(folderDefinition.localPath + "/" + folderDefinition.journalPath.append("-shm"));
|
||||
QFile oldJournalWal(folderDefinition.localPath + "/" + folderDefinition.journalPath.append("-wal"));
|
||||
|
||||
folderDefinition.journalPath = defaultJournalPath;
|
||||
|
||||
socketApi()->slotUnregisterPath(folderAlias);
|
||||
auto settings = account->settings();
|
||||
|
||||
Folder *f = addFolderInternal(folderDefinition, account.data());
|
||||
f->saveToSettings();
|
||||
|
||||
oldJournal.remove();
|
||||
oldJournalShm.remove();
|
||||
oldJournalWal.remove();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Migration: ._ files sometimes don't work
|
||||
// So if the configured journalPath is the default one ("._sync_*.db")
|
||||
// but the current default doesn't have the underscore, switch to the
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OCC {
|
||||
FolderStatusDelegate::FolderStatusDelegate()
|
||||
: QStyledItemDelegate()
|
||||
{
|
||||
m_moreIcon = QIcon(QLatin1String(":/client/resources/more.svg"));
|
||||
customizeStyle();
|
||||
}
|
||||
|
||||
QString FolderStatusDelegate::addFolderText()
|
||||
@@ -273,6 +273,11 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
rect.setHeight(texts.count() * subFm.height() + 2 * margin);
|
||||
rect.setRight(option.rect.right() - margin);
|
||||
|
||||
// save previous state to not mess up colours with the background (fixes issue: https://github.com/nextcloud/desktop/issues/1237)
|
||||
auto oldBrush = painter->brush();
|
||||
auto oldPen = painter->pen();
|
||||
auto oldFont = painter->font();
|
||||
|
||||
painter->setBrush(color);
|
||||
painter->setPen(QColor(0xaa, 0xaa, 0xaa));
|
||||
painter->drawRoundedRect(QStyle::visualRect(option.direction, option.rect, rect),
|
||||
@@ -290,6 +295,11 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
textRect.translate(0, textRect.height());
|
||||
}
|
||||
|
||||
// restore previous state
|
||||
painter->setBrush(oldBrush);
|
||||
painter->setPen(oldPen);
|
||||
painter->setFont(oldFont);
|
||||
|
||||
h = rect.bottom() + margin;
|
||||
};
|
||||
|
||||
@@ -349,7 +359,7 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
btnOpt.arrowType = Qt::NoArrow;
|
||||
btnOpt.subControls = QStyle::SC_ToolButton;
|
||||
btnOpt.rect = optionsButtonVisualRect;
|
||||
btnOpt.icon = m_moreIcon;
|
||||
btnOpt.icon = _iconMore;
|
||||
int e = QApplication::style()->pixelMetric(QStyle::PM_ButtonIconSize);
|
||||
btnOpt.iconSize = QSize(e,e);
|
||||
QApplication::style()->drawComplexControl(QStyle::CC_ToolButton, &btnOpt, painter);
|
||||
@@ -423,5 +433,14 @@ QRect FolderStatusDelegate::errorsListRect(QRect within)
|
||||
return within;
|
||||
}
|
||||
|
||||
void FolderStatusDelegate::slotStyleChanged()
|
||||
{
|
||||
customizeStyle();
|
||||
}
|
||||
|
||||
void FolderStatusDelegate::customizeStyle()
|
||||
{
|
||||
_iconMore = Theme::createColorAwareIcon(QLatin1String(":/client/resources/more.svg"));
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
@@ -26,7 +26,6 @@ class FolderStatusDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QIcon m_moreIcon;
|
||||
FolderStatusDelegate();
|
||||
|
||||
enum datarole { FolderAliasRole = Qt::UserRole + 100,
|
||||
@@ -62,9 +61,16 @@ public:
|
||||
static QRect errorsListRect(QRect within);
|
||||
static int rootFolderHeightWithoutErrors(const QFontMetrics &fm, const QFontMetrics &aliasFm);
|
||||
|
||||
public slots:
|
||||
void slotStyleChanged();
|
||||
|
||||
private:
|
||||
void customizeStyle();
|
||||
|
||||
static QString addFolderText();
|
||||
QPersistentModelIndex _pressedIndex;
|
||||
|
||||
QIcon _iconMore;
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>785</width>
|
||||
<width>516</width>
|
||||
<height>523</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
||||
146
src/gui/headerbanner.cpp
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (C) by Michael Schuster <michael@nextcloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
**
|
||||
** Based on Qt sourcecode:
|
||||
** qt5/qtbase/src/widgets/dialogs/qwizard.cpp
|
||||
**
|
||||
** https://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/dialogs/qwizard.cpp?h=v5.13.0
|
||||
**
|
||||
** Original license:
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtWidgets module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 3 requirements
|
||||
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 2.0 or (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "headerbanner.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyle>
|
||||
#include <QGuiApplication>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
// These fudge terms were needed a few places to obtain pixel-perfect results
|
||||
const int GapBetweenLogoAndRightEdge = 5;
|
||||
const int ModernHeaderTopMargin = 2;
|
||||
|
||||
HeaderBanner::HeaderBanner(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
setBackgroundRole(QPalette::Base);
|
||||
titleLabel = new QLabel(this);
|
||||
titleLabel->setBackgroundRole(QPalette::Base);
|
||||
logoLabel = new QLabel(this);
|
||||
QFont font = titleLabel->font();
|
||||
font.setBold(true);
|
||||
titleLabel->setFont(font);
|
||||
layout = new QGridLayout(this);
|
||||
layout->setContentsMargins(QMargins());
|
||||
layout->setSpacing(0);
|
||||
layout->setRowMinimumHeight(3, 1);
|
||||
layout->setRowStretch(4, 1);
|
||||
layout->setColumnStretch(2, 1);
|
||||
layout->setColumnMinimumWidth(4, 2 * GapBetweenLogoAndRightEdge);
|
||||
layout->setColumnMinimumWidth(6, GapBetweenLogoAndRightEdge);
|
||||
layout->addWidget(titleLabel, 1, 1, 5, 1);
|
||||
layout->addWidget(logoLabel, 1, 5, 5, 1);
|
||||
}
|
||||
|
||||
void HeaderBanner::setup(const QString &title, const QPixmap &logo, const QPixmap &banner,
|
||||
const Qt::TextFormat titleFormat, const QString &styleSheet)
|
||||
{
|
||||
QStyle *style = parentWidget()->style();
|
||||
//const int layoutHorizontalSpacing = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
|
||||
int topLevelMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, parentWidget());
|
||||
int topLevelMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, 0, parentWidget());
|
||||
int topLevelMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, 0, parentWidget());
|
||||
//int topLevelMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, parentWidget());
|
||||
|
||||
layout->setRowMinimumHeight(0, ModernHeaderTopMargin);
|
||||
layout->setRowMinimumHeight(1, topLevelMarginTop - ModernHeaderTopMargin - 1);
|
||||
layout->setRowMinimumHeight(6, 3);
|
||||
int minColumnWidth0 = topLevelMarginLeft + topLevelMarginRight;
|
||||
int minColumnWidth1 = topLevelMarginLeft + topLevelMarginRight + 1;
|
||||
layout->setColumnMinimumWidth(0, minColumnWidth0);
|
||||
layout->setColumnMinimumWidth(1, minColumnWidth1);
|
||||
titleLabel->setTextFormat(titleFormat);
|
||||
titleLabel->setText(title);
|
||||
if(!styleSheet.isEmpty())
|
||||
titleLabel->setStyleSheet(styleSheet);
|
||||
logoLabel->setPixmap(logo);
|
||||
bannerPixmap = banner;
|
||||
if (bannerPixmap.isNull()) {
|
||||
QSize size = layout->totalMinimumSize();
|
||||
setMinimumSize(size);
|
||||
setMaximumSize(QWIDGETSIZE_MAX, size.height());
|
||||
} else {
|
||||
setFixedHeight(banner.height() + 2);
|
||||
}
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
void HeaderBanner::paintEvent(QPaintEvent * /* event */)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.drawPixmap(0, 0, width(), bannerPixmap.height(), bannerPixmap);
|
||||
int x = width() - 2;
|
||||
int y = height() - 2;
|
||||
const QPalette &pal = QGuiApplication::palette();
|
||||
painter.setPen(pal.mid().color());
|
||||
painter.drawLine(0, y, x, y);
|
||||
painter.setPen(pal.base().color());
|
||||
painter.drawPoint(x + 1, y);
|
||||
painter.drawLine(0, y + 1, x + 1, y + 1);
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
93
src/gui/headerbanner.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (C) by Michael Schuster <michael@nextcloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
**
|
||||
** Based on Qt sourcecode:
|
||||
** qt5/qtbase/src/widgets/dialogs/qwizard.cpp
|
||||
**
|
||||
** https://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/dialogs/qwizard.cpp?h=v5.13.0
|
||||
**
|
||||
** Original license:
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtWidgets module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 3 requirements
|
||||
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 2.0 or (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef HEADERBANNER_H
|
||||
#define HEADERBANNER_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QGridLayout;
|
||||
class QPixmap;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class HeaderBanner : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HeaderBanner(QWidget *parent = 0);
|
||||
|
||||
void setup(const QString &title, const QPixmap &logo, const QPixmap &banner,
|
||||
const Qt::TextFormat titleFormat, const QString &styleSheet);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
QLabel *titleLabel;
|
||||
QLabel *logoLabel;
|
||||
QGridLayout *layout;
|
||||
QPixmap bannerPixmap;
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
#endif // HEADERBANNER_H
|
||||
@@ -23,6 +23,9 @@ IconJob::IconJob(const QUrl &url, QObject *parent) :
|
||||
this, &IconJob::finished);
|
||||
|
||||
QNetworkRequest request(url);
|
||||
#if (QT_VERSION >= 0x050600)
|
||||
request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
||||
#endif
|
||||
_accessManager.get(request);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ LegalNotice::LegalNotice(QDialog *parent)
|
||||
{
|
||||
_ui->setupUi(this);
|
||||
|
||||
QString notice = tr("<p>Copyright 2017-2019 Nextcloud GmbH<br />"
|
||||
QString notice = tr("<p>Copyright 2017-2020 Nextcloud GmbH<br />"
|
||||
"Copyright 2012-2018 ownCloud GmbH</p>");
|
||||
|
||||
notice += tr("<p>Licensed under the GNU General Public License (GPL) Version 2.0 or any later version.</p>");
|
||||
|
||||
@@ -32,6 +32,11 @@ NavigationPaneHelper::NavigationPaneHelper(FolderMan *folderMan)
|
||||
|
||||
_updateCloudStorageRegistryTimer.setSingleShot(true);
|
||||
connect(&_updateCloudStorageRegistryTimer, &QTimer::timeout, this, &NavigationPaneHelper::updateCloudStorageRegistry);
|
||||
|
||||
// Ensure that the folder integration stays persistent in Explorer,
|
||||
// the uninstaller removes the folder upon updating the client.
|
||||
_showInExplorerNavigationPane = !_showInExplorerNavigationPane;
|
||||
setShowInExplorerNavigationPane(!_showInExplorerNavigationPane);
|
||||
}
|
||||
|
||||
void NavigationPaneHelper::setShowInExplorerNavigationPane(bool show)
|
||||
@@ -139,7 +144,9 @@ void NavigationPaneHelper::updateCloudStorageRegistry()
|
||||
#else
|
||||
// This code path should only occur on Windows (the config will be false, and the checkbox invisible on other platforms).
|
||||
// Add runtime checks rather than #ifdefing out the whole code to help catch breakages when developing on other platforms.
|
||||
Q_ASSERT(false);
|
||||
|
||||
// Don't crash, by any means!
|
||||
// Q_ASSERT(false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>563</width>
|
||||
<width>516</width>
|
||||
<height>444</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
||||
@@ -73,6 +73,17 @@ void OcsShareJob::setPassword(const QString &shareId, const QString &password)
|
||||
start();
|
||||
}
|
||||
|
||||
void OcsShareJob::setNote(const QString &shareId, const QString ¬e)
|
||||
{
|
||||
appendPath(shareId);
|
||||
setVerb("PUT");
|
||||
|
||||
addParam(QString::fromLatin1("note"), note);
|
||||
_value = note;
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
void OcsShareJob::setPublicUpload(const QString &shareId, bool publicUpload)
|
||||
{
|
||||
appendPath(shareId);
|
||||
|
||||
@@ -61,6 +61,14 @@ public:
|
||||
*/
|
||||
void setExpireDate(const QString &shareId, const QDate &date);
|
||||
|
||||
/**
|
||||
* Set note a share
|
||||
*
|
||||
* @param note The note to a share, if the note is empty the
|
||||
* share will be removed
|
||||
*/
|
||||
void setNote(const QString &shareId, const QString ¬e);
|
||||
|
||||
/**
|
||||
* Set the password of a share
|
||||
*
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include "application.h"
|
||||
#include "owncloudgui.h"
|
||||
#include "ocsnavigationappsjob.h"
|
||||
#include "theme.h"
|
||||
#include "folderman.h"
|
||||
#include "progressdispatcher.h"
|
||||
@@ -46,9 +45,11 @@
|
||||
#include <QX11Info>
|
||||
#endif
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QQmlEngine>
|
||||
#include <QQmlComponent>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQuickItem>
|
||||
#include <QQmlContext>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
@@ -62,22 +63,32 @@ ownCloudGui::ownCloudGui(Application *parent)
|
||||
#ifdef WITH_LIBCLOUDPROVIDERS
|
||||
, _bus(QDBusConnection::sessionBus())
|
||||
#endif
|
||||
, _recentActionsMenu(nullptr)
|
||||
, _app(parent)
|
||||
{
|
||||
_tray = new Systray();
|
||||
_tray = Systray::instance();
|
||||
_tray->setParent(this);
|
||||
|
||||
// for the beginning, set the offline icon until the account was verified
|
||||
_tray->setIcon(Theme::instance()->folderOfflineIcon(/*systray?*/ true, /*currently visible?*/ false));
|
||||
_tray->setIcon(Theme::instance()->folderOfflineIcon(/*systray?*/ true));
|
||||
|
||||
_tray->show();
|
||||
|
||||
connect(_tray.data(), &QSystemTrayIcon::activated,
|
||||
this, &ownCloudGui::slotTrayClicked);
|
||||
|
||||
setupActions();
|
||||
setupContextMenu();
|
||||
connect(_tray.data(), &Systray::pauseSync,
|
||||
this, &ownCloudGui::slotPauseAllFolders);
|
||||
|
||||
_tray->show();
|
||||
connect(_tray.data(), &Systray::pauseSync,
|
||||
this, &ownCloudGui::slotUnpauseAllFolders);
|
||||
|
||||
connect(_tray.data(), &Systray::openHelp,
|
||||
this, &ownCloudGui::slotHelp);
|
||||
|
||||
connect(_tray.data(), &Systray::openSettings,
|
||||
this, &ownCloudGui::slotShowSettings);
|
||||
|
||||
connect(_tray.data(), &Systray::shutdown,
|
||||
this, &ownCloudGui::slotShutdown);
|
||||
|
||||
ProgressDispatcher *pd = ProgressDispatcher::instance();
|
||||
connect(pd, &ProgressDispatcher::progressInfo, this,
|
||||
@@ -87,17 +98,18 @@ ownCloudGui::ownCloudGui(Application *parent)
|
||||
connect(folderMan, &FolderMan::folderSyncStateChange,
|
||||
this, &ownCloudGui::slotSyncStateChange);
|
||||
|
||||
connect(AccountManager::instance(), &AccountManager::accountAdded,
|
||||
this, &ownCloudGui::updateContextMenuNeeded);
|
||||
connect(AccountManager::instance(), &AccountManager::accountRemoved,
|
||||
this, &ownCloudGui::updateContextMenuNeeded);
|
||||
|
||||
connect(Logger::instance(), &Logger::guiLog,
|
||||
this, &ownCloudGui::slotShowTrayMessage);
|
||||
connect(Logger::instance(), &Logger::optionalGuiLog,
|
||||
this, &ownCloudGui::slotShowOptionalTrayMessage);
|
||||
connect(Logger::instance(), &Logger::guiMessage,
|
||||
this, &ownCloudGui::slotShowGuiMessage);
|
||||
|
||||
}
|
||||
|
||||
void ownCloudGui::createTray()
|
||||
{
|
||||
_tray->create();
|
||||
}
|
||||
|
||||
#ifdef WITH_LIBCLOUDPROVIDERS
|
||||
@@ -140,13 +152,6 @@ void ownCloudGui::slotOpenSettingsDialog()
|
||||
|
||||
void ownCloudGui::slotTrayClicked(QSystemTrayIcon::ActivationReason reason)
|
||||
{
|
||||
if (_workaroundFakeDoubleClick) {
|
||||
static QElapsedTimer last_click;
|
||||
if (last_click.isValid() && last_click.elapsed() < 200) {
|
||||
return;
|
||||
}
|
||||
last_click.start();
|
||||
}
|
||||
|
||||
// Left click
|
||||
if (reason == QSystemTrayIcon::Trigger) {
|
||||
@@ -158,17 +163,15 @@ void ownCloudGui::slotTrayClicked(QSystemTrayIcon::ActivationReason reason)
|
||||
Q_ASSERT(shareDialog.data());
|
||||
raiseDialog(shareDialog);
|
||||
}
|
||||
} else if (_tray->isOpen()) {
|
||||
_tray->hideWindow();
|
||||
} else {
|
||||
#ifdef Q_OS_MAC
|
||||
// on macOS, a left click always opens menu.
|
||||
// However if the settings dialog is already visible but hidden
|
||||
// by other applications, this will bring it to the front.
|
||||
if (!_settingsDialog.isNull() && _settingsDialog->isVisible()) {
|
||||
raiseDialog(_settingsDialog.data());
|
||||
if (AccountManager::instance()->accounts().isEmpty()) {
|
||||
this->slotOpenSettingsDialog();
|
||||
} else {
|
||||
_tray->showWindow();
|
||||
}
|
||||
#else
|
||||
slotOpenSettingsDialog();
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
// FIXME: Also make sure that any auto updater dialogue https://github.com/owncloud/client/issues/5613
|
||||
@@ -178,7 +181,6 @@ void ownCloudGui::slotTrayClicked(QSystemTrayIcon::ActivationReason reason)
|
||||
void ownCloudGui::slotSyncStateChange(Folder *folder)
|
||||
{
|
||||
slotComputeOverallSyncStatus();
|
||||
updateContextMenuNeeded();
|
||||
|
||||
if (!folder) {
|
||||
return; // Valid, just a general GUI redraw was needed.
|
||||
@@ -194,16 +196,11 @@ void ownCloudGui::slotSyncStateChange(Folder *folder)
|
||||
|| result.status() == SyncResult::Error) {
|
||||
Logger::instance()->enterNextLogFile();
|
||||
}
|
||||
|
||||
if (result.status() == SyncResult::NotYetStarted) {
|
||||
_settingsDialog->slotRefreshActivity(folder->accountState());
|
||||
}
|
||||
}
|
||||
|
||||
void ownCloudGui::slotFoldersChanged()
|
||||
{
|
||||
slotComputeOverallSyncStatus();
|
||||
updateContextMenuNeeded();
|
||||
}
|
||||
|
||||
void ownCloudGui::slotOpenPath(const QString &path)
|
||||
@@ -213,7 +210,6 @@ void ownCloudGui::slotOpenPath(const QString &path)
|
||||
|
||||
void ownCloudGui::slotAccountStateChanged()
|
||||
{
|
||||
updateContextMenuNeeded();
|
||||
slotComputeOverallSyncStatus();
|
||||
}
|
||||
|
||||
@@ -239,7 +235,7 @@ void ownCloudGui::slotComputeOverallSyncStatus()
|
||||
// Don't overwrite the status if we're currently syncing
|
||||
if (FolderMan::instance()->currentSyncFolder())
|
||||
return;
|
||||
_actionStatus->setText(text);
|
||||
//_actionStatus->setText(text);
|
||||
};
|
||||
|
||||
foreach (auto a, AccountManager::instance()->accounts()) {
|
||||
@@ -259,7 +255,7 @@ void ownCloudGui::slotComputeOverallSyncStatus()
|
||||
}
|
||||
|
||||
if (!problemAccounts.empty()) {
|
||||
_tray->setIcon(Theme::instance()->folderOfflineIcon(true, contextMenuVisible()));
|
||||
_tray->setIcon(Theme::instance()->folderOfflineIcon(true));
|
||||
if (allDisconnected) {
|
||||
setStatusText(tr("Disconnected"));
|
||||
} else {
|
||||
@@ -289,12 +285,12 @@ void ownCloudGui::slotComputeOverallSyncStatus()
|
||||
}
|
||||
|
||||
if (allSignedOut) {
|
||||
_tray->setIcon(Theme::instance()->folderOfflineIcon(true, contextMenuVisible()));
|
||||
_tray->setIcon(Theme::instance()->folderOfflineIcon(true));
|
||||
_tray->setToolTip(tr("Please sign in"));
|
||||
setStatusText(tr("Signed out"));
|
||||
return;
|
||||
} else if (allPaused) {
|
||||
_tray->setIcon(Theme::instance()->syncStateIcon(SyncResult::Paused, true, contextMenuVisible()));
|
||||
_tray->setIcon(Theme::instance()->syncStateIcon(SyncResult::Paused, true));
|
||||
_tray->setToolTip(tr("Account synchronization is disabled"));
|
||||
setStatusText(tr("Synchronization is paused"));
|
||||
return;
|
||||
@@ -321,7 +317,7 @@ void ownCloudGui::slotComputeOverallSyncStatus()
|
||||
iconStatus = SyncResult::Problem;
|
||||
}
|
||||
|
||||
QIcon statusIcon = Theme::instance()->syncStateIcon(iconStatus, true, contextMenuVisible());
|
||||
QIcon statusIcon = Theme::instance()->syncStateIcon(iconStatus, true);
|
||||
_tray->setIcon(statusIcon);
|
||||
|
||||
// create the tray blob message, check if we have an defined state
|
||||
@@ -359,381 +355,6 @@ void ownCloudGui::slotComputeOverallSyncStatus()
|
||||
}
|
||||
}
|
||||
|
||||
void ownCloudGui::addAccountContextMenu(AccountStatePtr accountState, QMenu *menu, bool separateMenu)
|
||||
{
|
||||
// Only show the name in the action if it's not part of an
|
||||
// account sub menu.
|
||||
QString browserOpen = tr("Open in browser");
|
||||
if (!separateMenu) {
|
||||
browserOpen = tr("Open %1 in browser").arg(Theme::instance()->appNameGUI());
|
||||
}
|
||||
auto actionOpenoC = menu->addAction(browserOpen);
|
||||
actionOpenoC->setProperty(propertyAccountC, QVariant::fromValue(accountState->account()));
|
||||
QObject::connect(actionOpenoC, &QAction::triggered, this, &ownCloudGui::slotOpenOwnCloud);
|
||||
|
||||
FolderMan *folderMan = FolderMan::instance();
|
||||
bool firstFolder = true;
|
||||
bool singleSyncFolder = folderMan->map().size() == 1 && Theme::instance()->singleSyncFolder();
|
||||
bool onePaused = false;
|
||||
bool allPaused = true;
|
||||
foreach (Folder *folder, folderMan->map()) {
|
||||
if (folder->accountState() != accountState.data()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (folder->syncPaused()) {
|
||||
onePaused = true;
|
||||
} else {
|
||||
allPaused = false;
|
||||
}
|
||||
|
||||
if (firstFolder && !singleSyncFolder) {
|
||||
firstFolder = false;
|
||||
menu->addSeparator();
|
||||
menu->addAction(tr("Managed Folders:"))->setDisabled(true);
|
||||
}
|
||||
|
||||
QAction *action = menu->addAction(tr("Open folder '%1'").arg(folder->shortGuiLocalPath()));
|
||||
auto alias = folder->alias();
|
||||
connect(action, &QAction::triggered, this, [this, alias] { this->slotFolderOpenAction(alias); });
|
||||
}
|
||||
|
||||
menu->addSeparator();
|
||||
if (separateMenu) {
|
||||
if (onePaused) {
|
||||
QAction *enable = menu->addAction(tr("Resume all folders"));
|
||||
enable->setProperty(propertyAccountC, QVariant::fromValue(accountState));
|
||||
connect(enable, &QAction::triggered, this, &ownCloudGui::slotUnpauseAllFolders);
|
||||
}
|
||||
if (!allPaused) {
|
||||
QAction *enable = menu->addAction(tr("Pause all folders"));
|
||||
enable->setProperty(propertyAccountC, QVariant::fromValue(accountState));
|
||||
connect(enable, &QAction::triggered, this, &ownCloudGui::slotPauseAllFolders);
|
||||
}
|
||||
|
||||
if (accountState->isSignedOut()) {
|
||||
QAction *signin = menu->addAction(tr("Log in …"));
|
||||
signin->setProperty(propertyAccountC, QVariant::fromValue(accountState));
|
||||
connect(signin, &QAction::triggered, this, &ownCloudGui::slotLogin);
|
||||
} else {
|
||||
QAction *signout = menu->addAction(tr("Log out"));
|
||||
signout->setProperty(propertyAccountC, QVariant::fromValue(accountState));
|
||||
connect(signout, &QAction::triggered, this, &ownCloudGui::slotLogout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ownCloudGui::slotContextMenuAboutToShow()
|
||||
{
|
||||
_contextMenuVisibleManual = true;
|
||||
|
||||
// Update icon in sys tray, as it might change depending on the context menu state
|
||||
slotComputeOverallSyncStatus();
|
||||
|
||||
if (!_workaroundNoAboutToShowUpdate) {
|
||||
updateContextMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void ownCloudGui::slotContextMenuAboutToHide()
|
||||
{
|
||||
_contextMenuVisibleManual = false;
|
||||
|
||||
// Update icon in sys tray, as it might change depending on the context menu state
|
||||
slotComputeOverallSyncStatus();
|
||||
}
|
||||
|
||||
bool ownCloudGui::contextMenuVisible() const
|
||||
{
|
||||
// On some platforms isVisible doesn't work and always returns false,
|
||||
// elsewhere aboutToHide is unreliable.
|
||||
if (_workaroundManualVisibility)
|
||||
return _contextMenuVisibleManual;
|
||||
return _contextMenu->isVisible();
|
||||
}
|
||||
|
||||
static bool minimalTrayMenu()
|
||||
{
|
||||
static QByteArray var = qgetenv("OWNCLOUD_MINIMAL_TRAY_MENU");
|
||||
return !var.isEmpty();
|
||||
}
|
||||
|
||||
static bool updateWhileVisible()
|
||||
{
|
||||
static QByteArray var = qgetenv("OWNCLOUD_TRAY_UPDATE_WHILE_VISIBLE");
|
||||
if (var == "1") {
|
||||
return true;
|
||||
} else if (var == "0") {
|
||||
return false;
|
||||
} else {
|
||||
// triggers bug on OS X: https://bugreports.qt.io/browse/QTBUG-54845
|
||||
// or flickering on Xubuntu
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static QByteArray envForceQDBusTrayWorkaround()
|
||||
{
|
||||
static QByteArray var = qgetenv("OWNCLOUD_FORCE_QDBUS_TRAY_WORKAROUND");
|
||||
return var;
|
||||
}
|
||||
|
||||
static QByteArray envForceWorkaroundShowAndHideTray()
|
||||
{
|
||||
static QByteArray var = qgetenv("OWNCLOUD_FORCE_TRAY_SHOW_HIDE");
|
||||
return var;
|
||||
}
|
||||
|
||||
static QByteArray envForceWorkaroundNoAboutToShowUpdate()
|
||||
{
|
||||
static QByteArray var = qgetenv("OWNCLOUD_FORCE_TRAY_NO_ABOUT_TO_SHOW");
|
||||
return var;
|
||||
}
|
||||
|
||||
static QByteArray envForceWorkaroundFakeDoubleClick()
|
||||
{
|
||||
static QByteArray var = qgetenv("OWNCLOUD_FORCE_TRAY_FAKE_DOUBLE_CLICK");
|
||||
return var;
|
||||
}
|
||||
|
||||
static QByteArray envForceWorkaroundManualVisibility()
|
||||
{
|
||||
static QByteArray var = qgetenv("OWNCLOUD_FORCE_TRAY_MANUAL_VISIBILITY");
|
||||
return var;
|
||||
}
|
||||
|
||||
void ownCloudGui::setupContextMenu()
|
||||
{
|
||||
if (_contextMenu) {
|
||||
return;
|
||||
}
|
||||
|
||||
_contextMenu.reset(new QMenu());
|
||||
_contextMenu->setTitle(Theme::instance()->appNameGUI());
|
||||
|
||||
_recentActionsMenu = new QMenu(tr("Recent Changes"), _contextMenu.data());
|
||||
|
||||
// this must be called only once after creating the context menu, or
|
||||
// it will trigger a bug in Ubuntu's SNI bridge patch (11.10, 12.04).
|
||||
_tray->setContextMenu(_contextMenu.data());
|
||||
|
||||
// The tray menu is surprisingly problematic. Being able to switch to
|
||||
// a minimal version of it is a useful workaround and testing tool.
|
||||
if (minimalTrayMenu()) {
|
||||
_contextMenu->addAction(_actionQuit);
|
||||
return;
|
||||
}
|
||||
|
||||
auto applyEnvVariable = [](bool *sw, const QByteArray &value) {
|
||||
if (value == "1")
|
||||
*sw = true;
|
||||
if (value == "0")
|
||||
*sw = false;
|
||||
};
|
||||
|
||||
// This is an old compound flag that people might still depend on
|
||||
bool qdbusmenuWorkarounds = false;
|
||||
applyEnvVariable(&qdbusmenuWorkarounds, envForceQDBusTrayWorkaround());
|
||||
if (qdbusmenuWorkarounds) {
|
||||
_workaroundFakeDoubleClick = true;
|
||||
_workaroundNoAboutToShowUpdate = true;
|
||||
_workaroundShowAndHideTray = true;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
// https://bugreports.qt.io/browse/QTBUG-54633
|
||||
_workaroundNoAboutToShowUpdate = true;
|
||||
_workaroundManualVisibility = true;
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
// For KDE sessions if the platform plugin is missing,
|
||||
// neither aboutToShow() updates nor the isVisible() call
|
||||
// work. At least aboutToHide is reliable.
|
||||
// https://github.com/owncloud/client/issues/6545
|
||||
static QByteArray xdgCurrentDesktop = qgetenv("XDG_CURRENT_DESKTOP");
|
||||
static QByteArray desktopSession = qgetenv("DESKTOP_SESSION");
|
||||
bool isKde =
|
||||
xdgCurrentDesktop.contains("KDE")
|
||||
|| desktopSession.contains("plasma")
|
||||
|| desktopSession.contains("kde");
|
||||
QObject *platformMenu = reinterpret_cast<QObject *>(_tray->contextMenu()->platformMenu());
|
||||
if (isKde && platformMenu && platformMenu->metaObject()->className() == QLatin1String("QDBusPlatformMenu")) {
|
||||
_workaroundManualVisibility = true;
|
||||
_workaroundNoAboutToShowUpdate = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
applyEnvVariable(&_workaroundNoAboutToShowUpdate, envForceWorkaroundNoAboutToShowUpdate());
|
||||
applyEnvVariable(&_workaroundFakeDoubleClick, envForceWorkaroundFakeDoubleClick());
|
||||
applyEnvVariable(&_workaroundShowAndHideTray, envForceWorkaroundShowAndHideTray());
|
||||
applyEnvVariable(&_workaroundManualVisibility, envForceWorkaroundManualVisibility());
|
||||
|
||||
qCInfo(lcApplication) << "Tray menu workarounds:"
|
||||
<< "noabouttoshow:" << _workaroundNoAboutToShowUpdate
|
||||
<< "fakedoubleclick:" << _workaroundFakeDoubleClick
|
||||
<< "showhide:" << _workaroundShowAndHideTray
|
||||
<< "manualvisibility:" << _workaroundManualVisibility;
|
||||
|
||||
|
||||
connect(&_delayedTrayUpdateTimer, &QTimer::timeout, this, &ownCloudGui::updateContextMenu);
|
||||
_delayedTrayUpdateTimer.setInterval(2 * 1000);
|
||||
_delayedTrayUpdateTimer.setSingleShot(true);
|
||||
|
||||
connect(_contextMenu.data(), SIGNAL(aboutToShow()), SLOT(slotContextMenuAboutToShow()));
|
||||
// unfortunately aboutToHide is unreliable, it seems to work on OSX though
|
||||
connect(_contextMenu.data(), SIGNAL(aboutToHide()), SLOT(slotContextMenuAboutToHide()));
|
||||
|
||||
// Populate the context menu now.
|
||||
updateContextMenu();
|
||||
}
|
||||
|
||||
void ownCloudGui::updateContextMenu()
|
||||
{
|
||||
if (minimalTrayMenu()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If it's visible, we can't update live, and it won't be updated lazily: reschedule
|
||||
if (contextMenuVisible() && !updateWhileVisible() && _workaroundNoAboutToShowUpdate) {
|
||||
if (!_delayedTrayUpdateTimer.isActive()) {
|
||||
_delayedTrayUpdateTimer.start();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (_workaroundShowAndHideTray) {
|
||||
// To make tray menu updates work with these bugs (see setupContextMenu)
|
||||
// we need to hide and show the tray icon. We don't want to do that
|
||||
// while it's visible!
|
||||
if (contextMenuVisible()) {
|
||||
if (!_delayedTrayUpdateTimer.isActive()) {
|
||||
_delayedTrayUpdateTimer.start();
|
||||
}
|
||||
return;
|
||||
}
|
||||
_tray->hide();
|
||||
}
|
||||
|
||||
_contextMenu->clear();
|
||||
slotRebuildRecentMenus();
|
||||
|
||||
// We must call deleteLater because we might be called from the press in one of the actions.
|
||||
foreach (auto menu, _accountMenus) {
|
||||
menu->deleteLater();
|
||||
}
|
||||
_accountMenus.clear();
|
||||
|
||||
auto accountList = AccountManager::instance()->accounts();
|
||||
|
||||
bool isConfigured = (!accountList.isEmpty());
|
||||
bool atLeastOneConnected = false;
|
||||
bool atLeastOnePaused = false;
|
||||
bool atLeastOneNotPaused = false;
|
||||
foreach (auto a, accountList) {
|
||||
if (a->isConnected()) {
|
||||
atLeastOneConnected = true;
|
||||
}
|
||||
}
|
||||
foreach (auto f, FolderMan::instance()->map()) {
|
||||
if (f->syncPaused()) {
|
||||
atLeastOnePaused = true;
|
||||
} else {
|
||||
atLeastOneNotPaused = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (accountList.count() > 1) {
|
||||
foreach (AccountStatePtr account, accountList) {
|
||||
QMenu *accountMenu = new QMenu(account->account()->displayName(), _contextMenu.data());
|
||||
_accountMenus.append(accountMenu);
|
||||
_contextMenu->addMenu(accountMenu);
|
||||
|
||||
addAccountContextMenu(account, accountMenu, true);
|
||||
fetchNavigationApps(account);
|
||||
}
|
||||
} else if (accountList.count() == 1) {
|
||||
addAccountContextMenu(accountList.first(), _contextMenu.data(), false);
|
||||
fetchNavigationApps(accountList.first());
|
||||
}
|
||||
|
||||
_contextMenu->addSeparator();
|
||||
|
||||
_contextMenu->addAction(_actionStatus);
|
||||
if (isConfigured && atLeastOneConnected) {
|
||||
_contextMenu->addMenu(_recentActionsMenu);
|
||||
}
|
||||
|
||||
_contextMenu->addSeparator();
|
||||
|
||||
if (_navLinksMenu) {
|
||||
_contextMenu->addMenu(_navLinksMenu);
|
||||
}
|
||||
|
||||
_contextMenu->addSeparator();
|
||||
|
||||
if (accountList.isEmpty()) {
|
||||
_contextMenu->addAction(_actionNewAccountWizard);
|
||||
}
|
||||
_contextMenu->addAction(_actionSettings);
|
||||
if (!Theme::instance()->helpUrl().isEmpty()) {
|
||||
_contextMenu->addAction(_actionHelp);
|
||||
}
|
||||
|
||||
if (_actionCrash) {
|
||||
_contextMenu->addAction(_actionCrash);
|
||||
}
|
||||
|
||||
_contextMenu->addSeparator();
|
||||
|
||||
if (atLeastOnePaused) {
|
||||
QString text;
|
||||
if (accountList.count() > 1) {
|
||||
text = tr("Resume all synchronization");
|
||||
} else {
|
||||
text = tr("Resume synchronization");
|
||||
}
|
||||
QAction *action = _contextMenu->addAction(text);
|
||||
connect(action, &QAction::triggered, this, &ownCloudGui::slotUnpauseAllFolders);
|
||||
}
|
||||
if (atLeastOneNotPaused) {
|
||||
QString text;
|
||||
if (accountList.count() > 1) {
|
||||
text = tr("Pause all synchronization");
|
||||
} else {
|
||||
text = tr("Pause synchronization");
|
||||
}
|
||||
QAction *action = _contextMenu->addAction(text);
|
||||
connect(action, &QAction::triggered, this, &ownCloudGui::slotPauseAllFolders);
|
||||
}
|
||||
_contextMenu->addAction(_actionQuit);
|
||||
|
||||
if (_workaroundShowAndHideTray) {
|
||||
_tray->show();
|
||||
}
|
||||
}
|
||||
|
||||
void ownCloudGui::updateContextMenuNeeded()
|
||||
{
|
||||
// if it's visible and we can update live: update now
|
||||
if (contextMenuVisible() && updateWhileVisible()) {
|
||||
// Note: don't update while visible on OSX
|
||||
// https://bugreports.qt.io/browse/QTBUG-54845
|
||||
updateContextMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
// if we can't lazily update: update later
|
||||
if (_workaroundNoAboutToShowUpdate) {
|
||||
// Note: don't update immediately even in the invisible case
|
||||
// as that can lead to extremely frequent menu updates
|
||||
if (!_delayedTrayUpdateTimer.isActive()) {
|
||||
_delayedTrayUpdateTimer.start();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void ownCloudGui::slotShowTrayMessage(const QString &title, const QString &msg)
|
||||
{
|
||||
if (_tray)
|
||||
@@ -747,7 +368,6 @@ void ownCloudGui::slotShowOptionalTrayMessage(const QString &title, const QStrin
|
||||
slotShowTrayMessage(title, msg);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* open the folder with the given Alias
|
||||
*/
|
||||
@@ -771,156 +391,17 @@ void ownCloudGui::slotFolderOpenAction(const QString &alias)
|
||||
}
|
||||
}
|
||||
|
||||
void ownCloudGui::setupActions()
|
||||
{
|
||||
_actionStatus = new QAction(tr("Unknown status"), this);
|
||||
_actionStatus->setEnabled(false);
|
||||
_navLinksMenu = new QMenu(tr("Apps"));
|
||||
_navLinksMenu->setEnabled(false);
|
||||
_actionSettings = new QAction(tr("Settings …"), this);
|
||||
_actionNewAccountWizard = new QAction(tr("New account …"), this);
|
||||
_actionRecent = new QAction(tr("View more activity …"), this);
|
||||
_actionRecent->setEnabled(true);
|
||||
|
||||
QObject::connect(_actionRecent, &QAction::triggered, this, &ownCloudGui::slotShowSyncProtocol);
|
||||
QObject::connect(_actionSettings, &QAction::triggered, this, &ownCloudGui::slotShowSettings);
|
||||
QObject::connect(_actionNewAccountWizard, &QAction::triggered, this, &ownCloudGui::slotNewAccountWizard);
|
||||
_actionHelp = new QAction(tr("Help"), this);
|
||||
QObject::connect(_actionHelp, &QAction::triggered, this, &ownCloudGui::slotHelp);
|
||||
_actionQuit = new QAction(tr("Quit %1").arg(Theme::instance()->appNameGUI()), this);
|
||||
QObject::connect(_actionQuit, SIGNAL(triggered(bool)), _app, SLOT(quit()));
|
||||
|
||||
if (_app->debugMode()) {
|
||||
_actionCrash = new QAction(tr("Crash now", "Only shows in debug mode to allow testing the crash handler"), this);
|
||||
connect(_actionCrash, &QAction::triggered, _app, &Application::slotCrash);
|
||||
} else {
|
||||
_actionCrash = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ownCloudGui::slotEtagResponseHeaderReceived(const QByteArray &value, int statusCode){
|
||||
if(statusCode == 200){
|
||||
qCDebug(lcApplication) << "New navigation apps ETag Response Header received " << value;
|
||||
auto account = qvariant_cast<AccountStatePtr>(sender()->property(propertyAccountC));
|
||||
account->setNavigationAppsEtagResponseHeader(value);
|
||||
}
|
||||
}
|
||||
|
||||
void ownCloudGui::fetchNavigationApps(AccountStatePtr account){
|
||||
OcsNavigationAppsJob *job = new OcsNavigationAppsJob(account->account());
|
||||
job->setProperty(propertyAccountC, QVariant::fromValue(account));
|
||||
job->addRawHeader("If-None-Match", account->navigationAppsEtagResponseHeader());
|
||||
connect(job, &OcsNavigationAppsJob::appsJobFinished, this, &ownCloudGui::slotNavigationAppsFetched);
|
||||
connect(job, &OcsNavigationAppsJob::etagResponseHeaderReceived, this, &ownCloudGui::slotEtagResponseHeaderReceived);
|
||||
connect(job, &OcsNavigationAppsJob::ocsError, this, &ownCloudGui::slotOcsError);
|
||||
job->getNavigationApps();
|
||||
}
|
||||
|
||||
void ownCloudGui::buildNavigationAppsMenu(AccountStatePtr account, QMenu *accountMenu){
|
||||
auto navLinks = _navApps.value(account);
|
||||
|
||||
_navLinksMenu->clear();
|
||||
_navLinksMenu->setEnabled(navLinks.size() > 0);
|
||||
|
||||
if(navLinks.size() > 0){
|
||||
// when there is only one account add the nav links above the settings
|
||||
QAction *actionBefore = _actionSettings;
|
||||
|
||||
// when there is more than one account add the nav links above pause/unpause folder or logout action
|
||||
if(AccountManager::instance()->accounts().size() > 1){
|
||||
foreach(QAction *action, accountMenu->actions()){
|
||||
|
||||
// pause/unpause folder and logout actions have propertyAccountC
|
||||
if(auto actionAccount = qvariant_cast<AccountStatePtr>(action->property(propertyAccountC))){
|
||||
if(actionAccount == account){
|
||||
actionBefore = action;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create submenu with links
|
||||
foreach (const QJsonValue &value, navLinks) {
|
||||
auto navLink = value.toObject();
|
||||
QAction *action = new QAction(navLink.value("name").toString(), this);
|
||||
QUrl href(navLink.value("href").toString());
|
||||
connect(action, &QAction::triggered, this, [href] { QDesktopServices::openUrl(href); });
|
||||
_navLinksMenu->addAction(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ownCloudGui::slotNavigationAppsFetched(const QJsonDocument &reply, int statusCode)
|
||||
{
|
||||
if(auto account = qvariant_cast<AccountStatePtr>(sender()->property(propertyAccountC))){
|
||||
if (statusCode == 304) {
|
||||
qCWarning(lcApplication) << "Status code " << statusCode << " Not Modified - No new navigation apps.";
|
||||
} else {
|
||||
if(!reply.isEmpty()){
|
||||
auto element = reply.object().value("ocs").toObject().value("data");
|
||||
auto navLinks = element.toArray();
|
||||
_navApps.insert(account, navLinks);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO see pull #523
|
||||
auto accountList = AccountManager::instance()->accounts();
|
||||
if(accountList.size() > 1){
|
||||
// the list of apps will be displayed under the account that it belongs to
|
||||
foreach (QMenu *accountMenu, _accountMenus) {
|
||||
if(accountMenu->title() == account->account()->displayName()){
|
||||
buildNavigationAppsMenu(account, accountMenu);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if(accountList.size() == 1){
|
||||
buildNavigationAppsMenu(account, _contextMenu.data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ownCloudGui::slotOcsError(int statusCode, const QString &message)
|
||||
{
|
||||
emit serverError(statusCode, message);
|
||||
}
|
||||
|
||||
void ownCloudGui::slotRebuildRecentMenus()
|
||||
{
|
||||
_recentActionsMenu->clear();
|
||||
if (!_recentItemsActions.isEmpty()) {
|
||||
foreach (QAction *a, _recentItemsActions) {
|
||||
_recentActionsMenu->addAction(a);
|
||||
}
|
||||
_recentActionsMenu->addSeparator();
|
||||
} else {
|
||||
_recentActionsMenu->addAction(tr("No items synced recently"))->setEnabled(false);
|
||||
}
|
||||
// add a more... entry.
|
||||
_recentActionsMenu->addAction(_actionRecent);
|
||||
}
|
||||
|
||||
/// Returns true if the completion of a given item should show up in the
|
||||
/// 'Recent Activity' menu
|
||||
static bool shouldShowInRecentsMenu(const SyncFileItem &item)
|
||||
{
|
||||
return !Progress::isIgnoredKind(item._status)
|
||||
&& item._instruction != CSYNC_INSTRUCTION_EVAL
|
||||
&& item._instruction != CSYNC_INSTRUCTION_NONE;
|
||||
}
|
||||
|
||||
|
||||
void ownCloudGui::slotUpdateProgress(const QString &folder, const ProgressInfo &progress)
|
||||
{
|
||||
Q_UNUSED(folder);
|
||||
|
||||
if (progress.status() == ProgressInfo::Discovery) {
|
||||
if (!progress._currentDiscoveredRemoteFolder.isEmpty()) {
|
||||
_actionStatus->setText(tr("Checking for changes in remote '%1'")
|
||||
.arg(progress._currentDiscoveredRemoteFolder));
|
||||
//_actionStatus->setText(tr("Checking for changes in remote '%1'")
|
||||
//.arg(progress._currentDiscoveredRemoteFolder));
|
||||
} else if (!progress._currentDiscoveredLocalFolder.isEmpty()) {
|
||||
_actionStatus->setText(tr("Checking for changes in local '%1'")
|
||||
.arg(progress._currentDiscoveredLocalFolder));
|
||||
//_actionStatus->setText(tr("Checking for changes in local '%1'")
|
||||
//.arg(progress._currentDiscoveredLocalFolder));
|
||||
}
|
||||
} else if (progress.status() == ProgressInfo::Done) {
|
||||
QTimer::singleShot(2000, this, &ownCloudGui::slotComputeOverallSyncStatus);
|
||||
@@ -943,7 +424,7 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const ProgressInfo &
|
||||
.arg(currentFile)
|
||||
.arg(totalFileCount);
|
||||
}
|
||||
_actionStatus->setText(msg);
|
||||
//_actionStatus->setText(msg);
|
||||
} else {
|
||||
QString totalSizeStr = Utility::octetsToString(progress.totalSize());
|
||||
QString msg;
|
||||
@@ -954,18 +435,10 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const ProgressInfo &
|
||||
msg = tr("Syncing %1")
|
||||
.arg(totalSizeStr);
|
||||
}
|
||||
_actionStatus->setText(msg);
|
||||
//_actionStatus->setText(msg);
|
||||
}
|
||||
|
||||
_actionRecent->setIcon(QIcon()); // Fixme: Set a "in-progress"-item eventually.
|
||||
|
||||
if (!progress._lastCompletedItem.isEmpty()
|
||||
&& shouldShowInRecentsMenu(progress._lastCompletedItem)) {
|
||||
if (Progress::isWarningKind(progress._lastCompletedItem._status)) {
|
||||
// display a warn icon if warnings happened.
|
||||
QIcon warnIcon(":/client/resources/warning");
|
||||
_actionRecent->setIcon(warnIcon);
|
||||
}
|
||||
if (!progress._lastCompletedItem.isEmpty()) {
|
||||
|
||||
QString kindStr = Progress::asResultString(progress._lastCompletedItem);
|
||||
QString timeStr = QTime::currentTime().toString("hh:mm");
|
||||
@@ -984,12 +457,6 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const ProgressInfo &
|
||||
_recentItemsActions.takeFirst()->deleteLater();
|
||||
}
|
||||
_recentItemsActions.append(action);
|
||||
|
||||
// Update the "Recent" menu if the context menu is being shown,
|
||||
// otherwise it'll be updated later, when the context menu is opened.
|
||||
if (updateWhileVisible() && contextMenuVisible()) {
|
||||
slotRebuildRecentMenus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1075,6 +542,11 @@ void ownCloudGui::slotShowSettings()
|
||||
raiseDialog(_settingsDialog.data());
|
||||
}
|
||||
|
||||
void ownCloudGui::slotSettingsDialogActivated()
|
||||
{
|
||||
emit isShowingSettingsDialog();
|
||||
}
|
||||
|
||||
void ownCloudGui::slotShowSyncProtocol()
|
||||
{
|
||||
slotShowSettings();
|
||||
@@ -1092,6 +564,7 @@ void ownCloudGui::slotShutdown()
|
||||
_settingsDialog->close();
|
||||
if (!_logBrowser.isNull())
|
||||
_logBrowser->deleteLater();
|
||||
_app->quit();
|
||||
}
|
||||
|
||||
void ownCloudGui::slotToggleLogBrowser()
|
||||
|
||||
@@ -63,25 +63,18 @@ public:
|
||||
void setupCloudProviders();
|
||||
bool cloudProviderApiAvailable();
|
||||
#endif
|
||||
|
||||
/// Whether the tray menu is visible
|
||||
bool contextMenuVisible() const;
|
||||
void createTray();
|
||||
|
||||
signals:
|
||||
void setupProxy();
|
||||
void serverError(int code, const QString &message);
|
||||
void isShowingSettingsDialog();
|
||||
|
||||
public slots:
|
||||
void setupContextMenu();
|
||||
void updateContextMenu();
|
||||
void updateContextMenuNeeded();
|
||||
void slotContextMenuAboutToShow();
|
||||
void slotContextMenuAboutToHide();
|
||||
void slotComputeOverallSyncStatus();
|
||||
void slotShowTrayMessage(const QString &title, const QString &msg);
|
||||
void slotShowOptionalTrayMessage(const QString &title, const QString &msg);
|
||||
void slotFolderOpenAction(const QString &alias);
|
||||
void slotRebuildRecentMenus();
|
||||
void slotUpdateProgress(const QString &folder, const ProgressInfo &progress);
|
||||
void slotShowGuiMessage(const QString &title, const QString &message);
|
||||
void slotFoldersChanged();
|
||||
@@ -93,12 +86,11 @@ public slots:
|
||||
void slotToggleLogBrowser();
|
||||
void slotOpenOwnCloud();
|
||||
void slotOpenSettingsDialog();
|
||||
void slotSettingsDialogActivated();
|
||||
void slotHelp();
|
||||
void slotOpenPath(const QString &path);
|
||||
void slotAccountStateChanged();
|
||||
void slotTrayMessageIfServerUnsupported(Account *account);
|
||||
void slotNavigationAppsFetched(const QJsonDocument &reply, int statusCode);
|
||||
void slotEtagResponseHeaderReceived(const QByteArray &value, int statusCode);
|
||||
|
||||
|
||||
/**
|
||||
@@ -112,9 +104,6 @@ public slots:
|
||||
|
||||
void slotRemoveDestroyedShareDialogs();
|
||||
|
||||
protected slots:
|
||||
void slotOcsError(int statusCode, const QString &message);
|
||||
|
||||
private slots:
|
||||
void slotLogin();
|
||||
void slotLogout();
|
||||
@@ -124,47 +113,21 @@ private slots:
|
||||
|
||||
private:
|
||||
void setPauseOnAllFoldersHelper(bool pause);
|
||||
void setupActions();
|
||||
void addAccountContextMenu(AccountStatePtr accountState, QMenu *menu, bool separateMenu);
|
||||
void fetchNavigationApps(AccountStatePtr account);
|
||||
void buildNavigationAppsMenu(AccountStatePtr account, QMenu *accountMenu);
|
||||
|
||||
QPointer<Systray> _tray;
|
||||
QPointer<SettingsDialog> _settingsDialog;
|
||||
QPointer<LogBrowser> _logBrowser;
|
||||
// tray's menu
|
||||
QScopedPointer<QMenu> _contextMenu;
|
||||
|
||||
// Manually tracking whether the context menu is visible via aboutToShow
|
||||
// and aboutToHide. Unfortunately aboutToHide isn't reliable everywhere
|
||||
// so this only gets used with _workaroundManualVisibility (when the tray's
|
||||
// isVisible() is unreliable)
|
||||
bool _contextMenuVisibleManual = false;
|
||||
|
||||
#ifdef WITH_LIBCLOUDPROVIDERS
|
||||
QDBusConnection _bus;
|
||||
#endif
|
||||
|
||||
QMenu *_recentActionsMenu;
|
||||
QVector<QMenu *> _accountMenus;
|
||||
bool _workaroundShowAndHideTray = false;
|
||||
bool _workaroundNoAboutToShowUpdate = false;
|
||||
bool _workaroundFakeDoubleClick = false;
|
||||
bool _workaroundManualVisibility = false;
|
||||
QTimer _delayedTrayUpdateTimer;
|
||||
QMap<QString, QPointer<ShareDialog>> _shareDialogs;
|
||||
|
||||
QAction *_actionNewAccountWizard;
|
||||
QAction *_actionSettings;
|
||||
QAction *_actionStatus;
|
||||
QAction *_actionEstimate;
|
||||
QAction *_actionRecent;
|
||||
QAction *_actionHelp;
|
||||
QAction *_actionQuit;
|
||||
QAction *_actionCrash;
|
||||
|
||||
QMenu *_navLinksMenu;
|
||||
QMap<AccountStatePtr, QJsonArray> _navApps;
|
||||
|
||||
QList<QAction *> _recentItemsActions;
|
||||
Application *_app;
|
||||
|
||||
@@ -407,7 +407,8 @@ void OwncloudSetupWizard::slotAuthError()
|
||||
errorMsg = tr("There was an invalid response to an authenticated webdav request");
|
||||
}
|
||||
|
||||
_ocWizard->show();
|
||||
// bring wizard to top
|
||||
_ocWizard->bringToTop();
|
||||
if (_ocWizard->currentId() == WizardCommon::Page_ShibbolethCreds || _ocWizard->currentId() == WizardCommon::Page_OAuthCreds || _ocWizard->currentId() == WizardCommon::Page_Flow2AuthCreds) {
|
||||
_ocWizard->back();
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef SERVERNOTIFICATIONHANDLER_H
|
||||
#define SERVERNOTIFICATIONHANDLER_H
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
#include "activitywidget.h"
|
||||
|
||||
class QJsonDocument;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class ServerNotificationHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ServerNotificationHandler(AccountState *accountState, QObject *parent = nullptr);
|
||||
static QMap<int, QIcon> iconCache;
|
||||
|
||||
signals:
|
||||
void newNotificationList(ActivityList);
|
||||
|
||||
public slots:
|
||||
void slotFetchNotifications();
|
||||
|
||||
private slots:
|
||||
void slotNotificationsReceived(const QJsonDocument &json, int statusCode);
|
||||
void slotEtagResponseHeaderReceived(const QByteArray &value, int statusCode);
|
||||
void slotIconDownloaded(QByteArray iconData);
|
||||
|
||||
private:
|
||||
QPointer<JsonApiJob> _notificationJob;
|
||||
AccountState *_accountState;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SERVERNOTIFICATIONHANDLER_H
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "configfile.h"
|
||||
#include "progressdispatcher.h"
|
||||
#include "owncloudgui.h"
|
||||
#include "activitywidget.h"
|
||||
#include "accountmanager.h"
|
||||
|
||||
#include <QLabel>
|
||||
@@ -127,6 +126,8 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent)
|
||||
connect(showLogWindow, &QAction::triggered, gui, &ownCloudGui::slotToggleLogBrowser);
|
||||
addAction(showLogWindow);
|
||||
|
||||
connect(this, &SettingsDialog::onActivate, gui, &ownCloudGui::slotSettingsDialogActivated);
|
||||
|
||||
customizeStyle();
|
||||
|
||||
cfg.restoreGeometry(this);
|
||||
@@ -163,6 +164,10 @@ void SettingsDialog::changeEvent(QEvent *e)
|
||||
// Notify the other widgets (Dark-/Light-Mode switching)
|
||||
emit styleChanged();
|
||||
break;
|
||||
case QEvent::ActivationChange:
|
||||
if(isActiveWindow())
|
||||
emit onActivate();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -183,39 +188,13 @@ void SettingsDialog::showFirstPage()
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::showActivityPage()
|
||||
{
|
||||
if (auto account = qvariant_cast<AccountState*>(sender()->property("account"))) {
|
||||
_activitySettings[account]->show();
|
||||
_ui->stack->setCurrentWidget(_activitySettings[account]);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::showIssuesList(AccountState *account) {
|
||||
for (auto it = _actionGroupWidgets.begin(); it != _actionGroupWidgets.end(); ++it) {
|
||||
/*for (auto it = _actionGroupWidgets.begin(); it != _actionGroupWidgets.end(); ++it) {
|
||||
if (it.value() == _activitySettings[account]) {
|
||||
it.key()->activate(QAction::ActionEvent::Trigger);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::activityAdded(AccountState *s){
|
||||
_ui->stack->addWidget(_activitySettings[s]);
|
||||
connect(_activitySettings[s], &ActivitySettings::guiLog, _gui,
|
||||
&ownCloudGui::slotShowOptionalTrayMessage);
|
||||
|
||||
ConfigFile cfg;
|
||||
_activitySettings[s]->setNotificationRefreshInterval(cfg.notificationRefreshInterval());
|
||||
|
||||
// Note: all the actions have a '\n' because the account name is in two lines and
|
||||
// all buttons must have the same size in order to keep a good layout
|
||||
QAction *action = createColorAwareAction(QLatin1String(":/client/resources/activity.png"), tr("Activity"));
|
||||
action->setProperty("account", QVariant::fromValue(s));
|
||||
_toolBar->insertAction(_actionBefore, action);
|
||||
_actionGroup->addAction(action);
|
||||
_actionGroupWidgets.insert(action, _activitySettings[s]);
|
||||
connect(action, &QAction::triggered, this, &SettingsDialog::showActivityPage);
|
||||
}*/
|
||||
}
|
||||
|
||||
void SettingsDialog::accountAdded(AccountState *s)
|
||||
@@ -223,14 +202,6 @@ void SettingsDialog::accountAdded(AccountState *s)
|
||||
auto height = _toolBar->sizeHint().height();
|
||||
bool brandingSingleAccount = !Theme::instance()->multiAccount();
|
||||
|
||||
_activitySettings[s] = new ActivitySettings(s, this);
|
||||
|
||||
// if this is not the first account, then before we continue to add more accounts we add a separator
|
||||
if(AccountManager::instance()->accounts().first().data() != s &&
|
||||
AccountManager::instance()->accounts().size() >= 1){
|
||||
_actionGroupWidgets.insert(_toolBar->insertSeparator(_actionBefore), _activitySettings[s]);
|
||||
}
|
||||
|
||||
QAction *accountAction;
|
||||
QImage avatar = s->account()->avatar();
|
||||
const QString actionText = brandingSingleAccount ? tr("Account") : s->account()->displayName();
|
||||
@@ -254,22 +225,15 @@ void SettingsDialog::accountAdded(AccountState *s)
|
||||
_actionGroupWidgets.insert(accountAction, accountSettings);
|
||||
_actionForAccount.insert(s->account().data(), accountAction);
|
||||
accountAction->trigger();
|
||||
|
||||
// Connect styleChanged event, to adapt (Dark-/Light-Mode switching)
|
||||
connect(this, &SettingsDialog::styleChanged, accountSettings, &AccountSettings::slotStyleChanged);
|
||||
|
||||
connect(accountSettings, &AccountSettings::folderChanged, _gui, &ownCloudGui::slotFoldersChanged);
|
||||
connect(accountSettings, &AccountSettings::openFolderAlias,
|
||||
_gui, &ownCloudGui::slotFolderOpenAction);
|
||||
connect(accountSettings, &AccountSettings::showIssuesList, this, &SettingsDialog::showIssuesList);
|
||||
connect(s->account().data(), &Account::accountChangedAvatar, this, &SettingsDialog::slotAccountAvatarChanged);
|
||||
connect(s->account().data(), &Account::accountChangedDisplayName, this, &SettingsDialog::slotAccountDisplayNameChanged);
|
||||
|
||||
// Refresh immediatly when getting online
|
||||
connect(s, &AccountState::isConnectedChanged, this, &SettingsDialog::slotRefreshActivityAccountStateSender);
|
||||
|
||||
activityAdded(s);
|
||||
slotRefreshActivity(s);
|
||||
// Connect styleChanged event, to adapt (Dark-/Light-Mode switching)
|
||||
connect(this, &SettingsDialog::styleChanged, accountSettings, &AccountSettings::slotStyleChanged);
|
||||
}
|
||||
|
||||
void SettingsDialog::slotAccountAvatarChanged()
|
||||
@@ -325,19 +289,6 @@ void SettingsDialog::accountRemoved(AccountState *s)
|
||||
_actionForAccount.remove(s->account().data());
|
||||
}
|
||||
|
||||
if(_activitySettings.contains(s)){
|
||||
_activitySettings[s]->slotRemoveAccount();
|
||||
_activitySettings[s]->hide();
|
||||
|
||||
// get the settings widget and the separator
|
||||
foreach(QAction *action, _actionGroupWidgets.keys(_activitySettings[s])){
|
||||
_actionGroupWidgets.remove(action);
|
||||
_toolBar->removeAction(action);
|
||||
}
|
||||
_toolBar->widgetForAction(_actionBefore)->hide();
|
||||
_activitySettings.remove(s);
|
||||
}
|
||||
|
||||
// Hide when the last account is deleted. We want to enter the same
|
||||
// state we'd be in the client was started up without an account
|
||||
// configured.
|
||||
@@ -407,15 +358,4 @@ QAction *SettingsDialog::createColorAwareAction(const QString &iconPath, const Q
|
||||
return createActionWithIcon(coloredIcon, text, iconPath);
|
||||
}
|
||||
|
||||
void SettingsDialog::slotRefreshActivityAccountStateSender()
|
||||
{
|
||||
slotRefreshActivity(qobject_cast<AccountState*>(sender()));
|
||||
}
|
||||
|
||||
void SettingsDialog::slotRefreshActivity(AccountState *accountState)
|
||||
{
|
||||
if (accountState->isConnected())
|
||||
_activitySettings[accountState]->slotRefresh();
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
@@ -37,7 +37,6 @@ class AccountSettings;
|
||||
class Application;
|
||||
class FolderMan;
|
||||
class ownCloudGui;
|
||||
class ActivitySettings;
|
||||
|
||||
/**
|
||||
* @brief The SettingsDialog class
|
||||
@@ -55,16 +54,14 @@ public:
|
||||
|
||||
public slots:
|
||||
void showFirstPage();
|
||||
void showActivityPage();
|
||||
void showIssuesList(AccountState *account);
|
||||
void slotSwitchPage(QAction *action);
|
||||
void slotRefreshActivity(AccountState *accountState);
|
||||
void slotRefreshActivityAccountStateSender();
|
||||
void slotAccountAvatarChanged();
|
||||
void slotAccountDisplayNameChanged();
|
||||
|
||||
signals:
|
||||
void styleChanged();
|
||||
void onActivate();
|
||||
|
||||
protected:
|
||||
void reject() override;
|
||||
@@ -77,7 +74,6 @@ private slots:
|
||||
|
||||
private:
|
||||
void customizeStyle();
|
||||
void activityAdded(AccountState *);
|
||||
|
||||
QAction *createColorAwareAction(const QString &iconName, const QString &fileName);
|
||||
QAction *createActionWithIcon(const QIcon &icon, const QString &text, const QString &iconPath = QString());
|
||||
@@ -94,7 +90,6 @@ private:
|
||||
QHash<Account *, QAction *> _actionForAccount;
|
||||
|
||||
QToolBar *_toolBar;
|
||||
QMap<AccountState *, ActivitySettings *> _activitySettings;
|
||||
|
||||
ownCloudGui *_gui;
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>693</width>
|
||||
<width>516</width>
|
||||
<height>457</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QFileIconProvider>
|
||||
#include <QInputDialog>
|
||||
#include <QPointer>
|
||||
#include <QPushButton>
|
||||
#include <QFrame>
|
||||
@@ -137,6 +138,7 @@ ShareDialog::ShareDialog(QPointer<AccountState> accountState,
|
||||
_manager = new ShareManager(accountState->account(), this);
|
||||
connect(_manager, &ShareManager::sharesFetched, this, &ShareDialog::slotSharesFetched);
|
||||
connect(_manager, &ShareManager::linkShareCreated, this, &ShareDialog::slotAddLinkShareWidget);
|
||||
connect(_manager, &ShareManager::linkShareRequiresPassword, this, &ShareDialog::slotLinkShareRequiresPassword);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +170,7 @@ void ShareDialog::initLinkShareWidget(){
|
||||
_emptyShareLinkWidget = new ShareLinkWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, this);
|
||||
_linkWidgetList.append(_emptyShareLinkWidget);
|
||||
|
||||
// connect(_emptyShareLinkWidget, &ShareLinkWidget::resizeRequested, this, &ShareDialog::slotAdjustScrollWidgetSize);
|
||||
connect(_emptyShareLinkWidget, &ShareLinkWidget::resizeRequested, this, &ShareDialog::slotAdjustScrollWidgetSize);
|
||||
// connect(this, &ShareDialog::toggleAnimation, _emptyShareLinkWidget, &ShareLinkWidget::slotToggleAnimation);
|
||||
connect(_emptyShareLinkWidget, &ShareLinkWidget::createLinkShare, this, &ShareDialog::slotCreateLinkShare);
|
||||
|
||||
@@ -209,7 +211,6 @@ void ShareDialog::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
|
||||
emit toggleAnimation(false);
|
||||
}
|
||||
|
||||
// TODO
|
||||
void ShareDialog::slotAdjustScrollWidgetSize()
|
||||
{
|
||||
int count = this->findChildren<ShareLinkWidget *>().count();
|
||||
@@ -303,6 +304,24 @@ void ShareDialog::slotCreateLinkShare()
|
||||
_manager->createLinkShare(_sharePath, QString(), QString());
|
||||
}
|
||||
|
||||
void ShareDialog::slotLinkShareRequiresPassword()
|
||||
{
|
||||
bool ok;
|
||||
QString password = QInputDialog::getText(this,
|
||||
tr("Password for share required"),
|
||||
tr("Please enter a password for your link share:"),
|
||||
QLineEdit::Normal,
|
||||
QString(),
|
||||
&ok);
|
||||
|
||||
if (!ok) {
|
||||
// The dialog was canceled so no need to do anything
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to create the link share again with the newly entered password
|
||||
_manager->createLinkShare(_sharePath, QString(), password);
|
||||
}
|
||||
|
||||
void ShareDialog::slotDeleteShare()
|
||||
{
|
||||
|
||||
@@ -64,6 +64,7 @@ private slots:
|
||||
void slotAddLinkShareWidget(const QSharedPointer<LinkShare> &linkShare);
|
||||
void slotDeleteShare();
|
||||
void slotCreateLinkShare();
|
||||
void slotLinkShareRequiresPassword();
|
||||
void slotAdjustScrollWidgetSize();
|
||||
|
||||
signals:
|
||||
|
||||
@@ -6,159 +6,151 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>372</width>
|
||||
<width>385</width>
|
||||
<height>150</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="shareDialogVerticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0" columnstretch="0,0">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_sharePath">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0" columnstretch="0,0">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>315</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>share label</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_sharePath">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>315</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Nextcloud Path:</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="label_icon">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Icon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>315</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ownCloud Path:</string>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustIgnored</enum>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>315</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">share label</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="label_icon">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Icon</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>69</width>
|
||||
<height>69</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="scrollAreaVerticalLayout"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>367</width>
|
||||
<height>85</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="scrollAreaVerticalLayout"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <QDesktopServices>
|
||||
#include <QMessageBox>
|
||||
#include <QMenu>
|
||||
#include <QTextEdit>
|
||||
#include <QToolButton>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
@@ -47,6 +48,7 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
|
||||
, _localPath(localPath)
|
||||
, _linkShare(nullptr)
|
||||
, _passwordRequired(false)
|
||||
, _noteRequired(false)
|
||||
, _expiryRequired(false)
|
||||
, _namesSupported(true)
|
||||
, _linkContextMenu(nullptr)
|
||||
@@ -55,14 +57,13 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
|
||||
, _allowUploadEditingLinkAction(nullptr)
|
||||
, _allowUploadLinkAction(nullptr)
|
||||
, _passwordProtectLinkAction(nullptr)
|
||||
, _noteLinkAction(nullptr)
|
||||
, _expirationDateLinkAction(nullptr)
|
||||
, _unshareLinkAction(nullptr)
|
||||
{
|
||||
_ui->setupUi(this);
|
||||
|
||||
QSizePolicy sp = _ui->shareLinkToolButton->sizePolicy();
|
||||
sp.setRetainSizeWhenHidden(true);
|
||||
_ui->shareLinkToolButton->setSizePolicy(sp);
|
||||
_ui->shareLinkToolButton->hide();
|
||||
|
||||
//Is this a file or folder?
|
||||
@@ -72,6 +73,8 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
|
||||
connect(_ui->enableShareLink, &QPushButton::clicked, this, &ShareLinkWidget::slotCreateShareLink);
|
||||
connect(_ui->lineEdit_password, &QLineEdit::returnPressed, this, &ShareLinkWidget::slotCreatePassword);
|
||||
connect(_ui->confirmPassword, &QAbstractButton::clicked, this, &ShareLinkWidget::slotCreatePassword);
|
||||
connect(_ui->textEdit_note, &QTextEdit::textChanged, this, &ShareLinkWidget::slotCreateNote);
|
||||
connect(_ui->confirmNote, &QAbstractButton::clicked, this, &ShareLinkWidget::slotCreateNote);
|
||||
connect(_ui->confirmExpirationDate, &QAbstractButton::clicked, this, &ShareLinkWidget::slotSetExpireDate);
|
||||
connect(_ui->calendar, &QDateTimeEdit::dateChanged, this, &ShareLinkWidget::slotSetExpireDate);
|
||||
|
||||
@@ -97,6 +100,7 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
|
||||
|
||||
togglePasswordOptions(false);
|
||||
toggleExpireDateOptions(false);
|
||||
toggleNoteOptions(false);
|
||||
_ui->calendar->setMinimumDate(QDate::currentDate().addDays(1));
|
||||
|
||||
// check if the file is already inside of a synced folder
|
||||
@@ -111,7 +115,8 @@ ShareLinkWidget::~ShareLinkWidget()
|
||||
delete _ui;
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotToggleAnimation(bool start){
|
||||
void ShareLinkWidget::slotToggleAnimation(bool start)
|
||||
{
|
||||
if (start) {
|
||||
if (!_ui->progressIndicator->isAnimated())
|
||||
_ui->progressIndicator->startAnimation();
|
||||
@@ -120,21 +125,25 @@ void ShareLinkWidget::slotToggleAnimation(bool start){
|
||||
}
|
||||
}
|
||||
|
||||
void ShareLinkWidget::setLinkShare(QSharedPointer<LinkShare> linkShare){
|
||||
void ShareLinkWidget::setLinkShare(QSharedPointer<LinkShare> linkShare)
|
||||
{
|
||||
_linkShare = linkShare;
|
||||
}
|
||||
|
||||
QSharedPointer<LinkShare> ShareLinkWidget::getLinkShare(){
|
||||
QSharedPointer<LinkShare> ShareLinkWidget::getLinkShare()
|
||||
{
|
||||
return _linkShare;
|
||||
}
|
||||
|
||||
void ShareLinkWidget::setupUiOptions(){
|
||||
void ShareLinkWidget::setupUiOptions()
|
||||
{
|
||||
connect(_linkShare.data(), &LinkShare::expireDateSet, this, &ShareLinkWidget::slotExpireDateSet);
|
||||
connect(_linkShare.data(), &LinkShare::noteSet, this, &ShareLinkWidget::slotNoteSet);
|
||||
connect(_linkShare.data(), &LinkShare::passwordSet, this, &ShareLinkWidget::slotPasswordSet);
|
||||
connect(_linkShare.data(), &LinkShare::passwordSetError, this, &ShareLinkWidget::slotPasswordSetError);
|
||||
|
||||
// Prepare permissions check and create group action
|
||||
const QDate expireDate = _linkShare.data()->getExpireDate().isValid()? _linkShare.data()->getExpireDate() : QDate();
|
||||
const QDate expireDate = _linkShare.data()->getExpireDate().isValid() ? _linkShare.data()->getExpireDate() : QDate();
|
||||
const SharePermissions perm = _linkShare.data()->getPermissions();
|
||||
bool checked = false;
|
||||
QActionGroup *permissionsGroup = new QActionGroup(this);
|
||||
@@ -145,7 +154,7 @@ void ShareLinkWidget::setupUiOptions(){
|
||||
// radio button style
|
||||
permissionsGroup->setExclusive(true);
|
||||
|
||||
if(_isFile){
|
||||
if (_isFile) {
|
||||
checked = perm & (SharePermissionRead & SharePermissionUpdate);
|
||||
_allowEditingLinkAction = _linkContextMenu->addAction(tr("Allow Editing"));
|
||||
_allowEditingLinkAction->setCheckable(true);
|
||||
@@ -157,10 +166,7 @@ void ShareLinkWidget::setupUiOptions(){
|
||||
_readOnlyLinkAction->setCheckable(true);
|
||||
_readOnlyLinkAction->setChecked(checked);
|
||||
|
||||
checked = perm & (SharePermissionRead &
|
||||
SharePermissionCreate &
|
||||
SharePermissionUpdate &
|
||||
SharePermissionDelete);
|
||||
checked = perm & (SharePermissionRead & SharePermissionCreate & SharePermissionUpdate & SharePermissionDelete);
|
||||
_allowUploadEditingLinkAction = permissionsGroup->addAction(tr("Allow Upload && Editing"));
|
||||
_allowUploadEditingLinkAction->setCheckable(true);
|
||||
_allowUploadEditingLinkAction->setChecked(checked);
|
||||
@@ -172,7 +178,7 @@ void ShareLinkWidget::setupUiOptions(){
|
||||
}
|
||||
|
||||
// Adds permissions actions (radio button style)
|
||||
if(_isFile){
|
||||
if (_isFile) {
|
||||
_linkContextMenu->addAction(_allowEditingLinkAction);
|
||||
} else {
|
||||
_linkContextMenu->addAction(_readOnlyLinkAction);
|
||||
@@ -180,11 +186,21 @@ void ShareLinkWidget::setupUiOptions(){
|
||||
_linkContextMenu->addAction(_allowUploadLinkAction);
|
||||
}
|
||||
|
||||
// Adds action to display note widget (check box)
|
||||
_noteLinkAction = _linkContextMenu->addAction(tr("Add note to recipient"));
|
||||
_noteLinkAction->setCheckable(true);
|
||||
|
||||
if (_linkShare->getNote().isSimpleText()) {
|
||||
_ui->textEdit_note->setText(_linkShare->getNote());
|
||||
_noteLinkAction->setChecked(true);
|
||||
showNoteOptions(true);
|
||||
}
|
||||
|
||||
// Adds action to display password widget (check box)
|
||||
_passwordProtectLinkAction = _linkContextMenu->addAction(tr("Password Protect"));
|
||||
_passwordProtectLinkAction->setCheckable(true);
|
||||
|
||||
if(_linkShare.data()->isPasswordSet()){
|
||||
if (_linkShare.data()->isPasswordSet()) {
|
||||
_passwordProtectLinkAction->setChecked(true);
|
||||
_ui->lineEdit_password->setPlaceholderText("********");
|
||||
showPasswordOptions(true);
|
||||
@@ -200,7 +216,7 @@ void ShareLinkWidget::setupUiOptions(){
|
||||
// Adds action to display expiration date widget (check box)
|
||||
_expirationDateLinkAction = _linkContextMenu->addAction(tr("Expiration Date"));
|
||||
_expirationDateLinkAction->setCheckable(true);
|
||||
if(!expireDate.isNull()){
|
||||
if (!expireDate.isNull()) {
|
||||
_ui->calendar->setDate(expireDate);
|
||||
_expirationDateLinkAction->setChecked(true);
|
||||
showExpireDateOptions(true);
|
||||
@@ -217,12 +233,12 @@ void ShareLinkWidget::setupUiOptions(){
|
||||
|
||||
// Adds action to unshare widget (check box)
|
||||
_unshareLinkAction = _linkContextMenu->addAction(QIcon(":/client/resources/delete.png"),
|
||||
tr("Unshare"));
|
||||
tr("Unshare"));
|
||||
|
||||
_linkContextMenu->addSeparator();
|
||||
|
||||
_addAnotherLinkAction = _linkContextMenu->addAction(QIcon(":/client/resources/add.png"),
|
||||
tr("Add another link"));
|
||||
tr("Add another link"));
|
||||
|
||||
_ui->enableShareLink->setIcon(QIcon(":/client/resources/copy.svg"));
|
||||
disconnect(_ui->enableShareLink, &QPushButton::clicked, this, &ShareLinkWidget::slotCreateShareLink);
|
||||
@@ -245,7 +261,27 @@ void ShareLinkWidget::setupUiOptions(){
|
||||
customizeStyle();
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotCopyLinkShare(bool clicked){
|
||||
void ShareLinkWidget::setNote(const QString ¬e)
|
||||
{
|
||||
if (_linkShare) {
|
||||
slotToggleAnimation(true);
|
||||
_ui->errorLabel->hide();
|
||||
_linkShare->setNote(note);
|
||||
}
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotCreateNote()
|
||||
{
|
||||
setNote(_ui->textEdit_note->toPlainText());
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotNoteSet()
|
||||
{
|
||||
slotToggleAnimation(false);
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotCopyLinkShare(bool clicked)
|
||||
{
|
||||
Q_UNUSED(clicked);
|
||||
|
||||
QApplication::clipboard()->setText(_linkShare->getLink().toString());
|
||||
@@ -258,7 +294,7 @@ void ShareLinkWidget::slotExpireDateSet()
|
||||
|
||||
void ShareLinkWidget::slotSetExpireDate()
|
||||
{
|
||||
if(!_linkShare){
|
||||
if (!_linkShare) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -298,8 +334,8 @@ void ShareLinkWidget::slotPasswordSet()
|
||||
slotToggleAnimation(false);
|
||||
}
|
||||
|
||||
void ShareLinkWidget::startAnimation(const int start, const int end){
|
||||
|
||||
void ShareLinkWidget::startAnimation(const int start, const int end)
|
||||
{
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "maximumHeight", this);
|
||||
|
||||
animation->setDuration(500);
|
||||
@@ -307,7 +343,7 @@ void ShareLinkWidget::startAnimation(const int start, const int end){
|
||||
animation->setEndValue(end);
|
||||
|
||||
connect(animation, &QAbstractAnimation::finished, this, &ShareLinkWidget::slotAnimationFinished);
|
||||
if(end < start) // that is to remove the widget, not to show it
|
||||
if (end < start) // that is to remove the widget, not to show it
|
||||
connect(animation, &QAbstractAnimation::finished, this, &ShareLinkWidget::slotDeleteAnimationFinished);
|
||||
connect(animation, &QVariantAnimation::valueChanged, this, &ShareLinkWidget::resizeRequested);
|
||||
|
||||
@@ -323,10 +359,32 @@ void ShareLinkWidget::slotDeleteShareFetched()
|
||||
|
||||
_linkShare.clear();
|
||||
togglePasswordOptions(false);
|
||||
toggleNoteOptions(false);
|
||||
toggleExpireDateOptions(false);
|
||||
emit deleteLinkShare();
|
||||
}
|
||||
|
||||
void ShareLinkWidget::showNoteOptions(bool show)
|
||||
{
|
||||
_ui->noteLabel->setVisible(show);
|
||||
_ui->textEdit_note->setVisible(show);
|
||||
_ui->confirmNote->setVisible(show);
|
||||
}
|
||||
|
||||
|
||||
void ShareLinkWidget::toggleNoteOptions(bool enable)
|
||||
{
|
||||
showNoteOptions(enable);
|
||||
|
||||
if (enable) {
|
||||
_ui->textEdit_note->setFocus();
|
||||
} else {
|
||||
// 'deletes' note
|
||||
if (_linkShare)
|
||||
_linkShare->setNote(QString());
|
||||
}
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotAnimationFinished()
|
||||
{
|
||||
emit resizeRequested();
|
||||
@@ -367,11 +425,11 @@ void ShareLinkWidget::togglePasswordOptions(bool enable)
|
||||
{
|
||||
showPasswordOptions(enable);
|
||||
|
||||
if(enable) {
|
||||
if (enable) {
|
||||
_ui->lineEdit_password->setFocus();
|
||||
} else {
|
||||
// 'deletes' password
|
||||
if(_linkShare)
|
||||
if (_linkShare)
|
||||
_linkShare->setPassword(QString());
|
||||
}
|
||||
}
|
||||
@@ -394,7 +452,7 @@ void ShareLinkWidget::toggleExpireDateOptions(bool enable)
|
||||
_ui->calendar->setFocus();
|
||||
} else {
|
||||
// 'deletes' expire date
|
||||
if(_linkShare)
|
||||
if (_linkShare)
|
||||
_linkShare->setExpireDate(QDate());
|
||||
}
|
||||
}
|
||||
@@ -415,11 +473,11 @@ void ShareLinkWidget::confirmAndDeleteShare()
|
||||
|
||||
connect(messageBox, &QMessageBox::finished, this,
|
||||
[messageBox, yesButton, this]() {
|
||||
if (messageBox->clickedButton() == yesButton) {
|
||||
this->slotToggleAnimation(true);
|
||||
this->_linkShare->deleteShare();
|
||||
}
|
||||
});
|
||||
if (messageBox->clickedButton() == yesButton) {
|
||||
this->slotToggleAnimation(true);
|
||||
this->_linkShare->deleteShare();
|
||||
}
|
||||
});
|
||||
messageBox->open();
|
||||
}
|
||||
|
||||
@@ -440,11 +498,10 @@ void ShareLinkWidget::slotContextMenuButtonClicked()
|
||||
|
||||
void ShareLinkWidget::slotLinkContextMenuActionTriggered(QAction *action)
|
||||
{
|
||||
|
||||
bool state = action->isChecked();
|
||||
SharePermissions perm = SharePermissionRead;
|
||||
|
||||
if(action == _addAnotherLinkAction){
|
||||
if (action == _addAnotherLinkAction) {
|
||||
emit createLinkShare();
|
||||
|
||||
} else if (action == _readOnlyLinkAction && state) {
|
||||
@@ -468,6 +525,9 @@ void ShareLinkWidget::slotLinkContextMenuActionTriggered(QAction *action)
|
||||
} else if (action == _expirationDateLinkAction) {
|
||||
toggleExpireDateOptions(state);
|
||||
|
||||
} else if (action == _noteLinkAction) {
|
||||
toggleNoteOptions(state);
|
||||
|
||||
} else if (action == _unshareLinkAction) {
|
||||
confirmAndDeleteShare();
|
||||
}
|
||||
@@ -505,17 +565,16 @@ void ShareLinkWidget::customizeStyle()
|
||||
_addAnotherLinkAction->setIcon(Theme::createColorAwareIcon(":/client/resources/add.png"));
|
||||
|
||||
_ui->enableShareLink->setIcon(Theme::createColorAwareIcon(":/client/resources/copy.svg"));
|
||||
|
||||
// only on master, not in stable-2.6 yet
|
||||
// _ui->shareLinkIconLabel->setPixmap(Theme::createColorAwarePixmap(":/client/resources/public.svg"));
|
||||
_ui->createShareButton->setIcon(Theme::createColorAwareIcon(":/client/resources/public.svg"));
|
||||
|
||||
|
||||
_ui->shareLinkIconLabel->setPixmap(Theme::createColorAwarePixmap(":/client/resources/public.svg"));
|
||||
|
||||
_ui->shareLinkToolButton->setIcon(Theme::createColorAwareIcon(":/client/resources/more.svg"));
|
||||
|
||||
// only on master, not in stable-2.6 yet
|
||||
// _ui->confirmNote->setIcon(Theme::createColorAwareIcon(":/client/resources/confirm.svg"));
|
||||
|
||||
_ui->confirmNote->setIcon(Theme::createColorAwareIcon(":/client/resources/confirm.svg"));
|
||||
_ui->confirmPassword->setIcon(Theme::createColorAwareIcon(":/client/resources/confirm.svg"));
|
||||
_ui->confirmExpirationDate->setIcon(Theme::createColorAwareIcon(":/client/resources/confirm.svg"));
|
||||
|
||||
_ui->progressIndicator->setColor(QGuiApplication::palette().color(QPalette::Text));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -74,6 +74,9 @@ private slots:
|
||||
void slotPasswordSet();
|
||||
void slotPasswordSetError(int code, const QString &message);
|
||||
|
||||
void slotCreateNote();
|
||||
void slotNoteSet();
|
||||
|
||||
void slotSetExpireDate();
|
||||
void slotExpireDateSet();
|
||||
|
||||
@@ -95,6 +98,10 @@ private:
|
||||
void showPasswordOptions(bool show);
|
||||
void togglePasswordOptions(bool enable);
|
||||
|
||||
void showNoteOptions(bool show);
|
||||
void toggleNoteOptions(bool enable);
|
||||
void setNote(const QString ¬e);
|
||||
|
||||
void showExpireDateOptions(bool show);
|
||||
void toggleExpireDateOptions(bool enable);
|
||||
|
||||
@@ -122,6 +129,7 @@ private:
|
||||
bool _passwordRequired;
|
||||
bool _expiryRequired;
|
||||
bool _namesSupported;
|
||||
bool _noteRequired;
|
||||
|
||||
QMenu *_linkContextMenu;
|
||||
QAction *_readOnlyLinkAction;
|
||||
@@ -132,6 +140,7 @@ private:
|
||||
QAction *_expirationDateLinkAction;
|
||||
QAction *_unshareLinkAction;
|
||||
QAction *_addAnotherLinkAction;
|
||||
QAction *_noteLinkAction;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>350</width>
|
||||
<height>160</height>
|
||||
<width>365</width>
|
||||
<height>192</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@@ -16,166 +16,26 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDateEdit" name="calendar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="passwordLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QToolButton" name="shareLinkToolButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../client.qrc">
|
||||
<normaloff>:/client/resources/more.svg</normaloff>:/client/resources/more.svg</iconset>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::InstantPopup</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="4">
|
||||
<widget class="QLabel" name="errorLabel">
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>123</red>
|
||||
<green>121</green>
|
||||
<blue>134</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_password">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QToolButton" name="confirmPassword">
|
||||
<property name="icon">
|
||||
<iconset resource="../../client.qrc">
|
||||
<normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QToolButton" name="confirmExpirationDate">
|
||||
<property name="icon">
|
||||
<iconset resource="../../client.qrc">
|
||||
<normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="createShareButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">text-align: left</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="shareLinkIconLabel">
|
||||
<property name="text">
|
||||
<string>&Share link</string>
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../client.qrc">
|
||||
<normaloff>:/client/resources/public.svg</normaloff>:/client/resources/public.svg</iconset>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../client.qrc">:/client/resources/public.svg</pixmap>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="shareLinkLabel">
|
||||
<property name="text">
|
||||
<string>Share link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -225,21 +85,243 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="shareLinkToolButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../client.qrc">
|
||||
<normaloff>:/client/resources/more.svg</normaloff>:/client/resources/more.svg</iconset>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::InstantPopup</enum>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="expirationLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="noteLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>78</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Note:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit_note">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>60</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="confirmNote">
|
||||
<property name="icon">
|
||||
<iconset resource="../../client.qrc">
|
||||
<normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="passwordLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>78</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_password">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="confirmPassword">
|
||||
<property name="icon">
|
||||
<iconset resource="../../client.qrc">
|
||||
<normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="expirationLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>78</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Expires:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDateEdit" name="calendar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="confirmExpirationDate">
|
||||
<property name="icon">
|
||||
<iconset resource="../../client.qrc">
|
||||
<normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="errorLabel">
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>123</red>
|
||||
<green>121</green>
|
||||
<blue>134</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Expiration date:</string>
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>20</number>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -200,6 +200,11 @@ QString LinkShare::getName() const
|
||||
return _name;
|
||||
}
|
||||
|
||||
QString LinkShare::getNote() const
|
||||
{
|
||||
return _note;
|
||||
}
|
||||
|
||||
void LinkShare::setName(const QString &name)
|
||||
{
|
||||
OcsShareJob *job = new OcsShareJob(_account);
|
||||
@@ -208,6 +213,20 @@ void LinkShare::setName(const QString &name)
|
||||
job->setName(getId(), name);
|
||||
}
|
||||
|
||||
void LinkShare::setNote(const QString ¬e)
|
||||
{
|
||||
OcsShareJob *job = new OcsShareJob(_account);
|
||||
connect(job, &OcsShareJob::shareJobFinished, this, &LinkShare::slotNoteSet);
|
||||
connect(job, &OcsJob::ocsError, this, &LinkShare::slotOcsError);
|
||||
job->setNote(getId(), note);
|
||||
}
|
||||
|
||||
void LinkShare::slotNoteSet(const QJsonDocument &, const QVariant ¬e)
|
||||
{
|
||||
_note = note.toString();
|
||||
emit noteSet();
|
||||
}
|
||||
|
||||
QString LinkShare::getToken() const
|
||||
{
|
||||
return _token;
|
||||
|
||||
@@ -183,6 +183,12 @@ public:
|
||||
*/
|
||||
QString getName() const;
|
||||
|
||||
/*
|
||||
* Returns the note of the link share.
|
||||
*/
|
||||
|
||||
QString getNote() const;
|
||||
|
||||
/*
|
||||
* Set the name of the link share.
|
||||
*
|
||||
@@ -190,6 +196,12 @@ public:
|
||||
*/
|
||||
void setName(const QString &name);
|
||||
|
||||
|
||||
/*
|
||||
* Set the note of the link share.
|
||||
*/
|
||||
void setNote(const QString ¬e);
|
||||
|
||||
/*
|
||||
* Returns the token of the link share.
|
||||
*/
|
||||
@@ -224,11 +236,13 @@ public:
|
||||
signals:
|
||||
void expireDateSet();
|
||||
void passwordSet();
|
||||
void noteSet();
|
||||
void passwordSetError(int statusCode, const QString &message);
|
||||
void nameSet();
|
||||
|
||||
private slots:
|
||||
void slotPasswordSet(const QJsonDocument &, const QVariant &value);
|
||||
void slotNoteSet(const QJsonDocument &, const QVariant &value);
|
||||
void slotExpireDateSet(const QJsonDocument &reply, const QVariant &value);
|
||||
void slotSetPasswordError(int statusCode, const QString &message);
|
||||
void slotNameSet(const QJsonDocument &, const QVariant &value);
|
||||
@@ -237,6 +251,7 @@ private:
|
||||
QString _name;
|
||||
QString _token;
|
||||
bool _passwordSet;
|
||||
QString _note;
|
||||
QDate _expireDate;
|
||||
QUrl _url;
|
||||
};
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
#include <QPainter>
|
||||
#include <QListWidget>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account,
|
||||
@@ -206,7 +208,8 @@ void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>>
|
||||
}
|
||||
|
||||
// the owner of the file that shared it first
|
||||
if(x == 0 && !share->getUidOwner().isEmpty()){
|
||||
// leave out if it's the current user
|
||||
if(x == 0 && !share->getUidOwner().isEmpty() && !(share->getUidOwner() == _account->credentials()->user())) {
|
||||
_ui->mainOwnerLabel->setText(QString("Shared with you by ").append(share->getOwnerDisplayName()));
|
||||
}
|
||||
|
||||
@@ -377,6 +380,12 @@ void ShareUserGroupWidget::slotStyleChanged()
|
||||
void ShareUserGroupWidget::customizeStyle()
|
||||
{
|
||||
_ui->confirmShare->setIcon(Theme::createColorAwareIcon(":/client/resources/confirm.svg"));
|
||||
|
||||
_pi_sharee.setColor(QGuiApplication::palette().color(QPalette::Text));
|
||||
|
||||
foreach (auto pi, _parentScrollArea->findChildren<QProgressIndicator *>()) {
|
||||
pi->setColor(QGuiApplication::palette().color(QPalette::Text));;
|
||||
}
|
||||
}
|
||||
|
||||
ShareUserLine::ShareUserLine(QSharedPointer<Share> share,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>350</width>
|
||||
<height>55</height>
|
||||
<height>70</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@@ -17,30 +17,24 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="mainOwnerLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="shareeHorizontalLayout">
|
||||
<layout class="QHBoxLayout" name="shareeHorizontalLayout" stretch="0,0">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@@ -55,6 +49,12 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="shareeLineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Share with users or groups ...</string>
|
||||
</property>
|
||||
|
||||
@@ -6,35 +6,26 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>350</width>
|
||||
<height>45</height>
|
||||
<width>360</width>
|
||||
<height>58</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>360</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,2,2,2">
|
||||
<property name="spacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="avatar">
|
||||
<property name="sizePolicy">
|
||||
@@ -57,7 +48,7 @@
|
||||
<item>
|
||||
<widget class="OCC::ElidedLabel" name="sharedWith">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Maximum">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -70,6 +61,22 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="permissionsEdit">
|
||||
<property name="sizePolicy">
|
||||
@@ -89,9 +96,12 @@
|
||||
<iconset resource="../../client.qrc">
|
||||
<normaloff>:/client/resources/more.svg</normaloff>:/client/resources/more.svg</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include <QLocalSocket>
|
||||
#include <QStringBuilder>
|
||||
#include <QMessageBox>
|
||||
#include <QInputDialog>
|
||||
|
||||
#include <QClipboard>
|
||||
|
||||
@@ -454,7 +455,42 @@ void SocketApi::command_VERSION(const QString &, SocketListener *listener)
|
||||
|
||||
void SocketApi::command_SHARE_MENU_TITLE(const QString &, SocketListener *listener)
|
||||
{
|
||||
listener->sendMessage(QLatin1String("SHARE_MENU_TITLE:") + tr("Share with %1", "parameter is Nextcloud").arg(Theme::instance()->appNameGUI()));
|
||||
//listener->sendMessage(QLatin1String("SHARE_MENU_TITLE:") + tr("Share with %1", "parameter is Nextcloud").arg(Theme::instance()->appNameGUI()));
|
||||
listener->sendMessage(QLatin1String("SHARE_MENU_TITLE:") + Theme::instance()->appNameGUI());
|
||||
}
|
||||
|
||||
void SocketApi::command_EDIT(const QString &localFile, SocketListener *listener)
|
||||
{
|
||||
auto fileData = FileData::get(localFile);
|
||||
if (!fileData.folder) {
|
||||
qCWarning(lcSocketApi) << "Unknown path" << localFile;
|
||||
return;
|
||||
}
|
||||
|
||||
auto record = fileData.journalRecord();
|
||||
if (!record.isValid())
|
||||
return;
|
||||
|
||||
DirectEditor* editor = getDirectEditorForLocalFile(fileData.localPath);
|
||||
if (!editor)
|
||||
return;
|
||||
|
||||
JsonApiJob *job = new JsonApiJob(fileData.folder->accountState()->account(), QLatin1String("ocs/v2.php/apps/files/api/v1/directEditing/open"), this);
|
||||
|
||||
QUrlQuery params;
|
||||
params.addQueryItem("path", fileData.accountRelativePath);
|
||||
params.addQueryItem("editorId", editor->id());
|
||||
job->addQueryParams(params);
|
||||
job->usePOST();
|
||||
|
||||
QObject::connect(job, &JsonApiJob::jsonReceived, [](const QJsonDocument &json){
|
||||
auto data = json.object().value("ocs").toObject().value("data").toObject();
|
||||
auto url = QUrl(data.value("url").toString());
|
||||
|
||||
if(!url.isEmpty())
|
||||
Utility::openBrowser(url, nullptr);
|
||||
});
|
||||
job->start();
|
||||
}
|
||||
|
||||
// don't pull the share manager into socketapi unittests
|
||||
@@ -477,6 +513,8 @@ public:
|
||||
this, &GetOrCreatePublicLinkShare::linkShareCreated);
|
||||
connect(&_shareManager, &ShareManager::serverError,
|
||||
this, &GetOrCreatePublicLinkShare::serverError);
|
||||
connect(&_shareManager, &ShareManager::linkShareRequiresPassword,
|
||||
this, &GetOrCreatePublicLinkShare::passwordRequired);
|
||||
}
|
||||
|
||||
void run()
|
||||
@@ -512,6 +550,24 @@ private slots:
|
||||
success(share->getLink().toString());
|
||||
}
|
||||
|
||||
void passwordRequired() {
|
||||
bool ok;
|
||||
QString password = QInputDialog::getText(nullptr,
|
||||
tr("Password for share required"),
|
||||
tr("Please enter a password for your link share:"),
|
||||
QLineEdit::Normal,
|
||||
QString(),
|
||||
&ok);
|
||||
|
||||
if (!ok) {
|
||||
// The dialog was canceled so no need to do anything
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to create the link share again with the newly entered password
|
||||
_shareManager.createLinkShare(_localFile, QString(), password);
|
||||
}
|
||||
|
||||
void serverError(int code, const QString &message)
|
||||
{
|
||||
qCWarning(lcPublicLink) << "Share fetch/create error" << code << message;
|
||||
@@ -623,7 +679,7 @@ void SocketApi::command_GET_STRINGS(const QString &argument, SocketListener *lis
|
||||
{
|
||||
static std::array<std::pair<const char *, QString>, 5> strings { {
|
||||
{ "SHARE_MENU_TITLE", tr("Share options") },
|
||||
{ "CONTEXT_MENU_TITLE", tr("Share via %1").arg(Theme::instance()->appNameGUI())},
|
||||
{ "CONTEXT_MENU_TITLE", Theme::instance()->appNameGUI() },
|
||||
{ "COPY_PRIVATE_LINK_MENU_TITLE", tr("Copy private link to clipboard") },
|
||||
{ "EMAIL_PRIVATE_LINK_MENU_TITLE", tr("Send private link by email …") },
|
||||
} };
|
||||
@@ -717,13 +773,41 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe
|
||||
FileData fileData = hasSeveralFiles ? FileData{} : FileData::get(argument);
|
||||
bool isOnTheServer = fileData.journalRecord().isValid();
|
||||
auto flagString = isOnTheServer ? QLatin1String("::") : QLatin1String(":d:");
|
||||
auto capabilities = fileData.folder->accountState()->account()->capabilities();
|
||||
|
||||
if (fileData.folder && fileData.folder->accountState()->isConnected()) {
|
||||
DirectEditor* editor = getDirectEditorForLocalFile(fileData.localPath);
|
||||
if (editor) {
|
||||
//listener->sendMessage(QLatin1String("MENU_ITEM:EDIT") + flagString + tr("Edit via ") + editor->name());
|
||||
listener->sendMessage(QLatin1String("MENU_ITEM:EDIT") + flagString + tr("Edit"));
|
||||
} else {
|
||||
listener->sendMessage(QLatin1String("MENU_ITEM:OPEN_PRIVATE_LINK") + flagString + tr("Open in browser"));
|
||||
}
|
||||
|
||||
sendSharingContextMenuOptions(fileData, listener);
|
||||
listener->sendMessage(QLatin1String("MENU_ITEM:OPEN_PRIVATE_LINK") + flagString + tr("Open in browser"));
|
||||
}
|
||||
listener->sendMessage(QString("GET_MENU_ITEMS:END"));
|
||||
}
|
||||
|
||||
DirectEditor* SocketApi::getDirectEditorForLocalFile(const QString &localFile)
|
||||
{
|
||||
FileData fileData = FileData::get(localFile);
|
||||
auto capabilities = fileData.folder->accountState()->account()->capabilities();
|
||||
|
||||
if (fileData.folder && fileData.folder->accountState()->isConnected()) {
|
||||
QMimeDatabase db;
|
||||
QMimeType type = db.mimeTypeForFile(localFile);
|
||||
|
||||
DirectEditor* editor = capabilities.getDirectEditorForMimetype(type);
|
||||
if (!editor) {
|
||||
editor = capabilities.getDirectEditorForOptionalMimetype(type);
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QString SocketApi::buildRegisterPathMessage(const QString &path)
|
||||
{
|
||||
QFileInfo fi(path);
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace OCC {
|
||||
class SyncFileStatus;
|
||||
class Folder;
|
||||
class SocketListener;
|
||||
class DirectEditor;
|
||||
|
||||
/**
|
||||
* @brief The SocketApi class
|
||||
@@ -123,6 +124,10 @@ private:
|
||||
*/
|
||||
Q_INVOKABLE void command_GET_MENU_ITEMS(const QString &argument, SocketListener *listener);
|
||||
|
||||
/// Direct Editing
|
||||
Q_INVOKABLE void command_EDIT(const QString &localFile, SocketListener *listener);
|
||||
DirectEditor* getDirectEditorForLocalFile(const QString &localFile);
|
||||
|
||||
QString buildRegisterPathMessage(const QString &path);
|
||||
|
||||
QSet<QString> _registeredAliases;
|
||||
|
||||
@@ -12,9 +12,17 @@
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "accountmanager.h"
|
||||
#include "systray.h"
|
||||
#include "theme.h"
|
||||
#include "config.h"
|
||||
#include "tray/UserModel.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlComponent>
|
||||
#include <QQmlEngine>
|
||||
#include <QScreen>
|
||||
|
||||
#ifdef USE_FDO_NOTIFICATIONS
|
||||
#include <QDBusConnection>
|
||||
@@ -28,10 +36,78 @@
|
||||
|
||||
namespace OCC {
|
||||
|
||||
Systray *Systray::_instance = nullptr;
|
||||
|
||||
Systray *Systray::instance()
|
||||
{
|
||||
if (_instance == nullptr) {
|
||||
_instance = new Systray();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
Systray::Systray()
|
||||
: _isOpen(false)
|
||||
, _syncIsPaused(false)
|
||||
, _trayComponent(nullptr)
|
||||
, _trayContext(nullptr)
|
||||
{
|
||||
// Create QML tray engine, build component, set C++ backend context used in window.qml
|
||||
// Use pointer instead of engine() helper function until Qt 5.12 is minimum standard
|
||||
_trayEngine = new QQmlEngine;
|
||||
_trayEngine->addImageProvider("avatars", new ImageProvider);
|
||||
_trayEngine->rootContext()->setContextProperty("userModelBackend", UserModel::instance());
|
||||
_trayEngine->rootContext()->setContextProperty("appsMenuModelBackend", UserAppsModel::instance());
|
||||
_trayEngine->rootContext()->setContextProperty("systrayBackend", this);
|
||||
|
||||
_trayComponent = new QQmlComponent(_trayEngine, QUrl(QStringLiteral("qrc:/qml/src/gui/tray/Window.qml")));
|
||||
|
||||
connect(UserModel::instance(), &UserModel::newUserSelected,
|
||||
this, &Systray::slotNewUserSelected);
|
||||
|
||||
connect(AccountManager::instance(), &AccountManager::accountAdded,
|
||||
this, &Systray::showWindow);
|
||||
}
|
||||
|
||||
void Systray::create()
|
||||
{
|
||||
if (_trayContext == nullptr) {
|
||||
if (!AccountManager::instance()->accounts().isEmpty()) {
|
||||
_trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
|
||||
}
|
||||
_trayContext = _trayEngine->contextForObject(_trayComponent->create());
|
||||
hideWindow();
|
||||
}
|
||||
}
|
||||
|
||||
void Systray::slotNewUserSelected()
|
||||
{
|
||||
// Change ActivityModel
|
||||
_trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
|
||||
|
||||
// Rebuild App list
|
||||
UserAppsModel::instance()->buildAppList();
|
||||
}
|
||||
|
||||
bool Systray::isOpen()
|
||||
{
|
||||
return _isOpen;
|
||||
}
|
||||
|
||||
Q_INVOKABLE void Systray::setOpened()
|
||||
{
|
||||
_isOpen = true;
|
||||
}
|
||||
|
||||
Q_INVOKABLE void Systray::setClosed()
|
||||
{
|
||||
_isOpen = false;
|
||||
}
|
||||
|
||||
void Systray::showMessage(const QString &title, const QString &message, MessageIcon icon, int millisecondsTimeoutHint)
|
||||
{
|
||||
#ifdef USE_FDO_NOTIFICATIONS
|
||||
if(QDBusInterface(NOTIFICATIONS_SERVICE, NOTIFICATIONS_PATH, NOTIFICATIONS_IFACE).isValid()) {
|
||||
if (QDBusInterface(NOTIFICATIONS_SERVICE, NOTIFICATIONS_PATH, NOTIFICATIONS_IFACE).isValid()) {
|
||||
QList<QVariant> args = QList<QVariant>() << APPLICATION_NAME << quint32(0) << APPLICATION_ICON_NAME
|
||||
<< title << message << QStringList() << QVariantMap() << qint32(-1);
|
||||
QDBusMessage method = QDBusMessage::createMethodCall(NOTIFICATIONS_SERVICE, NOTIFICATIONS_PATH, NOTIFICATIONS_IFACE, "Notify");
|
||||
@@ -54,4 +130,95 @@ void Systray::setToolTip(const QString &tip)
|
||||
QSystemTrayIcon::setToolTip(tr("%1: %2").arg(Theme::instance()->appNameGUI(), tip));
|
||||
}
|
||||
|
||||
int Systray::calcTrayWindowX()
|
||||
{
|
||||
#ifdef Q_OS_OSX
|
||||
// macOS handles DPI awareness differently
|
||||
// and menu bar is always at the top, icons starting from the right
|
||||
|
||||
QPoint topLeft = this->geometry().topLeft();
|
||||
QPoint topRight = this->geometry().topRight();
|
||||
int trayIconTopCenterX = (topRight - ((topRight - topLeft) * 0.5)).x();
|
||||
return trayIconTopCenterX - (400 * 0.5);
|
||||
#else
|
||||
QScreen *trayScreen = QGuiApplication::primaryScreen();
|
||||
int screenWidth = trayScreen->geometry().width();
|
||||
int screenHeight = trayScreen->geometry().height();
|
||||
int availableWidth = trayScreen->availableGeometry().width();
|
||||
int availableHeight = trayScreen->availableGeometry().height();
|
||||
QPoint topRightDpiAware = this->geometry().topRight() / trayScreen->devicePixelRatio();
|
||||
QPoint topLeftDpiAware = this->geometry().topLeft() / trayScreen->devicePixelRatio();
|
||||
|
||||
// get coordinates from top center point of tray icon
|
||||
int trayIconTopCenterX = (topRightDpiAware - ((topRightDpiAware - topLeftDpiAware) * 0.5)).x();
|
||||
int trayIconTopCenterY = (topRightDpiAware - ((topRightDpiAware - topLeftDpiAware) * 0.5)).y();
|
||||
|
||||
if (availableHeight < screenHeight) {
|
||||
// taskbar is on top or bottom
|
||||
if (trayIconTopCenterX + (400 * 0.5) > availableWidth) {
|
||||
return availableWidth - 400 - 12;
|
||||
} else {
|
||||
return trayIconTopCenterX - (400 * 0.5);
|
||||
}
|
||||
} else {
|
||||
if (trayScreen->availableGeometry().x() > trayScreen->geometry().x()) {
|
||||
// on the left
|
||||
return (screenWidth - availableWidth) + 6;
|
||||
} else {
|
||||
// on the right
|
||||
return screenWidth - 400 - (screenWidth - availableWidth) - 6;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
int Systray::calcTrayWindowY()
|
||||
{
|
||||
#ifdef Q_OS_OSX
|
||||
// macOS menu bar is always 22 (effective) pixels
|
||||
// don't use availableGeometry() here, because this also excludes the dock
|
||||
return 22+6;
|
||||
#else
|
||||
QScreen *trayScreen = QGuiApplication::primaryScreen();
|
||||
int screenWidth = trayScreen->geometry().width();
|
||||
int screenHeight = trayScreen->geometry().height();
|
||||
int availableHeight = trayScreen->availableGeometry().height();
|
||||
QPoint topRightDpiAware = this->geometry().topRight() / trayScreen->devicePixelRatio();
|
||||
QPoint topLeftDpiAware = this->geometry().topLeft() / trayScreen->devicePixelRatio();
|
||||
|
||||
// get coordinates from top center point of tray icon
|
||||
int trayIconTopCenterX = (topRightDpiAware - ((topRightDpiAware - topLeftDpiAware) * 0.5)).x();
|
||||
int trayIconTopCenterY = (topRightDpiAware - ((topRightDpiAware - topLeftDpiAware) * 0.5)).y();
|
||||
|
||||
if (availableHeight < screenHeight) {
|
||||
// taskbar is on top or bottom
|
||||
if (trayScreen->availableGeometry().y() > trayScreen->geometry().y()) {
|
||||
// on top
|
||||
return (screenHeight - availableHeight) + 6;
|
||||
} else {
|
||||
// on bottom
|
||||
return screenHeight - 510 - (screenHeight - availableHeight) - 6;
|
||||
}
|
||||
} else {
|
||||
// on the left or right
|
||||
return (trayIconTopCenterY - 510 + 12);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Systray::syncIsPaused()
|
||||
{
|
||||
return _syncIsPaused;
|
||||
}
|
||||
|
||||
void Systray::pauseResumeSync()
|
||||
{
|
||||
if (_syncIsPaused) {
|
||||
_syncIsPaused = false;
|
||||
emit resumeSync();
|
||||
} else {
|
||||
_syncIsPaused = true;
|
||||
emit pauseSync();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
#define SYSTRAY_H
|
||||
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QQmlContext>
|
||||
|
||||
#include "accountmanager.h"
|
||||
#include "tray/UserModel.h"
|
||||
|
||||
class QIcon;
|
||||
|
||||
@@ -26,16 +30,56 @@ bool canOsXSendUserNotification();
|
||||
void sendOsXUserNotification(const QString &title, const QString &message);
|
||||
#endif
|
||||
|
||||
namespace Ui {
|
||||
class Systray;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The Systray class
|
||||
* @ingroup gui
|
||||
*/
|
||||
class Systray : public QSystemTrayIcon
|
||||
class Systray
|
||||
: public QSystemTrayIcon
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static Systray *instance();
|
||||
virtual ~Systray() {};
|
||||
|
||||
void create();
|
||||
void showMessage(const QString &title, const QString &message, MessageIcon icon = Information, int millisecondsTimeoutHint = 10000);
|
||||
void setToolTip(const QString &tip);
|
||||
bool isOpen();
|
||||
|
||||
Q_INVOKABLE void pauseResumeSync();
|
||||
Q_INVOKABLE int calcTrayWindowX();
|
||||
Q_INVOKABLE int calcTrayWindowY();
|
||||
Q_INVOKABLE bool syncIsPaused();
|
||||
Q_INVOKABLE void setOpened();
|
||||
Q_INVOKABLE void setClosed();
|
||||
|
||||
signals:
|
||||
void currentUserChanged();
|
||||
void openSettings();
|
||||
void openHelp();
|
||||
void shutdown();
|
||||
void pauseSync();
|
||||
void resumeSync();
|
||||
|
||||
Q_INVOKABLE void hideWindow();
|
||||
Q_INVOKABLE void showWindow();
|
||||
|
||||
public slots:
|
||||
void slotNewUserSelected();
|
||||
|
||||
private:
|
||||
static Systray *_instance;
|
||||
Systray();
|
||||
bool _isOpen;
|
||||
bool _syncIsPaused;
|
||||
QQmlEngine *_trayEngine;
|
||||
QQmlComponent *_trayComponent;
|
||||
QQmlContext *_trayContext;
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
#include "activitydata.h"
|
||||
#include "ActivityData.h"
|
||||
|
||||
|
||||
namespace OCC {
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
|
||||
Type _type;
|
||||
qlonglong _id;
|
||||
QString _fileAction;
|
||||
QString _objectType;
|
||||
QString _subject;
|
||||
QString _message;
|
||||
@@ -64,6 +65,8 @@ public:
|
||||
QUrl _link;
|
||||
QDateTime _dateTime;
|
||||
QString _accName;
|
||||
QString _icon;
|
||||
QString _iconData;
|
||||
|
||||
// Stores information about the error
|
||||
int _status;
|
||||