From 849635b8a835c188985fd88b214ff379cf20202d Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 9 Aug 2017 14:16:53 +0300 Subject: [PATCH 01/54] Added new GUI page. --HG-- branch : feature --- .../dialogs/dialogpatternproperties.ui | 267 +++++++++++++++++- 1 file changed, 265 insertions(+), 2 deletions(-) diff --git a/src/app/valentina/dialogs/dialogpatternproperties.ui b/src/app/valentina/dialogs/dialogpatternproperties.ui index eb98d5f2f..bab0fa5e3 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.ui +++ b/src/app/valentina/dialogs/dialogpatternproperties.ui @@ -6,7 +6,7 @@ 0 0 - 727 + 655 532 @@ -21,7 +21,7 @@ - 1 + 4 @@ -1298,6 +1298,269 @@ + + + Pattern label data + + + + + + + + Clear current and begin new label + + + ... + + + + + + + 24 + 24 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Import from label template + + + ... + + + + + + + 24 + 24 + + + + + + + + Export label as template + + + ... + + + + + + + 24 + 24 + + + + + + + + + + + 0 + 1 + + + + QAbstractItemView::InternalMove + + + + + + + + + 6 + + + + + Bold + + + ... + + + + + + true + + + + + + + Italic + + + ... + + + + + + true + + + + + + + Aligns with the left edge + + + ... + + + + + + true + + + + + + + Centers horizontally in the available space + + + ... + + + + + + true + + + + + + + Aligns with the right edge + + + ... + + + + + + true + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + ... + + + + .. + + + + + + + false + + + ... + + + + .. + + + + + + + + + Text: + + + + + + + + + true + + + Line of text + + + true + + + + + + + Insert placeholders + + + Insert... + + + + + + + + + From 56bb45aee73ffc920c0330dc7786beb7ea2f64ee Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 9 Aug 2017 14:17:21 +0300 Subject: [PATCH 02/54] Added new icons to local icon theme. --HG-- branch : feature --- .../16x16/actions/format-justify-center.png | Bin 0 -> 568 bytes .../16x16/actions/format-justify-left.png | Bin 0 -> 579 bytes .../16x16/actions/format-justify-right.png | Bin 0 -> 563 bytes .../16x16/actions/format-text-bold.png | Bin 0 -> 610 bytes .../16x16/actions/format-text-italic.png | Bin 0 -> 540 bytes .../24x24/actions/format-justify-center.png | Bin 0 -> 751 bytes .../24x24/actions/format-justify-left.png | Bin 0 -> 750 bytes .../24x24/actions/format-justify-right.png | Bin 0 -> 747 bytes .../24x24/actions/format-text-bold.png | Bin 0 -> 850 bytes .../24x24/actions/format-text-italic.png | Bin 0 -> 795 bytes .../32x32/actions/format-justify-center.png | Bin 0 -> 928 bytes .../32x32/actions/format-justify-left.png | Bin 0 -> 935 bytes .../32x32/actions/format-justify-right.png | Bin 0 -> 936 bytes .../32x32/actions/format-text-bold.png | Bin 0 -> 1051 bytes .../32x32/actions/format-text-italic.png | Bin 0 -> 987 bytes src/libs/vmisc/share/resources/theme.qrc | 15 +++++++++++++++ 16 files changed, 15 insertions(+) create mode 100755 src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/format-justify-center.png create mode 100755 src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/format-justify-left.png create mode 100755 src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/format-justify-right.png create mode 100755 src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/format-text-bold.png create mode 100755 src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/format-text-italic.png create mode 100755 src/libs/vmisc/share/resources/icons/win.icon.theme/24x24/actions/format-justify-center.png create mode 100755 src/libs/vmisc/share/resources/icons/win.icon.theme/24x24/actions/format-justify-left.png create mode 100755 src/libs/vmisc/share/resources/icons/win.icon.theme/24x24/actions/format-justify-right.png create mode 100755 src/libs/vmisc/share/resources/icons/win.icon.theme/24x24/actions/format-text-bold.png create mode 100755 src/libs/vmisc/share/resources/icons/win.icon.theme/24x24/actions/format-text-italic.png create mode 100755 src/libs/vmisc/share/resources/icons/win.icon.theme/32x32/actions/format-justify-center.png create mode 100755 src/libs/vmisc/share/resources/icons/win.icon.theme/32x32/actions/format-justify-left.png create mode 100755 src/libs/vmisc/share/resources/icons/win.icon.theme/32x32/actions/format-justify-right.png create mode 100755 src/libs/vmisc/share/resources/icons/win.icon.theme/32x32/actions/format-text-bold.png create mode 100755 src/libs/vmisc/share/resources/icons/win.icon.theme/32x32/actions/format-text-italic.png diff --git a/src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/format-justify-center.png b/src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/format-justify-center.png new file mode 100755 index 0000000000000000000000000000000000000000..1196e53fc41214675aadf0f260e90d09af9a9e0c GIT binary patch literal 568 zcmV-80>}M{P)&D+K90+7jM0+Q)? zJpMWwjqXVj|0ofW#bWVmI-ULykvjJKeZ&|)mu2~_D2gxmj~WaHk9nT|RMkI`BuEPB z0VH?@EC5Ik4Td-pz|CQ1IH=+y7b1dQjBs-taVG+Is48Z&8P@AH-5uO7 z2%7FBaZ?n?^ZbGUEdj~)uOA5<^Z+x1s$x}Dczt;RL@wmV7!hM^2)t<=Ny15}DO451 z!2rAA@NJl62Ub<6DZI1b1Os7eoeFL3$eDkLbT&FXyf`be&ZRGcQJuH?>RIAmSAa9BSX_`V+ zPZo|L(oZ1*#HTz*o@Eyb4u=|mGz$ED55P_VK3HaVgL|{grUs%V*lxE-lEkZZwM&v< zB<;#ICe^yyZ8jS>GsLH-X9%#2N&KGn(_0XJ<(fjhuYW&0JT3v?FV*IRHe}$)lmGw# zB6?I2D?NY%?PN(TTo*alb-Q_5Tb00002%=cIO)y+cO2>(i^T%<;Q)wSt4X9;hEJ0T z+;0GFcaSKG0&aG9f;`U=LV%fp^b^2AZy)Qr#&WqtQ`dJV7>!0q)3gP6+c=VhlQ1*5 zJF+xI62dirM3!af^?FcMs44u_f)fmcnzo;+P%~WiCxGPmCn7MlHUlT3lL&N}wi~Fb z3XSTG|NU-<&1QqLEMGJ5%PpuW+#PwIBXhqJhY%nl5D~aL)bw%-4l=;B4RN(vT}=>^ z1Z7zw#s~l~v$KU$h;+h^)S@VE#wQ8Y=JgiU^tgqS1rVwRRXs*_U1pb=97DtrP*oL@ zB=PNT`;sKVNZ!Aq^EoHm-S%a_-@BP1K0W<}0M9Xr-_k7o2*U9$0iizBzaJhRp8?=6 zgB^cIFGc7u0000YdQ@0+Q*UN;cVTj6004N}D=#nC%goCzPEIUH)ypqR2LLwM23QbN R%3J^d002ovPDHLkV1n1+^|Jr~ literal 0 HcmV?d00001 diff --git a/src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/format-justify-right.png b/src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/format-justify-right.png new file mode 100755 index 0000000000000000000000000000000000000000..2411b1fd0d0640fc557c76d7466ef240651730c8 GIT binary patch literal 563 zcmV-30?hr1P)zCl8%`NDDF`8r3|TbA-JKK^^%L20uDzStZ)Q*C^EpVS zv)SxRS(cwj5?79h$a=kAE*6XLBC?BFmLbOYaWa{Ft*YuX{^R6%{!kRf4^{mWNrI%1 z9zcTchy?)Yq1OQ-4OXkws|2Go#fLoa4ZI&5Ny15} zDO45X@fc-UqWw1pi5Mf?ds;t4aDss_?FmRiRiS1$Wf*Gh@A`LiB07n%@1Sj4)O8J2 zy^H{06eGH>gK6J^pKd`-;qEAk0;iifD=`GP`;p*KA_GhfW`-=w4ybiqL(R?z(lp%@ zoRmmEmN=v(fvT!5VvvNH?zb>Rz_CQU^O;o@ss>_j&@>H_B=ODj<|Rpjk+f?DB9d&L zH!s`m*3As@@$n}Fc#28|{ASLud1O}{ literal 0 HcmV?d00001 diff --git a/src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/format-text-bold.png b/src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/format-text-bold.png new file mode 100755 index 0000000000000000000000000000000000000000..f0d0f9725b8f1e411d0124f2842797c2c833e8bc GIT binary patch literal 610 zcmV-o0-gPdP)M&!&_(Jv+ZX;M|?3^!t6xY|_j=s_I=;Emc)i zb*kI#ZZos>0cJ+8*BddjQ)c!|RbQy;2Qx!en`U;<%s71Q(I6m2;O@BlAv4?T?k~%- z{I06=m5m`Yo9T2qHB}v4;?e7mNhwKD6jKo~aoUvGXTxj+}{bBtvP--V-jdb#0{V?B8UjU1>gy=1(*gN z0$qSj6{!a7i-?=Rf`}{vWmPP|4qyV<4vYd{fUmon=gU79wgN2?DMaK5aH1-v>N*2_ z1Kt3Oz$M`L$|e2)ZdH>A@N>m=d%*2gCtt1k_xJ@ss1x-sI)DNI001I-R9JLVZ)S9N wVRB^v0C?IfFE7{2%*!rLPAo{(%P&d?05;eLSP)anTmS$707*qoM6N<$f_df$HUIzs literal 0 HcmV?d00001 diff --git a/src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/format-text-italic.png b/src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/format-text-italic.png new file mode 100755 index 0000000000000000000000000000000000000000..fba9d06dfdfc406608f57169edf7e441e12951fe GIT binary patch literal 540 zcmV+%0^|LOP)FAZ($h-*ja=$7WOs~3rmYFWK~dGg=OJ;&e;4b zyFNC8PCIwbojU{nSen*c+jxT{%xtf_SDm&q}%kymI$BK<+N!tE8hpZ~Ox=Mm=w4pWS_3l1oC;9$*Gf#1t=aZ{UEmm?k>U6aW`O&^Vc?XcePg}rz#-rZaJ$w1a)TkT-a-p7 z{_tnO7T|!j+W%AE0pz#WZL?E^wg3PCB6?I2D? eNY%?PN(TTo*alb-Q_5Tb0000->W$%1VcyhPVLPoIHz=?fsSD?y?`st__tNx6t9#4}y^5<4Ld4YRRq|8vfq zGsm(4==FM>ot<%ddio^@g3o}mUYRfqf1jM3{7f-zfW5svTCG;?=;-Ksx7+=ys?l2L z##n>F;K%Xt@wZy7_LLC-c%HZ6IL@x?x;54H1Q=s*9B0?_yba(9hzV2`RaI3%MED4S zsw7x3hMhkkqUZ+*Fb0ugZ>AuUj41_I zRod+~`}_M;EGu&$?X%|(rw4+a9h%MN%IOu@s8$QTODz%+q9{)2C)b6A^e-<<2~?H())of`2UwPcF(&EPWHT8-QGu#buh;1v9fbvWw-qF0Silz4_~+MW(ngfa!F~?d>g-$z(x=s^V{N zCRp8wDbF`c)_7!ZjT2>z#Hf+!=; z5h!trH2EW~h5sgo4G@MQ&(F`}i~hy={r#UUh4p^=V1;*g=T}$1#+#d)>9bkY8}-1k zo%Xu(1H4XOhYx=r!u0+hTbbr~sR89K0000YdQ@0+Q*UN;cVTj6004N}D=#nC%goCz hPEIUH)ypqR2LLwM23QbN%3J^d002ovPDHLkV1mZiPTBwf literal 0 HcmV?d00001 diff --git a/src/libs/vmisc/share/resources/icons/win.icon.theme/24x24/actions/format-justify-left.png b/src/libs/vmisc/share/resources/icons/win.icon.theme/24x24/actions/format-justify-left.png new file mode 100755 index 0000000000000000000000000000000000000000..ea8d277060182192145817f1ad1617ba823225cd GIT binary patch literal 750 zcmV??Ck7tczDRc!NL0|irxUia!bW={BwVQ|68Hi0_gYqtgfzxySuxeH#avw ziilZCT`A}M{QS$_-rlD$3~x&SKoA6;>$+Xv_d}888c<5%x^6cJ0uQ(aGJuF6A|hh3 z*76*Hh|RS!jaGGowSqhYfKpgnKU;QC{1zQp5m*$Y6k4gggQ-@n1CeR zrv@8_AwYR{u0@blZ>?pLBn*c`?nfh<5CXK@Z3f%hbUGcBQaM0?nnm>v9IY7)1`DT2 zYmG6c0+?#%7G<|Z2WgseadAPCBu@(WdOdvKF9&O_&7`F=g92EcfyuAOERy^x_E!NF zhvr)Z(Cc;=vPeWok_4@Fvqc5KT1%3qd_O&9G#>L*js)oVKJT`+XuEDDMGq~?Q)G-m z0qg7Qm1^c!UY&)a8q5FcNPWmPfPknHkVUR}xbxhr#q^;?N`bYe1T3>MfT6UV+RIL| z502P{KLfLCR-*+F$1!(zcjJ@c$0!Tgr3c*ZWkj*N3?PKoA6;)_SW}tJOu;GoX}0YrPc&fd>qML_kCk5fQOi zYk7`ZE&KQr!tO`kh!1sCA?c%v^Dj+~1qM`#4L2J#2{r!?XRydA> zF(!AAG1G{W$5{seaU64feLb^jak;KbyWK`>o$R0TXCjiK1Emzk7)&a5j9Z@D=tz|r!@Z;iwQ55mSSAYP1t;U+S?1gn8DmgDyWK8i zuU33;j^m&T4xX4I0N?iukSL0X<9Mln>$*8(aYSlsYD>@VPT3Apd=TL z*wWX)e9bee0AUz%e}5mHe?LDN4F0?jSntw@N_cZ~a(VeP+Su60-c76VveD92{c7Fw z15Ex+Ztwoyh1v6e-6G7!j)RBU0000YdQ@0+Q*UN;cVTj6004N}D=#nC%goCzPEIUH d)ypqR2LLwM23QbN%3J^d002ovPDHLkV1l&MOgsPp literal 0 HcmV?d00001 diff --git a/src/libs/vmisc/share/resources/icons/win.icon.theme/24x24/actions/format-text-bold.png b/src/libs/vmisc/share/resources/icons/win.icon.theme/24x24/actions/format-text-bold.png new file mode 100755 index 0000000000000000000000000000000000000000..341110cb2bf8bed704a579aaa7b73f45d4f0ad06 GIT binary patch literal 850 zcmV-Y1FigtP)nn7FWq&1BYwTL5;Sc`%n6gm+)5u`YhBC${CpwQMqq4=PnMF&=? zbs#=65(}wu;vksx+^m1^)j`gc<89)-W~K`^95!pMZ~gn`xHnAx_7IGj?tFCu=*Ilm3u=~UYh@Y3ee?5j@oMW=+65@lHqOM2Sfk%YUilQc0fFu;LhpRFD6!n@Z z+}s99YX?YTX=$lX(xkgf(ozkw#oc#HV*KcpwE9C+Rs! zzexIA5{rwA?(QE-YSzt`v@4~=$kcTA07+ZjeN58j`T6ysz7Kd0xZTNv-iUZMB7TjCt7hikoqV;tdE#Js^TfdtD1mw45>Wrcwg9`^ zRoDu$Mu1O%lfaSI=C>cbLR;>`z^B00TJ2@vKsCfY3i^S!faAbA;3?oV@Yo6}w*&70 zgKhh}fD6Fut>Nn)81MkF2wVjkzQ3u=s-fUA9ZRgyI zZ-8-Dj|61?7jYMxyx|CYF*JPu001I-R9JLVZ)S9NVRB^v0C?IfFE7{2%*!rLPAo{( c%P&d?05;eLSP)anTmS$707*qoM6N<$g7Mdi_5c6? literal 0 HcmV?d00001 diff --git a/src/libs/vmisc/share/resources/icons/win.icon.theme/24x24/actions/format-text-italic.png b/src/libs/vmisc/share/resources/icons/win.icon.theme/24x24/actions/format-text-italic.png new file mode 100755 index 0000000000000000000000000000000000000000..acf4a99361fb137aab2c5464ce65506a8551debb GIT binary patch literal 795 zcmV+$1LXXPP)vj4VWy9t{ztBuZ8kre+qJC(1(ESlUv`Zf3%4#KvxvLQ2VkH(4nQ-h!G1(+tYY zyZ794Ec|F<-ZamwoXx$r&N<)j_kM5p!2cf7Y{A)qVF27cb9V>4zp|rYe%4I$N`I9Q z0wILX7~|a#!kI#$K=+O34QmR`08C6w0L&MW^X`7a-4~9Jj}MASoHIbz^=G7%06Kvq zW`?_$+FWzBta#9L~LO1YQL|y{qrqx1GkTD--=eDfQc5>tjQaH2 zNmLb8{h+E}Q%Wn$Y_*v+cSXC--(qxhlwz^i1(Z@sr_JnmxwntJ*%F`ySOAoO*G(x< zRodFxHl>sftLiH=TbVa1iAYIAmWs$X5t%O{>qUfeZ{O?`{7Q89E_Z)xWG^0H(-1B_cHu zc`71PnN#hr{Mx?D*EPW6=>X-s&YUyn+{X}%I6OSW)z#Ia=XtO4`8?(sN-11kUjD08DtAXmNAYvgf9mx*8jVKb zrQ4`fL`)SOo~t=?x2VM9Am! zk0OvGf-uJxhzJO_vK9eB(t@q6Eo^UZKU#A0v?790V@HxOvcOP)nbGg}!TKZ_V`*s# zuImnWCW6++?y}n;g7>?-s8y@+L5K(}GMad6bjZp!#*&k48wPJ66!^)OEXIjMBnOM3Lg#k3NfZwz(x*G1h~GohSK_a zX6eleG70c3IiNQPf&dQ>51GNuSXfwq>$>sjQ*vO)-emsg;sWhgp=W<+8Olt^(GrctRP5G6`51!Zrb=6b6GqDuIDgmh3TsT-b_D ztb_&O%cu+)FmL9|#bxa5>}0mUwn2~jv@)cy4E22=k+e^_BynUxdJ-~}n*W_p52KW6 zNY*%>Hvvw)59r>{>X{UfL@CDvf*`>4&5iPX|NgP9H!XbMzrVh@R_0A9CeUm)(d+g6 z2D?NY%?PN(TTo*alb-Q_5Tb0000j0~YHnGk7(1Zo;gh@E>*hif~2#LffL zBSo=n-+O-kpVuYC?D+T?*VorC9LITSnkLFLr4+8NuKqTg&Bv3IljuH$7oAQA-EP-9 zJ3IT-YPCKRk(3D_BGl{kPLGa`K6g5uX}8-209dgX;5bgLUax;}9Ou1Ass2GkxVgD; z9mn}1BE#^01fY}x0AglRN&zJUfC$V?04VU41c)mU{z~;9?47p%1`zJO5C9?&=JElE z=7u#1Kv@Nzib1h!5lP-astN#th=4@^5%|83-o*tT9v;?mzPY)H*1-X6+lHik%vFF8 zd_8jnWmy(%+fIWoGyz~))=bUdpHiAy=|%Ann5Kz?{e2Lv>VB4RA_8Uxk^b^@NK;8j z(Si_Sbbk*uo$4f7-aBmD#@5!>Y-ge<1i1hNfMWoj=i&VP9HY@_B^87jjYb29hlkNR zA_9wKLOG`oa0FnQCf>E%P|PdkfCLJ}t4S-snRl}QJW~JwYPH%5u9L<*b4WxGF6;vm z^?`8VbUH=9-^cjzacKnvK%-vA_V#w7+@c(y@U0YpentrZW(J3yamgGA`$+ujMI-{y zJ_u^ccA18?{CRxU%y0pL|~0MH|PJRT=DTg42+z{bV~48sT-+>+BUbm;j$eqLU} zb=|c(VXam}yWK{`wxhj^0caKi05FKKx4Zi!1q^)<0igHJ9Y%rwL?9@qB101hU*^53YTyYg2hS5P^$bh zVK|HyOhZbHmY8zkYuo{u#RQgW)_U27u~w005W(NYvs#NCr~XaaZh- z0000YdQ@0+Q*UN;cVTj6004N}D=#nC%goCzPEIUH)ypqR2LLwM23QbN%3J^d002ov JPDHLkV1i?Yl?4C* literal 0 HcmV?d00001 diff --git a/src/libs/vmisc/share/resources/icons/win.icon.theme/32x32/actions/format-justify-right.png b/src/libs/vmisc/share/resources/icons/win.icon.theme/32x32/actions/format-justify-right.png new file mode 100755 index 0000000000000000000000000000000000000000..a31a3ed9c905200e1f23845c25e421718915ec82 GIT binary patch literal 936 zcmV;Z16TZsP)$;rv5R;x8>x7z>!Gw}gj*R5=AZM}D0_pL~w_#h$-1_RG^ z-OnO2jGo5?wAKJX%uHHqpkM+Z0y7f;3bAGhB$bGMh2n>Mr|rKHi1uDd03s0P;t3GV zb?Ynv$|~?&8kD#ek=X}GWdT4C5wHj#0^j%1xxB=~!^4xn%jGhfhlj8%3zEW^s{kQ9 zJ#$RTG)-8Rl_tK@1b}IpQ#HeXN@;4Q7bRU_7zPdx4gzwtE`{k{%nYL7saVVEYWo0}k_m_RxRQZ4{EMLIwz)%W?VI*9@neVa$IO_t(ao{*ke)&^Mh)6(ym(~G^ z>p+?S5uxAjV{mhmI~xRmv$26jqcNKe6unIm2;R*GVI+A}8zL!l9z9;eiL?$dmbicu zF^~kSZEs_zR$E(sAn3F~5Uvpe(Za{a$M}9-Q%b>c94Mv20++KJMu21A$B%9op65NO z5>_e|9335@WLYzcEG9rx7XW}F!kb3pSqi9N5CIVEy|5XD_?aLqm&}i7X~#tp;Fa?LMZG}3kOJAjjtPuLBi!EIY0vYI|a5(hN&%b{8zEk^|(dzjo*Vn(k4Sx^42D?NY%?PN(TTo*alb-Q_5Tb0000< KMNUMnLSTZ-jFyoA literal 0 HcmV?d00001 diff --git a/src/libs/vmisc/share/resources/icons/win.icon.theme/32x32/actions/format-text-bold.png b/src/libs/vmisc/share/resources/icons/win.icon.theme/32x32/actions/format-text-bold.png new file mode 100755 index 0000000000000000000000000000000000000000..f9417f8de46794927f7a198717a174cbac2204f8 GIT binary patch literal 1051 zcmV+$1mydPP)Wi6l8)?x4F}Hu@3r>Y`|Jak@P9{W_rmzZ_qaPD zgdt$S-6P=c{vq&9xm;#qyszba9qkHmcYrJ1eZRZkO~im-K)na$=}b zsjN#~T3rEq56sj_cAMGt4b|6UgQRUSMn+%xa&-kr!pyoQjYu*{$F+p418XEbRIOG! zYPH(x3P|nWYG#`x{VeGvGdrE*!u>JE-d5Ytl7OL?KPO3&lBBV;$}eJ!UrG8pXAXKK z4Z1tqpZjEW1V|#rxZccmNcv0Cr%93|W;SVN)f^XwtJP{t!?>b=T`x=#V?@#}NjI3; ztfUiWM(V(Pjtd(kZIeX*vmY;;f5ke^B3iqmnu$ zO)o4g{9aF*&c;bIo6VVno*3hxyVEy5@!tfb1UE|>FthWLW;!}L)-EnCc5Qz0P*;*9 zU6o3uEa^ynC&U=Dtr&Lqb<1%S{*Lc@>U~P367K#q@P@lrV~q3eUUTyW#b9z#uT+H$KtShQc8XA>8EdJArc{gsD=gluMq$1z@Vc>Y=nfO=uF3 z`DAv65N-r!fw|?FGgTb{PURfg2;AL}f2q(0;u3H>a5eB^dg)!@BcKZW2-LDRW)j{8 zTmw7<4CIKI1l|G811ErF?%=+r8Mq91Et9~3$AHIyUxDqw=>jL82Ob7ufl(vCFmMvs z0i1>AA&kJWRAs%FA&ozPNN4Fk_exDrsH- z+#O&kupZdg(a~`*rF1P&iHJT)gOYmP{m(fExa--sitO(ORsc^|tJP{m{3z*^q&`W@ zB=rGv50JCJ2zU%Q0DPRg;WtSqbNTy$OMoAm`8%ggc-!_jiq>1>?w7m!xVxX8o}R|t zD=DQDDJ9%}K}zYelu}cl=L8TDxO>05Z*ccdBjTg1V`^$D-2J=U3FVa1kh`;b>+ZP$ zxOv+i+#Pqn)7`Ih_wkfc#ogJza~%;uO6l8_lJa-MW=69rw7dr*0-z6g95@Vo0I+}O zI)Eb31n^h>84abB%4Sw=8{qnFVlwBv%EXIFfsSg=Pk|F6cM2_5iNiJYMwut-vZt6O#I= zwW5mPc{HF3^yKBb6gbuvK+f_)U?Xr;(kSpd`7%=kuag&m(F`%z%>P*dMmCKV(_191 z0=5C)02~?L-00h{@>l|fig%yA^2Dq$T4}>xV56BGGqbnN?2O<*eSitT^L&^l*S>}T zbs60R+yJ}^{M-WY3E*^|FV6`ylr!k+0xt#@0lR>!fQNwNz^NG-7dGW=vl7@#?X)}& z+y{J5?TQvNm!eSxx`7vggTNis&iprl9cQr_0rml}152`Q5O^0D11^}&sL>`Y11Et` z_-8#kfg?cBSiZ=B%8zBc!*$Ej5slfVB<$6+q|ZzbAhK)pGe(@@gqL z0000YdQ@0+Q*UN;cVTj6004N}D=#nC%goCzPEIUH)ypqR2LLwM23QbN%3J^d002ov JPDHLkV1gnN!`T1; literal 0 HcmV?d00001 diff --git a/src/libs/vmisc/share/resources/theme.qrc b/src/libs/vmisc/share/resources/theme.qrc index bbca2edc7..a0753b552 100644 --- a/src/libs/vmisc/share/resources/theme.qrc +++ b/src/libs/vmisc/share/resources/theme.qrc @@ -84,5 +84,20 @@ icons/win.icon.theme/16x16/actions/help-about.png icons/win.icon.theme/24x24/actions/help-about.png icons/win.icon.theme/32x32/actions/help-about.png + icons/win.icon.theme/16x16/actions/format-justify-center.png + icons/win.icon.theme/16x16/actions/format-justify-left.png + icons/win.icon.theme/16x16/actions/format-justify-right.png + icons/win.icon.theme/16x16/actions/format-text-bold.png + icons/win.icon.theme/16x16/actions/format-text-italic.png + icons/win.icon.theme/24x24/actions/format-justify-left.png + icons/win.icon.theme/24x24/actions/format-justify-right.png + icons/win.icon.theme/24x24/actions/format-justify-center.png + icons/win.icon.theme/24x24/actions/format-text-bold.png + icons/win.icon.theme/24x24/actions/format-text-italic.png + icons/win.icon.theme/32x32/actions/format-justify-center.png + icons/win.icon.theme/32x32/actions/format-justify-left.png + icons/win.icon.theme/32x32/actions/format-justify-right.png + icons/win.icon.theme/32x32/actions/format-text-bold.png + icons/win.icon.theme/32x32/actions/format-text-italic.png From 80f6a5a7d164aeab87c7458193b461f29ec25d50 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 9 Aug 2017 17:33:20 +0300 Subject: [PATCH 03/54] Redesign. The Label editor should be in separate dialog window. --HG-- branch : feature --- .../dialogs/dialogpatternproperties.ui | 447 +++++------------- src/libs/vtools/dialogs/dialogs.pri | 9 +- .../dialogs/support/dialogeditlabel.cpp | 14 + .../vtools/dialogs/support/dialogeditlabel.h | 22 + .../vtools/dialogs/support/dialogeditlabel.ui | 352 ++++++++++++++ 5 files changed, 509 insertions(+), 335 deletions(-) create mode 100644 src/libs/vtools/dialogs/support/dialogeditlabel.cpp create mode 100644 src/libs/vtools/dialogs/support/dialogeditlabel.h create mode 100644 src/libs/vtools/dialogs/support/dialogeditlabel.ui diff --git a/src/app/valentina/dialogs/dialogpatternproperties.ui b/src/app/valentina/dialogs/dialogpatternproperties.ui index bab0fa5e3..93b8fa22f 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.ui +++ b/src/app/valentina/dialogs/dialogpatternproperties.ui @@ -14,18 +14,18 @@ Pattern properties - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - 4 + 0 - Description + Pattern @@ -85,7 +85,7 @@ - Author name + Author: @@ -183,7 +183,7 @@ - For technical notes. + For technical notes @@ -1205,83 +1205,131 @@ - General info + Label data - + - - - + + + - Pattern name: + Label: - - - - 30 + + + + Edit pattern label - - - - - Pattern number: + Edit label - - - - 30 + + + + Qt::Horizontal - - - - - - Company/Designer name: + + + 40 + 20 + - - - - - - 30 - - - - - - - Customer name: - - - - - - - 30 - - - - - - - Pattern size: - - - - - - - 40 - - + + + + + + 0 + 1 + + + + Label data + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Pattern name: + + + + + + + 30 + + + + + + + Pattern number: + + + + + + + 30 + + + + + + + Company/Designer name: + + + + + + + 30 + + + + + + + Customer name: + + + + + + + 30 + + + + + + + Pattern size: + + + + + + + 40 + + + + + + @@ -1298,269 +1346,6 @@ - - - Pattern label data - - - - - - - - Clear current and begin new label - - - ... - - - - - - - 24 - 24 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Import from label template - - - ... - - - - - - - 24 - 24 - - - - - - - - Export label as template - - - ... - - - - - - - 24 - 24 - - - - - - - - - - - 0 - 1 - - - - QAbstractItemView::InternalMove - - - - - - - - - 6 - - - - - Bold - - - ... - - - - - - true - - - - - - - Italic - - - ... - - - - - - true - - - - - - - Aligns with the left edge - - - ... - - - - - - true - - - - - - - Centers horizontally in the available space - - - ... - - - - - - true - - - - - - - Aligns with the right edge - - - ... - - - - - - true - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - ... - - - - .. - - - - - - - false - - - ... - - - - .. - - - - - - - - - Text: - - - - - - - - - true - - - Line of text - - - true - - - - - - - Insert placeholders - - - Insert... - - - - - - - - - @@ -1575,9 +1360,7 @@ - - - + buttonBox diff --git a/src/libs/vtools/dialogs/dialogs.pri b/src/libs/vtools/dialogs/dialogs.pri index 8678e3bfb..5d2fad588 100644 --- a/src/libs/vtools/dialogs/dialogs.pri +++ b/src/libs/vtools/dialogs/dialogs.pri @@ -45,7 +45,8 @@ HEADERS += \ $$PWD/tools/piece/dialogseamallowance.h \ $$PWD/tools/piece/dialogpiecepath.h \ $$PWD/tools/dialogpin.h \ - $$PWD/tools/dialoginsertnode.h + $$PWD/tools/dialoginsertnode.h \ + $$PWD/support/dialogeditlabel.h SOURCES += \ $$PWD/tools/dialogalongline.cpp \ @@ -90,7 +91,8 @@ SOURCES += \ $$PWD/tools/piece/dialogseamallowance.cpp \ $$PWD/tools/piece/dialogpiecepath.cpp \ $$PWD/tools/dialogpin.cpp \ - $$PWD/tools/dialoginsertnode.cpp + $$PWD/tools/dialoginsertnode.cpp \ + $$PWD/support/dialogeditlabel.cpp FORMS += \ $$PWD/tools/dialogalongline.ui \ @@ -139,4 +141,5 @@ FORMS += \ $$PWD/tools/piece/tabs/tabgrainline.ui \ $$PWD/tools/piece/tabs/tabpins.ui \ $$PWD/tools/dialoginsertnode.ui \ - $$PWD/tools/piece/tabs/tabpassmarks.ui + $$PWD/tools/piece/tabs/tabpassmarks.ui \ + $$PWD/support/dialogeditlabel.ui diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp new file mode 100644 index 000000000..fcee126b6 --- /dev/null +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -0,0 +1,14 @@ +#include "dialogeditlabel.h" +#include "ui_dialogeditlabel.h" + +DialogEditLabel::DialogEditLabel(QWidget *parent) : + QDialog(parent), + ui(new Ui::DialogEditLabel) +{ + ui->setupUi(this); +} + +DialogEditLabel::~DialogEditLabel() +{ + delete ui; +} diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h new file mode 100644 index 000000000..27222cd3b --- /dev/null +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -0,0 +1,22 @@ +#ifndef DIALOGEDITLABEL_H +#define DIALOGEDITLABEL_H + +#include + +namespace Ui { +class DialogEditLabel; +} + +class DialogEditLabel : public QDialog +{ + Q_OBJECT + +public: + explicit DialogEditLabel(QWidget *parent = 0); + ~DialogEditLabel(); + +private: + Ui::DialogEditLabel *ui; +}; + +#endif // DIALOGEDITLABEL_H diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.ui b/src/libs/vtools/dialogs/support/dialogeditlabel.ui new file mode 100644 index 000000000..f03651427 --- /dev/null +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.ui @@ -0,0 +1,352 @@ + + + DialogEditLabel + + + + 0 + 0 + 494 + 384 + + + + Dialog + + + + + + + + false + + + Clear current and begin new label + + + ... + + + + .. + + + + 24 + 24 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Import from label template + + + ... + + + + .. + + + + 24 + 24 + + + + + + + + false + + + Export label as template + + + ... + + + + .. + + + + 24 + 24 + + + + + + + + + + + 0 + 1 + + + + QAbstractItemView::InternalMove + + + + + + + + + 6 + + + + + false + + + Bold + + + ... + + + + .. + + + true + + + + + + + false + + + Italic + + + ... + + + + .. + + + true + + + + + + + false + + + Aligns with the left edge + + + ... + + + + .. + + + true + + + + + + + false + + + Centers horizontally in the available space + + + ... + + + + .. + + + true + + + + + + + false + + + Aligns with the right edge + + + ... + + + + .. + + + true + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + ... + + + + ../../../../app/valentina/dialogs../../../../app/valentina/dialogs + + + + + + + false + + + ... + + + + ../../../../app/valentina/dialogs../../../../app/valentina/dialogs + + + + + + + + + Text: + + + + + + + + + false + + + Line of text + + + true + + + + + + + false + + + Insert placeholders + + + Insert... + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + DialogEditLabel + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogEditLabel + reject() + + + 316 + 260 + + + 286 + 274 + + + + + From 7b13020e4e5a509f8bb0bb369c6eb1787cde9d80 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 9 Aug 2017 19:32:14 +0300 Subject: [PATCH 04/54] Button to call Label editor. --HG-- branch : feature --- .../dialogs/dialogpatternproperties.cpp | 9 +++++++++ .../valentina/dialogs/dialogpatternproperties.h | 1 + .../valentina/dialogs/dialogpatternproperties.ui | 12 +++++++----- .../vtools/dialogs/support/dialogeditlabel.h | 10 ++++++---- .../vtools/dialogs/support/dialogeditlabel.ui | 16 ++++++++++++++-- 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 11078857d..c087bf8a2 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -36,6 +36,7 @@ #include "../xml/vpattern.h" #include "../vpatterndb/vcontainer.h" #include "../core/vapplication.h" +#include "../vtools/dialogs/support/dialogeditlabel.h" // calc how many combinations we have static const int heightsCount = (static_cast(GHeights::H200) - @@ -201,6 +202,7 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte connect(ui->lineEditSize, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged); connect(ui->checkBoxShowDate, &QCheckBox::stateChanged, this, &DialogPatternProperties::GeneralInfoChanged); connect(ui->checkBoxShowMeasurements, &QCheckBox::stateChanged, this, &DialogPatternProperties::GeneralInfoChanged); + connect(ui->pushButtonEditPatternLabel, &QPushButton::clicked, this, &DialogPatternProperties::EditLabel); } //--------------------------------------------------------------------------------------------------------------------- @@ -849,3 +851,10 @@ void DialogPatternProperties::SaveImage() } } } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::EditLabel() +{ + DialogEditLabel editor; + editor.exec(); +} diff --git a/src/app/valentina/dialogs/dialogpatternproperties.h b/src/app/valentina/dialogs/dialogpatternproperties.h index ecdfae10d..21b186455 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.h +++ b/src/app/valentina/dialogs/dialogpatternproperties.h @@ -62,6 +62,7 @@ private slots: void DescEdited(); void ChangeImage(); void SaveImage(); + void EditLabel(); private: Q_DISABLE_COPY(DialogPatternProperties) Ui::DialogPatternProperties *ui; diff --git a/src/app/valentina/dialogs/dialogpatternproperties.ui b/src/app/valentina/dialogs/dialogpatternproperties.ui index 93b8fa22f..bbb31adcb 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.ui +++ b/src/app/valentina/dialogs/dialogpatternproperties.ui @@ -14,14 +14,14 @@ Pattern properties - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - 0 + 3 @@ -1213,7 +1213,7 @@ - Label: + Label template: @@ -1223,7 +1223,7 @@ Edit pattern label - Edit label + Edit template @@ -1360,7 +1360,9 @@ - + + + buttonBox diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h index 27222cd3b..c046e931f 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.h +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -3,8 +3,9 @@ #include -namespace Ui { -class DialogEditLabel; +namespace Ui +{ + class DialogEditLabel; } class DialogEditLabel : public QDialog @@ -12,10 +13,11 @@ class DialogEditLabel : public QDialog Q_OBJECT public: - explicit DialogEditLabel(QWidget *parent = 0); - ~DialogEditLabel(); + explicit DialogEditLabel(QWidget *parent = nullptr); + virtual ~DialogEditLabel(); private: + Q_DISABLE_COPY(DialogEditLabel) Ui::DialogEditLabel *ui; }; diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.ui b/src/libs/vtools/dialogs/support/dialogeditlabel.ui index f03651427..f39f918d1 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.ui +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.ui @@ -2,6 +2,9 @@ DialogEditLabel + + Qt::ApplicationModal + 0 @@ -11,7 +14,14 @@ - Dialog + Edit label template + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + true @@ -314,7 +324,9 @@ - + + + buttonBox From 7f570106dbd585fadbbbf42ba61c87accc492595 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 10 Aug 2017 14:47:56 +0300 Subject: [PATCH 05/54] Finished basic functions. --HG-- branch : feature --- .../dialogs/support/dialogeditlabel.cpp | 291 +++++++++++++++++- .../vtools/dialogs/support/dialogeditlabel.h | 41 +++ .../vtools/dialogs/support/dialogeditlabel.ui | 8 +- 3 files changed, 333 insertions(+), 7 deletions(-) diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index fcee126b6..08fee00ac 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -1,14 +1,299 @@ +/************************************************************************ + ** + ** @file dialogeditlabel.cpp + ** @author Roman Telezhynskyi + ** @date 11 8, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2013-2017 Valentina project + ** All Rights Reserved. + ** + ** Valentina 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 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina 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. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + #include "dialogeditlabel.h" #include "ui_dialogeditlabel.h" +#include "../vmisc/vabstractapplication.h" -DialogEditLabel::DialogEditLabel(QWidget *parent) : - QDialog(parent), - ui(new Ui::DialogEditLabel) +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +DialogEditLabel::DialogEditLabel(QWidget *parent) + : QDialog(parent), + ui(new Ui::DialogEditLabel) { ui->setupUi(this); + + ui->lineEditLine->setClearButtonEnabled(true); + + connect(ui->toolButtonAdd, &QToolButton::clicked, this, &DialogEditLabel::AddLine); + connect(ui->toolButtonRemove, &QToolButton::clicked, this, &DialogEditLabel::RemoveLine); + connect(ui->lineEditLine, &QLineEdit::textEdited, this, &DialogEditLabel::SaveLineText); + connect(ui->toolButtonBold, &QToolButton::toggled, this, &DialogEditLabel::SaveFontStyle); + connect(ui->toolButtonItalic, &QToolButton::toggled, this, &DialogEditLabel::SaveFontStyle); + connect(ui->toolButtonTextLeft, &QToolButton::toggled, this, &DialogEditLabel::SaveTextFormating); + connect(ui->toolButtonTextCenter, &QToolButton::toggled, this, &DialogEditLabel::SaveTextFormating); + connect(ui->toolButtonTextRight, &QToolButton::toggled, this, &DialogEditLabel::SaveTextFormating); + connect(ui->listWidget, &QListWidget::itemSelectionChanged, this, &DialogEditLabel::ShowLineDetails); + connect(ui->toolButtonNewLabel, &QToolButton::clicked, this, &DialogEditLabel::NewTemplate); } +//--------------------------------------------------------------------------------------------------------------------- DialogEditLabel::~DialogEditLabel() { delete ui; } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::ShowLineDetails() +{ + if (ui->listWidget->count() > 0) + { + const QListWidgetItem *line = ui->listWidget->currentItem(); + if (line) + { + ui->lineEditLine->blockSignals(true); + ui->lineEditLine->setText(line->text()); + ui->lineEditLine->selectAll(); + ui->lineEditLine->setFocus(); + ui->lineEditLine->blockSignals(false); + + const QFont lineFont = line->font(); + + ui->toolButtonBold->blockSignals(true); + ui->toolButtonBold->setChecked(lineFont.bold()); + ui->toolButtonBold->blockSignals(false); + + ui->toolButtonItalic->blockSignals(true); + ui->toolButtonItalic->setChecked(lineFont.italic()); + ui->toolButtonItalic->blockSignals(false); + + ui->toolButtonTextLeft->blockSignals(true); + ui->toolButtonTextCenter->blockSignals(true); + ui->toolButtonTextRight->blockSignals(true); + + const int lineAlignment = line->textAlignment(); + + if (lineAlignment & Qt::AlignLeft) + { + ui->toolButtonTextLeft->setChecked(true); + ui->toolButtonTextCenter->setChecked(false); + ui->toolButtonTextRight->setChecked(false); + } + else if (lineAlignment & Qt::AlignCenter) + { + ui->toolButtonTextLeft->setChecked(false); + ui->toolButtonTextCenter->setChecked(true); + ui->toolButtonTextRight->setChecked(false); + } + else if (lineAlignment & Qt::AlignRight) + { + ui->toolButtonTextLeft->setChecked(false); + ui->toolButtonTextCenter->setChecked(false); + ui->toolButtonTextRight->setChecked(true); + } + + ui->toolButtonTextLeft->blockSignals(false); + ui->toolButtonTextCenter->blockSignals(false); + ui->toolButtonTextRight->blockSignals(false); + } + } + + SetupControls(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::AddLine() +{ + int row = ui->listWidget->currentRow(); + ui->listWidget->insertItem(++row, new QListWidgetItem(tr(""))); + ui->listWidget->setCurrentRow(row); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::RemoveLine() +{ + ui->listWidget->blockSignals(true); + QListWidgetItem *curLine = ui->listWidget->takeItem(ui->listWidget->currentRow()); + if (curLine) + { + delete curLine; + } + ui->listWidget->blockSignals(false); + ShowLineDetails(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::SaveLineText(const QString &text) +{ + QListWidgetItem *curLine = ui->listWidget->currentItem(); + if (curLine) + { + curLine->setText(text); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::SaveFontStyle(bool checked) +{ + QListWidgetItem *curLine = ui->listWidget->currentItem(); + if (curLine) + { + QFont lineFont = curLine->font(); + + QToolButton *button = qobject_cast(sender()); + if (button) + { + if (button == ui->toolButtonBold) + { + lineFont.setBold(checked); + } + else if (button == ui->toolButtonItalic) + { + lineFont.setItalic(checked); + } + } + + curLine->setFont(lineFont); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::SaveTextFormating(bool checked) +{ + QListWidgetItem *curLine = ui->listWidget->currentItem(); + if (curLine) + { + QToolButton *button = qobject_cast(sender()); + if (button) + { + ui->toolButtonTextLeft->blockSignals(true); + ui->toolButtonTextCenter->blockSignals(true); + ui->toolButtonTextRight->blockSignals(true); + + if (button == ui->toolButtonTextLeft) + { + if (checked) + { + curLine->setTextAlignment(Qt::AlignLeft); + + ui->toolButtonTextCenter->setChecked(false); + ui->toolButtonTextRight->setChecked(false); + } + else + { + button->setChecked(true); + } + } + else if (button == ui->toolButtonTextCenter) + { + if (checked) + { + curLine->setTextAlignment(Qt::AlignCenter); + + ui->toolButtonTextLeft->setChecked(false); + ui->toolButtonTextRight->setChecked(false); + } + else + { + button->setChecked(true); + } + } + else if (button == ui->toolButtonTextRight) + { + if (checked) + { + curLine->setTextAlignment(Qt::AlignRight); + + ui->toolButtonTextCenter->setChecked(false); + ui->toolButtonTextRight->setChecked(false); + } + else + { + button->setChecked(true); + } + } + + ui->toolButtonTextLeft->blockSignals(false); + ui->toolButtonTextCenter->blockSignals(false); + ui->toolButtonTextRight->blockSignals(false); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::NewTemplate() +{ + if (ui->listWidget->count() > 0) + { + const QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Create new template"), + tr("Creating new template will overwrite the current, do " + "you want to continue?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + if (answer == QMessageBox::No) + { + return; + } + } + + ui->listWidget->blockSignals(true); + ui->listWidget->clear(); + ui->listWidget->blockSignals(false); + ShowLineDetails(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::ExportTemplate() +{ + +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::ImportTemplate() +{ + +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::SetupControls() +{ + const bool enabled = ui->listWidget->count() > 0; + + if (not enabled) + { + ui->lineEditLine->blockSignals(true); + ui->lineEditLine->clear(); + ui->lineEditLine->blockSignals(false); + } + + ui->toolButtonAdd->setEnabled(true); + ui->toolButtonImportLabel->setEnabled(true); + + ui->toolButtonRemove->setEnabled(enabled); + ui->toolButtonBold->setEnabled(enabled); + ui->toolButtonItalic->setEnabled(enabled); + ui->toolButtonTextLeft->setEnabled(enabled); + ui->toolButtonTextCenter->setEnabled(enabled); + ui->toolButtonTextRight->setEnabled(enabled); + ui->pushButtonInsert->setEnabled(enabled); + ui->toolButtonNewLabel->setEnabled(enabled); + ui->toolButtonExportLabel->setEnabled(enabled); + ui->lineEditLine->setEnabled(enabled); +} diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h index c046e931f..1c29af271 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.h +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -1,3 +1,31 @@ +/************************************************************************ + ** + ** @file dialogeditlabel.h + ** @author Roman Telezhynskyi + ** @date 11 8, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2013-2017 Valentina project + ** All Rights Reserved. + ** + ** Valentina 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 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina 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. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + #ifndef DIALOGEDITLABEL_H #define DIALOGEDITLABEL_H @@ -16,9 +44,22 @@ public: explicit DialogEditLabel(QWidget *parent = nullptr); virtual ~DialogEditLabel(); +private slots: + void ShowLineDetails(); + void AddLine(); + void RemoveLine(); + void SaveLineText(const QString &text); + void SaveFontStyle(bool checked); + void SaveTextFormating(bool checked); + void NewTemplate(); + void ExportTemplate(); + void ImportTemplate(); + private: Q_DISABLE_COPY(DialogEditLabel) Ui::DialogEditLabel *ui; + + void SetupControls(); }; #endif // DIALOGEDITLABEL_H diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.ui b/src/libs/vtools/dialogs/support/dialogeditlabel.ui index f39f918d1..de611d6a6 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.ui +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.ui @@ -241,7 +241,7 @@ - + 0 @@ -258,7 +258,7 @@ - + false @@ -283,7 +283,7 @@ - + false @@ -291,7 +291,7 @@ Line of text - true + false From 209a281cdc94b6a93cea0099b81623bae0cf331c Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 10 Aug 2017 14:51:17 +0300 Subject: [PATCH 06/54] New standard path for label templates. --HG-- branch : feature --- .../configpages/preferencespathpage.cpp | 16 +++++- src/libs/vmisc/vcommonsettings.cpp | 21 +++++++- src/libs/vmisc/vcommonsettings.h | 4 ++ .../dialogs/support/dialogeditlabel.cpp | 50 +++++++++++++++++++ 4 files changed, 89 insertions(+), 2 deletions(-) diff --git a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp index 9e0926409..c1cb7ff4d 100644 --- a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp @@ -63,6 +63,7 @@ void PreferencesPathPage::Apply() settings->SetPathPattern(ui->pathTable->item(2, 1)->text()); settings->SetPathLayout(ui->pathTable->item(3, 1)->text()); settings->SetPathTemplate(ui->pathTable->item(4, 1)->text()); + settings->SetPathLabelTemplate(ui->pathTable->item(5, 1)->text()); } //--------------------------------------------------------------------------------------------------------------------- @@ -91,6 +92,9 @@ void PreferencesPathPage::DefaultPath() case 4: // templates path = VCommonSettings::GetDefPathTemplate(); break; + case 5: // label templates + path = VSettings::GetDefPathLabelTemplate(); + break; default: break; } @@ -125,6 +129,9 @@ void PreferencesPathPage::EditPath() case 4: // templates path = qApp->ValentinaSettings()->GetPathTemplate(); break; + case 5: // label templates + path = qApp->ValentinaSettings()->GetPathLabelTemplate(); + break; default: break; } @@ -164,7 +171,7 @@ void PreferencesPathPage::EditPath() //--------------------------------------------------------------------------------------------------------------------- void PreferencesPathPage::InitTable() { - ui->pathTable->setRowCount(5); + ui->pathTable->setRowCount(6); ui->pathTable->setColumnCount(2); const VSettings *settings = qApp->ValentinaSettings(); @@ -204,6 +211,13 @@ void PreferencesPathPage::InitTable() ui->pathTable->setItem(4, 1, item); } + { + ui->pathTable->setItem(5, 0, new QTableWidgetItem(tr("My label templates"))); + QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathLabelTemplate()); + item->setToolTip(settings->GetPathLabelTemplate()); + ui->pathTable->setItem(5, 1, item); + } + ui->pathTable->verticalHeader()->setDefaultSectionSize(20); ui->pathTable->resizeColumnsToContents(); ui->pathTable->resizeRowsToContents(); diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index 4a38fef82..f70e61024 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -46,8 +46,9 @@ #include "../vpatterndb/pmsystems.h" const QString settingPathsIndividualMeasurements = QStringLiteral("paths/individual_measurements"); -const QString settingPathsMultisizeMeasurements = QStringLiteral("paths/standard_measurements"); +const QString settingPathsMultisizeMeasurements = QStringLiteral("paths/standard_measurements"); const QString settingPathsTemplates = QStringLiteral("paths/templates"); +const QString settingPathsLabelTemplate = QStringLiteral("paths/labelTemplate"); const QString settingConfigurationOsSeparator = QStringLiteral("configuration/osSeparator"); const QString settingConfigurationAutosaveState = QStringLiteral("configuration/autosave/state"); @@ -314,6 +315,24 @@ void VCommonSettings::SetPathTemplate(const QString &value) settings.sync(); } +//--------------------------------------------------------------------------------------------------------------------- +QString VCommonSettings::GetDefPathLabelTemplate() +{ + return QDir::homePath() + QLatin1String("/valentina/") + tr("label templates"); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VCommonSettings::GetPathLabelTemplate() const +{ + return value(settingPathsLabelTemplate, GetDefPathLabelTemplate()).toString(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VCommonSettings::SetPathLabelTemplate(const QString &value) +{ + setValue(settingPathsLabelTemplate, value); +} + //--------------------------------------------------------------------------------------------------------------------- bool VCommonSettings::GetOsSeparator() const { diff --git a/src/libs/vmisc/vcommonsettings.h b/src/libs/vmisc/vcommonsettings.h index fb2c79bba..c5d7d153d 100644 --- a/src/libs/vmisc/vcommonsettings.h +++ b/src/libs/vmisc/vcommonsettings.h @@ -66,6 +66,10 @@ public: QString GetPathTemplate() const; void SetPathTemplate(const QString &value); + static QString GetDefPathLabelTemplate(); + QString GetPathLabelTemplate() const; + void SetPathLabelTemplate(const QString &value); + bool GetOsSeparator() const; void SetOsSeparator(const bool &value); diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index 08fee00ac..74b60697f 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -53,6 +53,7 @@ DialogEditLabel::DialogEditLabel(QWidget *parent) connect(ui->toolButtonTextRight, &QToolButton::toggled, this, &DialogEditLabel::SaveTextFormating); connect(ui->listWidget, &QListWidget::itemSelectionChanged, this, &DialogEditLabel::ShowLineDetails); connect(ui->toolButtonNewLabel, &QToolButton::clicked, this, &DialogEditLabel::NewTemplate); + connect(ui->toolButtonExportLabel, &QToolButton::clicked, this, &DialogEditLabel::ExportTemplate); } //--------------------------------------------------------------------------------------------------------------------- @@ -262,7 +263,56 @@ void DialogEditLabel::NewTemplate() //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::ExportTemplate() { + QString filters(tr("Label template") + QLatin1String("(*.xml)")); + QString dir = qApp->Settings()->GetPathLabelTemplate(); + bool usedNotExistedDir = false; + QDir directory(dir); + if (not directory.exists()) + { + usedNotExistedDir = directory.mkpath("."); + } + + QString fileName = QFileDialog::getSaveFileName(this, tr("Export label template"), + dir + QLatin1String("/") + tr("template") + QLatin1String(".xml"), + filters, nullptr, QFileDialog::DontUseNativeDialog); + + auto RemoveTempDir = [usedNotExistedDir, dir]() + { + if (usedNotExistedDir) + { + QDir directory(dir); + directory.rmpath("."); + } + }; + + if (fileName.isEmpty()) + { + RemoveTempDir(); + return; + } + + QFileInfo f( fileName ); + if (f.suffix().isEmpty() && f.suffix() != QLatin1String("xml")) + { + fileName += QLatin1String(".xml"); + } + +// QString error; +// const bool result = doc->SaveDocument(fileName, error); +// if (result == false) +// { +// QMessageBox messageBox(this); +// messageBox.setIcon(QMessageBox::Warning); +// messageBox.setInformativeText(tr("Could not save file")); +// messageBox.setDefaultButton(QMessageBox::Ok); +// messageBox.setDetailedText(error); +// messageBox.setStandardButtons(QMessageBox::Ok); +// messageBox.exec(); +// } + + RemoveTempDir(); + return; } //--------------------------------------------------------------------------------------------------------------------- From b4c0651de4b6e681de5a7b856f18d85a158cd603 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 10 Aug 2017 17:14:39 +0300 Subject: [PATCH 07/54] Added export the template. --HG-- branch : feature --- src/libs/vformat/vformat.pri | 6 +- src/libs/vformat/vlabeltemplate.cpp | 86 +++++++++++++++++++ src/libs/vformat/vlabeltemplate.h | 69 +++++++++++++++ .../dialogs/support/dialogeditlabel.cpp | 54 +++++++++--- .../vtools/dialogs/support/dialogeditlabel.h | 4 + 5 files changed, 205 insertions(+), 14 deletions(-) create mode 100644 src/libs/vformat/vlabeltemplate.cpp create mode 100644 src/libs/vformat/vlabeltemplate.h diff --git a/src/libs/vformat/vformat.pri b/src/libs/vformat/vformat.pri index 5afe5834a..2d8f8f3ad 100644 --- a/src/libs/vformat/vformat.pri +++ b/src/libs/vformat/vformat.pri @@ -2,10 +2,12 @@ # This need for corect working file translations.pro SOURCES += \ - $$PWD/vmeasurements.cpp + $$PWD/vmeasurements.cpp \ + $$PWD/vlabeltemplate.cpp *msvc*:SOURCES += $$PWD/stable.cpp HEADERS += \ $$PWD/vmeasurements.h \ - $$PWD/stable.h + $$PWD/stable.h \ + $$PWD/vlabeltemplate.h diff --git a/src/libs/vformat/vlabeltemplate.cpp b/src/libs/vformat/vlabeltemplate.cpp new file mode 100644 index 000000000..b1ba21171 --- /dev/null +++ b/src/libs/vformat/vlabeltemplate.cpp @@ -0,0 +1,86 @@ +/************************************************************************ + ** + ** @file vlabeltemplate.cpp + ** @author Roman Telezhynskyi + ** @date 10 8, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina 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 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina 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. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "vlabeltemplate.h" + +const QString VLabelTemplate::TagTemplate = QStringLiteral("template"); +const QString VLabelTemplate::TagLines = QStringLiteral("lines"); +const QString VLabelTemplate::TagLine = QStringLiteral("line"); + +const QString VLabelTemplate::AttrText = QStringLiteral("text"); +const QString VLabelTemplate::AttrBold = QStringLiteral("bold"); +const QString VLabelTemplate::AttrItalic = QStringLiteral("italic"); +const QString VLabelTemplate::AttrAlignment = QStringLiteral("alignment"); + +//--------------------------------------------------------------------------------------------------------------------- +VLabelTemplate::VLabelTemplate() + : VDomDocument() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VLabelTemplate::CreateEmptyTemplate() +{ + clear(); + QDomElement templateElement = this->createElement(TagTemplate); + + QDomElement version = createElement(TagVersion); + QDomText newNodeText = createTextNode("1.0"/*VLabelTemplateConverter::TemplateMaxVerStr*/); + version.appendChild(newNodeText); + templateElement.appendChild(version); + + templateElement.appendChild(createElement(TagLines)); + + this->appendChild(templateElement); + insertBefore(createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""), this->firstChild()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLabelTemplate::AddLines(const QVector &lines) +{ + const QDomNodeList listLines = elementsByTagName(TagLines); + if (listLines.size() == 0) + { + return; + } + + QDomElement tagLines = listLines.at(0).toElement(); + if (not tagLines.isNull()) + { + for (int i=0; i < lines.size(); ++i) + { + QDomElement tagLine = createElement(TagLine); + + SetAttribute(tagLine, AttrText, lines.at(i).line); + SetAttribute(tagLine, AttrBold, lines.at(i).bold); + SetAttribute(tagLine, AttrItalic, lines.at(i).italic); + SetAttribute(tagLine, AttrAlignment, lines.at(i).alignment); + + tagLines.appendChild(tagLine); + } + } +} diff --git a/src/libs/vformat/vlabeltemplate.h b/src/libs/vformat/vlabeltemplate.h new file mode 100644 index 000000000..294b9a0ef --- /dev/null +++ b/src/libs/vformat/vlabeltemplate.h @@ -0,0 +1,69 @@ +/************************************************************************ + ** + ** @file vlabeltemplate.h + ** @author Roman Telezhynskyi + ** @date 10 8, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina 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 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina 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. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VLABELTEMPLATE_H +#define VLABELTEMPLATE_H + +#include "../ifc/xml/vdomdocument.h" + +QT_WARNING_PUSH +QT_WARNING_DISABLE_GCC("-Weffc++") + +struct VLabelTemplateLine +{ + QString line; + bool bold; + bool italic; + int alignment; +}; + +QT_WARNING_POP + +class VLabelTemplate : public VDomDocument +{ +public: + VLabelTemplate(); + virtual ~VLabelTemplate() Q_DECL_EQ_DEFAULT; + + static const QString TagTemplate; + static const QString TagLines; + static const QString TagLine; + + static const QString AttrText; + static const QString AttrBold; + static const QString AttrItalic; + static const QString AttrAlignment; + + void CreateEmptyTemplate(); + + void AddLines(const QVector &lines); +private: + Q_DISABLE_COPY(VLabelTemplate) +}; + +#endif // VLABELTEMPLATE_H diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index 74b60697f..885ed6e34 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -29,6 +29,7 @@ #include "dialogeditlabel.h" #include "ui_dialogeditlabel.h" #include "../vmisc/vabstractapplication.h" +#include "../vformat/vlabeltemplate.h" #include #include @@ -298,18 +299,22 @@ void DialogEditLabel::ExportTemplate() fileName += QLatin1String(".xml"); } -// QString error; -// const bool result = doc->SaveDocument(fileName, error); -// if (result == false) -// { -// QMessageBox messageBox(this); -// messageBox.setIcon(QMessageBox::Warning); -// messageBox.setInformativeText(tr("Could not save file")); -// messageBox.setDefaultButton(QMessageBox::Ok); -// messageBox.setDetailedText(error); -// messageBox.setStandardButtons(QMessageBox::Ok); -// messageBox.exec(); -// } + VLabelTemplate ltemplate; + ltemplate.CreateEmptyTemplate(); + ltemplate.AddLines(PrepareLines()); + + QString error; + const bool result = ltemplate.SaveDocument(fileName, error); + if (result == false) + { + QMessageBox messageBox(this); + messageBox.setIcon(QMessageBox::Warning); + messageBox.setInformativeText(tr("Could not save file")); + messageBox.setDefaultButton(QMessageBox::Ok); + messageBox.setDetailedText(error); + messageBox.setStandardButtons(QMessageBox::Ok); + messageBox.exec(); + } RemoveTempDir(); return; @@ -347,3 +352,28 @@ void DialogEditLabel::SetupControls() ui->toolButtonExportLabel->setEnabled(enabled); ui->lineEditLine->setEnabled(enabled); } + +//--------------------------------------------------------------------------------------------------------------------- +QVector DialogEditLabel::PrepareLines() const +{ + QVector lines; + + for (int i=0; ilistWidget->count(); ++i) + { + const QListWidgetItem *lineItem = ui->listWidget->item(i); + if (lineItem) + { + VLabelTemplateLine line; + line.line = lineItem->text(); + line.alignment = lineItem->textAlignment(); + + const QFont font = lineItem->font(); + line.bold = font.bold(); + line.italic = font.italic(); + + lines.append(line); + } + } + + return lines; +} diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h index 1c29af271..2040fbde2 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.h +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -36,6 +36,8 @@ namespace Ui class DialogEditLabel; } +class VLabelTemplateLine; + class DialogEditLabel : public QDialog { Q_OBJECT @@ -60,6 +62,8 @@ private: Ui::DialogEditLabel *ui; void SetupControls(); + + QVector PrepareLines() const; }; #endif // DIALOGEDITLABEL_H From c989cdf048ec792b1ee954734568e50a845cb383 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 10 Aug 2017 19:32:05 +0300 Subject: [PATCH 08/54] Added import the template. --HG-- branch : feature --- src/libs/ifc/schema.qrc | 1 + src/libs/ifc/schema/label_template/v1.0.0.xsd | 37 ++++++ src/libs/ifc/xml/vlabeltemplateconverter.cpp | 109 ++++++++++++++++++ src/libs/ifc/xml/vlabeltemplateconverter.h | 63 ++++++++++ src/libs/ifc/xml/xml.pri | 6 +- src/libs/vformat/vlabeltemplate.cpp | 36 +++++- src/libs/vformat/vlabeltemplate.h | 1 + .../dialogs/support/dialogeditlabel.cpp | 68 ++++++++++- .../vtools/dialogs/support/dialogeditlabel.h | 1 + 9 files changed, 316 insertions(+), 6 deletions(-) create mode 100644 src/libs/ifc/schema/label_template/v1.0.0.xsd create mode 100644 src/libs/ifc/xml/vlabeltemplateconverter.cpp create mode 100644 src/libs/ifc/xml/vlabeltemplateconverter.h diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index b585907db..3644ffb8b 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -45,5 +45,6 @@ schema/individual_measurements/v0.3.1.xsd schema/individual_measurements/v0.3.2.xsd schema/individual_measurements/v0.3.3.xsd + schema/label_template/v1.0.0.xsd diff --git a/src/libs/ifc/schema/label_template/v1.0.0.xsd b/src/libs/ifc/schema/label_template/v1.0.0.xsd new file mode 100644 index 000000000..3890aade3 --- /dev/null +++ b/src/libs/ifc/schema/label_template/v1.0.0.xsd @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vlabeltemplateconverter.cpp b/src/libs/ifc/xml/vlabeltemplateconverter.cpp new file mode 100644 index 000000000..4b7319828 --- /dev/null +++ b/src/libs/ifc/xml/vlabeltemplateconverter.cpp @@ -0,0 +1,109 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 10 8, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 Valentina project + ** All Rights Reserved. + ** + ** Valentina 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 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina 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. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "vlabeltemplateconverter.h" + +/* + * Version rules: + * 1. Version have three parts "major.minor.patch"; + * 2. major part only for stable releases; + * 3. minor - 10 or more patch changes, or one big change; + * 4. patch - little change. + */ + +const QString VLabelTemplateConverter::LabelTemplateMinVerStr = QStringLiteral("1.0.0"); +const QString VLabelTemplateConverter::LabelTemplateMaxVerStr = QStringLiteral("1.0.0"); +const QString VLabelTemplateConverter::CurrentSchema = QStringLiteral("://schema/label_template/v1.0.0.xsd"); + +//VLabelTemplateConverter::LabelTemplateMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! +//VLabelTemplateConverter::LabelTemplateMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! + +//--------------------------------------------------------------------------------------------------------------------- +VLabelTemplateConverter::VLabelTemplateConverter(const QString &fileName) + : VAbstractConverter(fileName) +{ + ValidateInputFile(CurrentSchema); +} + +//--------------------------------------------------------------------------------------------------------------------- +int VLabelTemplateConverter::MinVer() const +{ + return LabelTemplateMinVer; +} + +//--------------------------------------------------------------------------------------------------------------------- +int VLabelTemplateConverter::MaxVer() const +{ + return LabelTemplateMaxVer; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VLabelTemplateConverter::MinVerStr() const +{ + return LabelTemplateMinVerStr; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VLabelTemplateConverter::MaxVerStr() const +{ + return LabelTemplateMaxVerStr; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VLabelTemplateConverter::XSDSchema(int ver) const +{ + switch (ver) + { + case (0x010000): + return CurrentSchema; + default: + InvalidVersion(ver); + break; + } + return QString();//unreachable code +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLabelTemplateConverter::ApplyPatches() +{ + switch (m_ver) + { + case (0x010000): + break; + default: + InvalidVersion(m_ver); + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLabelTemplateConverter::DowngradeToCurrentMaxVersion() +{ + SetVersion(LabelTemplateMaxVerStr); + Save(); +} diff --git a/src/libs/ifc/xml/vlabeltemplateconverter.h b/src/libs/ifc/xml/vlabeltemplateconverter.h new file mode 100644 index 000000000..13669199b --- /dev/null +++ b/src/libs/ifc/xml/vlabeltemplateconverter.h @@ -0,0 +1,63 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 10 8, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 Valentina project + ** All Rights Reserved. + ** + ** Valentina 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 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina 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. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VLABELTEMPLATECONVERTER_H +#define VLABELTEMPLATECONVERTER_H + +#include "vabstractconverter.h" + +class VLabelTemplateConverter : public VAbstractConverter +{ +public: + explicit VLabelTemplateConverter(const QString &fileName); + virtual ~VLabelTemplateConverter() Q_DECL_EQ_DEFAULT; + + static const QString LabelTemplateMaxVerStr; + static const QString CurrentSchema; + static Q_DECL_CONSTEXPR const int LabelTemplateMinVer = CONVERTER_VERSION_CHECK(1, 0, 0); + static Q_DECL_CONSTEXPR const int LabelTemplateMaxVer = CONVERTER_VERSION_CHECK(1, 0, 0); + +protected: + virtual int MinVer() const Q_DECL_OVERRIDE; + virtual int MaxVer() const Q_DECL_OVERRIDE; + + virtual QString MinVerStr() const Q_DECL_OVERRIDE; + virtual QString MaxVerStr() const Q_DECL_OVERRIDE; + + virtual QString XSDSchema(int ver) const Q_DECL_OVERRIDE; + virtual void ApplyPatches() Q_DECL_OVERRIDE; + virtual void DowngradeToCurrentMaxVersion() Q_DECL_OVERRIDE; + + virtual bool IsReadOnly() const Q_DECL_OVERRIDE {return false;} + +private: + Q_DISABLE_COPY(VLabelTemplateConverter) + static const QString LabelTemplateMinVerStr; +}; + +#endif // VLABELTEMPLATECONVERTER_H diff --git a/src/libs/ifc/xml/xml.pri b/src/libs/ifc/xml/xml.pri index 0925a57b0..d5d333e23 100644 --- a/src/libs/ifc/xml/xml.pri +++ b/src/libs/ifc/xml/xml.pri @@ -9,7 +9,8 @@ HEADERS += \ $$PWD/vabstractpattern.h \ $$PWD/vvstconverter.h \ $$PWD//vvitconverter.h \ - $$PWD//vabstractmconverter.h + $$PWD//vabstractmconverter.h \ + $$PWD/vlabeltemplateconverter.h SOURCES += \ $$PWD/vabstractconverter.cpp \ @@ -19,4 +20,5 @@ SOURCES += \ $$PWD/vabstractpattern.cpp \ $$PWD/vvstconverter.cpp \ $$PWD//vvitconverter.cpp \ - $$PWD//vabstractmconverter.cpp + $$PWD//vabstractmconverter.cpp \ + $$PWD/vlabeltemplateconverter.cpp diff --git a/src/libs/vformat/vlabeltemplate.cpp b/src/libs/vformat/vlabeltemplate.cpp index b1ba21171..942c88405 100644 --- a/src/libs/vformat/vlabeltemplate.cpp +++ b/src/libs/vformat/vlabeltemplate.cpp @@ -27,6 +27,7 @@ *************************************************************************/ #include "vlabeltemplate.h" +#include "../ifc/xml/vlabeltemplateconverter.h" const QString VLabelTemplate::TagTemplate = QStringLiteral("template"); const QString VLabelTemplate::TagLines = QStringLiteral("lines"); @@ -49,7 +50,7 @@ void VLabelTemplate::CreateEmptyTemplate() QDomElement templateElement = this->createElement(TagTemplate); QDomElement version = createElement(TagVersion); - QDomText newNodeText = createTextNode("1.0"/*VLabelTemplateConverter::TemplateMaxVerStr*/); + QDomText newNodeText = createTextNode(VLabelTemplateConverter::LabelTemplateMaxVerStr); version.appendChild(newNodeText); templateElement.appendChild(version); @@ -84,3 +85,36 @@ void VLabelTemplate::AddLines(const QVector &lines) } } } + +//--------------------------------------------------------------------------------------------------------------------- +QVector VLabelTemplate::ReadLines() const +{ + QVector lines; + + const QDomNodeList listLines = elementsByTagName(TagLines); + if (listLines.size() == 0) + { + return lines; + } + + QDomElement tagLines = listLines.at(0).toElement(); + if (not tagLines.isNull()) + { + QDomElement tagLine = tagLines.firstChildElement(); + while (tagLine.isNull() == false) + { + if (tagLine.tagName() == TagLine) + { + VLabelTemplateLine line; + line.line = GetParametrString(tagLine, AttrText, tr("")); + line.bold = GetParametrBool(tagLine, AttrBold, falseStr); + line.italic = GetParametrBool(tagLine, AttrItalic, falseStr); + line.alignment = GetParametrUInt(tagLine, AttrAlignment, "0"); + lines.append(line); + } + tagLine = tagLine.nextSiblingElement(TagLine); + } + } + + return lines; +} diff --git a/src/libs/vformat/vlabeltemplate.h b/src/libs/vformat/vlabeltemplate.h index 294b9a0ef..c79960390 100644 --- a/src/libs/vformat/vlabeltemplate.h +++ b/src/libs/vformat/vlabeltemplate.h @@ -62,6 +62,7 @@ public: void CreateEmptyTemplate(); void AddLines(const QVector &lines); + QVector ReadLines() const; private: Q_DISABLE_COPY(VLabelTemplate) }; diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index 885ed6e34..b581b02d1 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -30,6 +30,8 @@ #include "ui_dialogeditlabel.h" #include "../vmisc/vabstractapplication.h" #include "../vformat/vlabeltemplate.h" +#include "../ifc/xml/vlabeltemplateconverter.h" +#include "../ifc/exception/vexception.h" #include #include @@ -55,6 +57,7 @@ DialogEditLabel::DialogEditLabel(QWidget *parent) connect(ui->listWidget, &QListWidget::itemSelectionChanged, this, &DialogEditLabel::ShowLineDetails); connect(ui->toolButtonNewLabel, &QToolButton::clicked, this, &DialogEditLabel::NewTemplate); connect(ui->toolButtonExportLabel, &QToolButton::clicked, this, &DialogEditLabel::ExportTemplate); + connect(ui->toolButtonImportLabel, &QToolButton::clicked, this, &DialogEditLabel::ImportTemplate); } //--------------------------------------------------------------------------------------------------------------------- @@ -99,7 +102,7 @@ void DialogEditLabel::ShowLineDetails() ui->toolButtonTextCenter->setChecked(false); ui->toolButtonTextRight->setChecked(false); } - else if (lineAlignment & Qt::AlignCenter) + else if (lineAlignment & Qt::AlignHCenter) { ui->toolButtonTextLeft->setChecked(false); ui->toolButtonTextCenter->setChecked(true); @@ -208,7 +211,7 @@ void DialogEditLabel::SaveTextFormating(bool checked) { if (checked) { - curLine->setTextAlignment(Qt::AlignCenter); + curLine->setTextAlignment(Qt::AlignHCenter); ui->toolButtonTextLeft->setChecked(false); ui->toolButtonTextRight->setChecked(false); @@ -317,13 +320,43 @@ void DialogEditLabel::ExportTemplate() } RemoveTempDir(); - return; } //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::ImportTemplate() { + if (ui->listWidget->count() > 0) + { + const QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Import template"), + tr("Import template will overwrite the current, do " + "you want to continue?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + if (answer == QMessageBox::No) + { + return; + } + } + QString filter(tr("Label template") + QLatin1String("(*.xml)")); + const QString fileName = QFileDialog::getOpenFileName(this, tr("Import template"), + qApp->Settings()->GetPathLabelTemplate(), filter, nullptr, + QFileDialog::DontUseNativeDialog); + if (fileName.isEmpty()) + { + return; + } + + try + { + VLabelTemplate ltemplate; + ltemplate.setXMLContent(VLabelTemplateConverter(fileName).Convert()); + InitLines(ltemplate.ReadLines()); + } + catch (VException &e) + { + qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -377,3 +410,32 @@ QVector DialogEditLabel::PrepareLines() const return lines; } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::InitLines(const QVector &lines) +{ + ui->listWidget->blockSignals(true); + ui->listWidget->clear(); + + int row = -1; + + for (int i=0; isetTextAlignment(lines.at(i).alignment); + + QFont font = item->font(); + font.setBold(lines.at(i).bold); + font.setItalic(lines.at(i).italic); + item->setFont(font); + + ui->listWidget->insertItem(++row, item); + } + + ui->listWidget->blockSignals(false); + + if (ui->listWidget->count() > 0) + { + ui->listWidget->setCurrentRow(0); + } +} diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h index 2040fbde2..9025674c9 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.h +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -64,6 +64,7 @@ private: void SetupControls(); QVector PrepareLines() const; + void InitLines(const QVector &lines); }; #endif // DIALOGEDITLABEL_H From 9202418d7c59517b22b197ef21d62bc43e9622fc Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 10 Aug 2017 19:36:31 +0300 Subject: [PATCH 09/54] Fix bug. Values "0" and "1" mean for us the same. --HG-- branch : feature --- src/libs/vtools/dialogs/support/dialogeditlabel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index b581b02d1..074809c42 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -96,7 +96,7 @@ void DialogEditLabel::ShowLineDetails() const int lineAlignment = line->textAlignment(); - if (lineAlignment & Qt::AlignLeft) + if (lineAlignment == 0 || lineAlignment & Qt::AlignLeft) { ui->toolButtonTextLeft->setChecked(true); ui->toolButtonTextCenter->setChecked(false); From d81be4f778cf30e590e76b1debf3ad535ec21e19 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 12 Aug 2017 11:40:58 +0300 Subject: [PATCH 10/54] Added placeholders list. --HG-- branch : feature --- .../dialogs/support/dialogeditlabel.cpp | 43 ++++++++++++++- .../vtools/dialogs/support/dialogeditlabel.h | 8 +++ .../vtools/dialogs/support/dialogeditlabel.ui | 9 ++- src/libs/vwidgets/vlineedit.cpp | 55 +++++++++++++++++++ src/libs/vwidgets/vlineedit.h | 44 +++++++++++++++ src/libs/vwidgets/vwidgets.pri | 6 +- 6 files changed, 161 insertions(+), 4 deletions(-) create mode 100644 src/libs/vwidgets/vlineedit.cpp create mode 100644 src/libs/vwidgets/vlineedit.h diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index 074809c42..ec60822b6 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -36,11 +36,15 @@ #include #include #include +#include +#include //--------------------------------------------------------------------------------------------------------------------- DialogEditLabel::DialogEditLabel(QWidget *parent) : QDialog(parent), - ui(new Ui::DialogEditLabel) + ui(new Ui::DialogEditLabel), + m_placeholdersMenu(new QMenu(this)), + m_placeholders() { ui->setupUi(this); @@ -58,6 +62,11 @@ DialogEditLabel::DialogEditLabel(QWidget *parent) connect(ui->toolButtonNewLabel, &QToolButton::clicked, this, &DialogEditLabel::NewTemplate); connect(ui->toolButtonExportLabel, &QToolButton::clicked, this, &DialogEditLabel::ExportTemplate); connect(ui->toolButtonImportLabel, &QToolButton::clicked, this, &DialogEditLabel::ImportTemplate); + + InitPlaceholders(); + InitPlaceholdersMenu(); + + ui->pushButtonInsert->setMenu(m_placeholdersMenu); } //--------------------------------------------------------------------------------------------------------------------- @@ -359,6 +368,17 @@ void DialogEditLabel::ImportTemplate() } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::InsertPlaceholder() +{ + QAction *action = qobject_cast(sender()); + if (action) + { + ui->lineEditLine->insert(action->data().toString()); + ui->lineEditLine->setFocus(); + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::SetupControls() { @@ -386,6 +406,27 @@ void DialogEditLabel::SetupControls() ui->lineEditLine->setEnabled(enabled); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::InitPlaceholdersMenu() +{ + auto i = m_placeholders.constBegin(); + while (i != m_placeholders.constEnd()) + { + auto value = i.value(); + QAction *action = m_placeholdersMenu->addAction(value.first); + action->setData(i.key()); + connect(action, &QAction::triggered, this, &DialogEditLabel::InsertPlaceholder); + ++i; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::InitPlaceholders() +{ + QLocale locale(qApp->Settings()->GetLocale()); + m_placeholders.insert("%date%", qMakePair(tr("Date"), locale.toString(QDate::currentDate(), "dd MMMM yyyy"))); +} + //--------------------------------------------------------------------------------------------------------------------- QVector DialogEditLabel::PrepareLines() const { diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h index 9025674c9..b94783a3c 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.h +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -30,6 +30,7 @@ #define DIALOGEDITLABEL_H #include +#include namespace Ui { @@ -37,6 +38,7 @@ namespace Ui } class VLabelTemplateLine; +class QMenu; class DialogEditLabel : public QDialog { @@ -56,12 +58,18 @@ private slots: void NewTemplate(); void ExportTemplate(); void ImportTemplate(); + void InsertPlaceholder(); private: Q_DISABLE_COPY(DialogEditLabel) Ui::DialogEditLabel *ui; + QMenu *m_placeholdersMenu; + + QMap> m_placeholders; void SetupControls(); + void InitPlaceholdersMenu(); + void InitPlaceholders(); QVector PrepareLines() const; void InitLines(const QVector &lines); diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.ui b/src/libs/vtools/dialogs/support/dialogeditlabel.ui index de611d6a6..4aafee6a1 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.ui +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.ui @@ -283,7 +283,7 @@ - + false @@ -324,6 +324,13 @@ + + + VLineEdit + QLineEdit +
vlineedit.h
+
+
diff --git a/src/libs/vwidgets/vlineedit.cpp b/src/libs/vwidgets/vlineedit.cpp new file mode 100644 index 000000000..fb1d78162 --- /dev/null +++ b/src/libs/vwidgets/vlineedit.cpp @@ -0,0 +1,55 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 12 8, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 Valentina project + ** All Rights Reserved. + ** + ** Valentina 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 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina 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. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "vlineedit.h" + +//--------------------------------------------------------------------------------------------------------------------- +VLineEdit::VLineEdit(QWidget *parent) + : QLineEdit(parent) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VLineEdit::VLineEdit(const QString &contents, QWidget *parent) + : QLineEdit(contents, parent) +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VLineEdit::focusOutEvent(QFocusEvent *e) +{ + const int start = selectionStart(); + int selectionLength = selectedText().length(); + const bool wasTextSelected = hasSelectedText(); + + QLineEdit::focusOutEvent(e); + + if (wasTextSelected) + { + setSelection(start, selectionLength); + } +} + diff --git a/src/libs/vwidgets/vlineedit.h b/src/libs/vwidgets/vlineedit.h new file mode 100644 index 000000000..7dd0df160 --- /dev/null +++ b/src/libs/vwidgets/vlineedit.h @@ -0,0 +1,44 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 12 8, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 Valentina project + ** All Rights Reserved. + ** + ** Valentina 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 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina 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. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VLINEEDIT_H +#define VLINEEDIT_H + +#include + +class VLineEdit : public QLineEdit +{ +public: + VLineEdit(QWidget * parent = nullptr); + VLineEdit(const QString &contents, QWidget *parent = nullptr); + +protected: + virtual void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE; +}; + +#endif // VLINEEDIT_H diff --git a/src/libs/vwidgets/vwidgets.pri b/src/libs/vwidgets/vwidgets.pri index 400730a4a..f77837b0d 100644 --- a/src/libs/vwidgets/vwidgets.pri +++ b/src/libs/vwidgets/vwidgets.pri @@ -21,7 +21,8 @@ SOURCES += \ $$PWD/vcurvepathitem.cpp \ $$PWD/global.cpp \ $$PWD/vscenepoint.cpp \ - $$PWD/scalesceneitems.cpp + $$PWD/scalesceneitems.cpp \ + $$PWD/vlineedit.cpp *msvc*:SOURCES += $$PWD/stable.cpp @@ -46,4 +47,5 @@ HEADERS += \ $$PWD/vcurvepathitem.h \ $$PWD/global.h \ $$PWD/vscenepoint.h \ - $$PWD/scalesceneitems.h + $$PWD/scalesceneitems.h \ + $$PWD/vlineedit.h From 0c13d610eb0886650e37b7e5a306841685287aad Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 12 Aug 2017 11:57:46 +0300 Subject: [PATCH 11/54] =?UTF-8?q?=D0=95ext=20in=20QLineEdit=20selected=20o?= =?UTF-8?q?n=20edit=20start.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --HG-- branch : feature --- .../dialogs/support/dialogeditlabel.cpp | 1 - src/libs/vwidgets/vlineedit.cpp | 27 ++++++++++++++++--- src/libs/vwidgets/vlineedit.h | 6 +++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index ec60822b6..14a29f957 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -85,7 +85,6 @@ void DialogEditLabel::ShowLineDetails() { ui->lineEditLine->blockSignals(true); ui->lineEditLine->setText(line->text()); - ui->lineEditLine->selectAll(); ui->lineEditLine->setFocus(); ui->lineEditLine->blockSignals(false); diff --git a/src/libs/vwidgets/vlineedit.cpp b/src/libs/vwidgets/vlineedit.cpp index fb1d78162..392fa657a 100644 --- a/src/libs/vwidgets/vlineedit.cpp +++ b/src/libs/vwidgets/vlineedit.cpp @@ -30,19 +30,29 @@ //--------------------------------------------------------------------------------------------------------------------- VLineEdit::VLineEdit(QWidget *parent) - : QLineEdit(parent) + : QLineEdit(parent), + m_selectOnMousePress(false) {} //--------------------------------------------------------------------------------------------------------------------- VLineEdit::VLineEdit(const QString &contents, QWidget *parent) - : QLineEdit(contents, parent) + : QLineEdit(contents, parent), + m_selectOnMousePress(false) {} +//--------------------------------------------------------------------------------------------------------------------- +void VLineEdit::focusInEvent(QFocusEvent *e) +{ + QLineEdit::focusInEvent(e); + selectAll(); + m_selectOnMousePress = true; +} + //--------------------------------------------------------------------------------------------------------------------- void VLineEdit::focusOutEvent(QFocusEvent *e) { const int start = selectionStart(); - int selectionLength = selectedText().length(); + const int selectionLength = selectedText().length(); const bool wasTextSelected = hasSelectedText(); QLineEdit::focusOutEvent(e); @@ -53,3 +63,14 @@ void VLineEdit::focusOutEvent(QFocusEvent *e) } } +//--------------------------------------------------------------------------------------------------------------------- +void VLineEdit::mousePressEvent(QMouseEvent *e) +{ + QLineEdit::mousePressEvent(e); + if(m_selectOnMousePress) + { + selectAll(); + m_selectOnMousePress = false; + } +} + diff --git a/src/libs/vwidgets/vlineedit.h b/src/libs/vwidgets/vlineedit.h index 7dd0df160..9b9561608 100644 --- a/src/libs/vwidgets/vlineedit.h +++ b/src/libs/vwidgets/vlineedit.h @@ -33,12 +33,18 @@ class VLineEdit : public QLineEdit { + Q_OBJECT public: VLineEdit(QWidget * parent = nullptr); VLineEdit(const QString &contents, QWidget *parent = nullptr); protected: + virtual void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE; virtual void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + virtual void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; +private: + Q_DISABLE_COPY(VLineEdit) + bool m_selectOnMousePress; }; #endif // VLINEEDIT_H From 4aa002f5103f19715fdc4e57a4089004afe83bdf Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 12 Aug 2017 13:19:13 +0300 Subject: [PATCH 12/54] Added Preview tab. --HG-- branch : feature --- .../dialogs/support/dialogeditlabel.cpp | 112 +++-- .../vtools/dialogs/support/dialogeditlabel.h | 6 +- .../vtools/dialogs/support/dialogeditlabel.ui | 412 +++++++++--------- 3 files changed, 306 insertions(+), 224 deletions(-) diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index 14a29f957..b0a9a65e2 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -58,7 +58,8 @@ DialogEditLabel::DialogEditLabel(QWidget *parent) connect(ui->toolButtonTextLeft, &QToolButton::toggled, this, &DialogEditLabel::SaveTextFormating); connect(ui->toolButtonTextCenter, &QToolButton::toggled, this, &DialogEditLabel::SaveTextFormating); connect(ui->toolButtonTextRight, &QToolButton::toggled, this, &DialogEditLabel::SaveTextFormating); - connect(ui->listWidget, &QListWidget::itemSelectionChanged, this, &DialogEditLabel::ShowLineDetails); + connect(ui->listWidgetEdit, &QListWidget::itemSelectionChanged, this, &DialogEditLabel::ShowLineDetails); + connect(ui->tabWidget, &QTabWidget::currentChanged, this, &DialogEditLabel::TabChanged); connect(ui->toolButtonNewLabel, &QToolButton::clicked, this, &DialogEditLabel::NewTemplate); connect(ui->toolButtonExportLabel, &QToolButton::clicked, this, &DialogEditLabel::ExportTemplate); connect(ui->toolButtonImportLabel, &QToolButton::clicked, this, &DialogEditLabel::ImportTemplate); @@ -78,14 +79,13 @@ DialogEditLabel::~DialogEditLabel() //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::ShowLineDetails() { - if (ui->listWidget->count() > 0) + if (ui->listWidgetEdit->count() > 0) { - const QListWidgetItem *line = ui->listWidget->currentItem(); + const QListWidgetItem *line = ui->listWidgetEdit->currentItem(); if (line) { ui->lineEditLine->blockSignals(true); ui->lineEditLine->setText(line->text()); - ui->lineEditLine->setFocus(); ui->lineEditLine->blockSignals(false); const QFont lineFont = line->font(); @@ -135,28 +135,28 @@ void DialogEditLabel::ShowLineDetails() //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::AddLine() { - int row = ui->listWidget->currentRow(); - ui->listWidget->insertItem(++row, new QListWidgetItem(tr(""))); - ui->listWidget->setCurrentRow(row); + int row = ui->listWidgetEdit->currentRow(); + ui->listWidgetEdit->insertItem(++row, new QListWidgetItem(tr(""))); + ui->listWidgetEdit->setCurrentRow(row); } //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::RemoveLine() { - ui->listWidget->blockSignals(true); - QListWidgetItem *curLine = ui->listWidget->takeItem(ui->listWidget->currentRow()); + ui->listWidgetEdit->blockSignals(true); + QListWidgetItem *curLine = ui->listWidgetEdit->takeItem(ui->listWidgetEdit->currentRow()); if (curLine) { delete curLine; } - ui->listWidget->blockSignals(false); + ui->listWidgetEdit->blockSignals(false); ShowLineDetails(); } //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::SaveLineText(const QString &text) { - QListWidgetItem *curLine = ui->listWidget->currentItem(); + QListWidgetItem *curLine = ui->listWidgetEdit->currentItem(); if (curLine) { curLine->setText(text); @@ -166,7 +166,7 @@ void DialogEditLabel::SaveLineText(const QString &text) //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::SaveFontStyle(bool checked) { - QListWidgetItem *curLine = ui->listWidget->currentItem(); + QListWidgetItem *curLine = ui->listWidgetEdit->currentItem(); if (curLine) { QFont lineFont = curLine->font(); @@ -191,7 +191,7 @@ void DialogEditLabel::SaveFontStyle(bool checked) //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::SaveTextFormating(bool checked) { - QListWidgetItem *curLine = ui->listWidget->currentItem(); + QListWidgetItem *curLine = ui->listWidgetEdit->currentItem(); if (curLine) { QToolButton *button = qobject_cast(sender()); @@ -254,7 +254,7 @@ void DialogEditLabel::SaveTextFormating(bool checked) //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::NewTemplate() { - if (ui->listWidget->count() > 0) + if (ui->listWidgetEdit->count() > 0) { const QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Create new template"), tr("Creating new template will overwrite the current, do " @@ -266,9 +266,9 @@ void DialogEditLabel::NewTemplate() } } - ui->listWidget->blockSignals(true); - ui->listWidget->clear(); - ui->listWidget->blockSignals(false); + ui->listWidgetEdit->blockSignals(true); + ui->listWidgetEdit->clear(); + ui->listWidgetEdit->blockSignals(false); ShowLineDetails(); } @@ -333,7 +333,7 @@ void DialogEditLabel::ExportTemplate() //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::ImportTemplate() { - if (ui->listWidget->count() > 0) + if (ui->listWidgetEdit->count() > 0) { const QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Import template"), tr("Import template will overwrite the current, do " @@ -358,7 +358,7 @@ void DialogEditLabel::ImportTemplate() { VLabelTemplate ltemplate; ltemplate.setXMLContent(VLabelTemplateConverter(fileName).Convert()); - InitLines(ltemplate.ReadLines()); + InitEditLines(ltemplate.ReadLines()); } catch (VException &e) { @@ -378,10 +378,26 @@ void DialogEditLabel::InsertPlaceholder() } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::TabChanged(int index) +{ + if (index == ui->tabWidget->indexOf(ui->tabPreview)) + { + ui->toolButtonNewLabel->setDisabled(true); + ui->toolButtonImportLabel->setDisabled(true); + InitPreviewLines(PrepareLines()); + } + else + { + ui->toolButtonNewLabel->setEnabled(ui->listWidgetEdit->count() > 0); + ui->toolButtonImportLabel->setEnabled(true); + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::SetupControls() { - const bool enabled = ui->listWidget->count() > 0; + const bool enabled = ui->listWidgetEdit->count() > 0; if (not enabled) { @@ -426,14 +442,26 @@ void DialogEditLabel::InitPlaceholders() m_placeholders.insert("%date%", qMakePair(tr("Date"), locale.toString(QDate::currentDate(), "dd MMMM yyyy"))); } +//--------------------------------------------------------------------------------------------------------------------- +QString DialogEditLabel::ReplacePlaceholders(QString line) const +{ + auto i = m_placeholders.constBegin(); + while (i != m_placeholders.constEnd()) + { + line.replace(i.key(), i.value().second); + ++i; + } + return line; +} + //--------------------------------------------------------------------------------------------------------------------- QVector DialogEditLabel::PrepareLines() const { QVector lines; - for (int i=0; ilistWidget->count(); ++i) + for (int i=0; ilistWidgetEdit->count(); ++i) { - const QListWidgetItem *lineItem = ui->listWidget->item(i); + const QListWidgetItem *lineItem = ui->listWidgetEdit->item(i); if (lineItem) { VLabelTemplateLine line; @@ -452,10 +480,10 @@ QVector DialogEditLabel::PrepareLines() const } //--------------------------------------------------------------------------------------------------------------------- -void DialogEditLabel::InitLines(const QVector &lines) +void DialogEditLabel::InitEditLines(const QVector &lines) { - ui->listWidget->blockSignals(true); - ui->listWidget->clear(); + ui->listWidgetEdit->blockSignals(true); + ui->listWidgetEdit->clear(); int row = -1; @@ -469,13 +497,39 @@ void DialogEditLabel::InitLines(const QVector &lines) font.setItalic(lines.at(i).italic); item->setFont(font); - ui->listWidget->insertItem(++row, item); + ui->listWidgetEdit->insertItem(++row, item); } - ui->listWidget->blockSignals(false); + ui->listWidgetEdit->blockSignals(false); - if (ui->listWidget->count() > 0) + if (ui->listWidgetEdit->count() > 0) { - ui->listWidget->setCurrentRow(0); + ui->listWidgetEdit->setCurrentRow(0); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::InitPreviewLines(const QVector &lines) +{ + ui->listWidgetPreview->clear(); + + int row = -1; + + for (int i=0; isetTextAlignment(lines.at(i).alignment); + + QFont font = item->font(); + font.setBold(lines.at(i).bold); + font.setItalic(lines.at(i).italic); + item->setFont(font); + + ui->listWidgetPreview->insertItem(++row, item); + } + + if (ui->listWidgetPreview->count() > 0) + { + ui->listWidgetPreview->setCurrentRow(0); } } diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h index b94783a3c..5f0da10d4 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.h +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -59,6 +59,7 @@ private slots: void ExportTemplate(); void ImportTemplate(); void InsertPlaceholder(); + void TabChanged(int index); private: Q_DISABLE_COPY(DialogEditLabel) @@ -71,8 +72,11 @@ private: void InitPlaceholdersMenu(); void InitPlaceholders(); + QString ReplacePlaceholders(QString line) const; + QVector PrepareLines() const; - void InitLines(const QVector &lines); + void InitEditLines(const QVector &lines); + void InitPreviewLines(const QVector &lines); }; #endif // DIALOGEDITLABEL_H diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.ui b/src/libs/vtools/dialogs/support/dialogeditlabel.ui index 4aafee6a1..8efd7d4f2 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.ui +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.ui @@ -9,8 +9,8 @@ 0 0 - 494 - 384 + 437 + 464 @@ -23,7 +23,7 @@ true - + @@ -108,209 +108,233 @@ - - - - 0 - 1 - + + + 0 - - QAbstractItemView::InternalMove - - - - - - - - - 6 - + + + Edit + + - - - false - - - Bold - - - ... - - - - .. - - - true - - - - - - - false - - - Italic - - - ... - - - - .. - - - true - - - - - - - false - - - Aligns with the left edge - - - ... - - - - .. - - - true - - - - - - - false - - - Centers horizontally in the available space - - - ... - - - - .. - - - true - - - - - - - false - - - Aligns with the right edge - - - ... - - - - .. - - - true - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - + - + 0 - 0 + 1 - - ... - - - - ../../../../app/valentina/dialogs../../../../app/valentina/dialogs - - - - - - - false - - - ... - - - - ../../../../app/valentina/dialogs../../../../app/valentina/dialogs - - - - - - - - - Text: - - - - - - - - - false - - - Line of text - - - false + + QAbstractItemView::InternalMove - - - false - - - Insert placeholders - - - Insert... - - + + + + + 6 + + + + + false + + + Bold + + + ... + + + + .. + + + true + + + + + + + false + + + Italic + + + ... + + + + .. + + + true + + + + + + + false + + + Aligns with the left edge + + + ... + + + + .. + + + true + + + + + + + false + + + Centers horizontally in the available space + + + ... + + + + .. + + + true + + + + + + + false + + + Aligns with the right edge + + + ... + + + + .. + + + true + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + ... + + + + ../../../../app/valentina/dialogs../../../../app/valentina/dialogs + + + + + + + false + + + ... + + + + ../../../../app/valentina/dialogs../../../../app/valentina/dialogs + + + + + + + + + Text: + + + + + + + + + false + + + Line of text + + + false + + + + + + + false + + + Insert placeholders + + + Insert... + + + + + + - - +
+ + + Preview + + + + + + + +
From 67cee35426b23b0c4a3e3cf60da0bc6bacdcb263 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 14 Aug 2017 12:03:20 +0300 Subject: [PATCH 13/54] Ask about change of label data. User must save data before editing a template to be able to see changes in template. --HG-- branch : feature --- .../dialogs/dialogpatternproperties.cpp | 57 ++++++++++++------- .../dialogs/dialogpatternproperties.h | 7 ++- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index c087bf8a2..35cc078b9 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -33,6 +33,8 @@ #include #include #include +#include + #include "../xml/vpattern.h" #include "../vpatterndb/vcontainer.h" #include "../core/vapplication.h" @@ -59,7 +61,8 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte gradationChanged(false), defaultChanged(false), securityChanged(false), - generalInfoChanged(false), + labelDataChanged(false), + askSaveLabelData(false), deleteAction(nullptr), changeImageAction(nullptr), saveImageAction(nullptr), @@ -195,13 +198,13 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte ui->checkBoxShowMeasurements->setChecked(doc->IsMeasurementsVisible()); } - connect(ui->lineEditPatternName, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged); - connect(ui->lineEditPatternNumber, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged); - connect(ui->lineEditCompanyName, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged); - connect(ui->lineEditCustomerName, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged); - connect(ui->lineEditSize, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged); - connect(ui->checkBoxShowDate, &QCheckBox::stateChanged, this, &DialogPatternProperties::GeneralInfoChanged); - connect(ui->checkBoxShowMeasurements, &QCheckBox::stateChanged, this, &DialogPatternProperties::GeneralInfoChanged); + connect(ui->lineEditPatternName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); + connect(ui->lineEditPatternNumber, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); + connect(ui->lineEditCompanyName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); + connect(ui->lineEditCustomerName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); + connect(ui->lineEditSize, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); + connect(ui->checkBoxShowDate, &QCheckBox::stateChanged, this, &DialogPatternProperties::LabelDataChanged); + connect(ui->checkBoxShowMeasurements, &QCheckBox::stateChanged, this, &DialogPatternProperties::LabelDataChanged); connect(ui->pushButtonEditPatternLabel, &QPushButton::clicked, this, &DialogPatternProperties::EditLabel); } @@ -234,11 +237,8 @@ void DialogPatternProperties::Apply() emit doc->patternChanged(false); break; case 3: - SaveGeneralInfo(); - generalInfoChanged = false; - emit doc->patternChanged(false); + SaveLabelData(); break; - default: break; } @@ -275,11 +275,9 @@ void DialogPatternProperties::Ok() emit doc->patternChanged(false); } - if (generalInfoChanged == true) + if (labelDataChanged == true) { - SaveGeneralInfo(); - generalInfoChanged = false; - emit doc->patternChanged(false); + SaveLabelData(); } close(); @@ -423,9 +421,10 @@ void DialogPatternProperties::DefValueChanged() } //--------------------------------------------------------------------------------------------------------------------- -void DialogPatternProperties::GeneralInfoChanged() +void DialogPatternProperties::LabelDataChanged() { - generalInfoChanged = true; + labelDataChanged = true; + askSaveLabelData = true; } //--------------------------------------------------------------------------------------------------------------------- @@ -597,7 +596,7 @@ void DialogPatternProperties::SaveDefValues() } //--------------------------------------------------------------------------------------------------------------------- -void DialogPatternProperties::SaveGeneralInfo() +void DialogPatternProperties::SaveLabelData() { doc->SetPatternName(ui->lineEditPatternName->text()); doc->SetPatternNumber(ui->lineEditPatternNumber->text()); @@ -606,6 +605,10 @@ void DialogPatternProperties::SaveGeneralInfo() doc->SetPatternSize(ui->lineEditSize->text()); doc->SetDateVisible(ui->checkBoxShowDate->isChecked()); doc->SetMesurementsVisible(ui->checkBoxShowMeasurements->isChecked()); + + labelDataChanged = false; + askSaveLabelData = false; + emit doc->patternChanged(false); } //--------------------------------------------------------------------------------------------------------------------- @@ -855,6 +858,22 @@ void DialogPatternProperties::SaveImage() //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::EditLabel() { + if (labelDataChanged && askSaveLabelData) + { + QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Save label data."), + tr("Label data were changed. Do you want to save them before editing label template?"), + QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes); + + if (answer == QMessageBox::Yes) + { + SaveLabelData(); + } + else + { + askSaveLabelData = false; + } + } + DialogEditLabel editor; editor.exec(); } diff --git a/src/app/valentina/dialogs/dialogpatternproperties.h b/src/app/valentina/dialogs/dialogpatternproperties.h index 21b186455..7429a302e 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.h +++ b/src/app/valentina/dialogs/dialogpatternproperties.h @@ -53,7 +53,7 @@ signals: void UpdateGradation(); private slots: void DefValueChanged(); - void GeneralInfoChanged(); + void LabelDataChanged(); void Apply(); void Ok(); void SelectAll(int state); @@ -77,7 +77,8 @@ private: bool gradationChanged; bool defaultChanged; bool securityChanged; - bool generalInfoChanged; + bool labelDataChanged; + bool askSaveLabelData; QAction *deleteAction; QAction *changeImageAction; QAction *saveImageAction; @@ -98,7 +99,7 @@ private: void SaveDescription(); void SaveGradation(); void SaveDefValues(); - void SaveGeneralInfo(); + void SaveLabelData(); void SetDefaultHeight(const QString &def); void SetDefaultSize(const QString &def); From 89ed92e93f75e50cb4d3410ffa755bcec01a2671 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 14 Aug 2017 15:11:14 +0300 Subject: [PATCH 14/54] Added more placeholders. --HG-- branch : feature --- .../dialogs/dialogpatternproperties.cpp | 16 ++-- .../dialogs/dialogpatternproperties.h | 4 +- .../dialogs/dialogpatternproperties.ui | 2 +- src/app/valentina/mainwindow.cpp | 87 ++++++++++--------- src/app/valentina/mainwindowsnogui.cpp | 3 +- src/app/valentina/mainwindowsnogui.h | 3 - src/libs/vmisc/def.cpp | 14 ++- src/libs/vmisc/def.h | 10 +++ src/libs/vmisc/vabstractapplication.cpp | 1 + src/libs/vmisc/vabstractapplication.h | 17 +++- src/libs/vpatterndb/vtranslatevars.cpp | 10 +++ src/libs/vpatterndb/vtranslatevars.h | 2 + .../dialogs/support/dialogeditlabel.cpp | 43 ++++++++- .../vtools/dialogs/support/dialogeditlabel.h | 4 +- 14 files changed, 151 insertions(+), 65 deletions(-) diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 35cc078b9..f73e26746 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -46,8 +46,7 @@ static const int heightsCount = (static_cast(GHeights::H200) - static const int sizesCount = (static_cast(GSizes::S72) - (static_cast(GSizes::S22) - sizeStep))/sizeStep; //--------------------------------------------------------------------------------------------------------------------- -DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPattern *doc, VContainer *pattern, - QWidget *parent) +DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent) : QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc), @@ -66,8 +65,7 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte deleteAction(nullptr), changeImageAction(nullptr), saveImageAction(nullptr), - showImageAction(nullptr), - m_filePath(filePath) + showImageAction(nullptr) { ui->setupUi(this); @@ -77,7 +75,7 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); - if (m_filePath.isEmpty()) + if (qApp->GetPPath().isEmpty()) { ui->lineEditPathToFile->setText(tr("")); ui->lineEditPathToFile->setToolTip(tr("File was not saved yet.")); @@ -85,15 +83,15 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte } else { - ui->lineEditPathToFile->setText(QDir::toNativeSeparators(m_filePath)); - ui->lineEditPathToFile->setToolTip(QDir::toNativeSeparators(m_filePath)); + ui->lineEditPathToFile->setText(QDir::toNativeSeparators(qApp->GetPPath())); + ui->lineEditPathToFile->setToolTip(QDir::toNativeSeparators(qApp->GetPPath())); ui->pushButtonShowInExplorer->setEnabled(true); } ui->lineEditPathToFile->setCursorPosition(0); connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, this, [this]() { - ShowInGraphicalShell(m_filePath); + ShowInGraphicalShell(qApp->GetPPath()); }); #if defined(Q_OS_MAC) ui->pushButtonShowInExplorer->setText(tr("Show in Finder")); @@ -874,6 +872,6 @@ void DialogPatternProperties::EditLabel() } } - DialogEditLabel editor; + DialogEditLabel editor(doc); editor.exec(); } diff --git a/src/app/valentina/dialogs/dialogpatternproperties.h b/src/app/valentina/dialogs/dialogpatternproperties.h index 7429a302e..d72c8eaae 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.h +++ b/src/app/valentina/dialogs/dialogpatternproperties.h @@ -46,8 +46,7 @@ class DialogPatternProperties : public QDialog { Q_OBJECT public: - explicit DialogPatternProperties(const QString &filePath, VPattern *doc, VContainer *pattern, - QWidget *parent = nullptr); + explicit DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent = nullptr); virtual ~DialogPatternProperties() Q_DECL_OVERRIDE; signals: void UpdateGradation(); @@ -83,7 +82,6 @@ private: QAction *changeImageAction; QAction *saveImageAction; QAction *showImageAction; - const QString &m_filePath; void SetHeightsChecked(bool enabled); void SetSizesChecked(bool enabled); diff --git a/src/app/valentina/dialogs/dialogpatternproperties.ui b/src/app/valentina/dialogs/dialogpatternproperties.ui index bbb31adcb..cf5244d3d 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.ui +++ b/src/app/valentina/dialogs/dialogpatternproperties.ui @@ -21,7 +21,7 @@ - 3 + 0 diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index a7e5984d2..dd9c16689 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1519,10 +1519,10 @@ void MainWindow::LoadIndividual() { if (not doc->MPath().isEmpty()) { - watcher->removePath(AbsoluteMPath(curFile, doc->MPath())); + watcher->removePath(AbsoluteMPath(qApp->GetPPath(), doc->MPath())); } ui->actionUnloadMeasurements->setEnabled(true); - doc->SetPath(RelativeMPath(curFile, mPath)); + doc->SetPath(RelativeMPath(qApp->GetPPath(), mPath)); watcher->addPath(mPath); PatternChangesWereSaved(false); ui->actionEditCurrent->setEnabled(true); @@ -1568,10 +1568,10 @@ void MainWindow::LoadMultisize() { if (not doc->MPath().isEmpty()) { - watcher->removePath(AbsoluteMPath(curFile, doc->MPath())); + watcher->removePath(AbsoluteMPath(qApp->GetPPath(), doc->MPath())); } ui->actionUnloadMeasurements->setEnabled(true); - doc->SetPath(RelativeMPath(curFile, mPath)); + doc->SetPath(RelativeMPath(qApp->GetPPath(), mPath)); watcher->addPath(mPath); PatternChangesWereSaved(false); ui->actionEditCurrent->setEnabled(true); @@ -1607,7 +1607,7 @@ void MainWindow::UnloadMeasurements() if (doc->ListMeasurements().isEmpty()) { - watcher->removePath(AbsoluteMPath(curFile, doc->MPath())); + watcher->removePath(AbsoluteMPath(qApp->GetPPath(), doc->MPath())); doc->SetPath(QString()); PatternChangesWereSaved(false); ui->actionEditCurrent->setEnabled(false); @@ -1628,7 +1628,7 @@ void MainWindow::ShowMeasurements() { if (not doc->MPath().isEmpty()) { - const QString absoluteMPath = AbsoluteMPath(curFile, doc->MPath()); + const QString absoluteMPath = AbsoluteMPath(qApp->GetPPath(), doc->MPath()); QStringList arguments; if (qApp->patternType() == MeasurementsType::Multisize) @@ -1700,7 +1700,7 @@ void MainWindow::SyncMeasurements() { if (mChanges) { - const QString path = AbsoluteMPath(curFile, doc->MPath()); + const QString path = AbsoluteMPath(qApp->GetPPath(), doc->MPath()); if(UpdateMeasurements(path, static_cast(VContainer::size()), static_cast(VContainer::height()))) { if (not watcher->files().contains(path)) @@ -2530,7 +2530,14 @@ bool MainWindow::SaveAs() { QString filters(tr("Pattern files") + QLatin1String("(*.val)")); QString dir; - curFile.isEmpty() ? dir = qApp->ValentinaSettings()->GetPathPattern() : dir = QFileInfo(curFile).absolutePath(); + if (qApp->GetPPath().isEmpty()) + { + dir = qApp->ValentinaSettings()->GetPathPattern(); + } + else + { + dir = QFileInfo(qApp->GetPPath()).absolutePath(); + } bool usedNotExistedDir = false; QDir directory(dir); @@ -2632,7 +2639,7 @@ bool MainWindow::SaveAs() */ bool MainWindow::Save() { - if (curFile.isEmpty() || patternReadOnly) + if (qApp->GetPPath().isEmpty() || patternReadOnly) { return SaveAs(); } @@ -2646,7 +2653,7 @@ bool MainWindow::Save() #ifdef Q_OS_WIN32 qt_ntfs_permission_lookup++; // turn checking on #endif /*Q_OS_WIN32*/ - const bool isFileWritable = QFileInfo(curFile).isWritable(); + const bool isFileWritable = QFileInfo(qApp->GetPPath()).isWritable(); #ifdef Q_OS_WIN32 qt_ntfs_permission_lookup--; // turn it off again #endif /*Q_OS_WIN32*/ @@ -2665,8 +2672,8 @@ bool MainWindow::Save() #ifdef Q_OS_WIN32 qt_ntfs_permission_lookup++; // turn checking on #endif /*Q_OS_WIN32*/ - bool changed = QFile::setPermissions(curFile, - QFileInfo(curFile).permissions() | QFileDevice::WriteUser); + bool changed = QFile::setPermissions(qApp->GetPPath(), + QFileInfo(qApp->GetPPath()).permissions() | QFileDevice::WriteUser); #ifdef Q_OS_WIN32 qt_ntfs_permission_lookup--; // turn it off again #endif /*Q_OS_WIN32*/ @@ -2675,7 +2682,7 @@ bool MainWindow::Save() { QMessageBox messageBox(this); messageBox.setIcon(QMessageBox::Warning); - messageBox.setText(tr("Cannot set permissions for %1 to writable.").arg(curFile)); + messageBox.setText(tr("Cannot set permissions for %1 to writable.").arg(qApp->GetPPath())); messageBox.setInformativeText(tr("Could not save the file.")); messageBox.setDefaultButton(QMessageBox::Ok); messageBox.setStandardButtons(QMessageBox::Ok); @@ -2690,10 +2697,10 @@ bool MainWindow::Save() } QString error; - bool result = SavePattern(curFile, error); + bool result = SavePattern(qApp->GetPPath(), error); if (result) { - QFile::remove(curFile + autosavePrefix); + QFile::remove(qApp->GetPPath() + autosavePrefix); m_curFileFormatVersion = VPatternConverter::PatternMaxVer; m_curFileFormatVersionStr = VPatternConverter::PatternMaxVerStr; } @@ -2754,9 +2761,9 @@ void MainWindow::Clear() qCDebug(vMainWindow, "Returned to Draw mode."); pattern->Clear(); qCDebug(vMainWindow, "Clearing pattern."); - if (not curFile.isEmpty() && not doc->MPath().isEmpty()) + if (not qApp->GetPPath().isEmpty() && not doc->MPath().isEmpty()) { - watcher->removePath(AbsoluteMPath(curFile, doc->MPath())); + watcher->removePath(AbsoluteMPath(qApp->GetPPath(), doc->MPath())); } doc->clear(); setCurrentFile(QString()); @@ -2807,16 +2814,16 @@ void MainWindow::FileClosedCorrect() //File was closed correct. QStringList restoreFiles = qApp->ValentinaSettings()->GetRestoreFileList(); - restoreFiles.removeAll(curFile); + restoreFiles.removeAll(qApp->GetPPath()); qApp->ValentinaSettings()->SetRestoreFileList(restoreFiles); // Remove autosave file - QFile autofile(curFile + autosavePrefix); + QFile autofile(qApp->GetPPath() + autosavePrefix); if (autofile.exists()) { autofile.remove(); } - qCDebug(vMainWindow, "File %s closed correct.", qUtf8Printable(curFile)); + qCDebug(vMainWindow, "File %s closed correct.", qUtf8Printable(qApp->GetPPath())); } //--------------------------------------------------------------------------------------------------------------------- @@ -3161,7 +3168,8 @@ void MainWindow::PatternChangesWereSaved(bool saved) void MainWindow::ChangedSize(const QString & text) { const int size = static_cast(VContainer::size()); - if (UpdateMeasurements(AbsoluteMPath(curFile, doc->MPath()), text.toInt(), static_cast(VContainer::height()))) + if (UpdateMeasurements(AbsoluteMPath(qApp->GetPPath(), doc->MPath()), text.toInt(), + static_cast(VContainer::height()))) { doc->LiteParseTree(Document::LiteParse); emit sceneDetails->DimensionsChanged(); @@ -3190,7 +3198,8 @@ void MainWindow::ChangedSize(const QString & text) void MainWindow::ChangedHeight(const QString &text) { const int height = static_cast(VContainer::height()); - if (UpdateMeasurements(AbsoluteMPath(curFile, doc->MPath()), static_cast(VContainer::size()), text.toInt())) + if (UpdateMeasurements(AbsoluteMPath(qApp->GetPPath(), doc->MPath()), static_cast(VContainer::size()), + text.toInt())) { doc->LiteParseTree(Document::LiteParse); emit sceneDetails->DimensionsChanged(); @@ -3374,8 +3383,8 @@ bool MainWindow::SavePattern(const QString &fileName, QString &error) qCDebug(vMainWindow, "Saving pattern file %s.", qUtf8Printable(fileName)); QFileInfo tempInfo(fileName); - const QString mPath = AbsoluteMPath(curFile, doc->MPath()); - if (not mPath.isEmpty() && curFile != fileName) + const QString mPath = AbsoluteMPath(qApp->GetPPath(), doc->MPath()); + if (not mPath.isEmpty() && qApp->GetPPath() != fileName) { doc->SetPath(RelativeMPath(fileName, mPath)); } @@ -3407,9 +3416,9 @@ void MainWindow::AutoSavePattern() { qCDebug(vMainWindow, "Autosaving pattern."); - if (curFile.isEmpty() == false && this->isWindowModified() == true) + if (qApp->GetPPath().isEmpty() == false && this->isWindowModified() == true) { - QString autofile = curFile + autosavePrefix; + QString autofile = qApp->GetPPath() + autosavePrefix; QString error; SavePattern(autofile, error); } @@ -3424,10 +3433,10 @@ void MainWindow::AutoSavePattern() void MainWindow::setCurrentFile(const QString &fileName) { qCDebug(vMainWindow, "Set current name to \"%s\"", qUtf8Printable(fileName)); - curFile = fileName; + qApp->SetPPath(fileName); qApp->getUndoStack()->setClean(); - if (not curFile.isEmpty() && VApplication::IsGUIMode()) + if (not qApp->GetPPath().isEmpty() && VApplication::IsGUIMode()) { qCDebug(vMainWindow, "Updating recent file list."); VSettings *settings = qApp->ValentinaSettings(); @@ -3512,7 +3521,7 @@ bool MainWindow::MaybeSave() messageBox->setEscapeButton(QMessageBox::Cancel); messageBox->setButtonText(QMessageBox::Yes, - curFile.isEmpty() || patternReadOnly ? tr("Save...") : tr("Save")); + qApp->GetPPath().isEmpty() || patternReadOnly ? tr("Save...") : tr("Save")); messageBox->setButtonText(QMessageBox::No, tr("Don't Save")); messageBox->setWindowModality(Qt::ApplicationModal); @@ -3849,7 +3858,7 @@ void MainWindow::InitDocksContain() //--------------------------------------------------------------------------------------------------------------------- bool MainWindow::OpenNewValentina(const QString &fileName) const { - if (this->isWindowModified() || curFile.isEmpty() == false) + if (this->isWindowModified() || qApp->GetPPath().isEmpty() == false) { VApplication::NewValentina(fileName); return true; @@ -3972,7 +3981,7 @@ void MainWindow::CreateActions() connect(ui->actionPattern_properties, &QAction::triggered, this, [this]() { - DialogPatternProperties proper(curFile, doc, pattern, this); + DialogPatternProperties proper(doc, pattern, this); connect(&proper, &DialogPatternProperties::UpdateGradation, this, [this]() { UpdateHeightsList(VMeasurement::ListHeights(doc->GetGradationHeights(), qApp->patternUnit())); @@ -4813,7 +4822,7 @@ bool MainWindow::SetSize(const QString &text) { if (not VApplication::IsGUIMode()) { - if (this->isWindowModified() || not curFile.isEmpty()) + if (this->isWindowModified() || not qApp->GetPPath().isEmpty()) { if (qApp->patternType() == MeasurementsType::Multisize) { @@ -4856,7 +4865,7 @@ bool MainWindow::SetHeight(const QString &text) { if (not VApplication::IsGUIMode()) { - if (this->isWindowModified() || not curFile.isEmpty()) + if (this->isWindowModified() || not qApp->GetPPath().isEmpty()) { if (qApp->patternType() == MeasurementsType::Multisize) { @@ -4969,9 +4978,9 @@ void MainWindow::ProcessCMD() QString MainWindow::GetPatternFileName() { QString shownName = tr("untitled.val"); - if(not curFile.isEmpty()) + if(not qApp->GetPPath().isEmpty()) { - shownName = StrippedName(curFile); + shownName = StrippedName(qApp->GetPPath()); } shownName += QLatin1String("[*]"); return shownName; @@ -4987,7 +4996,7 @@ QString MainWindow::GetMeasurementFileName() else { QString shownName(" ["); - shownName += StrippedName(AbsoluteMPath(curFile, doc->MPath())); + shownName += StrippedName(AbsoluteMPath(qApp->GetPPath(), doc->MPath())); if(mChanges) { @@ -5003,12 +5012,12 @@ QString MainWindow::GetMeasurementFileName() void MainWindow::UpdateWindowTitle() { bool isFileWritable = true; - if (not curFile.isEmpty()) + if (not qApp->GetPPath().isEmpty()) { #ifdef Q_OS_WIN32 qt_ntfs_permission_lookup++; // turn checking on #endif /*Q_OS_WIN32*/ - isFileWritable = QFileInfo(curFile).isWritable(); + isFileWritable = QFileInfo(qApp->GetPPath()).isWritable(); #ifdef Q_OS_WIN32 qt_ntfs_permission_lookup--; // turn it off again #endif /*Q_OS_WIN32*/ @@ -5023,7 +5032,7 @@ void MainWindow::UpdateWindowTitle() setWindowTitle(GetPatternFileName()+GetMeasurementFileName() + QLatin1String(" (") + tr("read only") + QLatin1String(")")); } - setWindowFilePath(curFile); + setWindowFilePath(qApp->GetPPath()); #if defined(Q_OS_MAC) static QIcon fileIcon = QIcon(QCoreApplication::applicationDirPath() + diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index c917a3ee7..8b05e458f 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -101,7 +101,6 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent) redoAction(nullptr), actionDockWidgetToolOptions(nullptr), actionDockWidgetGroups(nullptr), - curFile(), isNoScaling(false), isLayoutStale(true), ignorePrinterFields(false), @@ -1512,7 +1511,7 @@ void MainWindowsNoGUI::ExportScene(const DialogSaveLayout &dialog, const QListGetPPath().isEmpty() ? fileName = tr("unnamed") : fileName = qApp->GetPPath(); return QFileInfo(fileName).baseName(); } diff --git a/src/app/valentina/mainwindowsnogui.h b/src/app/valentina/mainwindowsnogui.h index fcc5e4029..3c23bf983 100644 --- a/src/app/valentina/mainwindowsnogui.h +++ b/src/app/valentina/mainwindowsnogui.h @@ -82,9 +82,6 @@ protected: QAction *actionDockWidgetToolOptions; QAction *actionDockWidgetGroups; - /** @brief fileName name current pattern file. */ - QString curFile; - bool isNoScaling; bool isLayoutStale; bool ignorePrinterFields; diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 4bb1adb3d..54f896133 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -109,8 +109,18 @@ const QStringList builInPostfixOperators = QStringList() << cm_Oprt << mm_Oprt << in_Oprt; -const QString pl_size = QStringLiteral("size"); -const QString pl_height = QStringLiteral("height"); +const QString pl_size = QStringLiteral("size"); +const QString pl_height = QStringLiteral("height"); +const QString pl_date = QStringLiteral("date"); +const QString pl_time = QStringLiteral("time"); +const QString pl_patternName = QStringLiteral("patternName"); +const QString pl_patternNumber = QStringLiteral("patternNumber"); +const QString pl_author = QStringLiteral("author"); +const QString pl_customer = QStringLiteral("customer"); +const QString pl_pExt = QStringLiteral("pExt"); +const QString pl_pFileName = QStringLiteral("pFileName"); +const QString pl_mFileName = QStringLiteral("mFileName"); +const QString pl_mExt = QStringLiteral("mExt"); const QString cursorArrowOpenHand = QStringLiteral("://cursor/cursor-arrow-openhand.png"); const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png"); diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 23cff43ea..e91a04d3c 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -353,6 +353,16 @@ extern const QStringList builInPostfixOperators; // Placeholders extern const QString pl_size; extern const QString pl_height; +extern const QString pl_date; +extern const QString pl_time; +extern const QString pl_patternName; +extern const QString pl_patternNumber; +extern const QString pl_author; +extern const QString pl_customer; +extern const QString pl_pExt; +extern const QString pl_pFileName; +extern const QString pl_mFileName; +extern const QString pl_mExt; extern const QString cursorArrowOpenHand; extern const QString cursorArrowCloseHand; diff --git a/src/libs/vmisc/vabstractapplication.cpp b/src/libs/vmisc/vabstractapplication.cpp index 8ad3b3cf0..0321cf8fd 100644 --- a/src/libs/vmisc/vabstractapplication.cpp +++ b/src/libs/vmisc/vabstractapplication.cpp @@ -54,6 +54,7 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv) pmsTranslator(nullptr), _patternUnit(Unit::Cm), _patternType(MeasurementsType::Unknown), + patternFilePath(), currentScene(nullptr), sceneView(nullptr), doc(nullptr), diff --git a/src/libs/vmisc/vabstractapplication.h b/src/libs/vmisc/vabstractapplication.h index 75701e48e..857a143be 100644 --- a/src/libs/vmisc/vabstractapplication.h +++ b/src/libs/vmisc/vabstractapplication.h @@ -105,6 +105,9 @@ public: virtual bool IsAppInGUIMode()const =0; + QString GetPPath() const; + void SetPPath(const QString &value); + protected: QUndoStack *undoStack; @@ -131,7 +134,7 @@ private: Q_DISABLE_COPY(VAbstractApplication) Unit _patternUnit; MeasurementsType _patternType; - + QString patternFilePath; QGraphicsScene **currentScene; VMainGraphicsView *sceneView; @@ -147,6 +150,18 @@ private: void ClearTranslation(); }; +//--------------------------------------------------------------------------------------------------------------------- +inline QString VAbstractApplication::GetPPath() const +{ + return patternFilePath; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VAbstractApplication::SetPPath(const QString &value) +{ + patternFilePath = value; +} + //--------------------------------------------------------------------------------------------------------------------- template diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index 22810a645..39ed1c424 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -459,6 +459,16 @@ void VTranslateVars::InitPlaceholder() { placeholders.insert(pl_size, translate("VTranslateVars", "size", "placeholder")); placeholders.insert(pl_height, translate("VTranslateVars", "height", "placeholder")); + placeholders.insert(pl_date, translate("VTranslateVars", "date", "placeholder")); + placeholders.insert(pl_time, translate("VTranslateVars", "time", "placeholder")); + placeholders.insert(pl_patternName, translate("VTranslateVars", "patternName", "placeholder")); + placeholders.insert(pl_patternNumber, translate("VTranslateVars", "patternNumber", "placeholder")); + placeholders.insert(pl_author, translate("VTranslateVars", "author", "placeholder")); + placeholders.insert(pl_customer, translate("VTranslateVars", "customer", "placeholder")); + placeholders.insert(pl_pExt, translate("VTranslateVars", "pExt", "placeholder")); + placeholders.insert(pl_pFileName, translate("VTranslateVars", "pFileName", "placeholder")); + placeholders.insert(pl_mFileName, translate("VTranslateVars", "mFileName", "placeholder")); + placeholders.insert(pl_mExt, translate("VTranslateVars", "mExt", "placeholder")); } #undef translate diff --git a/src/libs/vpatterndb/vtranslatevars.h b/src/libs/vpatterndb/vtranslatevars.h index a8a8213d9..929585fef 100644 --- a/src/libs/vpatterndb/vtranslatevars.h +++ b/src/libs/vpatterndb/vtranslatevars.h @@ -34,6 +34,8 @@ #include "vtranslatemeasurements.h" +#define trPL(pl) QLatin1String("%") + qApp->TrVars()->PlaceholderToUser((pl)) + QLatin1String("%") + class VTranslateVars : public VTranslateMeasurements { public: diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index b0a9a65e2..058e994fe 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -31,7 +31,9 @@ #include "../vmisc/vabstractapplication.h" #include "../vformat/vlabeltemplate.h" #include "../ifc/xml/vlabeltemplateconverter.h" +#include "../ifc/xml/vabstractpattern.h" #include "../ifc/exception/vexception.h" +#include "../vpatterndb/vcontainer.h" #include #include @@ -40,10 +42,11 @@ #include //--------------------------------------------------------------------------------------------------------------------- -DialogEditLabel::DialogEditLabel(QWidget *parent) +DialogEditLabel::DialogEditLabel(VAbstractPattern *doc, QWidget *parent) : QDialog(parent), ui(new Ui::DialogEditLabel), m_placeholdersMenu(new QMenu(this)), + m_doc(doc), m_placeholders() { ui->setupUi(this); @@ -429,7 +432,7 @@ void DialogEditLabel::InitPlaceholdersMenu() { auto value = i.value(); QAction *action = m_placeholdersMenu->addAction(value.first); - action->setData(i.key()); + action->setData(trPL(i.key())); connect(action, &QAction::triggered, this, &DialogEditLabel::InsertPlaceholder); ++i; } @@ -439,7 +442,39 @@ void DialogEditLabel::InitPlaceholdersMenu() void DialogEditLabel::InitPlaceholders() { QLocale locale(qApp->Settings()->GetLocale()); - m_placeholders.insert("%date%", qMakePair(tr("Date"), locale.toString(QDate::currentDate(), "dd MMMM yyyy"))); + m_placeholders.insert(pl_date, qMakePair(tr("Date"), locale.toString(QDate::currentDate()))); + m_placeholders.insert(pl_time, qMakePair(tr("Time"), locale.toString(QTime::currentTime()))); + + m_placeholders.insert(pl_patternName, qMakePair(tr("Pattern name"), m_doc->GetPatternName())); + m_placeholders.insert(pl_patternNumber, qMakePair(tr("Pattern number"), m_doc->GetPatternNumber())); + m_placeholders.insert(pl_author, qMakePair(tr("Company name or designer name"), + m_doc->GetCompanyName())); + m_placeholders.insert(pl_customer, qMakePair(tr("Customer name"), m_doc->GetCustomerName())); + m_placeholders.insert(pl_pExt, qMakePair(tr("Pattern extension"), QString("val"))); + + const QString patternFilePath = QFileInfo(qApp->GetPPath()).fileName(); + m_placeholders.insert(pl_pFileName, qMakePair(tr("Pattern file name"), patternFilePath)); + + const QString measurementsFilePath = QFileInfo(m_doc->MPath()).fileName(); + m_placeholders.insert(pl_mFileName, qMakePair(tr("Measurments file name"), measurementsFilePath)); + + QString curSize; + QString curHeight; + QString mExt; + if (qApp->patternType() == MeasurementsType::Multisize) + { + curSize = QString::number(VContainer::size()); + curHeight = QString::number(VContainer::height()); + mExt = "vst"; + } + else if (qApp->patternType() == MeasurementsType::Individual) + { + mExt = "vit"; + } + + m_placeholders.insert(pl_size, qMakePair(tr("Size"), curSize)); + m_placeholders.insert(pl_height, qMakePair(tr("Height"), curHeight)); + m_placeholders.insert(pl_mExt, qMakePair(tr("Measurments extension"), mExt)); } //--------------------------------------------------------------------------------------------------------------------- @@ -448,7 +483,7 @@ QString DialogEditLabel::ReplacePlaceholders(QString line) const auto i = m_placeholders.constBegin(); while (i != m_placeholders.constEnd()) { - line.replace(i.key(), i.value().second); + line.replace(QChar('%')+i.key()+QChar('%'), i.value().second); ++i; } return line; diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h index 5f0da10d4..c02bba8bb 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.h +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -39,13 +39,14 @@ namespace Ui class VLabelTemplateLine; class QMenu; +class VAbstractPattern; class DialogEditLabel : public QDialog { Q_OBJECT public: - explicit DialogEditLabel(QWidget *parent = nullptr); + explicit DialogEditLabel(VAbstractPattern *doc, QWidget *parent = nullptr); virtual ~DialogEditLabel(); private slots: @@ -65,6 +66,7 @@ private: Q_DISABLE_COPY(DialogEditLabel) Ui::DialogEditLabel *ui; QMenu *m_placeholdersMenu; + VAbstractPattern *m_doc; QMap> m_placeholders; From 0b3342fe3d10102270c2789825405db5ad331cea Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 14 Aug 2017 15:48:14 +0300 Subject: [PATCH 15/54] Translation from/to user text. --HG-- branch : feature --- src/libs/vpatterndb/vtranslatevars.cpp | 38 +++++++++++++++++++ src/libs/vpatterndb/vtranslatevars.h | 5 ++- .../dialogs/support/dialogeditlabel.cpp | 7 ++-- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index 39ed1c424..bdf6ddfc4 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -683,6 +683,44 @@ QString VTranslateVars::PlaceholderToUser(const QString &var) const return var; } +//--------------------------------------------------------------------------------------------------------------------- +QString VTranslateVars::PlaceholderToUserText(QString text) const +{ + QChar per('%'); + auto i = placeholders.constBegin(); + while (i != placeholders.constEnd()) + { + const QString translated = per + i.value().translate() + per; + const QString original = per + i.key() + per; + + while (text.indexOf(original) != -1) + { + text.replace(original, translated); + } + ++i; + } + return text; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VTranslateVars::PlaceholderFromUserText(QString text) const +{ + QChar per('%'); + auto i = placeholders.constBegin(); + while (i != placeholders.constEnd()) + { + const QString translated = per + i.value().translate() + per; + const QString original = per + i.key() + per; + + while (text.indexOf(translated) != -1) + { + text.replace(translated, original); + } + ++i; + } + return text; +} + //--------------------------------------------------------------------------------------------------------------------- QString VTranslateVars::VarToUser(const QString &var) const { diff --git a/src/libs/vpatterndb/vtranslatevars.h b/src/libs/vpatterndb/vtranslatevars.h index 929585fef..1ac8a7c68 100644 --- a/src/libs/vpatterndb/vtranslatevars.h +++ b/src/libs/vpatterndb/vtranslatevars.h @@ -34,8 +34,6 @@ #include "vtranslatemeasurements.h" -#define trPL(pl) QLatin1String("%") + qApp->TrVars()->PlaceholderToUser((pl)) + QLatin1String("%") - class VTranslateVars : public VTranslateMeasurements { public: @@ -50,6 +48,9 @@ public: QString InternalVarToUser(const QString &var) const; QString PlaceholderToUser(const QString &var) const; + QString PlaceholderToUserText(QString text) const; + QString PlaceholderFromUserText(QString text) const; + QString VarToUser(const QString &var) const; QString VarFromUser(const QString &var) const; diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index 058e994fe..542a43137 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -427,12 +427,13 @@ void DialogEditLabel::SetupControls() //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::InitPlaceholdersMenu() { + QChar per('%'); auto i = m_placeholders.constBegin(); while (i != m_placeholders.constEnd()) { auto value = i.value(); QAction *action = m_placeholdersMenu->addAction(value.first); - action->setData(trPL(i.key())); + action->setData(per + qApp->TrVars()->PlaceholderToUser(i.key()) + per); connect(action, &QAction::triggered, this, &DialogEditLabel::InsertPlaceholder); ++i; } @@ -500,7 +501,7 @@ QVector DialogEditLabel::PrepareLines() const if (lineItem) { VLabelTemplateLine line; - line.line = lineItem->text(); + line.line = qApp->TrVars()->PlaceholderFromUserText(lineItem->text()); line.alignment = lineItem->textAlignment(); const QFont font = lineItem->font(); @@ -524,7 +525,7 @@ void DialogEditLabel::InitEditLines(const QVector &lines) for (int i=0; iTrVars()->PlaceholderToUserText(lines.at(i).line)); item->setTextAlignment(lines.at(i).alignment); QFont font = item->font(); From 5a649d47470c4e7391cc8f3fed792dbb057d77db Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 14 Aug 2017 17:13:16 +0300 Subject: [PATCH 16/54] Fix bug translation placeholders. --HG-- branch : feature --- src/libs/vpatterndb/vtranslatevars.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index bdf6ddfc4..b3af9481a 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -693,9 +693,12 @@ QString VTranslateVars::PlaceholderToUserText(QString text) const const QString translated = per + i.value().translate() + per; const QString original = per + i.key() + per; - while (text.indexOf(original) != -1) + if (translated != original) { - text.replace(original, translated); + while (text.indexOf(original) != -1) + { + text.replace(original, translated); + } } ++i; } @@ -712,9 +715,12 @@ QString VTranslateVars::PlaceholderFromUserText(QString text) const const QString translated = per + i.value().translate() + per; const QString original = per + i.key() + per; - while (text.indexOf(translated) != -1) + if (translated != original) { - text.replace(translated, original); + while (text.indexOf(translated) != -1) + { + text.replace(translated, original); + } } ++i; } From 5c754a51d7e91976b8b9db27d7458998f9362f94 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 14 Aug 2017 17:13:54 +0300 Subject: [PATCH 17/54] Fix file valentina.sharedmimeinfo. --HG-- branch : feature --- dist/debian/valentina.sharedmimeinfo | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/debian/valentina.sharedmimeinfo b/dist/debian/valentina.sharedmimeinfo index 00f1b4197..41bb06377 100644 --- a/dist/debian/valentina.sharedmimeinfo +++ b/dist/debian/valentina.sharedmimeinfo @@ -76,8 +76,8 @@ Valentina pattern Valentina pattern Valentina pattern - OValentina pattern - OValentina pattern + Valentina pattern + Valentina pattern Valentina pattern Valentina pattern Valentina pattern @@ -170,8 +170,8 @@ Valentina individual measurments Valentina individual measurments Valentina individual measurments - OValentina individual measurments - OValentina individual measurments + Valentina individual measurments + Valentina individual measurments Valentina individual measurments Valentina individual measurments Valentina individual measurments @@ -264,8 +264,8 @@ Valentina standard measurments Valentina standard measurments Valentina standard measurments - OValentina standard measurments - OValentina standard measurments + Valentina standard measurments + Valentina standard measurments Valentina standard measurments Valentina standard measurments Valentina standard measurments From 0f4c993c83536b92f11fdcb0c17ef3d19140fd16 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 14 Aug 2017 17:17:40 +0300 Subject: [PATCH 18/54] Added default pattern label template. --HG-- branch : feature --- dist/OBS_debian/debian.valentina.dirs | 1 + dist/OBS_debian/debian.valentina.install | 1 + dist/OBS_debian/debian.valentina.sharedmimeinfo | 12 ++++++------ dist/debian/valentina.dirs | 1 + dist/debian/valentina.install | 1 + dist/rpm/valentina.spec | 2 ++ dist/win/inno/valentina.iss | 1 + src/app/share/labels/def_pattern_label.xml | 11 +++++++++++ src/app/tables.pri | 4 ++++ src/app/valentina/valentina.pro | 16 +++++++++++++++- src/libs/vmisc/vcommonsettings.cpp | 2 +- 11 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 src/app/share/labels/def_pattern_label.xml diff --git a/dist/OBS_debian/debian.valentina.dirs b/dist/OBS_debian/debian.valentina.dirs index 4d8be8137..bd0bdc98e 100644 --- a/dist/OBS_debian/debian.valentina.dirs +++ b/dist/OBS_debian/debian.valentina.dirs @@ -2,6 +2,7 @@ /usr/share/valentina/translations /usr/share/valentina/tables/multisize /usr/share/valentina/tables/templates +/usr/share/valentina/labels /usr/share/mime/packages /usr/share/applications diff --git a/dist/OBS_debian/debian.valentina.install b/dist/OBS_debian/debian.valentina.install index d0f0eebc6..c2c52fea9 100644 --- a/dist/OBS_debian/debian.valentina.install +++ b/dist/OBS_debian/debian.valentina.install @@ -4,5 +4,6 @@ usr/share/valentina/* usr/share/valentina/translations/* usr/share/valentina/tables/multisize/* usr/share/valentina/tables/templates/* +usr/share/valentina/labels/* usr/share/pixmaps/* usr/share/applications/* diff --git a/dist/OBS_debian/debian.valentina.sharedmimeinfo b/dist/OBS_debian/debian.valentina.sharedmimeinfo index 00f1b4197..41bb06377 100644 --- a/dist/OBS_debian/debian.valentina.sharedmimeinfo +++ b/dist/OBS_debian/debian.valentina.sharedmimeinfo @@ -76,8 +76,8 @@ Valentina pattern Valentina pattern Valentina pattern - OValentina pattern - OValentina pattern + Valentina pattern + Valentina pattern Valentina pattern Valentina pattern Valentina pattern @@ -170,8 +170,8 @@ Valentina individual measurments Valentina individual measurments Valentina individual measurments - OValentina individual measurments - OValentina individual measurments + Valentina individual measurments + Valentina individual measurments Valentina individual measurments Valentina individual measurments Valentina individual measurments @@ -264,8 +264,8 @@ Valentina standard measurments Valentina standard measurments Valentina standard measurments - OValentina standard measurments - OValentina standard measurments + Valentina standard measurments + Valentina standard measurments Valentina standard measurments Valentina standard measurments Valentina standard measurments diff --git a/dist/debian/valentina.dirs b/dist/debian/valentina.dirs index 4d8be8137..bd0bdc98e 100644 --- a/dist/debian/valentina.dirs +++ b/dist/debian/valentina.dirs @@ -2,6 +2,7 @@ /usr/share/valentina/translations /usr/share/valentina/tables/multisize /usr/share/valentina/tables/templates +/usr/share/valentina/labels /usr/share/mime/packages /usr/share/applications diff --git a/dist/debian/valentina.install b/dist/debian/valentina.install index d0f0eebc6..c2c52fea9 100644 --- a/dist/debian/valentina.install +++ b/dist/debian/valentina.install @@ -4,5 +4,6 @@ usr/share/valentina/* usr/share/valentina/translations/* usr/share/valentina/tables/multisize/* usr/share/valentina/tables/templates/* +usr/share/valentina/labels/* usr/share/pixmaps/* usr/share/applications/* diff --git a/dist/rpm/valentina.spec b/dist/rpm/valentina.spec index 707fa70e2..2bfe1fcaa 100644 --- a/dist/rpm/valentina.spec +++ b/dist/rpm/valentina.spec @@ -154,6 +154,8 @@ fi %{_datadir}/%{name}/tables/multisize/*.vst %dir %{_datadir}/%{name}/tables/templates %{_datadir}/%{name}/tables/templates/*.vit +%dir %{_datadir}/%{name}/labels +%{_datadir}/%{name}/labels/*.xml %clean rm -f dist/debian/%{name}.1.gz dist/debian/tape.1.gz dist/debian/%{name}.xml dist/debian/%{name} diff --git a/dist/win/inno/valentina.iss b/dist/win/inno/valentina.iss index 420ddf34a..88e8cec89 100644 --- a/dist/win/inno/valentina.iss +++ b/dist/win/inno/valentina.iss @@ -213,6 +213,7 @@ Source: ".\valentina\iconengines\*"; DestDir: "{app}\iconengines"; Flags: recurs Source: ".\valentina\platforms\*"; DestDir: "{app}\platforms"; Flags: recursesubdirs createallsubdirs Source: ".\valentina\printsupport\*"; DestDir: "{app}\printsupport"; Flags: recursesubdirs createallsubdirs Source: ".\valentina\tables\*"; DestDir: "{app}\tables"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: ".\valentina\labels\*"; DestDir: "{app}\labels"; Flags: ignoreversion recursesubdirs createallsubdirs Source: ".\valentina\*.exe"; DestDir: "{app}"; Flags: ignoreversion Source: ".\valentina\*.dll"; DestDir: "{app}" Source: ".\valentina\*.txt"; DestDir: "{app}"; Flags: ignoreversion diff --git a/src/app/share/labels/def_pattern_label.xml b/src/app/share/labels/def_pattern_label.xml new file mode 100644 index 000000000..5991c970c --- /dev/null +++ b/src/app/share/labels/def_pattern_label.xml @@ -0,0 +1,11 @@ + + diff --git a/src/app/tables.pri b/src/app/tables.pri index e5e059b62..e0efdbaef 100644 --- a/src/app/tables.pri +++ b/src/app/tables.pri @@ -6,4 +6,8 @@ INSTALL_STANDARD_TEMPLATES += \ $$PWD/share/tables/templates/template_all_measurements.vit \ $$PWD/share/tables/templates/t_Aldrich_Women.vit +# Keep path to all label templates we provide right now +INSTALL_LABEL_TEMPLATES += $$PWD/share/labels/def_pattern_label.vst + copyToDestdir($$INSTALL_MULTISIZE_MEASUREMENTS, $$shell_path($${OUT_PWD}/$$DESTDIR/tables/multisize)) +copyToDestdir($$INSTALL_LABEL_TEMPLATES, $$shell_path($${OUT_PWD}/$$DESTDIR/labels)) diff --git a/src/app/valentina/valentina.pro b/src/app/valentina/valentina.pro index 9e013e879..fb4e6342a 100644 --- a/src/app/valentina/valentina.pro +++ b/src/app/valentina/valentina.pro @@ -167,6 +167,10 @@ unix{ templates.path = /usr/share/$${TARGET}/tables/templates/ templates.files = $$INSTALL_STANDARD_TEMPLATES + # Path to label templates after installation + label.path = /usr/share/$${TARGET}/labels/ + label.files = $$INSTALL_LABEL_TEMPLATES + INSTALLS += \ target \ tape \ @@ -174,7 +178,8 @@ unix{ pixmaps \ translations \ multisize \ - templates + templates \ + label } macx{ # Some macx stuff @@ -234,6 +239,10 @@ unix{ templates.path = $$RESOURCES_DIR/tables/templates/ templates.files = $$INSTALL_STANDARD_TEMPLATES + # Path to label templates after installation + label.path = /usr/share/$${TARGET}/labels/ + label.files = $$INSTALL_LABEL_TEMPLATES + icns_resources.path = $$RESOURCES_DIR/ icns_resources.files += $$PWD/../../../dist/macx/i-measurements.icns icns_resources.files += $$PWD/../../../dist/macx/s-measurements.icns @@ -246,6 +255,7 @@ unix{ QMAKE_BUNDLE_DATA += \ templates \ multisize \ + label \ libraries \ tape \ xpdf \ @@ -316,6 +326,10 @@ win32:*g++* { package_templates.files += $$INSTALL_STANDARD_TEMPLATES INSTALLS += package_templates + package_labels.path = $${OUT_PWD}/../../../package/valentina/labels + package_labels.files += $$INSTALL_LABEL_TEMPLATES + INSTALLS += package_labels + package_translations.path = $${OUT_PWD}/../../../package/valentina/translations package_translations.files += \ $$INSTALL_TRANSLATIONS \ # Valentina diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index f70e61024..ded19bd84 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -48,7 +48,7 @@ const QString settingPathsIndividualMeasurements = QStringLiteral("paths/individual_measurements"); const QString settingPathsMultisizeMeasurements = QStringLiteral("paths/standard_measurements"); const QString settingPathsTemplates = QStringLiteral("paths/templates"); -const QString settingPathsLabelTemplate = QStringLiteral("paths/labelTemplate"); +const QString settingPathsLabelTemplate = QStringLiteral("paths/labels"); const QString settingConfigurationOsSeparator = QStringLiteral("configuration/osSeparator"); const QString settingConfigurationAutosaveState = QStringLiteral("configuration/autosave/state"); From d5c2b1b50d582319745def5b138b2b2bc11582e3 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 14 Aug 2017 19:34:33 +0300 Subject: [PATCH 19/54] GetTemplate after editing. --HG-- branch : feature --- .../dialogs/dialogpatternproperties.cpp | 61 ++++++++++++++----- .../dialogs/dialogpatternproperties.h | 6 ++ .../dialogs/support/dialogeditlabel.cpp | 6 +- .../vtools/dialogs/support/dialogeditlabel.h | 4 +- 4 files changed, 57 insertions(+), 20 deletions(-) diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index f73e26746..9f09d477d 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -62,10 +62,12 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat securityChanged(false), labelDataChanged(false), askSaveLabelData(false), + templateDataChanged(false), deleteAction(nullptr), changeImageAction(nullptr), saveImageAction(nullptr), - showImageAction(nullptr) + showImageAction(nullptr), + templateLines() { ui->setupUi(this); @@ -236,6 +238,7 @@ void DialogPatternProperties::Apply() break; case 3: SaveLabelData(); + SaveTemplateData(); break; default: break; @@ -273,10 +276,8 @@ void DialogPatternProperties::Ok() emit doc->patternChanged(false); } - if (labelDataChanged == true) - { - SaveLabelData(); - } + SaveLabelData(); + SaveTemplateData(); close(); } @@ -596,17 +597,31 @@ void DialogPatternProperties::SaveDefValues() //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::SaveLabelData() { - doc->SetPatternName(ui->lineEditPatternName->text()); - doc->SetPatternNumber(ui->lineEditPatternNumber->text()); - doc->SetCompanyName(ui->lineEditCompanyName->text()); - doc->SetCustomerName(ui->lineEditCustomerName->text()); - doc->SetPatternSize(ui->lineEditSize->text()); - doc->SetDateVisible(ui->checkBoxShowDate->isChecked()); - doc->SetMesurementsVisible(ui->checkBoxShowMeasurements->isChecked()); + if (labelDataChanged) + { + doc->SetPatternName(ui->lineEditPatternName->text()); + doc->SetPatternNumber(ui->lineEditPatternNumber->text()); + doc->SetCompanyName(ui->lineEditCompanyName->text()); + doc->SetCustomerName(ui->lineEditCustomerName->text()); + doc->SetPatternSize(ui->lineEditSize->text()); + doc->SetDateVisible(ui->checkBoxShowDate->isChecked()); + doc->SetMesurementsVisible(ui->checkBoxShowMeasurements->isChecked()); - labelDataChanged = false; - askSaveLabelData = false; - emit doc->patternChanged(false); + labelDataChanged = false; + askSaveLabelData = false; + emit doc->patternChanged(false); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::SaveTemplateData() +{ + if (templateDataChanged) + { + //doc->SetTemplate(templateLines); + templateDataChanged = false; + //emit doc->patternChanged(false); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -873,5 +888,19 @@ void DialogPatternProperties::EditLabel() } DialogEditLabel editor(doc); - editor.exec(); + +// if (templateDataChanged) +// { +// editor.SetTemplate(templateLines); +// } +// else +// { +// editor.SetTemplate(doc->GetTemplate()); +// } + + if (QDialog::Accepted == editor.exec()) + { + templateLines = editor.GetTemplate(); + templateDataChanged = true; + } } diff --git a/src/app/valentina/dialogs/dialogpatternproperties.h b/src/app/valentina/dialogs/dialogpatternproperties.h index d72c8eaae..7c0ee719b 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.h +++ b/src/app/valentina/dialogs/dialogpatternproperties.h @@ -33,6 +33,8 @@ #include "../options.h" #include +#include "../vformat/vlabeltemplate.h" + class VPattern; class VContainer; class QCheckBox; @@ -78,11 +80,14 @@ private: bool securityChanged; bool labelDataChanged; bool askSaveLabelData; + bool templateDataChanged; QAction *deleteAction; QAction *changeImageAction; QAction *saveImageAction; QAction *showImageAction; + QVector templateLines; + void SetHeightsChecked(bool enabled); void SetSizesChecked(bool enabled); void InitHeights(); @@ -98,6 +103,7 @@ private: void SaveGradation(); void SaveDefValues(); void SaveLabelData(); + void SaveTemplateData(); void SetDefaultHeight(const QString &def); void SetDefaultSize(const QString &def); diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index 542a43137..59a80d36a 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -315,7 +315,7 @@ void DialogEditLabel::ExportTemplate() VLabelTemplate ltemplate; ltemplate.CreateEmptyTemplate(); - ltemplate.AddLines(PrepareLines()); + ltemplate.AddLines(GetTemplate()); QString error; const bool result = ltemplate.SaveDocument(fileName, error); @@ -388,7 +388,7 @@ void DialogEditLabel::TabChanged(int index) { ui->toolButtonNewLabel->setDisabled(true); ui->toolButtonImportLabel->setDisabled(true); - InitPreviewLines(PrepareLines()); + InitPreviewLines(GetTemplate()); } else { @@ -491,7 +491,7 @@ QString DialogEditLabel::ReplacePlaceholders(QString line) const } //--------------------------------------------------------------------------------------------------------------------- -QVector DialogEditLabel::PrepareLines() const +QVector DialogEditLabel::GetTemplate() const { QVector lines; diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h index c02bba8bb..3450af694 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.h +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -49,6 +49,8 @@ public: explicit DialogEditLabel(VAbstractPattern *doc, QWidget *parent = nullptr); virtual ~DialogEditLabel(); + QVector GetTemplate() const; + private slots: void ShowLineDetails(); void AddLine(); @@ -76,7 +78,7 @@ private: QString ReplacePlaceholders(QString line) const; - QVector PrepareLines() const; + void InitEditLines(const QVector &lines); void InitPreviewLines(const QVector &lines); }; From 10e1c2fbfa0a38dfc1ff174e7984da9018c203f4 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 14 Aug 2017 19:44:20 +0300 Subject: [PATCH 20/54] Refactoring. --HG-- branch : feature --- .../dialogs/dialogpatternproperties.cpp | 97 +++++++++---------- .../dialogs/dialogpatternproperties.h | 1 + 2 files changed, 47 insertions(+), 51 deletions(-) diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 9f09d477d..3a444c1b3 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -221,20 +221,13 @@ void DialogPatternProperties::Apply() { case 0: SaveDescription(); - descriptionChanged = false; - emit doc->patternChanged(false); break; case 1: SaveGradation(); - gradationChanged = false; SaveDefValues(); - defaultChanged = false; - emit doc->patternChanged(false); break; case 2: - doc->SetReadOnly(ui->checkBoxPatternReadOnly->isChecked()); - securityChanged = false; - emit doc->patternChanged(false); + SaveReadOnlyState(); break; case 3: SaveLabelData(); @@ -248,34 +241,10 @@ void DialogPatternProperties::Apply() //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::Ok() { - if (descriptionChanged) - { - SaveDescription(); - descriptionChanged = false; - emit doc->patternChanged(false); - } - - if (gradationChanged) - { - SaveGradation(); - gradationChanged = false; - emit doc->patternChanged(false); - } - - if (defaultChanged) - { - SaveDefValues(); - defaultChanged = false; - emit doc->patternChanged(false); - } - - if (securityChanged) - { - doc->SetReadOnly(ui->checkBoxPatternReadOnly->isChecked()); - securityChanged = false; - emit doc->patternChanged(false); - } - + SaveDescription(); + SaveGradation(); + SaveDefValues(); + SaveReadOnlyState(); SaveLabelData(); SaveTemplateData(); @@ -565,33 +534,48 @@ void DialogPatternProperties::CheckApplyOk() //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::SaveDescription() { - doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText()); - doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText()); - doc->SetAuthor(ui->lineEditAuthor->text()); + if (descriptionChanged) + { + doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText()); + doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText()); + doc->SetAuthor(ui->lineEditAuthor->text()); + + descriptionChanged = false; + emit doc->patternChanged(false); + } } //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::SaveGradation() { - doc->SetGradationHeights(heights); - doc->SetGradationSizes(sizes); - emit UpdateGradation(); + if (gradationChanged) + { + doc->SetGradationHeights(heights); + doc->SetGradationSizes(sizes); + emit UpdateGradation(); + gradationChanged = false; + emit doc->patternChanged(false); + } } //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::SaveDefValues() { - if (ui->radioButtonDefFromM->isChecked()) + if (defaultChanged) { - doc->SetDefCustom(false); + if (ui->radioButtonDefFromM->isChecked()) + { + doc->SetDefCustom(false); + } + else + { + doc->SetDefCustom(true); + doc->SetDefCustomHeight(ui->comboBoxHeight->currentText().toInt()); + doc->SetDefCustomSize(ui->comboBoxSize->currentText().toInt()); + } + defaultChanged = false; + emit doc->patternChanged(false); } - else - { - doc->SetDefCustom(true); - doc->SetDefCustomHeight(ui->comboBoxHeight->currentText().toInt()); - doc->SetDefCustomSize(ui->comboBoxSize->currentText().toInt()); - } - defaultChanged = false; } //--------------------------------------------------------------------------------------------------------------------- @@ -624,6 +608,17 @@ void DialogPatternProperties::SaveTemplateData() } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::SaveReadOnlyState() +{ + if (securityChanged) + { + doc->SetReadOnly(ui->checkBoxPatternReadOnly->isChecked()); + securityChanged = false; + emit doc->patternChanged(false); + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::SetDefaultHeight(const QString &def) { diff --git a/src/app/valentina/dialogs/dialogpatternproperties.h b/src/app/valentina/dialogs/dialogpatternproperties.h index 7c0ee719b..052dd1dd7 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.h +++ b/src/app/valentina/dialogs/dialogpatternproperties.h @@ -104,6 +104,7 @@ private: void SaveDefValues(); void SaveLabelData(); void SaveTemplateData(); + void SaveReadOnlyState(); void SetDefaultHeight(const QString &def); void SetDefaultSize(const QString &def); From b9bd1b60e47e55f68791a4c58f957175a182aed3 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 14 Aug 2017 20:00:19 +0300 Subject: [PATCH 21/54] Method SetTemplate. --HG-- branch : feature --- src/libs/vtools/dialogs/support/dialogeditlabel.cpp | 4 ++-- src/libs/vtools/dialogs/support/dialogeditlabel.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index 59a80d36a..af36f047e 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -361,7 +361,7 @@ void DialogEditLabel::ImportTemplate() { VLabelTemplate ltemplate; ltemplate.setXMLContent(VLabelTemplateConverter(fileName).Convert()); - InitEditLines(ltemplate.ReadLines()); + SetTemplate(ltemplate.ReadLines()); } catch (VException &e) { @@ -516,7 +516,7 @@ QVector DialogEditLabel::GetTemplate() const } //--------------------------------------------------------------------------------------------------------------------- -void DialogEditLabel::InitEditLines(const QVector &lines) +void DialogEditLabel::SetTemplate(const QVector &lines) { ui->listWidgetEdit->blockSignals(true); ui->listWidgetEdit->clear(); diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h index 3450af694..ad785ddfa 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.h +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -50,6 +50,7 @@ public: virtual ~DialogEditLabel(); QVector GetTemplate() const; + void SetTemplate(const QVector &lines); private slots: void ShowLineDetails(); @@ -78,8 +79,6 @@ private: QString ReplacePlaceholders(QString line) const; - - void InitEditLines(const QVector &lines); void InitPreviewLines(const QVector &lines); }; From 8466e84eefdb3dde45d9af5244f1833c38c6ff7c Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 15 Aug 2017 10:44:00 +0300 Subject: [PATCH 22/54] Read/Write pattern label. --HG-- branch : feature --- .../dialogs/dialogpatternproperties.cpp | 13 ++--- src/libs/ifc/ifcdef.h | 13 +++++ src/libs/ifc/xml/vabstractpattern.cpp | 32 +++++++++-- src/libs/ifc/xml/vabstractpattern.h | 4 ++ src/libs/ifc/xml/vdomdocument.cpp | 53 ++++++++++++++++++- src/libs/ifc/xml/vdomdocument.h | 9 ++++ src/libs/vformat/vlabeltemplate.cpp | 48 ++--------------- src/libs/vformat/vlabeltemplate.h | 19 ------- 8 files changed, 113 insertions(+), 78 deletions(-) diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 3a444c1b3..3b428f707 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -602,9 +602,9 @@ void DialogPatternProperties::SaveTemplateData() { if (templateDataChanged) { - //doc->SetTemplate(templateLines); + doc->SetPatternLabelTemplate(templateLines); templateDataChanged = false; - //emit doc->patternChanged(false); + emit doc->patternChanged(false); } } @@ -884,14 +884,7 @@ void DialogPatternProperties::EditLabel() DialogEditLabel editor(doc); -// if (templateDataChanged) -// { -// editor.SetTemplate(templateLines); -// } -// else -// { -// editor.SetTemplate(doc->GetTemplate()); -// } + templateDataChanged ? editor.SetTemplate(templateLines) : editor.SetTemplate(doc->GetPatternLabelTemplate()); if (QDialog::Accepted == editor.exec()) { diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index 9b0b8e565..21899c820 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -213,4 +213,17 @@ extern const QString currentSeamAllowance; extern const QStringList builInVariables; +QT_WARNING_PUSH +QT_WARNING_DISABLE_GCC("-Weffc++") + +struct VLabelTemplateLine +{ + QString line; + bool bold; + bool italic; + int alignment; +}; + +QT_WARNING_POP + #endif // IFCDEF_H diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index c1092679a..4ef4e0585 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -87,6 +87,7 @@ const QString VAbstractPattern::TagPatternName = QStringLiteral("patternNam const QString VAbstractPattern::TagPatternNum = QStringLiteral("patternNumber"); const QString VAbstractPattern::TagCustomerName = QStringLiteral("customer"); const QString VAbstractPattern::TagCompanyName = QStringLiteral("company"); +const QString VAbstractPattern::TagPatternLabel = QStringLiteral("patternLabel"); const QString VAbstractPattern::TagSize = QStringLiteral("size"); const QString VAbstractPattern::TagShowDate = QStringLiteral("showDate"); const QString VAbstractPattern::TagShowMeasurements = QStringLiteral("showMeasurements"); @@ -1374,6 +1375,25 @@ void VAbstractPattern::SetMesurementsVisible(bool bVisible) emit patternChanged(false); } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPattern::SetPatternLabelTemplate(const QVector &lines) +{ + QDomElement tag = CheckTagExists(TagPatternLabel); + RemoveAllChildren(tag); + SetLabelTemplate(tag, lines); +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VAbstractPattern::GetPatternLabelTemplate() const +{ + const QDomNodeList list = elementsByTagName(TagPatternLabel); + if (list.isEmpty()) + { + return QVector(); + } + return GetLabelTemplate(list.at(0).toElement()); +} + //--------------------------------------------------------------------------------------------------------------------- QString VAbstractPattern::GetImage() const { @@ -1516,7 +1536,8 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag) { const QStringList tags = QStringList() << TagUnit << TagImage << TagAuthor << TagDescription << TagNotes << TagGradation << TagPatternName << TagPatternNum << TagCompanyName - << TagCustomerName << TagSize << TagShowDate << TagShowMeasurements; + << TagCustomerName << TagPatternLabel << TagSize << TagShowDate + << TagShowMeasurements; switch (tags.indexOf(tag)) { case 1: //TagImage @@ -1556,13 +1577,16 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag) case 9: // TagCustomerName element = createElement(TagCustomerName); break; - case 10: // TagSize + case 10: // TagPatternLabel + element = createElement(TagPatternLabel); + break; + case 11: // TagSize element = createElement(TagSize); break; - case 11: // TagShowDate + case 12: // TagShowDate element = createElement(TagShowDate); break; - case 12: // TagShowMeasurements + case 13: // TagShowMeasurements element = createElement(TagShowMeasurements); break; case 0: //TagUnit (Mandatory tag) diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index b7b285052..bc81b2ea8 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -154,6 +154,9 @@ public: bool IsMeasurementsVisible() const; void SetMesurementsVisible(bool bVisible); + void SetPatternLabelTemplate(const QVector &lines); + QVector GetPatternLabelTemplate() const; + QString GetImage() const; QString GetImageExtension() const; void SetImage(const QString &text, const QString &extension); @@ -209,6 +212,7 @@ public: static const QString TagPatternNum; static const QString TagCompanyName; static const QString TagCustomerName; + static const QString TagPatternLabel; static const QString TagSize; static const QString TagShowDate; static const QString TagShowMeasurements; diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 7199346df..c2a5e1587 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -178,9 +178,15 @@ void MessageHandler::handleMessage(QtMsgType type, const QString &description, c Q_LOGGING_CATEGORY(vXML, "v.xml") -const QString VDomDocument::AttrId = QStringLiteral("id"); +const QString VDomDocument::AttrId = QStringLiteral("id"); +const QString VDomDocument::AttrText = QStringLiteral("text"); +const QString VDomDocument::AttrBold = QStringLiteral("bold"); +const QString VDomDocument::AttrItalic = QStringLiteral("italic"); +const QString VDomDocument::AttrAlignment = QStringLiteral("alignment"); + const QString VDomDocument::TagVersion = QStringLiteral("version"); const QString VDomDocument::TagUnit = QStringLiteral("unit"); +const QString VDomDocument::TagLine = QStringLiteral("line"); //--------------------------------------------------------------------------------------------------------------------- VDomDocument::VDomDocument() @@ -899,3 +905,48 @@ bool VDomDocument::SafeCopy(const QString &source, const QString &destination, Q return result; } + +//--------------------------------------------------------------------------------------------------------------------- +QVector VDomDocument::GetLabelTemplate(const QDomElement &element) const +{ + QVector lines; + + if (not element.isNull()) + { + QDomElement tagLine = element.firstChildElement(); + while (tagLine.isNull() == false) + { + if (tagLine.tagName() == TagLine) + { + VLabelTemplateLine line; + line.line = GetParametrString(tagLine, AttrText, tr("")); + line.bold = GetParametrBool(tagLine, AttrBold, falseStr); + line.italic = GetParametrBool(tagLine, AttrItalic, falseStr); + line.alignment = GetParametrUInt(tagLine, AttrAlignment, "0"); + lines.append(line); + } + tagLine = tagLine.nextSiblingElement(TagLine); + } + } + + return lines; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDomDocument::SetLabelTemplate(QDomElement &element, const QVector &lines) +{ + if (not element.isNull()) + { + for (int i=0; i < lines.size(); ++i) + { + QDomElement tagLine = createElement(TagLine); + + SetAttribute(tagLine, AttrText, lines.at(i).line); + SetAttribute(tagLine, AttrBold, lines.at(i).bold); + SetAttribute(tagLine, AttrItalic, lines.at(i).italic); + SetAttribute(tagLine, AttrAlignment, lines.at(i).alignment); + + element.appendChild(tagLine); + } + } +} diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h index b2e0dafc5..58906bf13 100644 --- a/src/libs/ifc/xml/vdomdocument.h +++ b/src/libs/ifc/xml/vdomdocument.h @@ -83,8 +83,14 @@ class VDomDocument : public QDomDocument Q_DECLARE_TR_FUNCTIONS(VDomDocument) public: static const QString AttrId; + static const QString AttrText; + static const QString AttrBold; + static const QString AttrItalic; + static const QString AttrAlignment; + static const QString TagVersion; static const QString TagUnit; + static const QString TagLine; VDomDocument(); virtual ~VDomDocument() Q_DECL_EQ_DEFAULT; @@ -130,6 +136,9 @@ protected: void TestUniqueId() const; void CollectId(const QDomElement &node, QVector &vector)const; + QVector GetLabelTemplate(const QDomElement &element) const; + void SetLabelTemplate(QDomElement &element, const QVector &lines); + private: Q_DISABLE_COPY(VDomDocument) /** @brief Map used for finding element by id. */ diff --git a/src/libs/vformat/vlabeltemplate.cpp b/src/libs/vformat/vlabeltemplate.cpp index 942c88405..78f6ba385 100644 --- a/src/libs/vformat/vlabeltemplate.cpp +++ b/src/libs/vformat/vlabeltemplate.cpp @@ -31,12 +31,6 @@ const QString VLabelTemplate::TagTemplate = QStringLiteral("template"); const QString VLabelTemplate::TagLines = QStringLiteral("lines"); -const QString VLabelTemplate::TagLine = QStringLiteral("line"); - -const QString VLabelTemplate::AttrText = QStringLiteral("text"); -const QString VLabelTemplate::AttrBold = QStringLiteral("bold"); -const QString VLabelTemplate::AttrItalic = QStringLiteral("italic"); -const QString VLabelTemplate::AttrAlignment = QStringLiteral("alignment"); //--------------------------------------------------------------------------------------------------------------------- VLabelTemplate::VLabelTemplate() @@ -69,52 +63,18 @@ void VLabelTemplate::AddLines(const QVector &lines) return; } - QDomElement tagLines = listLines.at(0).toElement(); - if (not tagLines.isNull()) - { - for (int i=0; i < lines.size(); ++i) - { - QDomElement tagLine = createElement(TagLine); - - SetAttribute(tagLine, AttrText, lines.at(i).line); - SetAttribute(tagLine, AttrBold, lines.at(i).bold); - SetAttribute(tagLine, AttrItalic, lines.at(i).italic); - SetAttribute(tagLine, AttrAlignment, lines.at(i).alignment); - - tagLines.appendChild(tagLine); - } - } + QDomElement tag = listLines.at(0).toElement(); + VDomDocument::SetLabelTemplate(tag, lines); } //--------------------------------------------------------------------------------------------------------------------- QVector VLabelTemplate::ReadLines() const { - QVector lines; - const QDomNodeList listLines = elementsByTagName(TagLines); if (listLines.size() == 0) { - return lines; + return QVector(); } - QDomElement tagLines = listLines.at(0).toElement(); - if (not tagLines.isNull()) - { - QDomElement tagLine = tagLines.firstChildElement(); - while (tagLine.isNull() == false) - { - if (tagLine.tagName() == TagLine) - { - VLabelTemplateLine line; - line.line = GetParametrString(tagLine, AttrText, tr("")); - line.bold = GetParametrBool(tagLine, AttrBold, falseStr); - line.italic = GetParametrBool(tagLine, AttrItalic, falseStr); - line.alignment = GetParametrUInt(tagLine, AttrAlignment, "0"); - lines.append(line); - } - tagLine = tagLine.nextSiblingElement(TagLine); - } - } - - return lines; + return VDomDocument::GetLabelTemplate(listLines.at(0).toElement()); } diff --git a/src/libs/vformat/vlabeltemplate.h b/src/libs/vformat/vlabeltemplate.h index c79960390..dd091479e 100644 --- a/src/libs/vformat/vlabeltemplate.h +++ b/src/libs/vformat/vlabeltemplate.h @@ -31,19 +31,6 @@ #include "../ifc/xml/vdomdocument.h" -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Weffc++") - -struct VLabelTemplateLine -{ - QString line; - bool bold; - bool italic; - int alignment; -}; - -QT_WARNING_POP - class VLabelTemplate : public VDomDocument { public: @@ -52,12 +39,6 @@ public: static const QString TagTemplate; static const QString TagLines; - static const QString TagLine; - - static const QString AttrText; - static const QString AttrBold; - static const QString AttrItalic; - static const QString AttrAlignment; void CreateEmptyTemplate(); From cd06b70c6f28a10ada80f4417a0f4f1407bfb028 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 15 Aug 2017 11:17:54 +0300 Subject: [PATCH 23/54] New pattern format version 0.6.0. --HG-- branch : feature --- src/libs/ifc/schema.qrc | 1 + src/libs/ifc/schema/pattern/v0.6.0.xsd | 952 +++++++++++++++++++++++++ src/libs/ifc/xml/vpatternconverter.cpp | 22 +- src/libs/ifc/xml/vpatternconverter.h | 3 +- 4 files changed, 974 insertions(+), 4 deletions(-) create mode 100644 src/libs/ifc/schema/pattern/v0.6.0.xsd diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 3644ffb8b..78bfb02d4 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -34,6 +34,7 @@ schema/pattern/v0.4.8.xsd schema/pattern/v0.5.0.xsd schema/pattern/v0.5.1.xsd + schema/pattern/v0.6.0.xsd schema/standard_measurements/v0.3.0.xsd schema/standard_measurements/v0.4.0.xsd schema/standard_measurements/v0.4.1.xsd diff --git a/src/libs/ifc/schema/pattern/v0.6.0.xsd b/src/libs/ifc/schema/pattern/v0.6.0.xsd new file mode 100644 index 000000000..71bb2b232 --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.6.0.xsd @@ -0,0 +1,952 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 25bbe6e8c..8c8500f4c 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -58,8 +58,8 @@ class QDomElement; */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.5.1"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.5.1.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.6.0"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.6.0.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -215,6 +215,8 @@ QString VPatternConverter::XSDSchema(int ver) const case (0x000500): return QStringLiteral("://schema/pattern/v0.5.0.xsd"); case (0x000501): + return QStringLiteral("://schema/pattern/v0.5.1.xsd"); + case (0x000600): return CurrentSchema; default: InvalidVersion(ver); @@ -361,6 +363,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(0x000501), m_convertedFileName); V_FALLTHROUGH case (0x000501): + ToV0_6_0(); + ValidateXML(XSDSchema(0x000600), m_convertedFileName); + V_FALLTHROUGH + case (0x000600): break; default: InvalidVersion(m_ver); @@ -379,7 +385,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion() bool VPatternConverter::IsReadOnly() const { // Check if attribute readOnly was not changed in file format - Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 5, 1), + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 6, 0), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. @@ -768,6 +774,16 @@ void VPatternConverter::ToV0_5_1() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_6_0() +{ + // TODO. Delete if minimal supported version is 0.6.0 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 6, 0), + "Time to refactor the code."); + SetVersion(QStringLiteral("0.6.0")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 449f75c18..a8d0559e3 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -53,7 +53,7 @@ public: static const QString PatternMaxVerStr; static const QString CurrentSchema; static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 5, 1); + static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 6, 0); protected: virtual int MinVer() const Q_DECL_OVERRIDE; @@ -105,6 +105,7 @@ private: void ToV0_4_8(); void ToV0_5_0(); void ToV0_5_1(); + void ToV0_6_0(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); From 882cf360e2ebc2ac3d9e62750db9ffce85d64681 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 15 Aug 2017 11:23:48 +0300 Subject: [PATCH 24/54] We use implicit conversion. That's why check if values are still the same as excpected. --HG-- branch : feature --- src/libs/ifc/xml/vdomdocument.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index c2a5e1587..27970f670 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -909,6 +909,11 @@ bool VDomDocument::SafeCopy(const QString &source, const QString &destination, Q //--------------------------------------------------------------------------------------------------------------------- QVector VDomDocument::GetLabelTemplate(const QDomElement &element) const { + // We use implicit conversion. That's why check if values are still the same as excpected. + Q_STATIC_ASSERT(Qt::AlignLeft == 1); + Q_STATIC_ASSERT(Qt::AlignRight == 2); + Q_STATIC_ASSERT(Qt::AlignHCenter == 4); + QVector lines; if (not element.isNull()) From 3b60eaff08f7ed14398160592ef0c174ecf1df5a Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 15 Aug 2017 11:38:36 +0300 Subject: [PATCH 25/54] List to speed up reading a template by many pieces. --HG-- branch : feature --- src/libs/ifc/xml/vabstractpattern.cpp | 16 ++++++++++++---- src/libs/ifc/xml/vabstractpattern.h | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 4ef4e0585..a987db4eb 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -194,6 +194,7 @@ const QString VAbstractPattern::NodeSpline = QStringLiteral("NodeSpline"); const QString VAbstractPattern::NodeSplinePath = QStringLiteral("NodeSplinePath"); QHash VAbstractPattern::tools = QHash(); +QVector VAbstractPattern::patternLabelLines = QVector(); namespace { @@ -1381,17 +1382,24 @@ void VAbstractPattern::SetPatternLabelTemplate(const QVector QDomElement tag = CheckTagExists(TagPatternLabel); RemoveAllChildren(tag); SetLabelTemplate(tag, lines); + patternLabelLines = lines; } //--------------------------------------------------------------------------------------------------------------------- QVector VAbstractPattern::GetPatternLabelTemplate() const { - const QDomNodeList list = elementsByTagName(TagPatternLabel); - if (list.isEmpty()) + if (patternLabelLines.isEmpty()) { - return QVector(); + const QDomNodeList list = elementsByTagName(TagPatternLabel); + if (list.isEmpty()) + { + return QVector(); + } + + patternLabelLines = GetLabelTemplate(list.at(0).toElement()); } - return GetLabelTemplate(list.at(0).toElement()); + + return patternLabelLines; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index bc81b2ea8..33a4e9647 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -387,6 +387,8 @@ protected: /** @brief tools list with pointer on tools. */ static QHash tools; + /** @brief patternLabelLines list to speed up reading a template by many pieces. */ + static QVector patternLabelLines; static void ToolExists(const quint32 &id); static VPiecePath ParsePathNodes(const QDomElement &domElement); From b80bd85dec8932ecba27f0d7eb5eecec4d876f9d Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 15 Aug 2017 15:21:31 +0300 Subject: [PATCH 26/54] Just replace() method is enough. It replaces all occurrences. --HG-- branch : feature --- src/libs/vpatterndb/vtranslatevars.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index b3af9481a..4952e0f21 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -695,10 +695,7 @@ QString VTranslateVars::PlaceholderToUserText(QString text) const if (translated != original) { - while (text.indexOf(original) != -1) - { - text.replace(original, translated); - } + text.replace(original, translated); } ++i; } @@ -717,10 +714,7 @@ QString VTranslateVars::PlaceholderFromUserText(QString text) const if (translated != original) { - while (text.indexOf(translated) != -1) - { - text.replace(translated, original); - } + text.replace(translated, original); } ++i; } From b212d04d1175a5401320876267d915592ca6cfb2 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 15 Aug 2017 15:22:33 +0300 Subject: [PATCH 27/54] Parse template and prepare pattern label. --HG-- branch : feature --- src/libs/ifc/xml/vabstractpattern.cpp | 14 ++ src/libs/ifc/xml/vabstractpattern.h | 4 + src/libs/vlayout/vlayoutpiece.cpp | 11 +- src/libs/vlayout/vlayoutpiece.h | 2 +- src/libs/vlayout/vtextmanager.cpp | 232 +++++++++---------- src/libs/vlayout/vtextmanager.h | 12 +- src/libs/vtools/tools/vtoolseamallowance.cpp | 2 +- src/libs/vwidgets/vtextgraphicsitem.cpp | 27 +-- src/libs/vwidgets/vtextgraphicsitem.h | 4 +- 9 files changed, 149 insertions(+), 159 deletions(-) diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index a987db4eb..d2d9480cf 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -195,6 +195,7 @@ const QString VAbstractPattern::NodeSplinePath = QStringLiteral("NodeSplinePath" QHash VAbstractPattern::tools = QHash(); QVector VAbstractPattern::patternLabelLines = QVector(); +bool VAbstractPattern::patternLabelWasChanged = false; namespace { @@ -1383,6 +1384,7 @@ void VAbstractPattern::SetPatternLabelTemplate(const QVector RemoveAllChildren(tag); SetLabelTemplate(tag, lines); patternLabelLines = lines; + patternLabelWasChanged = true; } //--------------------------------------------------------------------------------------------------------------------- @@ -1402,6 +1404,18 @@ QVector VAbstractPattern::GetPatternLabelTemplate() const return patternLabelLines; } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPattern::SetPatternWasChanged(bool changed) +{ + patternLabelWasChanged = changed; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VAbstractPattern::GetPatternWasChanged() const +{ + return patternLabelWasChanged; +} + //--------------------------------------------------------------------------------------------------------------------- QString VAbstractPattern::GetImage() const { diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 33a4e9647..65cbf2da9 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -157,6 +157,9 @@ public: void SetPatternLabelTemplate(const QVector &lines); QVector GetPatternLabelTemplate() const; + void SetPatternWasChanged(bool changed); + bool GetPatternWasChanged() const; + QString GetImage() const; QString GetImageExtension() const; void SetImage(const QString &text, const QString &extension); @@ -389,6 +392,7 @@ protected: static QHash tools; /** @brief patternLabelLines list to speed up reading a template by many pieces. */ static QVector patternLabelLines; + static bool patternLabelWasChanged; static void ToolExists(const quint32 &id); static VPiecePath ParsePathNodes(const QDomElement &domElement); diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 65b6c713f..2655f9068 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -400,8 +400,7 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern if (geom.IsVisible() == true) { VAbstractPattern* pDoc = qApp->getCurrentDocument(); - det.SetPatternInfo(pDoc, geom, qApp->Settings()->GetLabelFont(), VContainer::size(), VContainer::height(), - pattern); + det.SetPatternInfo(pDoc, geom, qApp->Settings()->GetLabelFont(), pattern); } const VGrainlineData& grainlineGeom = piece.GetGrainlineGeometry(); @@ -545,7 +544,7 @@ QStringList VLayoutPiece::GetPatternText() const //--------------------------------------------------------------------------------------------------------------------- void VLayoutPiece::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternLabelData& geom, const QFont &font, - qreal dSize, qreal dHeight, const VContainer *pattern) + const VContainer *pattern) { QPointF ptPos; qreal labelWidth = 0; @@ -578,7 +577,7 @@ void VLayoutPiece::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternLa d->m_tmPattern.SetFont(font); d->m_tmPattern.SetFontSize(geom.GetFontSize()); - d->m_tmPattern.Update(pDoc, dSize, dHeight); + d->m_tmPattern.Update(pDoc); // generate lines of text d->m_tmPattern.SetFontSize(geom.GetFontSize()); @@ -1026,8 +1025,8 @@ void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector GetGrainline() const; diff --git a/src/libs/vlayout/vtextmanager.cpp b/src/libs/vlayout/vtextmanager.cpp index a6e219e8b..accd56963 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -38,6 +38,7 @@ #include "../vpatterndb/floatItemData/vpiecelabeldata.h" #include "../vmisc/vabstractapplication.h" #include "../vmisc/vmath.h" +#include "../vpatterndb/vcontainer.h" #include "vtextmanager.h" //--------------------------------------------------------------------------------------------------------------------- @@ -47,11 +48,92 @@ TextLine::TextLine() : m_qsText(), m_iFontSize(MIN_FONT_SIZE), - m_eFontWeight(QFont::Normal), - m_eStyle(QFont::StyleNormal), + bold(false), + italic(false), m_eAlign(Qt::AlignCenter) {} +QList VTextManager::m_patternLabelLines = QList(); + +namespace +{ + +//--------------------------------------------------------------------------------------------------------------------- +QMap PreparePlaceholders(const VAbstractPattern *doc) +{ + SCASSERT(doc != nullptr) + + QMap placeholders; + + QLocale locale(qApp->Settings()->GetLocale()); + placeholders.insert(pl_date, locale.toString(QDate::currentDate())); + placeholders.insert(pl_time, locale.toString(QTime::currentTime())); + placeholders.insert(pl_patternName, doc->GetPatternName()); + placeholders.insert(pl_patternNumber, doc->GetPatternNumber()); + placeholders.insert(pl_author, doc->GetCompanyName()); + placeholders.insert(pl_customer, doc->GetCustomerName()); + placeholders.insert(pl_pExt, QString("val")); + placeholders.insert(pl_pFileName, QFileInfo(qApp->GetPPath()).fileName()); + placeholders.insert(pl_mFileName, QFileInfo(doc->MPath()).fileName()); + + QString curSize; + QString curHeight; + QString mExt; + if (qApp->patternType() == MeasurementsType::Multisize) + { + curSize = QString::number(VContainer::size()); + curHeight = QString::number(VContainer::height()); + mExt = "vst"; + } + else if (qApp->patternType() == MeasurementsType::Individual) + { + mExt = "vit"; + } + + placeholders.insert(pl_size, curSize); + placeholders.insert(pl_height, curHeight); + placeholders.insert(pl_mExt, mExt); + + return placeholders; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString ReplacePlaceholders(const QMap &placeholders, QString line) +{ + QChar per('%'); + auto i = placeholders.constBegin(); + while (i != placeholders.constEnd()) + { + line.replace(per+i.key()+per, i.value()); + ++i; + } + return line; +} + +//--------------------------------------------------------------------------------------------------------------------- +QList PrepareLines(const QVector &lines) +{ + QList textLines; + + for (int i=0; i < lines.size(); ++i) + { + if (not lines.at(i).line.isEmpty()) + { + TextLine tl; + tl.m_qsText = lines.at(i).line; + tl.m_eAlign = static_cast(lines.at(i).alignment); + tl.m_iFontSize = 0; + tl.bold = lines.at(i).bold; + tl.italic = lines.at(i).italic; + + textLines << tl; + } + } + + return textLines; +} +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VTextManager::VTextManager constructor @@ -60,13 +142,6 @@ VTextManager::VTextManager() : m_font(), m_liLines() {} -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief VTextManager::~VTextManager destructor - */ -VTextManager::~VTextManager() -{} - //--------------------------------------------------------------------------------------------------------------------- VTextManager::VTextManager(const VTextManager &text) : m_font(text.GetFont()), m_liLines(text.GetAllSourceLines()) @@ -130,25 +205,6 @@ QList VTextManager::GetAllSourceLines() const return m_liLines; } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddSourceLine add new text line to the list - * @param tl text line object to be added - */ -void VTextManager::AddSourceLine(const TextLine& tl) -{ - m_liLines << tl; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief ClearSourceLines deletes the list of texts - */ -void VTextManager::ClearSourceLines() -{ - m_liLines.clear(); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief VTextManager::GetSourceLinesCount returns the number of input text lines @@ -202,8 +258,8 @@ void VTextManager::FitFontSize(qreal fW, qreal fH) const TextLine& tl = GetSourceLine(i); fnt = m_font; fnt.setPixelSize(iFS + tl.m_iFontSize); - fnt.setWeight(tl.m_eFontWeight); - fnt.setStyle(tl.m_eStyle); + fnt.setBold(tl.bold); + fnt.setItalic(tl.italic); QFontMetrics fm(fnt); const int iTW = fm.width(tl.m_qsText); if (iTW > iMaxLen) @@ -215,8 +271,8 @@ void VTextManager::FitFontSize(qreal fW, qreal fH) if (iMaxLen > fW) { QFont fnt = m_font; - fnt.setWeight(maxLine.m_eFontWeight); - fnt.setStyle(maxLine.m_eStyle); + fnt.setBold(maxLine.bold); + fnt.setItalic(maxLine.italic); int lineLength = 0; do @@ -240,27 +296,27 @@ void VTextManager::FitFontSize(qreal fW, qreal fH) */ void VTextManager::Update(const QString& qsName, const VPieceLabelData& data) { - ClearSourceLines(); + m_liLines.clear(); + TextLine tl; // all text must be centered and normal style! tl.m_eAlign = Qt::AlignCenter; - tl.m_eStyle = QFont::StyleNormal; // letter tl.m_qsText = data.GetLetter(); if (tl.m_qsText.isEmpty() == false) { - tl.m_eFontWeight = QFont::Bold; + tl.bold = true; tl.m_iFontSize = 6; - AddSourceLine(tl); + m_liLines << tl; } // name tl.m_qsText = qsName; if (tl.m_qsText.isEmpty() == false) { - tl.m_eFontWeight = QFont::DemiBold; + tl.bold = true; tl.m_iFontSize = 2; - AddSourceLine(tl); + m_liLines << tl; } // MCP QStringList qslMaterials; @@ -271,7 +327,7 @@ void VTextManager::Update(const QString& qsName, const VPieceLabelData& data) QString qsText = QLatin1String("%1, ") + tr("cut") + QLatin1String(" %2%3"); QStringList qslPlace; qslPlace << "" << QLatin1String(" ") + tr("on fold"); - tl.m_eFontWeight = QFont::Normal; + tl.bold = false; tl.m_iFontSize = 0; for (int i = 0; i < data.GetMCPCount(); ++i) { @@ -289,7 +345,7 @@ void VTextManager::Update(const QString& qsName, const VPieceLabelData& data) } tl.m_qsText = qsText.arg(qsMat).arg(mcp.m_iCutNumber). arg(qslPlace[int(mcp.m_ePlacement)]); - AddSourceLine(tl); + m_liLines << tl; } } } @@ -299,89 +355,27 @@ void VTextManager::Update(const QString& qsName, const VPieceLabelData& data) * @brief VTextManager::Update updates the text lines with pattern info * @param pDoc pointer to the abstract pattern object */ -void VTextManager::Update(const VAbstractPattern *pDoc, qreal dSize, qreal dHeight) +void VTextManager::Update(const VAbstractPattern *pDoc) { - ClearSourceLines(); - TextLine tl; - // all information must be centered - tl.m_eAlign = Qt::AlignCenter; + m_liLines.clear(); - // Company name - tl.m_qsText = pDoc->GetCompanyName(); - if (tl.m_qsText.isEmpty() == false) + if (m_patternLabelLines.isEmpty() || pDoc->GetPatternWasChanged()) { - tl.m_eFontWeight = QFont::DemiBold; - tl.m_eStyle = QFont::StyleNormal; - tl.m_iFontSize = 4; - AddSourceLine(tl); - } - // Pattern name - tl.m_qsText = pDoc->GetPatternName(); - if (tl.m_qsText.isEmpty() == false) - { - tl.m_eFontWeight = QFont::Normal; - tl.m_eStyle = QFont::StyleNormal; - tl.m_iFontSize = 2; - AddSourceLine(tl); - } - // Pattern number - tl.m_qsText = pDoc->GetPatternNumber(); - if (tl.m_qsText.isEmpty() == false) - { - tl.m_eFontWeight = QFont::Normal; - tl.m_eStyle = QFont::StyleNormal; - tl.m_iFontSize = 0; - AddSourceLine(tl); - } - // Customer name - tl.m_qsText = pDoc->GetCustomerName(); - if (tl.m_qsText.isEmpty() == false) - { - tl.m_eFontWeight = QFont::Normal; - tl.m_eStyle = QFont::StyleItalic; - tl.m_iFontSize = 0; - AddSourceLine(tl); - } - // Size - tl.m_qsText = pDoc->GetPatternSize(); - if (tl.m_qsText.isEmpty() == false) - { - // Such describing placeholders will help avoid mistake of localization. - // Translators very often remove '%'. - QString placeholder = QLatin1String("%") + qApp->TrVars()->PlaceholderToUser(pl_size) + QLatin1String("%"); - tl.m_qsText.replace(placeholder, QString::number(dSize)); + QVector lines = pDoc->GetPatternLabelTemplate(); + if (lines.isEmpty() && m_patternLabelLines.isEmpty()) + { + return; // Nothing to parse + } - placeholder = QLatin1String("%") + qApp->TrVars()->PlaceholderToUser(pl_height) + QLatin1String("%"); - tl.m_qsText.replace(placeholder, QString::number(dHeight)); + const QMap placeholders = PreparePlaceholders(pDoc); - tl.m_eFontWeight = QFont::Normal; - tl.m_eStyle = QFont::StyleNormal; - tl.m_iFontSize = 0; - AddSourceLine(tl); - } - // Measurements - tl.m_qsText = QFileInfo(pDoc->MPath()).fileName(); - if (tl.m_qsText.isEmpty() == false && pDoc->IsMeasurementsVisible() == true) - { - tl.m_eFontWeight = QFont::Normal; - tl.m_eStyle = QFont::StyleNormal; - tl.m_iFontSize = 0; - AddSourceLine(tl); - } - // Date - QDate date; - if (pDoc->IsDateVisible() == true) - { - date = QDate::currentDate(); - } - if (date.isValid() == true) - { - QLocale locale(qApp->Settings()->GetLocale()); - tl.m_qsText = locale.toString(date, "dd MMMM yyyy"); - tl.m_eFontWeight = QFont::Normal; - tl.m_eStyle = QFont::StyleNormal; - tl.m_iFontSize = 0; - AddSourceLine(tl); + for (int i=0; i GetAllSourceLines() const; - void AddSourceLine(const TextLine& tl); - void ClearSourceLines(); int GetSourceLinesCount() const; const TextLine& GetSourceLine(int i) const; void Update(const QString& qsName, const VPieceLabelData& data); - void Update(const VAbstractPattern* pDoc, qreal dSize, qreal dHeight); + void Update(const VAbstractPattern* pDoc); private: QFont m_font; QList m_liLines; + + static QList m_patternLabelLines; }; #endif // VTEXTMANAGER_H diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 6ea8ba99e..4f753e06e 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -578,7 +578,7 @@ void VToolSeamAllowance::UpdatePatternInfo() if (PrepareLabelData(geom, m_patternInfo, pos, labelAngle)) { - m_patternInfo->UpdateData(doc, VContainer::size(), VContainer::height()); + m_patternInfo->UpdateData(doc); UpdateLabelItem(m_patternInfo, pos, labelAngle); } } diff --git a/src/libs/vwidgets/vtextgraphicsitem.cpp b/src/libs/vwidgets/vtextgraphicsitem.cpp index cd916d53f..9cc1121a5 100644 --- a/src/libs/vwidgets/vtextgraphicsitem.cpp +++ b/src/libs/vwidgets/vtextgraphicsitem.cpp @@ -164,8 +164,8 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem const TextLine& tl = m_tm.GetSourceLine(i); fnt.setPixelSize(m_tm.GetFont().pixelSize() + tl.m_iFontSize); - fnt.setWeight(tl.m_eFontWeight); - fnt.setStyle(tl.m_eStyle); + fnt.setBold(tl.bold); + fnt.setItalic(tl.italic); QString qsText = tl.m_qsText; QFontMetrics fm(fnt); @@ -235,25 +235,6 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem } } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief VTextGraphicsItem::AddLine adds a line of text to the label list. - * @param tl line of text to add - */ -void VTextGraphicsItem::AddLine(const TextLine& tl) -{ - m_tm.AddSourceLine(tl); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief VTextGraphicsItem::Clear deletes all the label texts - */ -void VTextGraphicsItem::Clear() -{ - m_tm.ClearSourceLines(); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief VTextGraphicsItem::SetSize Tries to set the label size to (fW, fH). If any of those is too small, the label @@ -362,9 +343,9 @@ void VTextGraphicsItem::UpdateData(const QString &qsName, const VPieceLabelData * @brief VTextGraphicsItem::UpdateData Updates the pattern label * @param pDoc pointer to the pattern object */ -void VTextGraphicsItem::UpdateData(const VAbstractPattern* pDoc, qreal dSize, qreal dHeight) +void VTextGraphicsItem::UpdateData(const VAbstractPattern* pDoc) { - m_tm.Update(pDoc, dSize, dHeight); + m_tm.Update(pDoc); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vwidgets/vtextgraphicsitem.h b/src/libs/vwidgets/vtextgraphicsitem.h index f59ce5388..be29a12f1 100644 --- a/src/libs/vwidgets/vtextgraphicsitem.h +++ b/src/libs/vwidgets/vtextgraphicsitem.h @@ -63,12 +63,10 @@ public: void SetFont(const QFont& fnt); int GetFontSize() const; - void AddLine(const TextLine& tl); - void Clear(); void SetSize(qreal fW, qreal fH); bool IsContained(QRectF rectBB, qreal dRot, qreal& dX, qreal& dY) const; void UpdateData(const QString& qsName, const VPieceLabelData& data); - void UpdateData(const VAbstractPattern* pDoc, qreal dSize, qreal dHeight); + void UpdateData(const VAbstractPattern* pDoc); int GetTextLines() const; protected: From 2137cd816d52a6ec84b85d277b3b2f38fb6d00a2 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 15 Aug 2017 16:01:07 +0300 Subject: [PATCH 28/54] Added menu option to call the Template editor independently. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 7 +++++++ src/app/valentina/mainwindow.ui | 27 +++++++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index dd9c16689..9bb2e5575 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -63,6 +63,7 @@ #include "dialogs/vwidgetdetails.h" #include "../vpatterndb/vpiecepath.h" #include "../qmuparser/qmuparsererror.h" +#include "../vtools/dialogs/support/dialogeditlabel.h" #include #include @@ -4051,6 +4052,12 @@ void MainWindow::CreateActions() connect(ui->actionSyncMeasurements, &QAction::triggered, this, &MainWindow::SyncMeasurements); connect(ui->actionUnloadMeasurements, &QAction::triggered, this, &MainWindow::UnloadMeasurements); + + connect(ui->actionLabelTemplateEditor, &QAction::triggered, this, [this]() + { + DialogEditLabel editor(doc); + editor.exec(); + }); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index 10c90405b..38422502b 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -55,8 +55,8 @@ 0 0 - 126 - 351 + 127 + 358 @@ -402,7 +402,7 @@ 0 0 140 - 108 + 110 @@ -511,7 +511,7 @@ 0 0 140 - 243 + 248 @@ -773,7 +773,7 @@ 0 0 140 - 243 + 248 @@ -1038,7 +1038,7 @@ 0 0 140 - 102 + 104 @@ -1121,7 +1121,7 @@ 0 0 140 - 326 + 328 @@ -1325,7 +1325,7 @@ 0 0 140 - 192 + 196 @@ -1535,7 +1535,7 @@ 0 0 140 - 326 + 328 @@ -1635,7 +1635,7 @@ 0 0 1100 - 19 + 25 @@ -1664,6 +1664,8 @@ + + @@ -2668,6 +2670,11 @@ QAction::NoRole + + + Label template editor + + From 0c0719114c94301d5c81fe6b6aac0c06c2283ac0 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 15 Aug 2017 16:01:32 +0300 Subject: [PATCH 29/54] Fix default pattern label template. --HG-- branch : feature --- src/app/share/labels/def_pattern_label.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/share/labels/def_pattern_label.xml b/src/app/share/labels/def_pattern_label.xml index 5991c970c..09460b9b7 100644 --- a/src/app/share/labels/def_pattern_label.xml +++ b/src/app/share/labels/def_pattern_label.xml @@ -2,7 +2,7 @@