first commit
|
@ -0,0 +1,18 @@
|
|||
2021-12-01 17:57:39
|
||||
* 添加应用字体接口
|
||||
|
||||
2021-12-01 15:23:08
|
||||
* LibFun::copy 接口第二个参数改为目录 , 函数内部拼接目的文件名
|
||||
|
||||
2021-11-29 17:10:08
|
||||
* 移除 uuid 主键 , 使用 path 作为主键
|
||||
|
||||
2021-11-17 16:00:01
|
||||
* lib_fun.cc 更改头文件引入 #include <ft2build.h> ---> #include <freetype2/ft2build.h>
|
||||
|
||||
2021-11-17 09:51:32
|
||||
* Core 修改成单例模式
|
||||
* 添加取消收藏接口
|
||||
|
||||
2021-11-16 15:36:25
|
||||
* 字体管理器后端开发完成
|
After Width: | Height: | Size: 82 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 302 B |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 122 KiB |
|
@ -0,0 +1,37 @@
|
|||
# Font Viewer
|
||||
|
||||
## Summary
|
||||
|
||||
The font manager is a tool for viewing font styles. While viewing font styles, you can apply fonts, uninstall fonts, export fonts, collect fonts, and change preview content and preview font size.
|
||||
|
||||
"All fonts" includes "system fonts" and "my fonts"; "System font" is the font in the system; "My font" is the font installed by the user; "Favorite font" is the font that users collect.
|
||||
|
||||
![Figure 1 Font manager main interface-big](image/1.png)
|
||||
<br>
|
||||
|
||||
### Preview Area
|
||||
|
||||
In the preview area, you can modify the preview content and preview font size.
|
||||
|
||||
![Figure 2 Preview Area-big](image/2.png)
|
||||
|
||||
### Add font
|
||||
|
||||
Click "! [] (image/3. PNG)" icon to add a font.
|
||||
The added fonts will be displayed in "My font" and "All fonts".
|
||||
|
||||
![Figure 3 My font-big](image/4.png)
|
||||
|
||||
### Right click menu
|
||||
|
||||
Right click the font list of "my font" to pop up a menu. You can add fonts, apply fonts, uninstall fonts, export fonts, collect fonts and view font information. Right click system font to add font, apply font, collect font and view font information.
|
||||
|
||||
![Figure 4 "My font" right click function-big](image/5.png)
|
||||
|
||||
![Figure 5 "System font" right click function-big](image/6.png)
|
||||
|
||||
### Help and about
|
||||
|
||||
Click Help in the menu bar to open the help manual of the font viewer.
|
||||
|
||||
Click "about" to view the information about the font viewer.
|
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 98 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 302 B |
After Width: | Height: | Size: 78 KiB |
After Width: | Height: | Size: 103 KiB |
After Width: | Height: | Size: 80 KiB |
|
@ -0,0 +1,40 @@
|
|||
# 字体管理器
|
||||
|
||||
## 概 述
|
||||
|
||||
字体管理器是一个用于查看字体样式的工具。在查看字体样式的同时,可以应用字体、卸载字体、导出字体、收藏字体,还可以改变预览内容和预览字号。
|
||||
|
||||
“所有字体”包含“系统字体”和“我的字体”;“系统字体”是系统中自带的字体;“我的字体”是用户自己进行安装的字体;“收藏字体”是用户进行收藏的字体。
|
||||
|
||||
主界面如图1所示。
|
||||
|
||||
![图 1 字体管理器主界面-big](image/1.png)
|
||||
<br>
|
||||
|
||||
### 预览区域
|
||||
|
||||
在预览区域可以修改预览内容和预览字体的大小。
|
||||
|
||||
![图 2 预览区域-big](image/2.png)
|
||||
|
||||
### 添加字体
|
||||
|
||||
点击“![](image/3.png)”图标可以添加字体。
|
||||
|
||||
添加后的字体会在“我的字体”和“所有字体”中显示出来。
|
||||
|
||||
![图 3 我的字体-big](image/4.png)
|
||||
|
||||
### 右键菜单
|
||||
|
||||
右击“我的字体”的字体列表会弹出菜单可以对字体进行添加字体、应用字体、卸载字体、导出字体、收藏字体、查看字体信息的操作。对于“系统字体”右键只可以进行添加字体、应用字体、收藏字体、查看字体信息的操作。
|
||||
|
||||
![图 5 “我的字体”右键功能-big](image/5.png)
|
||||
|
||||
![图 6 “系统字体”右键功能-big](image/6.png)
|
||||
|
||||
### 帮助和关于
|
||||
|
||||
在菜单栏中点击帮助可打开字体管理器的帮助手册。
|
||||
|
||||
点击“关于”,可查看字体管理器的关于信息。
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="15px" height="16px" viewBox="0 0 15 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>avatar-default-symbolic-w</title>
|
||||
<g id="浅色模式3.1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="字体-右键" transform="translate(-1502.000000, -901.000000)">
|
||||
<g id="avatar-default-symbolic-w" transform="translate(1502.000000, 901.000000)">
|
||||
<g id="编组" transform="translate(0.000000, 0.500000)">
|
||||
<g transform="translate(0.000000, 8.500000)" fill="#FFFFFF" fill-rule="nonzero" id="形状">
|
||||
<path d="M10.5,1 C11.9,1 13,2.1 13,3.5 L13,4.7 C13,5.4 12.4,6 11.7,6 L2.3,6 C1.6,6 1,5.4 1,4.7 L1,3.5 C1,2.1 2.1,1 3.5,1 L10.5,1 M10.5,0 L3.5,0 C1.6,0 0,1.6 0,3.5 L0,4.7 C0,6 1,7 2.3,7 L11.7,7 C13,7 14,6 14,4.7 L14,3.5 C14,1.6 12.4,0 10.5,0 L10.5,0 Z"></path>
|
||||
</g>
|
||||
<circle id="椭圆形" stroke="#FFFFFF" cx="7" cy="3.5" r="3.5"></circle>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="128px" height="128px" viewBox="0 0 128 128" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>编组 12</title>
|
||||
<defs>
|
||||
<rect id="path-1" x="0" y="0" width="100" height="100" rx="32"></rect>
|
||||
<rect id="path-3" x="0" y="0" width="100" height="100" rx="32"></rect>
|
||||
<linearGradient x1="2.77555756e-13%" y1="50%" x2="100%" y2="50%" id="linearGradient-5">
|
||||
<stop stop-color="#484E55" offset="0%"></stop>
|
||||
<stop stop-color="#575E67" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="浅色模式3.1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="字体-空白页" transform="translate(-1450.000000, -361.000000)">
|
||||
<g id="编组-9" transform="translate(1004.000000, 179.000000)">
|
||||
<g id="编组-12" transform="translate(446.000000, 182.000000)">
|
||||
<rect id="矩形" x="0" y="0" width="128" height="128"></rect>
|
||||
<g id="编组" transform="translate(12.000000, 14.000000)">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<g id="蒙版"></g>
|
||||
<mask id="mask-4" fill="white">
|
||||
<use xlink:href="#path-3"></use>
|
||||
</mask>
|
||||
<use id="蒙版" fill="#393D42" xlink:href="#path-3"></use>
|
||||
<path d="M21.0003174,2 L21.0003174,98.1186867 C8.74586136,93.633122 -1.82964754e-13,81.8675854 -1.82964754e-13,68.0593433 L-1.82964754e-13,32.0593433 C-1.82964754e-13,18.2511013 8.74586136,6.48556463 21.0003174,2 Z" id="路径" fill="url(#linearGradient-5)" mask="url(#mask-4)"></path>
|
||||
</g>
|
||||
<path d="M97.81893,72 C98.8751767,72 99.9238631,72.0771597 100.965021,72.2314815 C102.006178,72.3858032 102.949241,72.7021581 103.794239,73.1805556 C104.639236,73.658953 105.318242,74.3302426 105.831276,75.1944444 C106.34431,76.0586463 106.600823,77.1851782 106.600823,78.5740741 L106.600823,90.8888889 C106.600823,91.8148194 106.653635,92.493825 106.759259,92.9259259 C106.864884,93.3580269 107.219476,93.5740741 107.823045,93.5740741 C108.155009,93.5740741 108.547323,93.4969144 109,93.3425926 L109,96.3981481 C108.336073,96.7993847 107.415644,97 106.238683,97 C105.242793,97 104.45062,96.714509 103.86214,96.1435185 C103.27366,95.572528 102.979424,94.6388954 102.979424,93.3425926 C101.923177,94.6388954 100.693423,95.572528 99.2901235,96.1435185 C97.8868243,96.714509 96.3703785,97 94.7407407,97 C93.684494,97 92.6810747,96.8765444 91.7304527,96.6296296 C90.7798306,96.3827148 89.9574795,95.9969162 89.2633745,95.4722222 C88.5692695,94.9475282 88.0185206,94.2608067 87.6111111,93.412037 C87.2037017,92.5632674 87,91.5370431 87,90.3333333 C87,88.9753019 87.2263352,87.8642019 87.6790123,87 C88.1316895,86.1357981 88.7277055,85.4336447 89.4670782,84.8935185 C90.2064509,84.3533924 91.0514356,83.9444458 92.0020576,83.6666667 C92.7150241,83.4583323 93.440714,83.2760417 94.1791395,83.1197919 L94.9218107,82.9722222 C95.7668081,82.7993819 96.5779959,82.6611111 97.3553896,82.5574075 L97.9320988,82.4861111 C98.8827208,82.3780859 99.720161,82.2237664 100.444444,82.0231481 C101.168728,81.8225299 101.74211,81.5293229 102.164609,81.1435185 C102.587108,80.7577141 102.798354,80.1944481 102.798354,79.4537037 C102.798354,78.5895019 102.639919,77.8950644 102.323045,77.3703704 C102.006171,76.8456764 101.598768,76.4444458 101.100823,76.1666667 C100.602878,75.8888875 100.044585,75.7037042 99.4259259,75.6111111 C98.8072671,75.5185181 98.1961621,75.4722222 97.5925926,75.4722222 C95.9629548,75.4722222 94.6049437,75.7885771 93.5185185,76.4212963 C92.4320933,77.0540155 91.8436219,78.2499912 91.7530864,80.0092593 L87.9053498,80.0092593 C87.9657067,78.5277704 88.267487,77.2777829 88.8106996,76.2592593 C89.3539122,75.2407356 90.0781848,74.4151266 90.9835391,73.7824074 C91.8888934,73.1496882 92.9224908,72.6944458 94.0843621,72.4166667 C95.2462335,72.1388875 96.491077,72 97.81893,72 Z M72.3564955,63 L85,96 L80.2416918,96 L76.7069486,86.0630252 L63.021148,86.0630252 L59.3957704,96 L55,96 L67.5981873,63 L72.3564955,63 Z M103,84 C102.503873,84.3529429 101.852717,84.6102933 101.046512,84.7720588 C100.240306,84.9338243 99.3953533,85.066176 98.5116279,85.1691176 C97.6279026,85.2720593 96.7364386,85.3897052 95.8372093,85.5220588 C94.93798,85.6544124 94.1317865,85.8676456 93.4186047,86.1617647 C92.7054228,86.4558838 92.1240333,86.8749973 91.6744186,87.4191176 C91.224804,87.963238 91,88.7058776 91,89.6470588 C91,90.264709 91.1317816,90.7867626 91.3953488,91.2132353 C91.658916,91.639708 92,91.9852928 92.4186047,92.25 C92.8372114,92.5147072 93.3255786,92.7058818 93.8837209,92.8235294 C94.4418633,92.9411771 95.0310047,93 95.6511628,93 C96.9534949,93 98.0697628,92.830884 99,92.4926471 C99.9302372,92.1544101 100.68992,91.7279437 101.27907,91.2132353 C101.86822,90.6985268 102.302324,90.1397089 102.581395,89.5367647 C102.820599,89.0199554 102.957286,88.5301633 102.991457,88.0673776 L103,87.8382353 L103,84 Z M69.5909091,67 L69.5,67 L64,82 L75,82 L69.5909091,67 Z" id="形状结合" fill="#67707B" fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 5.3 KiB |
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 59 (86127) - https://sketch.com -->
|
||||
<title>删除</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<g id="传书" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="聊天窗口3.0" transform="translate(-1196.000000, -249.000000)">
|
||||
<g id="编组-4" transform="translate(820.000000, 162.000000)">
|
||||
<g id="删除" transform="translate(376.000000, 87.000000)">
|
||||
<circle id="椭圆形" fill="#F44E50" fill-rule="nonzero" cx="8" cy="8" r="8"></circle>
|
||||
<path d="M11.01045,11.01045 C11.2057104,10.8151896 11.2057107,10.4986101 11.0104507,10.3033493 L8.88909,8.18198 L8.88909,8.18198 L11.0104446,6.06065964 C11.2057077,5.86539976 11.2057102,5.54881839 11.0104504,5.35355536 C11.0104502,5.35355524 11.0104501,5.35355512 11.01045,5.353555 C10.8151896,5.15829179 10.4986077,5.15828907 10.3033439,5.35354893 L8.18198,7.47487 L8.18198,7.47487 L6.060665,5.353555 C5.86540197,5.15829197 5.54881803,5.15829197 5.353555,5.353555 C5.15829197,5.54881803 5.15829197,5.86540197 5.353555,6.060665 L7.47487,8.18198 L7.47487,8.18198 L5.35354893,10.3033439 C5.15828907,10.4986077 5.15829179,10.8151896 5.353555,11.01045 C5.54881784,11.2057101 5.86539921,11.2057078 6.06065929,11.010445 C6.0606594,11.0104449 6.06065952,11.0104448 6.06065964,11.0104446 L8.18198,8.88909 L8.18198,8.88909 L10.3033493,11.0104507 C10.4986101,11.2057107 10.8151896,11.2057104 11.01045,11.01045 Z" id="路径" fill="#FFFFFF"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.7 KiB |
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="16px" height="10px" viewBox="0 0 16 10" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>font-select-symbolic-w</title>
|
||||
<g id="浅色模式3.1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="字体-右键" transform="translate(-1525.000000, -904.000000)" fill="#FFFFFF" fill-rule="nonzero">
|
||||
<g id="图层_2_1_" transform="translate(1525.950000, 904.000000)">
|
||||
<path d="M11.95,9 L8.05,0 L7.05,0 L3.15,9 L2.05,9 L2.05,10 L5.05,10 L5.05,9 L4.25,9 L5.05,7 L10.05,7 L10.95,9 L10.05,9 L10.05,10 L13.05,10 L13.05,9 L11.95,9 Z M5.55,6 L7.05,2.5 L7.55,1.4 L8.05,2.5 L9.55,6 L5.55,6 Z" id="形状"></path>
|
||||
<path d="M0.55,8 C0.45,8 0.25,8 0.15,7.9 C-0.05,7.7 -0.05,7.4 0.15,7.2 L1.75,5.6 L0.15,3.9 C0.05,3.7 0.05,3.3 0.15,3.1 C0.25,2.9 0.65,2.9 0.85,3.1 L2.85,5.1 C3.05,5.3 3.05,5.7 2.95,5.9 L0.95,7.9 C0.85,8 0.65,8 0.55,8 Z" id="路径"></path>
|
||||
<path d="M14.55,8 C14.45,8 14.25,8 14.15,7.9 L12.15,5.9 C11.95,5.7 11.95,5.4 12.15,5.2 L14.15,3.2 C14.35,3 14.65,3 14.85,3.2 C15.05,3.4 15.05,3.7 14.85,3.9 L13.25,5.5 L14.85,7.1 C15.05,7.3 15.05,7.6 14.85,7.8 C14.85,8 14.65,8 14.55,8 Z" id="路径"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 5.3 KiB |
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="128px" height="128px" viewBox="0 0 128 128" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>编组 11</title>
|
||||
<defs>
|
||||
<linearGradient x1="2.77555756e-13%" y1="50%" x2="100%" y2="50%" id="linearGradient-1">
|
||||
<stop stop-color="#D8DDE2" offset="0%"></stop>
|
||||
<stop stop-color="#C5CAD1" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="浅色模式3.1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="字体-空白页" transform="translate(-565.000000, -361.000000)">
|
||||
<g id="编组-2" transform="translate(119.000000, 179.000000)">
|
||||
<g id="编组-11" transform="translate(446.000000, 182.000000)">
|
||||
<rect id="矩形" x="0" y="0" width="128" height="128"></rect>
|
||||
<g id="编组" transform="translate(12.000000, 14.000000)">
|
||||
<rect id="蒙版" fill="#E4E7EA" x="0" y="0" width="100" height="100" rx="32"></rect>
|
||||
<path d="M21.0003174,1.94065667 L21.0003174,98.0593433 C8.74586136,93.5737787 0,81.808242 0,68 L0,32 C0,18.191758 8.74586136,6.4262213 21.0003174,1.94065667 Z" id="路径" fill="url(#linearGradient-1)"></path>
|
||||
</g>
|
||||
<path d="M97.81893,72 C98.8751767,72 99.9238631,72.0771597 100.965021,72.2314815 C102.006178,72.3858032 102.949241,72.7021581 103.794239,73.1805556 C104.639236,73.658953 105.318242,74.3302426 105.831276,75.1944444 C106.34431,76.0586463 106.600823,77.1851782 106.600823,78.5740741 L106.600823,90.8888889 C106.600823,91.8148194 106.653635,92.493825 106.759259,92.9259259 C106.864884,93.3580269 107.219476,93.5740741 107.823045,93.5740741 C108.155009,93.5740741 108.547323,93.4969144 109,93.3425926 L109,96.3981481 C108.336073,96.7993847 107.415644,97 106.238683,97 C105.242793,97 104.45062,96.714509 103.86214,96.1435185 C103.27366,95.572528 102.979424,94.6388954 102.979424,93.3425926 C101.923177,94.6388954 100.693423,95.572528 99.2901235,96.1435185 C97.8868243,96.714509 96.3703785,97 94.7407407,97 C93.684494,97 92.6810747,96.8765444 91.7304527,96.6296296 C90.7798306,96.3827148 89.9574795,95.9969162 89.2633745,95.4722222 C88.5692695,94.9475282 88.0185206,94.2608067 87.6111111,93.412037 C87.2037017,92.5632674 87,91.5370431 87,90.3333333 C87,88.9753019 87.2263352,87.8642019 87.6790123,87 C88.1316895,86.1357981 88.7277055,85.4336447 89.4670782,84.8935185 C90.2064509,84.3533924 91.0514356,83.9444458 92.0020576,83.6666667 C92.7150241,83.4583323 93.440714,83.2760417 94.1791395,83.1197919 L94.9218107,82.9722222 C95.7668081,82.7993819 96.5779959,82.6611111 97.3553896,82.5574075 L97.9320988,82.4861111 C98.8827208,82.3780859 99.720161,82.2237664 100.444444,82.0231481 C101.168728,81.8225299 101.74211,81.5293229 102.164609,81.1435185 C102.587108,80.7577141 102.798354,80.1944481 102.798354,79.4537037 C102.798354,78.5895019 102.639919,77.8950644 102.323045,77.3703704 C102.006171,76.8456764 101.598768,76.4444458 101.100823,76.1666667 C100.602878,75.8888875 100.044585,75.7037042 99.4259259,75.6111111 C98.8072671,75.5185181 98.1961621,75.4722222 97.5925926,75.4722222 C95.9629548,75.4722222 94.6049437,75.7885771 93.5185185,76.4212963 C92.4320933,77.0540155 91.8436219,78.2499912 91.7530864,80.0092593 L87.9053498,80.0092593 C87.9657067,78.5277704 88.267487,77.2777829 88.8106996,76.2592593 C89.3539122,75.2407356 90.0781848,74.4151266 90.9835391,73.7824074 C91.8888934,73.1496882 92.9224908,72.6944458 94.0843621,72.4166667 C95.2462335,72.1388875 96.491077,72 97.81893,72 Z M72.3564955,63 L85,96 L80.2416918,96 L76.7069486,86.0630252 L63.021148,86.0630252 L59.3957704,96 L55,96 L67.5981873,63 L72.3564955,63 Z M103,84 C102.503873,84.3529429 101.852717,84.6102933 101.046512,84.7720588 C100.240306,84.9338243 99.3953533,85.066176 98.5116279,85.1691176 C97.6279026,85.2720593 96.7364386,85.3897052 95.8372093,85.5220588 C94.93798,85.6544124 94.1317865,85.8676456 93.4186047,86.1617647 C92.7054228,86.4558838 92.1240333,86.8749973 91.6744186,87.4191176 C91.224804,87.963238 91,88.7058776 91,89.6470588 C91,90.264709 91.1317816,90.7867626 91.3953488,91.2132353 C91.658916,91.639708 92,91.9852928 92.4186047,92.25 C92.8372114,92.5147072 93.3255786,92.7058818 93.8837209,92.8235294 C94.4418633,92.9411771 95.0310047,93 95.6511628,93 C96.9534949,93 98.0697628,92.830884 99,92.4926471 C99.9302372,92.1544101 100.68992,91.7279437 101.27907,91.2132353 C101.86822,90.6985268 102.302324,90.1397089 102.581395,89.5367647 C102.820599,89.0199554 102.957286,88.5301633 102.991457,88.0673776 L103,87.8382353 L103,84 Z M69.5909091,67 L69.5,67 L64,82 L75,82 L69.5909091,67 Z" id="形状结合" fill="#B3BAC3" fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.7 KiB |
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="14px" height="13px" viewBox="0 0 14 13" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>system-computer-symbolic-w</title>
|
||||
<g id="浅色模式3.1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="字体-右键" transform="translate(-1549.000000, -903.000000)" fill="#FFFFFF" fill-rule="nonzero">
|
||||
<g id="system-computer-symbolic-w" transform="translate(1549.000000, 903.000000)">
|
||||
<path d="M12,0 L2,0 C0.9,0 0,0.9 0,2 L0,9 C0,10.1 0.9,11 2,11 L6.1,11 L6.1,12 L4.5,12 C4.2,12 4,12.2 4,12.5 C4,12.8 4.2,13 4.5,13 L9.5,13 C9.8,13 10,12.8 10,12.5 C10,12.2 9.8,12 9.5,12 L8,12 L8,11 L12,11 C13.1,11 14,10.1 14,9 L14,2 C14,0.9 13.1,0 12,0 Z M13,9 C13,9.6 12.6,10 12,10 L8,10 L6.1,10 L2,10 C1.4,10 1,9.6 1,9 L1,2 C1,1.4 1.4,1 2,1 L12,1 C12.6,1 13,1.4 13,2 L13,9 Z" id="形状"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 990 B |
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="22px" height="22px" viewBox="0 0 22 22" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 59 (86127) - https://sketch.com -->
|
||||
<title>ukui-dialog-error-24</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<g id="组件" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="icon/success-24x24" transform="translate(-1.000000, -1.000000)">
|
||||
<g id="ukui-dialog-error-24">
|
||||
<g transform="translate(1.000000, 1.000000)">
|
||||
<circle id="椭圆形" fill="#04BA6B" fill-rule="nonzero" cx="11" cy="11" r="11"></circle>
|
||||
<g id="编组-8" transform="translate(7.000000, 8.000000)" opacity="0.75868879" stroke="#FFFFFF" stroke-linecap="round" stroke-width="1.6">
|
||||
<line x1="0" y1="3" x2="2.7" y2="5.7" id="路径"></line>
|
||||
<line x1="9" y1="0" x2="3" y2="6" id="路径"></line>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="17px" height="15px" viewBox="0 0 17 15" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ukui-play-love-red</title>
|
||||
<g id="浅色模式3.1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="字体-右键" transform="translate(-1547.000000, -877.000000)" fill="#FF4848" fill-rule="nonzero">
|
||||
<g id="ukui-play-love-red" transform="translate(1547.000000, 877.000000)">
|
||||
<path d="M8.025,14.0149097 C7.625,14.0149097 7.225,13.9149097 6.925,13.6149097 L1.425,8.11490973 C-0.475,6.21490973 -0.475,3.31490973 1.425,1.41490973 C3.325,-0.385090269 6.125,-0.485090269 8.025,1.21490973 L8.025,1.21490973 L8.025,1.21490973 C10.025,-0.485090269 12.725,-0.385090269 14.625,1.41490973 C15.525,2.31490973 16.025,3.51490973 16.025,4.81490973 C16.025,6.11490973 15.425,7.31490973 14.525,8.11490973 L9.025,13.6149097 C8.825,13.8149097 8.425,14.0149097 8.025,14.0149097 Z" id="形状"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="17px" height="15px" viewBox="0 0 17 15" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ukui-play-love-symbolic-b</title>
|
||||
<g id="浅色模式3.1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" opacity="0.75">
|
||||
<g id="字体-右键" transform="translate(-1501.000000, -877.000000)" fill="#1F2022" fill-rule="nonzero">
|
||||
<g id="ukui-play-love-symbolic-b" transform="translate(1501.000000, 877.000000)">
|
||||
<path d="M8.025,14.0149097 C7.625,14.0149097 7.225,13.9149097 6.925,13.6149097 L1.425,8.11490973 C-0.475,6.21490973 -0.475,3.31490973 1.425,1.41490973 C3.325,-0.385090269 6.125,-0.485090269 8.025,1.21490973 L8.025,1.21490973 L8.025,1.21490973 C10.025,-0.485090269 12.725,-0.385090269 14.625,1.41490973 C15.525,2.31490973 16.025,3.51490973 16.025,4.81490973 C16.025,6.11490973 15.425,7.31490973 14.525,8.11490973 L9.025,13.6149097 C8.825,13.8149097 8.425,14.0149097 8.025,14.0149097 Z M4.825,1.01490973 C3.825,1.01490973 2.925,1.31490973 2.125,2.11490973 C0.625,3.61490973 0.625,5.91490973 2.125,7.41490973 L7.625,12.9149097 C7.825,13.1149097 8.125,13.1149097 8.325,12.9149097 L13.825,7.41490973 C14.625,6.71490973 15.025,5.81490973 15.025,4.81490973 C15.025,3.81490973 14.625,2.91490973 13.925,2.21490973 C12.525,0.714909731 10.325,0.614909731 8.725,2.01490973 L8.125,2.61490973 L7.425,2.01490973 C6.625,1.31490973 5.725,1.01490973 4.825,1.01490973 Z" id="形状"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="17px" height="15px" viewBox="0 0 17 15" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ukui-play-love-symbolic-w</title>
|
||||
<g id="浅色模式3.1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="字体-右键" transform="translate(-1525.000000, -877.000000)" fill="#FFFFFF" fill-rule="nonzero">
|
||||
<g id="ukui-play-love-symbolic-w" transform="translate(1525.000000, 877.000000)">
|
||||
<path d="M8.025,14.0149097 C7.625,14.0149097 7.225,13.9149097 6.925,13.6149097 L1.425,8.11490973 C-0.475,6.21490973 -0.475,3.31490973 1.425,1.41490973 C3.325,-0.385090269 6.125,-0.485090269 8.025,1.21490973 L8.025,1.21490973 L8.025,1.21490973 C10.025,-0.485090269 12.725,-0.385090269 14.625,1.41490973 C15.525,2.31490973 16.025,3.51490973 16.025,4.81490973 C16.025,6.11490973 15.425,7.31490973 14.525,8.11490973 L9.025,13.6149097 C8.825,13.8149097 8.425,14.0149097 8.025,14.0149097 Z M4.825,1.01490973 C3.825,1.01490973 2.925,1.31490973 2.125,2.11490973 C0.625,3.61490973 0.625,5.91490973 2.125,7.41490973 L7.625,12.9149097 C7.825,13.1149097 8.125,13.1149097 8.325,12.9149097 L13.825,7.41490973 C14.625,6.71490973 15.025,5.81490973 15.025,4.81490973 C15.025,3.81490973 14.625,2.91490973 13.925,2.21490973 C12.525,0.714909731 10.325,0.614909731 8.725,2.01490973 L8.125,2.61490973 L7.425,2.01490973 C6.625,1.31490973 5.725,1.01490973 4.825,1.01490973 Z" id="形状"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
|
@ -0,0 +1,17 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Font Viewer
|
||||
Name[zh_CN]=字体管理器
|
||||
Name[bo_CN]=ཡིག་གཟུགས་དོ་དམ་ཆས་
|
||||
GenericName[bo_CN]=ཡིག་གཟུགས་དོ་དམ་ཆས་
|
||||
Comment=kylin-font-viewer is used to manage , preview , install and uninstall fonts.
|
||||
Comment[zh_CN]=字体管理器用于管理,预览,安装和卸载字体。
|
||||
Comment[bo_CN]=ཡིག་གཟུགས་དོ་དམ་ཆས་ནི་དོ་དམ་ལ་སྤྱོད་པ་དང་།སྔོན་ལ་ལྟ་བ།ཡིག་གཟུགས་སྒྲིག་སྦྱོར་དང་འབེབས་པ།
|
||||
Exec=/usr/bin/kylin-font-viewer %u
|
||||
Icon=kylin-font-viewer
|
||||
StartupNotify=false
|
||||
Terminal=false
|
||||
MimeType=font/ttf;application/vnd.ms-opentype;font/otf;font/ttc;font/sfnt;
|
||||
Type=Application
|
||||
Categories=InstantMessaging;
|
||||
X-KDE-Wayland-Interfaces=org_kde_plasma_window_management,org_kde_plasma_activation_feedback,org_kde_kwin_keystate,org_kde_kwin_fake_input,zkde_screencast_unstable_v1
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schemalist>
|
||||
<schema id="org.kylin.font.viewer.gsettings" path="/org/kylin/font/viewer/gsettings/">
|
||||
<key type="s" name="collect-font">
|
||||
<default>''</default>
|
||||
<summary>Collection Font</summary>
|
||||
<description>Collection Font</description>
|
||||
</key>
|
||||
<key type="s" name="setting-font-tips">
|
||||
<default>"true"</default>
|
||||
<summary>Tips For Fonts</summary>
|
||||
<description>Tips For Fonts</description>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
|
@ -0,0 +1,39 @@
|
|||
<schemalist gettext-domain="ukui-log4qt-kylin-font-view">
|
||||
<schema id="org.ukui.ukui-log4qt-kylin-font-view" path="/org/ukui/ukui-log4qt-kylin-font-view/">
|
||||
<key type="s" name="log4j-handleqtmessages">
|
||||
<default>"true"</default>
|
||||
<summary>hook qt messages</summary>
|
||||
<description>Control if hook qt messages</description>
|
||||
</key>
|
||||
<key type="s" name="log4j-rootlogger">
|
||||
<default>"DEBUG,console,daily"</default>
|
||||
<summary>config rootLogger's level and appenders</summary>
|
||||
<description>config rootLogger's level and appenders:"level,appender"</description>
|
||||
</key>
|
||||
<key type="s" name="log4j-appender-daily-datepattern">
|
||||
<default>".yyyy-MM-dd"</default>
|
||||
<summary>daily log file pattern</summary>
|
||||
<description>set daily log file pattern format:one day</description>
|
||||
</key>
|
||||
<key type="s" name="log4j-appender-daily-layout-conversionpattern">
|
||||
<default>"%d{yyyy-MM-dd HH:mm:ss,zzz}(%-4r)[%t]|%-5p| - %m%n"</default>
|
||||
<summary>set log message's format</summary>
|
||||
<description>set log message's format</description>
|
||||
</key>
|
||||
<key type="i" name="delaytime">
|
||||
<default>3600</default>
|
||||
<summary>set check log files delay time</summary>
|
||||
<description>set check log files delay time</description>
|
||||
</key>
|
||||
<key type="i" name="maxfilecount">
|
||||
<default>7</default>
|
||||
<summary>set log files count</summary>
|
||||
<description>set log files count,unit s</description>
|
||||
</key>
|
||||
<key type="i" name="maxfilesize">
|
||||
<default>512</default>
|
||||
<summary>set log files total size</summary>
|
||||
<description>set log files total size, unit M</description>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
|
@ -0,0 +1,8 @@
|
|||
#! /bin/bash
|
||||
|
||||
ts_file_list=(`ls data/translations/*.ts`)
|
||||
|
||||
for ts in "${ts_file_list[@]}"
|
||||
do
|
||||
lrelease "${ts}"
|
||||
done
|
|
@ -0,0 +1,290 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="bo_CN">
|
||||
<context>
|
||||
<name>BasePopupTitle</name>
|
||||
<message>
|
||||
<source>Font Viewer</source>
|
||||
<translation>ཡིག་གཟུགས་ལྟ་མཁན།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close</source>
|
||||
<translation>སྒོ་རྒྱག་པ།</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BasePreviewArea</name>
|
||||
<message>
|
||||
<source>Enter Text Content For Preview</source>
|
||||
<translation>ཡི་གེའི་ནང་དོན་ནང་འཇུག་བྱས་ནས་སྔོན་སྦྱོང་</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BaseSearchEdit</name>
|
||||
<message>
|
||||
<source>Search</source>
|
||||
<translation>འཚོལ་ཞིབ།</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BlankPage</name>
|
||||
<message>
|
||||
<source>No Font</source>
|
||||
<translation>གནས་སྐབས་མེད་པའི་ཡིག་གཟུགས།</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>FontListView</name>
|
||||
<message>
|
||||
<source>Add Font</source>
|
||||
<translation>ཡིག་གཟུགས་ཁ་སྣོན་བྱེད་པ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Apply Font</source>
|
||||
<translation>ཡིག་གཟུགས་བཀོལ་སྤྱོད་བྱེད་པ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Remove Font</source>
|
||||
<translation>ཡིག་གཟུགས་མེད་པར་བཟོ་བ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Export Font</source>
|
||||
<translation>ཕྱིར་གཏོང་ཡིག་གཟུགས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel Collection</source>
|
||||
<translation>བསྡུ་ལེན་མེད་པར་བཟོ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Check Font</source>
|
||||
<translation>ཡིག་གཟུགས་ལ་ཞིབ་བཤེར་བྱེད</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Collection</source>
|
||||
<translation>བསྡུ་ཉར།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Add Fonts</source>
|
||||
<translation>ཡིག་གཟུགས་ཁ་སྣོན་བྱེད་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>font(*.ttf *.otf)</source>
|
||||
<translation>ཡིག་གཟུགས་(*.ttf *.otf)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Export Fonts</source>
|
||||
<translation>ཕྱིར་གཏོང་ཡིག་གཟུགས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Build the core strength of Chinese operating system</source>
|
||||
<translation>ཀྲུང་གོའི་བཀོལ་སྤྱོད་མ་ལག་གི་ལྟེ་བའི་སྟོབས་ཤུགས་འཛུགས་སྐྱོང་བྱ</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>FunctionWid</name>
|
||||
<message>
|
||||
<source>All Font</source>
|
||||
<translation>ཡིག་གཟུགས་ཡོད་ཚད།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>System Font</source>
|
||||
<translation>མ་ལག་གི་ཡིག་གཟུགས</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>User Font</source>
|
||||
<translation>སྤྱོད་མཁན་གྱི་ཡིག་གཟུགས</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Collection Font</source>
|
||||
<translation>འཚོལ་སྡུད་བྱས་པའི་ཡིག་</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainView</name>
|
||||
<message>
|
||||
<source>Font Viewer</source>
|
||||
<translation>ཡིག་གཟུགས་ལྟ་མཁན།</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PopupAbout</name>
|
||||
<message>
|
||||
<source>Version: </source>
|
||||
<translation type="vanished">པར་གཞི་འདི་ལྟ་སྟེ། </translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Font Viewer is a tool to help users install and organize management; After installation, the font can be applied to self-developed applications, third-party pre installed applications and user self installed applications.</source>
|
||||
<translation type="vanished">ཡིག་གཟུགས་ལྟ་མཁན་ནི་སྤྱོད་མཁན་གྱིས་དོ་དམ་སྒྲིག་སྦྱོར་དང་སྒྲིག་འཛུགས་བྱེད་པར་རོགས་རམ་བྱེད་པའི་ལག་ཆ་ཞིག་ སྒྲིག་སྦྱོར་བྱས་རྗེས་ཡིག་གཟུགས་དེ་རང་གིས་གསར་སྤེལ་བྱས་པའི་ཉེར་སྤྱོད་གོ་རིམ་དང་། ཕྱོགས་གསུམ་པའི་སྔོན་ལ་སྒྲིག་སྦྱོར་བྱས་པའི་ཉེར་སྤྱོད་གོ་རིམ། སྤྱོད་མཁན་རང་གིས་རང་ལ་སྒྲིག་སྦྱོར་བྱས་པའི་ཉེར་སྤྱོད་གོ་རིམ་བཅས་སུ་སྤྱད་ཆོག</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Service & Support: </source>
|
||||
<translation type="vanished">ཞབས་ཞུ་ & རྒྱབ་སྐྱོར་: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Font Viewer</source>
|
||||
<translation type="vanished">ཡིག་གཟུགས་ལྟ་མཁན།</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PopupFontInfo</name>
|
||||
<message>
|
||||
<source>FontName</source>
|
||||
<translation>ཡིག་གཟུགས་ཀྱི་མིང་།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>FontSeries</source>
|
||||
<translation>ཡིག་གཟུགས་རིམ་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>FontStyle</source>
|
||||
<translation>ཡིག་གཟུགས་ཀྱི་མ་ལག</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>FontType</source>
|
||||
<translation>ཡིག་གཟུགས་རིགས་དབྱིབས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>FontVersion</source>
|
||||
<translation>ཡིག་གཟུགས་ལ་ངོ་རྒོལ་བྱེད་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>FontPath</source>
|
||||
<translation>ཡིག་གཟུགས་ཀྱི་ལམ་ཕྱོགས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>FontCopyright</source>
|
||||
<translation>ཡིག་གཟུགས་ཁའོ་ཕུའུ་ལའེ་ཐེ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>FontTrademark</source>
|
||||
<translation>ཡིག་གཟུགས་ཉོ་ཚོང་མཚོན་རྟགས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Continue</source>
|
||||
<translation type="vanished">继续</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation>ཕྱིར་འཐེན།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Confirm</source>
|
||||
<translation>གཏན་འཁེལ་བྱ་དགོས།</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PopupInstallFail</name>
|
||||
<message>
|
||||
<source>There is a problem with the font file. Installation failed!</source>
|
||||
<translation>ཡིག་གཟུགས་ཡིག་ཆ་ལ་གནད་དོན་ཡོད། སྒྲིག་སྦྱོར་བྱས་ཀྱང་ཕམ་སོང་།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>confirm</source>
|
||||
<translation>ངོས་འཛིན་བྱས་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Continue</source>
|
||||
<translation type="vanished">继续</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation type="vanished">取消</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PopupInstallSuccess</name>
|
||||
<message>
|
||||
<source>already installed </source>
|
||||
<translation>སྒྲིག་སྦྱོར་བྱས་ཟིན་པ། </translation>
|
||||
</message>
|
||||
<message>
|
||||
<source> fonts!</source>
|
||||
<translation> ཡིག་གཟུགས་ཀྱི་ཡིག་གཟུགས་རེད།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source> fonts! </source>
|
||||
<translation type="vanished">款字体!</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PopupRemove</name>
|
||||
<message>
|
||||
<source>Are you sure you want to remove this font?</source>
|
||||
<translation>ཁྱོད་ཀྱིས་དངོས་གནས་ཡིག་གཟུགས་འདི་མེད་པར་བཟོ་དགོས་སམ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Confirm</source>
|
||||
<translation>གཏན་འཁེལ་བྱ་དགོས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation>ཕྱིར་འཐེན།</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PopupTips</name>
|
||||
<message>
|
||||
<source>Installing new fonts takes effect after restarting!</source>
|
||||
<translation>ཡིག་གཟུགས་གསར་པ་སྒྲིག་སྦྱོར་བྱས་རྗེས་ནུས་པ་ཐོན་གྱི་འདུག</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Confirm</source>
|
||||
<translation>ངོས་འཛིན་</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do not show again</source>
|
||||
<translation>མི་འཆར་བ་</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TitleBar</name>
|
||||
<message>
|
||||
<source>Add Font</source>
|
||||
<translation>ཡིག་གཟུགས་ཁ་སྣོན་བྱེད་པ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Minimize</source>
|
||||
<translation>ཉུང་དུ་གཏོང་གང་ཐུབ་བྱ་དགོས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close</source>
|
||||
<translation>སྒོ་རྒྱག་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Menu</source>
|
||||
<translation>ཟས་ཐོ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Help</source>
|
||||
<translation>རོགས་རམ་བྱེད་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Quit</source>
|
||||
<translation>ཕྱིར་འབུད་</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>About</source>
|
||||
<translation>འབྲེལ་ཡོད་ཀྱི་སྐོར།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Maximize</source>
|
||||
<translation>ཚད་གཞི་མཐོ་ཤོས་ཀྱི་སྒོ་ནས</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Normal</source>
|
||||
<translation>རྒྱུན་ལྡན་གྱི་གནས་</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Version: </source>
|
||||
<translation>པར་གཞི་འདི་ལྟ་སྟེ། : </translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Font Viewer is a tool to help users install and organize management; After installation, the font can be applied to self-developed applications, third-party pre installed applications and user self installed applications.</source>
|
||||
<translation>ཡིག་གཟུགས་ལྟ་མཁན་ནི་སྤྱོད་མཁན་གྱིས་དོ་དམ་སྒྲིག་སྦྱོར་དང་སྒྲིག་འཛུགས་བྱེད་པར་རོགས་རམ་བྱེད་པའི་ལག་ཆ་ཞིག་ སྒྲིག་སྦྱོར་བྱས་རྗེས་ཡིག་གཟུགས་དེ་རང་གིས་གསར་སྤེལ་བྱས་པའི་ཉེར་སྤྱོད་གོ་རིམ་དང་། ཕྱོགས་གསུམ་པའི་སྔོན་ལ་སྒྲིག་སྦྱོར་བྱས་པའི་ཉེར་སྤྱོད་གོ་རིམ། སྤྱོད་མཁན་རང་གིས་རང་ལ་སྒྲིག་སྦྱོར་བྱས་པའི་ཉེར་སྤྱོད་གོ་རིམ་བཅས་སུ་སྤྱད་ཆོག.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Font Viewer</source>
|
||||
<translation>ཡིག་གཟུགས་ལྟ་མཁན།</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
|
@ -0,0 +1,294 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="zh_CN">
|
||||
<context>
|
||||
<name>BasePopupTitle</name>
|
||||
<message>
|
||||
<source>Font Viewer</source>
|
||||
<translation>字体管理器</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close</source>
|
||||
<translation>关闭</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BasePreviewArea</name>
|
||||
<message>
|
||||
<source>Enter Text Content For Preview</source>
|
||||
<translation>输入文字内容进行预览</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BaseSearchEdit</name>
|
||||
<message>
|
||||
<source>Search</source>
|
||||
<translation>搜索</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>FontListView</name>
|
||||
<message>
|
||||
<source>Add Font</source>
|
||||
<translation>添加字体</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Apply Font</source>
|
||||
<translation>应用字体</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Remove Font</source>
|
||||
<translation>卸载字体</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Export Font</source>
|
||||
<translation>导出字体</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel Collection</source>
|
||||
<translation>取消收藏</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Check Font</source>
|
||||
<translation>字体信息</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Collection</source>
|
||||
<translation>收藏字体</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Add Fonts</source>
|
||||
<translation>添加字体</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>font(*.ttf *.fon *.ttc *.afm)</source>
|
||||
<translation type="vanished">字体文件(*.ttf *.fon *.ttc *.afm)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Export Fonts</source>
|
||||
<translation>导出字体</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Build the core strength of Chinese operating system</source>
|
||||
<translation>打造中国操作系统核心力量</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>font(*.ttf *.otf)</source>
|
||||
<translation>字体文件(*.ttf *otf)</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>FunctionWid</name>
|
||||
<message>
|
||||
<source>All Font</source>
|
||||
<translation>所有字体</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>System Font</source>
|
||||
<translation>系统字体</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>User Font</source>
|
||||
<translation>我的字体</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Collection Font</source>
|
||||
<translation>收藏字体</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainView</name>
|
||||
<message>
|
||||
<source>Font Viewer</source>
|
||||
<translation>字体管理器</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PopupAbout</name>
|
||||
<message>
|
||||
<source>Version: </source>
|
||||
<translation type="vanished">版本:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Font Viewer is a tool to help users install and organize management; After installation, the font can be applied to self-developed applications, third-party pre installed applications and user self installed applications.</source>
|
||||
<translation type="vanished">字体管理器是一款帮助用户安装和组织管理的一款工具;安装后字体可运用至自研应用、第三方预装应用和用户自装应用。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Service & Support: </source>
|
||||
<translation type="vanished">服务与支持:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Font Viewer</source>
|
||||
<translation type="vanished">字体管理器</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PopupFontInfo</name>
|
||||
<message>
|
||||
<source>FontName</source>
|
||||
<translation>名称</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>FontSeries</source>
|
||||
<translation>系列</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>FontStyle</source>
|
||||
<translation>样式</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>FontType</source>
|
||||
<translation>种类</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>FontVersion</source>
|
||||
<translation>版本</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>FontPath</source>
|
||||
<translation>位置</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>FontCopyright</source>
|
||||
<translation>版权</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>FontTrademark</source>
|
||||
<translation>商标</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Continue</source>
|
||||
<translation type="vanished">继续</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation>取消</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Confirm</source>
|
||||
<translation>确定</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PopupInstallFail</name>
|
||||
<message>
|
||||
<source>There is a problem with the font file. Installation failed!</source>
|
||||
<translation>字体文件存在问题,安装失败!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>confirm</source>
|
||||
<translation>确认</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Continue</source>
|
||||
<translation type="vanished">继续</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation type="vanished">取消</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PopupInstallSuccess</name>
|
||||
<message>
|
||||
<source>already installed </source>
|
||||
<translation>已安装 </translation>
|
||||
</message>
|
||||
<message>
|
||||
<source> fonts!</source>
|
||||
<translation> 款字体!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source> fonts! </source>
|
||||
<translation type="vanished">款字体!</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PopupRemove</name>
|
||||
<message>
|
||||
<source>Are you sure you want to remove this font?</source>
|
||||
<translation>确认要移除该字体吗?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Confirm</source>
|
||||
<translation>确定</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation>取消</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PopupTips</name>
|
||||
<message>
|
||||
<source>Installing new fonts takes effect after restarting!</source>
|
||||
<translation>安装新字体需要重启后生效!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Confirm</source>
|
||||
<translation>确认</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do not show again</source>
|
||||
<translation>不再显示</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TitleBar</name>
|
||||
<message>
|
||||
<source>Add Font</source>
|
||||
<translation>添加字体</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Minimize</source>
|
||||
<translation>最小化</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close</source>
|
||||
<translation>关闭</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Menu</source>
|
||||
<translation>菜单</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Quit</source>
|
||||
<translation>退出</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Help</source>
|
||||
<translation>帮助</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>About</source>
|
||||
<translation>关于</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Maximize</source>
|
||||
<translation>最大化</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Normal</source>
|
||||
<translation>还原</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Version: </source>
|
||||
<translation>版本: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Font Viewer is a tool to help users install and organize management; After installation, the font can be applied to self-developed applications, third-party pre installed applications and user self installed applications.</source>
|
||||
<translation>字体管理器是一款帮助用户安装和组织管理的一款工具;安装后字体可运用至自研应用、第三方预装应用和用户自装应用。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Font Viewer</source>
|
||||
<translation>字体管理器</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BlankPage</name>
|
||||
<message>
|
||||
<source>No Font</source>
|
||||
<translation>暂无字体</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
|
@ -0,0 +1,15 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>data/image/avatar-default-symbolic-w.svg</file>
|
||||
<file>data/image/delete.svg</file>
|
||||
<file>data/image/font-select-symbolic-w.svg</file>
|
||||
<file>data/image/system-computer-symbolic-w.svg</file>
|
||||
<file>data/image/ukui-dialog-error-24.svg</file>
|
||||
<file>data/image/ukui-play-love-red.svg</file>
|
||||
<file>data/image/ukui-play-love-symbolic-b.svg</file>
|
||||
<file>data/image/ukui-play-love-symbolic-w.svg</file>
|
||||
<file>data/image/kylin-font-viewer.svg</file>
|
||||
<file>data/image/dark.svg</file>
|
||||
<file>data/image/light.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
|
@ -0,0 +1,50 @@
|
|||
#ifndef __CORE_H__
|
||||
#define __CORE_H__
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "include/libfun.h"
|
||||
#include "include/external.h"
|
||||
|
||||
class Core : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
~Core();
|
||||
|
||||
static Core *getInstance(void); /* 获取单例指针 */
|
||||
QList<ViewData> getViewData(void); /* 获取全部字体 */
|
||||
FontInformation getFontDetails(QString path); /* 获取单个字体详细信息 */
|
||||
QList<ViewData> getSystemFont(void); /* 获取系统字体 */
|
||||
QList<ViewData> getMyFont(void); /* 获取我的字体 */
|
||||
QList<ViewData> getCollectFont(void); /* 获取收藏字体 */
|
||||
bool collectFont(QString path); /* 收藏字体 */
|
||||
bool unCollectFont(QString path); /* 取消收藏字体 */
|
||||
bool installFont(QString path); /* 安装字体 */
|
||||
bool uninstallFont(QString path, QString fontName); /* 卸载字体 */
|
||||
bool copyFont(QString srcPath , QString dstPath); /* 复制字体 */
|
||||
bool isSystemFont(QString path); /* 判断是否为系统字体 */
|
||||
bool applyFont(QString family); /* 应用字体 */
|
||||
QString ControlUsingFont(); /* 获取正在使用的字体名称 */
|
||||
void updateFontList(); /* 更新字体列表 */
|
||||
|
||||
bool judgeBadFontFile(QString path); /* 判断字体文件是否损坏 */
|
||||
bool getSettingFontTips(); /* 获取字体提示状态 */
|
||||
bool settingFontTips(bool state); /* 字体提示状态 */
|
||||
private:
|
||||
Core();
|
||||
|
||||
bool init(void);
|
||||
void printFontData(void);
|
||||
|
||||
QString m_installPath;
|
||||
|
||||
External m_external;
|
||||
QList<FontInformation> m_fontData;
|
||||
QList<FontInformation> m_collectFontData;
|
||||
|
||||
public slots:
|
||||
void slotStart(void);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,35 @@
|
|||
#ifndef __EXTERNAL_H__
|
||||
#define __EXTERNAL_H__
|
||||
|
||||
#include <QObject>
|
||||
#include <QGSettings>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QProcess>
|
||||
|
||||
class External : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
External();
|
||||
~External();
|
||||
QList<QString> getCollectFont(void);
|
||||
bool addCollectFont(QString path);
|
||||
bool removeCollectFont(QString path);
|
||||
|
||||
bool applyFont(QString path);
|
||||
QStringList getFontFromControl();
|
||||
bool setFontIntoList(QString font);
|
||||
QString isUsingFont();
|
||||
bool removeFontFormContro(QString font);
|
||||
bool getFontTipsData(); /* 获取gsetting的显示提示窗口的状态 */
|
||||
bool setFontIntoList(bool state); /* 设置gsetting的显示提示窗口的状态 */
|
||||
private:
|
||||
QGSettings *m_gsettings = nullptr;
|
||||
QGSettings *m_themeGsettings = nullptr;
|
||||
QGSettings *m_contolGsettings = nullptr;
|
||||
// QProcess *m_process = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,49 @@
|
|||
#ifndef __LIB_FUN_H__
|
||||
#define __LIB_FUN_H__
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
|
||||
#define INSTALL_PATH "/.local/share/fonts/kylin-font-viewer/"
|
||||
|
||||
#define WHITESPACE_CHARS "\f \t"
|
||||
#define MATCH_VERSION_STR "Version"
|
||||
|
||||
typedef struct _FontInformation
|
||||
{
|
||||
QString path; /* 路径 */
|
||||
QString name; /* 名称 */
|
||||
QString family; /* 系列 */
|
||||
QString style; /* 样式 */
|
||||
QString type; /* 种类 */
|
||||
QString version; /* 版本 */
|
||||
QString copyright; /* 版权 */
|
||||
QString manufacturer; /* 商标 */
|
||||
QString description; /* 描述 */
|
||||
QString designer; /* 设计师 */
|
||||
QString license; /* 许可证 */
|
||||
} FontInformation;
|
||||
|
||||
typedef struct _ViewData
|
||||
{
|
||||
QString path;
|
||||
QString family;
|
||||
QString style;
|
||||
} ViewData;
|
||||
|
||||
class LibFun
|
||||
{
|
||||
public:
|
||||
static QList<FontInformation> getAllFontInformation(void);
|
||||
static bool installFont(QString path);
|
||||
static bool uninstallFont(QString path);
|
||||
static bool copyFont(QString src , QString dst);
|
||||
static void remove_whitespace(char **ori);
|
||||
static void remove_version(char **ori);
|
||||
static bool chooseFontFile(QString path);
|
||||
static bool caseInsensitiveLessThan(const FontInformation &s1, const FontInformation &s2);
|
||||
static QString getFontInfo(QString path);
|
||||
static bool isFontFile(QString path);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Log 类中实现了 Qt 的日志注册函数并且调用了 kysdk-log 库中的日志模块,调用方需要链接 Qt库 及 kysdk-log 库
|
||||
*/
|
||||
|
||||
#ifndef LOG_HPP_
|
||||
#define LOG_HPP_
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <libkylog.h>
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
|
||||
namespace kabase
|
||||
{
|
||||
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
Log() = default;
|
||||
~Log() = default;
|
||||
|
||||
static void logOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
{
|
||||
QByteArray localMsg = msg.toLocal8Bit();
|
||||
const char *message = localMsg.constData();
|
||||
const char *file = context.file ? context.file : "";
|
||||
const char *function = context.function ? context.function : "";
|
||||
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
klog_debug("%s (%s:%u,%s)\n", message, file, context.line, function);
|
||||
break;
|
||||
case QtInfoMsg:
|
||||
klog_info("%s (%s:%u,%s)\n", message, file, context.line, function);
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
klog_warning("%s (%s:%u,%s)\n", message, file, context.line, function);
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
klog_err("%s (%s:%u,%s)\n", message, file, context.line, function);
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
klog_emerg("%s (%s:%u,%s)\n", message, file, context.line, function);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,88 @@
|
|||
#ifndef QT_WINDOWMANAGE_HPP_
|
||||
#define QT_WINDOWMANAGE_HPP_
|
||||
|
||||
/*
|
||||
* windowmanage 类使用了 kysdk-waylandhelper 库,使用时需要链接 kysdk-waylandhelper 库
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
#include <QWidget>
|
||||
#include <QRect>
|
||||
|
||||
#include <windowmanager/windowmanager.h>
|
||||
#include <ukuistylehelper/ukuistylehelper.h>
|
||||
|
||||
namespace kabase
|
||||
{
|
||||
|
||||
class WindowManage : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
WindowManage() = default;
|
||||
~WindowManage() = default;
|
||||
|
||||
static void setScalingProperties(void)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
#endif
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
#endif
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
static void setMiddleOfScreen(QWidget *w) {
|
||||
int sw = QGuiApplication::primaryScreen()->availableGeometry().width();
|
||||
int sh = QGuiApplication::primaryScreen()->availableGeometry().height();
|
||||
kdk::WindowManager::setGeometry(w->windowHandle(), QRect((sw - w->width()) / 2, (sh - w->height()) / 2, w->width(), w->height()));
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
static void removeHeader(QWidget *w) {
|
||||
kdk::UkuiStyleHelper::self()->removeHeader(w);
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
/* id 的初始值必须为 0 */
|
||||
static void getWindowId(quint32 *id) {
|
||||
connect(kdk::WindowManager::self(), &kdk::WindowManager::windowAdded, [=](const kdk::WindowId &windowId) {
|
||||
if (getpid() == (int)kdk::WindowManager::getPid(windowId) && *id == 0) {
|
||||
*id = windowId.toLongLong();
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
static void keepWindowAbove(const quint32 id) {
|
||||
kdk::WindowManager::keepWindowAbove(id);
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
static void activateWindow(const quint32 id) {
|
||||
kdk::WindowManager::activateWindow(id);
|
||||
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* wayland 下使用窗口置顶接口 desktop 文件需要注意以下两点
|
||||
* 1. 增加字段: X-KDE-Wayland-Interfaces=org_kde_plasma_window_management,org_kde_plasma_activation_feedback,org_kde_kwin_keystate,org_kde_kwin_fake_input,zkde_screencast_unstable_v1
|
||||
* 2. Exec字段需要为绝对路径并且不能携带参数
|
||||
*/
|
||||
|
||||
#endif
|
|
@ -0,0 +1,306 @@
|
|||
/*
|
||||
* BuriedPoint 类使用了 kysdk-log 和 kysdk-diagnostics 库,调用方需要链接 kysdk-log 和 kysdk-diagnostics 库
|
||||
*/
|
||||
|
||||
#ifndef BURIEDPOINT_HPP_
|
||||
#define BURIEDPOINT_HPP_
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
#include <map>
|
||||
|
||||
#include <libkydiagnostics.h>
|
||||
#include <libkylog.h>
|
||||
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace kabase
|
||||
{
|
||||
|
||||
class BuriedPoint
|
||||
{
|
||||
public:
|
||||
BuriedPoint() = default;
|
||||
~BuriedPoint() = default;
|
||||
|
||||
/* 埋点类型 */
|
||||
enum BuriedPointType {
|
||||
FunctionType = 0, /* 功能性打点 */
|
||||
PerformanceType, /* 性能型打点 */
|
||||
StabilityType, /* 稳定型打点 */
|
||||
TestType /* 测试预留 */
|
||||
};
|
||||
|
||||
/* 点位 */
|
||||
/* 规则说明 */
|
||||
/* 0x 00 0 000
|
||||
* | | |
|
||||
* 应用标识 类型标识 点位
|
||||
*/
|
||||
enum PT {
|
||||
KylinIpmsgNicknameModify = 0x010001, /* 昵称修改 */
|
||||
KylinIpmsgOpenSaveDir = 0x010002, /* 打开文件保存目录(主界面入口) */
|
||||
KylinIpmsgMainSearch = 0x010003, /* 主界面搜索 */
|
||||
KylinIpmsgHistorySearch = 0x010004, /* 历史记录搜索 */
|
||||
KylinIpmsgSetTop = 0x010005, /* 设置置顶 */
|
||||
KylinIpmsgModifyFriendNotes = 0x010006, /* 修改好友备注 */
|
||||
KylinIpmsgViewInformation = 0x010007, /* 查看资料 */
|
||||
KylinIpmsgChangeDir = 0x010008, /* 更改目录 */
|
||||
KylinIpmsgCleanCache = 0x010009, /* 清空缓存 */
|
||||
KylinIpmsgClearChatRecord = 0x010010, /* 清空聊天记录 */
|
||||
KylinIpmsgClearSingleChatRecord = 0x010011, /* 清空单人聊天记录 */
|
||||
KylinIpmsgDeleteRecord = 0x010012, /* 删除记录 */
|
||||
KylinIpmsgBatchDelete = 0x010013, /* 批量删除 */
|
||||
KylinIpmsgSendMessage = 0x010014, /* 发送消息 */
|
||||
KylinIpmsgSendFiles = 0x010015, /* 发送文件 */
|
||||
KylinIpmsgSendDir = 0x010016, /* 发送目录 */
|
||||
KylinIpmsgSendScreenshot = 0x010017, /* 发送截屏 */
|
||||
KylinIpmsgResend = 0x010018, /* 重新发送 */
|
||||
KylinIpmsgCopy = 0x010019, /* 复制 */
|
||||
KylinIpmsgOpen = 0x010020, /* 打开 */
|
||||
KylinIpmsgOpenDir = 0x010021, /* 打开目录 */
|
||||
KylinIpmsgSaveAs = 0x010022, /* 另存为 */
|
||||
KylinIpmsgTray = 0x010023, /* 托盘 */
|
||||
|
||||
KylinFontViewInstallFont = 0x020001, /* 安装字体 */
|
||||
KylinFontViewUninstallFont = 0x020002, /* 卸载字体 */
|
||||
KylinFontViewSearchFont = 0x020003, /* 搜索字体 */
|
||||
KylinFontViewApplyFont = 0x020004, /* 应用字体 */
|
||||
KylinFontViewExportFont = 0x020005, /* 导出字体 */
|
||||
KylinFontViewCollectionFont = 0x020006, /* 收藏字体 */
|
||||
KylinFontViewCancelCollectionFont = 0x020007, /* 取消收藏字体 */
|
||||
KylinFontViewFontInformation = 0x020008, /* 字体信息 */
|
||||
KylinFontViewCopywritingChange = 0x020009, /* 文案更改 */
|
||||
KylinFontViewFontSizeChange = 0x020010, /* 预览字号调整 */
|
||||
|
||||
KylinCalaulatorStandardMode = 0x030001, /* 标准模式 */
|
||||
KylinCalaulatorScientificMode = 0x030002, /* 科学模式 */
|
||||
KylinCalaulatorRateMode = 0x030003, /* 汇率模式 */
|
||||
KylinCalaulatorProgrammerMode = 0x030004, /* 程序员模式 */
|
||||
|
||||
KylinWeatherCollection = 0x040001, /* 收藏 */
|
||||
KylinWeatherChangeCity = 0x040002, /* 切换城市 */
|
||||
KylinWeatherCitySearch = 0x040003, /* 城市搜索 */
|
||||
KylinWeatherFullScreen = 0x040004, /* 全屏 */
|
||||
|
||||
KylinPhotoViewerOpenPicture = 0x050001, /* 打开图片 */
|
||||
KylinPhotoViewerSwitchPicture = 0x050002, /* 切换图片 */
|
||||
KylinPhotoViewerFlip = 0x050003, /* 翻转 */
|
||||
KylinPhotoViewerRotate = 0x050004, /* 旋转 */
|
||||
KylinPhotoViewerAddPicture = 0x050005, /* 添加图片 */
|
||||
KylinPhotoViewerZoomInandOut = 0x050006, /* 放大缩小 */
|
||||
KylinPhotoViewerPictureDetails = 0x050007, /* 图片详情 */
|
||||
KylinPhotoViewerCutting = 0x050008, /* 裁剪 */
|
||||
KylinPhotoViewerCoyp = 0x050009, /* 复制 */
|
||||
KylinPhotoViewerPrint = 0x050010, /* 打印 */
|
||||
KylinPhotoViewerDelete = 0x050011, /* 删除 */
|
||||
KylinPhotoViewerSaveAs = 0x050012, /* 另存为 */
|
||||
KylinPhotoViewerRename = 0x050013, /* 重命名 */
|
||||
KylinPhotoViewerSetAsDesktopWallpaper = 0x050014, /* 设置为桌面壁纸 */
|
||||
KylinPhotoViewerShowInFolder = 0x050015, /* 在文件夹中显示 */
|
||||
KylinPhotoViewerPicturePreview = 0x050016, /* 图片预览 */
|
||||
KylinPhotoViewerCurrentPointZoom = 0x050017, /* 当前点缩放 */
|
||||
|
||||
KylinServiceSupportFileUpload = 0x060001, /* 文件上传 */
|
||||
KylinServiceSupportVideoape = 0x060002, /* 录像 */
|
||||
KylinServiceSupportFileCopy = 0x060003, /* 文件拷贝 */
|
||||
KylinServiceSupportJumpOfficicalWebsite = 0x060004, /* 跳转官网主页 */
|
||||
KylinServiceSupportJumpOnlineService = 0x060005, /* 跳转在线客服 */
|
||||
|
||||
KylinPrinterManuallyInstallPrinter = 0x070001, /* 手动安装打印机 */
|
||||
KylinPrinterSetResolution = 0x070002, /* 设置分辨率 */
|
||||
KylinPrinterSetPaperSize = 0x070003, /* 设置纸张大小 */
|
||||
KylinPrinterSetPaperType = 0x070004, /* 设置纸张类型 */
|
||||
KylinPrinterSetCationSource = 0x070005, /* 设置纸盒来源 */
|
||||
KylinPrinterSetDuplexPrint = 0x070006, /* 设置双面打印 */
|
||||
KylinPrinterSetInkType = 0x070007, /* 设置墨水类型 */
|
||||
KylinPrinterADDRemovePrinter = 0x070008, /* 添加删除打印机 */
|
||||
KylinPrinterSetShareStartup = 0x070009, /* 设置共享启动 */
|
||||
KylinPrintTestPage = 0x070010, /* 打印测试页 */
|
||||
KylinPrinterCancelPrintJob = 0x070011, /* 取消打印任务 */
|
||||
KylinPrinterDeletePrintJob = 0x070012, /* 删除打印任务 */
|
||||
KylinPrinterRePrint = 0x070013, /* 重新打印 */
|
||||
KylinPrinterManualyModifyDrive = 0x070014, /* 手动修改驱动 */
|
||||
KylinPrinterRename = 0x070015, /* 重命名 */
|
||||
|
||||
KylinRecorderRecording = 0x080001, /* 录音 */
|
||||
KylinRecorderPlayPause = 0x080002, /* 播放暂停 */
|
||||
KylinRecorderClip = 0x080003, /* 剪辑 */
|
||||
KylinRecorderSign = 0x080004, /* 标记 */
|
||||
KylinRecorderDelete = 0x080005, /* 删除 */
|
||||
KylinRecorderBluetoothRecord = 0x080006, /* 蓝牙录音 */
|
||||
KylinRecorderSaveAs = 0x080007, /* 另存为 */
|
||||
KylinRecorderOpenFileLocation = 0x080008, /* 打开文件位置 */
|
||||
KylinRecorderTopicSwitch = 0x080009, /* 主题切换 */
|
||||
|
||||
KylinCameraPreviewMonitor = 0x090001, /* 预览画面 */
|
||||
KylinCameraSingleShot = 0x090002, /* 单拍 */
|
||||
KylinCameraContinuousShot = 0x090003, /* 连拍 */
|
||||
KylinCameraDelay = 0x090004, /* 延时拍照 */
|
||||
KylinCameraVideotape = 0x090005, /* 录像 */
|
||||
KylinCameraCameraSelection = 0x090006, /* 摄像头选用 */
|
||||
KylinCameraResolutionSelection = 0x090007, /* 分辨率选用 */
|
||||
KylinCameraVideoFormatSelection = 0x090008, /* 视频格式选用 */
|
||||
KylinCameraPictureFormatSelection = 0x090009, /* 图片格式选用 */
|
||||
KylinCameraChangeSavePath = 0x090010, /* 更改存储路径 */
|
||||
KylinCameraThumbnail = 0x090011, /* 缩略图 */
|
||||
KylinCameraGridLine = 0x090012, /* 网格线 */
|
||||
KylinCameraMirrorFun = 0x090013, /* 镜像功能 */
|
||||
|
||||
KylinNotebookOrderList = 0x100001, /* 有序列表 */
|
||||
KylinNotebookUnorderList = 0x100002, /* 无序列表 */
|
||||
KylinNotebookBold = 0x100003, /* 加粗 */
|
||||
KylinNotebookItalics = 0x100004, /* 斜体 */
|
||||
KylinNotebookUnderline = 0x100005, /* 下划线 */
|
||||
KylinNotebookDeleteline = 0x100006, /* 删除线 */
|
||||
KylinNotebookFontSize = 0x100007, /* 字号 */
|
||||
KylinNotebookFontColor = 0x100008, /* 字体颜色 */
|
||||
KylinNotebookInsertPicture = 0x100009, /* 插入图片 */
|
||||
KylinNotebookInterfaceColor = 0x100010, /* 界面配色 */
|
||||
KylinNotebookDeleteCurrent = 0x100011, /* 删除当前 */
|
||||
KylinNotebookUiTop = 0x100012, /* UI 置顶 */
|
||||
KylinNotebookListMode = 0x100013, /* 列表模式 */
|
||||
KylinNotebookIconMode = 0x100014, /* 图标模式 */
|
||||
KylinNotebookNewNote = 0x100015, /* 新建便签 */
|
||||
KylinNotebookSearch = 0x100016, /* 搜索 */
|
||||
KylinNotebookDelete = 0x100017, /* 删除 */
|
||||
KylinNotebookModeChange = 0x100018, /* 模式切换 */
|
||||
|
||||
KylinOsManagerGarbageClean = 0x110001, /* 垃圾清理 */
|
||||
KylinOsManagerFileShredding = 0x110002, /* 文件粉碎 */
|
||||
|
||||
KylinGpuControllerBaseInfo = 0x120001, /* 基本信息 */
|
||||
KylinGpuControllerRunState = 0x120002, /* 运行状态 */
|
||||
KylinGpuControllerDriveInfo = 0x120003, /* 驱动信息 */
|
||||
KylinGpuControllerSwitch = 0x120003, /* 显卡切换 */
|
||||
|
||||
KylinNetworkCheckStartCheck = 0x130001, /* 开始检测 */
|
||||
|
||||
KylinGallerySwitchFolder = 0x140001, /* 切换目录 */
|
||||
KylinGalleryOpenViewer = 0x140002, /* 打开麒麟看图 */
|
||||
|
||||
KylinMobileAssistantAndroidConn = 0x150001, /* 安卓链接 */
|
||||
KylinMobileAssistantPcConn = 0x150002, /* PC链接 */
|
||||
KylinMobileAssistantUsbConn = 0x150003, /* Usb链接 */
|
||||
KylinMobileAssistantWifiConn = 0x150004, /* Wifi链接 */
|
||||
KylinMobileAssistantDeviceDiscovery = 0x150005, /* 设备发现 */
|
||||
KylinMobileAssistantDisconnect = 0x150006, /* 断开链接 */
|
||||
KylinMobileAssistantMobileScreen = 0x150007, /* 手机投屏 */
|
||||
KylinMobileAssistantPcScreen = 0x150008, /* PC 投屏 */
|
||||
KylinMobileAssistantPictureList = 0x150009, /* 图片列表 */
|
||||
KylinMobileAssistantVideoList = 0x150010, /* 视频列表 */
|
||||
KylinMobileAssistantAudioList = 0x150011, /* 音频列表 */
|
||||
KylinMobileAssistantDocList = 0x150012, /* 文档列表 */
|
||||
KylinMobileAssistantQQFileList = 0x150013, /* QQ 文件列表 */
|
||||
KylinMobileAssistantWechatFileList = 0x150014, /* 微信文件列表 */
|
||||
KylinMobileAssistantMobileStorage = 0x150015, /* 手机存储 */
|
||||
KylinMobileAssistantSwitchView = 0x150016, /* 切换视图 */
|
||||
KylinMobileAssistantRefreshList = 0x150017, /* 刷新列表 */
|
||||
KylinMobileAssistantUploadFile = 0x150018, /* 上传文件 */
|
||||
KylinMobileAssistantDownloadFile = 0x150019, /* 下载文件 */
|
||||
KylinMobileAssistantOpenFile = 0x150020, /* 打开文件 */
|
||||
|
||||
KylinScannerOneClickBeautification = 0x160001, /* 一键美化 */
|
||||
KylinScannerRectification = 0x160002, /* 自动纠偏 */
|
||||
KylinScannerTextRecognition = 0x160003, /* 文本识别 */
|
||||
KylinScannerCutting = 0x160004, /* 裁剪 */
|
||||
KylinScannerRotate = 0x160005, /* 旋转 */
|
||||
KylinScannerImage = 0x160006, /* 镜像 */
|
||||
KylinScannerAddWatermark = 0x160007, /* 加水印 */
|
||||
KylinScannerSendMail = 0x160008, /* 发送邮件 */
|
||||
KylinScannerSaveAs = 0x160009, /* 另存为 */
|
||||
KylinScannerSinglePageScan = 0x160010, /* 单页扫描 */
|
||||
KylinScannerMultiPageScan = 0x160011, /* 多页扫描 */
|
||||
|
||||
KylinCalendarMonthDetails = 0x170001, /* 查看月详情 */
|
||||
KylinCalendarMonthSwitch = 0x170002, /* 月切换 */
|
||||
KylinCalendarDoday = 0x170003, /* 定位到今天 */
|
||||
|
||||
TestFunPoint = 0x999999 /* 测试预留 */
|
||||
};
|
||||
|
||||
static bool functionBuriedPoint(AppName packageName, PT point)
|
||||
{
|
||||
static char *messageType = (char *)"FunctionType";
|
||||
char *appName = strdup(Utils::getAppName(packageName).c_str());
|
||||
|
||||
std::string hex;
|
||||
std::stringstream ss;
|
||||
|
||||
ss << std::hex << point;
|
||||
ss >> hex;
|
||||
|
||||
KBuriedPoint pt;
|
||||
pt.key = "FunctionName";
|
||||
pt.value = hex.c_str();
|
||||
|
||||
if (kdk_buried_point(appName, messageType, &pt, 1)) {
|
||||
free(appName);
|
||||
klog_err("kabase: buried point fail !\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
free(appName);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
static bool buriedPoint(AppName packageName, BuriedPointType buriedPointType, std::map<std::string, std::string> data)
|
||||
{
|
||||
char *appName = strdup(Utils::getAppName(packageName).c_str());
|
||||
|
||||
char type[128];
|
||||
memset(type, '\0', sizeof(type));
|
||||
switch (buriedPointType) {
|
||||
case BuriedPointType::FunctionType:
|
||||
strcpy(type, "FunctionType");
|
||||
break;
|
||||
case BuriedPointType::PerformanceType:
|
||||
strcpy(type, "PerformanceType");
|
||||
break;
|
||||
case BuriedPointType::StabilityType:
|
||||
strcpy(type, "StabilityType");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!strlen(type)) {
|
||||
klog_err("kabase: buried point type is empty !\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
int size = data.size();
|
||||
if (size == 0) {
|
||||
klog_err("kabase: buried point data is empty !\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
KBuriedPoint *pt = (KBuriedPoint *)malloc(sizeof(KBuriedPoint) * size);
|
||||
{
|
||||
int i;
|
||||
std::map<std::string, std::string>::iterator it;
|
||||
for (i = 0, it = data.begin(); it != data.end() && i < size; it++, i++) {
|
||||
pt[i].key = it->first.c_str();
|
||||
pt[i].value = it->second.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
if (kdk_buried_point(appName, type, pt, size)) {
|
||||
free(appName);
|
||||
free(pt);
|
||||
klog_err("kabase: buried point fail !\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
free(appName);
|
||||
free(pt);
|
||||
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,88 @@
|
|||
#ifndef UTILS_HPP_
|
||||
#define UTILS_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace kabase
|
||||
{
|
||||
|
||||
/* 应用名 */
|
||||
enum AppName {
|
||||
KylinIpmsg = 0, /* 传书 */
|
||||
KylinFontViewer, /* 字体管理器 */
|
||||
KylinCalculator, /* 麒麟计算器 */
|
||||
KylinGpuController, /* 显卡控制器 */
|
||||
KylinMusic, /* 音乐 */
|
||||
KylinWeather, /* 天气 */
|
||||
KylinPhotoViewer, /* 看图 */
|
||||
KylinServiceSupport, /* 服务与支持 */
|
||||
KylinPrinter, /* 麒麟打印 */
|
||||
KylinCalendar, /* 日历 */
|
||||
KylinRecorder, /* 录音 */
|
||||
KylinCamera, /* 摄像头 */
|
||||
KylinNotebook, /* 便签 */
|
||||
KylinOsManager, /* 麒麟管家 */
|
||||
KylinNetworkCheck, /* 网络检测工具 */
|
||||
KylinGallery, /* 相册 */
|
||||
KylinScanner, /* 扫描 */
|
||||
KylinMobileAssistant, /* 多端协同 */
|
||||
KylinTest /* 测试预留 */
|
||||
};
|
||||
|
||||
class Utils
|
||||
{
|
||||
public:
|
||||
Utils() = default;
|
||||
~Utils() = default;
|
||||
|
||||
static std::string getAppName(AppName appName)
|
||||
{
|
||||
switch (appName) {
|
||||
case AppName::KylinCalculator:
|
||||
return "kylin-calaulator";
|
||||
case AppName::KylinCalendar:
|
||||
return "kylin-calendar";
|
||||
case AppName::KylinCamera:
|
||||
return "kylin-camera";
|
||||
case AppName::KylinFontViewer:
|
||||
return "kylin-font-viewer";
|
||||
case AppName::KylinGpuController:
|
||||
return "kylin-gpu-controller";
|
||||
case AppName::KylinIpmsg:
|
||||
return "kylin-ipmsg";
|
||||
case AppName::KylinMusic:
|
||||
return "kylin-music";
|
||||
case AppName::KylinPhotoViewer:
|
||||
return "kylin-photo-viewer";
|
||||
case AppName::KylinPrinter:
|
||||
return "kylin-printer";
|
||||
case AppName::KylinRecorder:
|
||||
return "kylin-recorder";
|
||||
case AppName::KylinServiceSupport:
|
||||
return "kylin-service-support";
|
||||
case AppName::KylinWeather:
|
||||
return "kylin-weather";
|
||||
case AppName::KylinNotebook:
|
||||
return "kylin-notebook";
|
||||
case AppName::KylinOsManager:
|
||||
return "kylin-os-manager";
|
||||
case AppName::KylinNetworkCheck:
|
||||
return "kylin-network-check-tools";
|
||||
case AppName::KylinGallery:
|
||||
return "kylin-gallery";
|
||||
case AppName::KylinScanner:
|
||||
return "kylin-scanner";
|
||||
case AppName::KylinMobileAssistant:
|
||||
return "kylin-mobile-assistant";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
||||
/* 不应该被执行 */
|
||||
return "";
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,118 @@
|
|||
QT += widgets core dbus KWindowSystem
|
||||
|
||||
QMAKE_CXXFLAGS += -Wall -g
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
TARGET = kylin-font-viewer
|
||||
|
||||
#check Qt version
|
||||
QT_VERSION = $$[QT_VERSION]
|
||||
QT_VERSION = $$split(QT_VERSION, ".")
|
||||
QT_VER_MAJ = $$member(QT_VERSION, 0)
|
||||
QT_VER_MIN = $$member(QT_VERSION, 1)
|
||||
|
||||
# about widget version
|
||||
VERSION = 1.1.0-13
|
||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||
|
||||
CONFIG += link_pkgconfig c++11
|
||||
|
||||
PKGCONFIG += gio-2.0 glib-2.0 gobject-2.0 gsettings-qt freetype2 fontconfig
|
||||
|
||||
# 配置kysdk
|
||||
PKGCONFIG += kysdk-qtwidgets kysdk-waylandhelper kysdk-alm kysdk-ukenv kysdk-log kysdk-diagnostics
|
||||
|
||||
INCLUDEPATH += \
|
||||
kabase/ \
|
||||
kabase/Qt
|
||||
|
||||
LIBS += -lfontconfig -lfreetype
|
||||
|
||||
SOURCES += $$PWD/src/main.cc \
|
||||
$$PWD/src/core.cc \
|
||||
$$PWD/src/libfun.cc \
|
||||
$$PWD/src/external.cc \
|
||||
$$PWD/src/view/baseiconbutton.cc \
|
||||
$$PWD/src/view/basepopuptitle.cc \
|
||||
$$PWD/src/view/basepreviewarea.cc \
|
||||
$$PWD/src/view/basesearchedit.cc \
|
||||
$$PWD/src/view/fontlistdelegate.cc \
|
||||
$$PWD/src/view/fontlistfilter.cc \
|
||||
$$PWD/src/view/fontlistmodel.cc \
|
||||
$$PWD/src/view/fontlistview.cc \
|
||||
$$PWD/src/view/fontwid.cc \
|
||||
$$PWD/src/view/functionwid.cc \
|
||||
$$PWD/src/view/globalsizedata.cc \
|
||||
$$PWD/src/view/mainview.cc \
|
||||
$$PWD/src/view/picturetowhite.cc \
|
||||
$$PWD/src/view/popupfontinfo.cc \
|
||||
$$PWD/src/view/popupinstallfail.cc \
|
||||
$$PWD/src/view/popupinstallsuccess.cc \
|
||||
$$PWD/src/view/popupremove.cc \
|
||||
$$PWD/src/view/titlebar.cc \
|
||||
$$PWD/src/view/getfontthread.cc \
|
||||
$$PWD/src/view/popuptips.cc \
|
||||
$$PWD/src/view/blankpage.cc \
|
||||
$$PWD/src/view/rotatechangeinfo.cc
|
||||
|
||||
HEADERS += $$PWD/include/core.h \
|
||||
$$PWD/include/libfun.h \
|
||||
$$PWD/include/external.h \
|
||||
$$PWD/src/view/baseiconbutton.h \
|
||||
$$PWD/src/view/basepopuptitle.h \
|
||||
$$PWD/src/view/basepreviewarea.h \
|
||||
$$PWD/src/view/basesearchedit.h \
|
||||
$$PWD/src/view/fontlistdelegate.h \
|
||||
$$PWD/src/view/fontlistfilter.h \
|
||||
$$PWD/src/view/fontlistmodel.h \
|
||||
$$PWD/src/view/fontlistview.h \
|
||||
$$PWD/src/view/fontwid.h \
|
||||
$$PWD/src/view/functionwid.h \
|
||||
$$PWD/src/view/globalsizedata.h \
|
||||
$$PWD/src/view/mainview.h \
|
||||
$$PWD/src/view/picturetowhite.h \
|
||||
$$PWD/src/view/popupfontinfo.h \
|
||||
$$PWD/src/view/popupinstallfail.h \
|
||||
$$PWD/src/view/popupinstallsuccess.h \
|
||||
$$PWD/src/view/popupremove.h \
|
||||
$$PWD/src/view/titlebar.h \
|
||||
$$PWD/src/view/getfontthread.h \
|
||||
$$PWD/src/view/popuptips.h \
|
||||
$$PWD/src/view/blankpage.h \
|
||||
$$PWD/src/view/rotatechangeinfo.h
|
||||
|
||||
# 翻译
|
||||
TRANSLATIONS = data/translations/kylin-font-viewer_zh_CN.ts
|
||||
TRANSLATIONS = data/translations/kylin-font-viewer_bo_CN.ts
|
||||
|
||||
!system($$PWD/data/translations/generate_translations_pm.sh): error("Failed to generate pm")
|
||||
|
||||
# 安装
|
||||
qm_file.files = $$PWD/data/translations/*.qm
|
||||
qm_file.path = /usr/share/kylin-font-viewer/data/translations/
|
||||
|
||||
gsettings.files = $$PWD/data/org.kylin.font.viewer.gschema.xml
|
||||
gsettings.path = /usr/share/glib-2.0/schemas/
|
||||
|
||||
logger.files = $$PWD/data/org.ukui.log4qt.kylin-font-view.gschema.xml
|
||||
logger.path = /usr/share/glib-2.0/schemas/
|
||||
|
||||
bin.files = $$TARGET
|
||||
bin.path = /usr/bin/
|
||||
|
||||
guide.files = $$PWD/data/guide/kylin-font-viewer/
|
||||
guide.path = /usr/share/kylin-user-guide/data/guide
|
||||
|
||||
desktop.files = $$PWD/data/kylin-font-viewer.desktop
|
||||
desktop.path = /usr/share/applications/
|
||||
|
||||
INSTALLS += qm_file \
|
||||
gsettings \
|
||||
bin \
|
||||
guide \
|
||||
logger \
|
||||
desktop \
|
||||
|
||||
RESOURCES += \
|
||||
image.qrc
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
qmake .
|
||||
make clean
|
||||
make distclean
|
|
@ -0,0 +1,334 @@
|
|||
#include "include/core.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QList>
|
||||
#include <QStandardPaths>
|
||||
|
||||
Core::Core()
|
||||
{
|
||||
this->slotStart();
|
||||
}
|
||||
|
||||
Core::~Core()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Core *Core::getInstance(void)
|
||||
{
|
||||
static Core instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
bool Core::init(void)
|
||||
{
|
||||
this->m_installPath = QStandardPaths::writableLocation(QStandardPaths::FontsLocation) + "/";
|
||||
|
||||
this->m_fontData = LibFun::getAllFontInformation();
|
||||
|
||||
QList<QString> collectFontPaths = this->m_external.getCollectFont();
|
||||
for (int i = 0 ; i < collectFontPaths.count() ; i++) {
|
||||
QString path = collectFontPaths.at(i);
|
||||
for (int j = 0 ; j < this->m_fontData.count() ; j++) {
|
||||
if (this->m_fontData.at(j).path == path) {
|
||||
this->m_collectFontData << this->m_fontData.at(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QList<ViewData> Core::getViewData(void)
|
||||
{
|
||||
QList<ViewData> ret;
|
||||
ret.clear();
|
||||
|
||||
for (int i = 0 ; i < this->m_fontData.count() ; i++) {
|
||||
ViewData item;
|
||||
FontInformation tmp = this->m_fontData.at(i);
|
||||
|
||||
item.path = tmp.path;
|
||||
item.family = tmp.family;
|
||||
item.style = tmp.style;
|
||||
|
||||
ret << item;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
FontInformation Core::getFontDetails(QString path)
|
||||
{
|
||||
FontInformation ret;
|
||||
|
||||
for (int i = 0 ; i < this->m_fontData.count() ; i++) {
|
||||
if (this->m_fontData.at(i).path == path) {
|
||||
ret = this->m_fontData.at(i);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QList<ViewData> Core::getSystemFont(void)
|
||||
{
|
||||
QList<ViewData> ret;
|
||||
|
||||
for (int i = 0 ; i < this->m_fontData.count() ; i++) {
|
||||
FontInformation item = this->m_fontData.at(i);
|
||||
|
||||
if (!item.path.contains(this->m_installPath)) {
|
||||
ViewData tmp;
|
||||
tmp.path = item.path;
|
||||
tmp.family = item.family;
|
||||
tmp.style = item.style;
|
||||
|
||||
ret << tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QList<ViewData> Core::getMyFont(void)
|
||||
{
|
||||
QList<ViewData> ret;
|
||||
|
||||
for (int i = 0 ; i < this->m_fontData.count() ; i++) {
|
||||
FontInformation item = this->m_fontData.at(i);
|
||||
|
||||
if (item.path.contains(this->m_installPath)) {
|
||||
ViewData tmp;
|
||||
tmp.path = item.path;
|
||||
tmp.family = item.family;
|
||||
tmp.style = item.style;
|
||||
|
||||
ret << tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QList<ViewData> Core::getCollectFont(void)
|
||||
{
|
||||
QList<ViewData> ret;
|
||||
|
||||
for (int i = 0 ; i < this->m_collectFontData.count() ; i++) {
|
||||
FontInformation item = this->m_collectFontData.at(i);
|
||||
ViewData tmp;
|
||||
tmp.path = item.path;
|
||||
tmp.family = item.family;
|
||||
tmp.style = item.style;
|
||||
|
||||
ret << tmp;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Core::unCollectFont(QString path)
|
||||
{
|
||||
for (int i = 0 ; i < this->m_collectFontData.count() ; i++) {
|
||||
FontInformation item = this->m_collectFontData.at(i);
|
||||
|
||||
if (item.path == path) {
|
||||
if (!this->m_external.removeCollectFont(item.path)) {
|
||||
qCritical() << "Error : Core , unCollectFont , font cancel collect fail";
|
||||
return false;
|
||||
}
|
||||
|
||||
this->m_collectFontData.removeAt(i);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Core::collectFont(QString path)
|
||||
{
|
||||
FontInformation item;
|
||||
|
||||
for (int i = 0 ; i < this->m_fontData.count() ; i++) {
|
||||
if (this->m_fontData.at(i).path == path) {
|
||||
item = this->m_fontData.at(i);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (item.path.isEmpty()) {
|
||||
qCritical() << "Error : Core , collectFont , font not found";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this->m_external.addCollectFont(item.path)) {
|
||||
qCritical() << "Error : Core , collectFont , font collect fail";
|
||||
return false;
|
||||
}
|
||||
|
||||
this->m_collectFontData << item;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Core::installFont(QString path)
|
||||
{
|
||||
if (!LibFun::installFont(path)) {
|
||||
qCritical() << "Error : Core , installFont , font install fail";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Core::uninstallFont(QString path, QString fontName)
|
||||
{
|
||||
qDebug() << "remove font :" << fontName;
|
||||
if (m_external.removeFontFormContro(fontName) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0 ; i < this->m_fontData.count() ; i++) {
|
||||
if (this->m_fontData.at(i).path == path) {
|
||||
if (!LibFun::uninstallFont(this->m_fontData.at(i).path)) {
|
||||
qCritical() << "Error : Core , uninstallFont , font uninstall fail";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int j = 0 ; j < this->m_collectFontData.count() ; j++) {
|
||||
if (this->m_collectFontData.at(j).path == path) {
|
||||
if (!this->m_external.removeCollectFont(this->m_collectFontData.at(j).path)) {
|
||||
qWarning() << "Waring : Core , remove collect font fail";
|
||||
}
|
||||
|
||||
this->m_collectFontData.removeAt(j);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this->m_fontData.removeAt(i);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Core::copyFont(QString srcPath , QString dstPath)
|
||||
{
|
||||
for (int i = 0 ; i < this->m_fontData.count() ; i++) {
|
||||
if (this->m_fontData.at(i).path == srcPath) {
|
||||
if (!LibFun::copyFont(this->m_fontData.at(i).path , dstPath)) {
|
||||
qCritical() << "Error : Core , copyFont , copy font fail";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Core::isSystemFont(QString path)
|
||||
{
|
||||
for (int i = 0 ; i < this->m_fontData.count() ; i++) {
|
||||
FontInformation item = this->m_fontData.at(i);
|
||||
|
||||
if (item.path == path) {
|
||||
if (item.path.contains(this->m_installPath)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Core::applyFont(QString family)
|
||||
{
|
||||
return this->m_external.applyFont(family);
|
||||
}
|
||||
|
||||
void Core::slotStart(void)
|
||||
{
|
||||
if (!this->init()) {
|
||||
qCritical() << "Error : Core , Core , init fail";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void Core::printFontData(void)
|
||||
{
|
||||
for (int i = 0 ; i < this->m_fontData.count() ; i++) {
|
||||
FontInformation item = this->m_fontData.at(i);
|
||||
|
||||
qDebug() << "**************************************************************************************************************";
|
||||
|
||||
qDebug() << " path : " << item.path << " name : " << item.name << " famile : " << item.family << "\n"
|
||||
<< " style : " << item.style << " type : " << item.type << " version " << item.version << "\n"
|
||||
<< " copyright : " << item.copyright << "\n"
|
||||
<< " manufacturer : " << item.manufacturer << "\n"
|
||||
<< " description : " << item.description << "\n"
|
||||
<< " designer : " << item.designer << "\n"
|
||||
<< " license : " << item.license;
|
||||
}
|
||||
|
||||
qDebug() << "**************************************************************************************************************";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QString Core::ControlUsingFont()
|
||||
{
|
||||
QString font = m_external.isUsingFont();
|
||||
qDebug() << "当前正在使用的字体是: " << font;
|
||||
return font;
|
||||
}
|
||||
|
||||
void Core::updateFontList()
|
||||
{
|
||||
/* PRO : 此处先重新获取全部字体信息来处理 , 后续优化为获取单个字体信息 */
|
||||
this->m_fontData = LibFun::getAllFontInformation();
|
||||
return;
|
||||
}
|
||||
|
||||
bool Core::judgeBadFontFile(QString path)
|
||||
{
|
||||
// 判断文件是否为损坏文件
|
||||
if (LibFun::getFontInfo(path) == path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Core::getSettingFontTips()
|
||||
{
|
||||
bool setTips = m_external.getFontTipsData();
|
||||
return setTips;
|
||||
}
|
||||
|
||||
bool Core::settingFontTips(bool state)
|
||||
{
|
||||
bool setTips = m_external.setFontIntoList(state);
|
||||
return setTips;
|
||||
}
|
|
@ -0,0 +1,214 @@
|
|||
#include <QDebug>
|
||||
#include <QProcess>
|
||||
|
||||
#include "include/external.h"
|
||||
|
||||
#define KYLIN_FONT_VIEWER_GSETTINGS "org.kylin.font.viewer.gsettings"
|
||||
#define COLLECT_FONT_KEY "collect-font"
|
||||
#define TIPS_FONT_KEY "setting-font-tips"
|
||||
#define THEME_GSETTINGS "org.ukui.style"
|
||||
#define APPLY_FONT_KEY "system-font"
|
||||
#define KYLIN_CONTROL_CENTER_GSETTINGS "org.ukui.control-center"
|
||||
#define FONTS_LIST "fonts-list"
|
||||
|
||||
External::External()
|
||||
{
|
||||
if (QGSettings::isSchemaInstalled(KYLIN_FONT_VIEWER_GSETTINGS)) {
|
||||
this->m_gsettings = new QGSettings(KYLIN_FONT_VIEWER_GSETTINGS);
|
||||
} else {
|
||||
qCritical() << "Error : External , External , create gsettings fail";
|
||||
}
|
||||
|
||||
if (QGSettings::isSchemaInstalled(THEME_GSETTINGS)) {
|
||||
this->m_themeGsettings = new QGSettings(THEME_GSETTINGS);
|
||||
} else {
|
||||
qCritical() << "Error : External , External , create theme gsettings fail";
|
||||
}
|
||||
|
||||
if (QGSettings::isSchemaInstalled(KYLIN_CONTROL_CENTER_GSETTINGS)) {
|
||||
this->m_contolGsettings = new QGSettings(KYLIN_CONTROL_CENTER_GSETTINGS);
|
||||
} else {
|
||||
qCritical() << "Error : External , External , create theme gsettings fail";
|
||||
}
|
||||
// m_process = new QProcess(this);
|
||||
}
|
||||
|
||||
External::~External()
|
||||
{
|
||||
if (this->m_gsettings != nullptr) {
|
||||
delete this->m_gsettings;
|
||||
}
|
||||
if (this->m_themeGsettings != nullptr) {
|
||||
delete this->m_themeGsettings;
|
||||
}
|
||||
if (this->m_contolGsettings != nullptr) {
|
||||
delete this->m_contolGsettings;
|
||||
}
|
||||
// if (this->m_process != nullptr) {
|
||||
// delete this->m_process;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
QList<QString> External::getCollectFont(void)
|
||||
{
|
||||
QList<QString> ret;
|
||||
ret.clear();
|
||||
|
||||
if (this->m_gsettings == nullptr) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString paths = this->m_gsettings->get(COLLECT_FONT_KEY).toString();
|
||||
|
||||
ret = paths.split(';');
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool External::addCollectFont(QString path)
|
||||
{
|
||||
if (this->m_gsettings == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString paths = this->m_gsettings->get(COLLECT_FONT_KEY).toString();
|
||||
|
||||
if (paths.isEmpty()) {
|
||||
paths.append(path);
|
||||
} else {
|
||||
paths.append(";");
|
||||
paths.append(path);
|
||||
}
|
||||
|
||||
this->m_gsettings->set(COLLECT_FONT_KEY , paths);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool External::removeCollectFont(QString path)
|
||||
{
|
||||
if (this->m_gsettings == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString paths = this->m_gsettings->get(COLLECT_FONT_KEY).toString();
|
||||
|
||||
QList<QString> tmp = paths.split(';');
|
||||
QString dst;
|
||||
dst.clear();
|
||||
|
||||
for (int i = 0 ; i < tmp.count() ; i++) {
|
||||
if (tmp.at(i) != path) {
|
||||
if (dst.isEmpty()) {
|
||||
dst.append(tmp.at(i));
|
||||
} else {
|
||||
dst.append(';');
|
||||
dst.append(tmp.at(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->m_gsettings->set(COLLECT_FONT_KEY , dst);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool External::applyFont(QString family)
|
||||
{
|
||||
qDebug() << "apply font name "<< family;
|
||||
if (setFontIntoList(family) != true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->m_themeGsettings->set(APPLY_FONT_KEY, family);
|
||||
// QString cmd = "ukui-control-center -m fonts";
|
||||
// m_process->startDetached(cmd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QStringList External::getFontFromControl()
|
||||
{
|
||||
QStringList fontList;
|
||||
fontList.clear();
|
||||
|
||||
if (this->m_contolGsettings == nullptr) {
|
||||
qCritical() << "Error : gsettings fail , org.ukui.control-center";
|
||||
return fontList;
|
||||
}
|
||||
|
||||
fontList = this->m_contolGsettings->get(FONTS_LIST).toStringList();
|
||||
|
||||
return fontList;
|
||||
}
|
||||
|
||||
bool External::setFontIntoList(QString font)
|
||||
{
|
||||
QStringList fontList;
|
||||
fontList.clear();
|
||||
fontList = getFontFromControl();
|
||||
if (fontList.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (!fontList.contains(font)) {
|
||||
fontList.append(font);
|
||||
}
|
||||
m_contolGsettings->set(FONTS_LIST, fontList);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString External::isUsingFont()
|
||||
{
|
||||
QString font = "";
|
||||
if (this->m_themeGsettings == nullptr) {
|
||||
qCritical() << "Error : gsettings fail , org.ukui.style";
|
||||
return font;
|
||||
}
|
||||
font = this->m_themeGsettings->get(APPLY_FONT_KEY).toString();
|
||||
qDebug() << "using font name: " << font;
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
bool External::removeFontFormContro(QString font)
|
||||
{
|
||||
QStringList fontList;
|
||||
fontList.clear();
|
||||
fontList = getFontFromControl();
|
||||
if (fontList.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (font == isUsingFont()) {
|
||||
return false;
|
||||
}
|
||||
if (fontList.contains(font)) {
|
||||
fontList.removeOne(font);
|
||||
}
|
||||
m_contolGsettings->set(FONTS_LIST, fontList);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool External::getFontTipsData()
|
||||
{
|
||||
bool settingTips;
|
||||
if (this->m_gsettings == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
settingTips = this->m_gsettings->get(TIPS_FONT_KEY).toBool();
|
||||
|
||||
return settingTips;
|
||||
}
|
||||
|
||||
bool External::setFontIntoList(bool state)
|
||||
{
|
||||
if (this->m_gsettings == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->m_gsettings->set(TIPS_FONT_KEY , state);
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,459 @@
|
|||
#include <gio/gio.h>
|
||||
#include <fontconfig/fontconfig.h>
|
||||
#include <freetype2/ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_TYPE1_TABLES_H
|
||||
#include FT_SFNT_NAMES_H
|
||||
#include FT_TRUETYPE_IDS_H
|
||||
#include FT_MULTIPLE_MASTERS_H
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QProcess>
|
||||
|
||||
#include "include/libfun.h"
|
||||
|
||||
void LibFun::remove_whitespace(char **ori)
|
||||
{
|
||||
g_auto(GStrv) split = NULL;
|
||||
g_autoptr(GString) reassembled = NULL;
|
||||
gchar *str = NULL;
|
||||
gint i = 0;
|
||||
gint stripped = 0;
|
||||
size_t len = 0;
|
||||
|
||||
reassembled = g_string_new(NULL);
|
||||
|
||||
split = g_strsplit(*ori , "\n" , -1);
|
||||
|
||||
for (i = 0 ; split[i] != NULL ; i++) {
|
||||
str = split[i];
|
||||
|
||||
len = strspn(str , WHITESPACE_CHARS);
|
||||
if (len) {
|
||||
str += len;
|
||||
}
|
||||
|
||||
if (strlen(str) == 0 && ((split[i + 1] == NULL) || (strlen(split[i + 1]) == 0))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stripped++ > 0) {
|
||||
g_string_append(reassembled , "\n");
|
||||
}
|
||||
|
||||
g_string_append(reassembled , str);
|
||||
}
|
||||
|
||||
g_free(*ori);
|
||||
*ori = g_strdup(reassembled->str);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void LibFun::remove_version(char **ori)
|
||||
{
|
||||
gchar *p = NULL;
|
||||
gchar *stripped = NULL;
|
||||
|
||||
p = g_strstr_len(*ori , -1 , MATCH_VERSION_STR);
|
||||
if (p == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p += strlen(MATCH_VERSION_STR);
|
||||
stripped = g_strdup(p);
|
||||
|
||||
remove_whitespace(&stripped);
|
||||
|
||||
g_free(*ori);
|
||||
*ori = stripped;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QList<FontInformation> LibFun::getAllFontInformation(void)
|
||||
{
|
||||
QList<FontInformation> ret;
|
||||
ret.clear();
|
||||
|
||||
FT_Library ft_library;
|
||||
FT_Error err = FT_Init_FreeType(&ft_library);
|
||||
|
||||
if (err != FT_Err_Ok) {
|
||||
qCritical() << "Error : LibFun , getAllFontInformation , init freetype fail";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!FcInitReinitialize()) {
|
||||
qCritical() << "Error : LibFun , getAllFontInformation , init font list fail";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
FcConfig *config = FcInitLoadConfigAndFonts();
|
||||
FcPattern *pat = FcPatternCreate();
|
||||
FcObjectSet *os = FcObjectSetBuild(FC_FILE , FC_FAMILY , FC_STYLE , FC_INDEX , NULL);
|
||||
|
||||
FcFontSet *fs = FcFontList(config , pat , os);
|
||||
|
||||
qInfo() << "Info : LibFun , getAllFontInformation , total matching fonts is " << fs->nfont;
|
||||
|
||||
for (int i = 0 ; i < fs->nfont && fs != NULL ; i++) {
|
||||
FontInformation item;
|
||||
FcChar8 *path = NULL;
|
||||
FcChar8 *family = NULL;
|
||||
FcChar8 *style = NULL;
|
||||
int index;
|
||||
|
||||
FcPattern *font = fs->fonts[i];
|
||||
|
||||
if (FcPatternGetString(font , FC_FILE , 0 , &path) == FcResultMatch &&
|
||||
FcPatternGetString(font , FC_FAMILY , 0 , &family) == FcResultMatch &&
|
||||
FcPatternGetString(font , FC_STYLE , 0 , &style) == FcResultMatch &&
|
||||
FcPatternGetInteger(font , FC_INDEX , 0 , &index) == FcResultMatch)
|
||||
{
|
||||
item.path = QString((char *)path);
|
||||
item.family = QString((char *)family);
|
||||
item.style = QString((char *)style);
|
||||
}
|
||||
|
||||
/* 对字体文件进行判断(判断后缀名是否为.ttf .otf)*/
|
||||
if (!chooseFontFile(item.path)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
gchar *fontData = NULL;
|
||||
gsize fontDataLenth;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
GFile *fd = g_file_new_for_path((const gchar *)path);
|
||||
if (!g_file_load_contents(fd , NULL , &fontData , &fontDataLenth , NULL , &error)) {
|
||||
qWarning() << "Waring : LibFun , getAllFontInformation , load font file fail , Path is [ " << path << " ]" << " error is [ " << error->message << " ]";
|
||||
|
||||
ret << item;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
FT_Error ft_error;
|
||||
FT_Face ft_retval;
|
||||
|
||||
ft_error = FT_New_Memory_Face(ft_library , (const FT_Byte *)fontData , (FT_Long)fontDataLenth , index , &ft_retval);
|
||||
if (ft_error != FT_Err_Ok) {
|
||||
qWarning() << "Waring : LibFun , getAllFontInformation , read font data fail , Path is [ " << path << " ]";
|
||||
|
||||
ret << item;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* 名字 */
|
||||
if (ft_retval->family_name) {
|
||||
item.name = QString((char *)ft_retval->family_name);
|
||||
}
|
||||
|
||||
/* 样式 */
|
||||
if (ft_retval->style_name) {
|
||||
item.style = QString((char *)ft_retval->style_name);
|
||||
}
|
||||
|
||||
/* 路径 */
|
||||
g_autofree gchar *location = NULL;
|
||||
location = g_file_get_path(fd);
|
||||
item.path = QString((char *)location);
|
||||
|
||||
/* 种类 */
|
||||
g_autoptr(GFileInfo) fileInfo;
|
||||
fileInfo = g_file_query_info(fd , G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," G_FILE_ATTRIBUTE_STANDARD_SIZE , G_FILE_QUERY_INFO_NONE , NULL , NULL);
|
||||
if (fileInfo != NULL) {
|
||||
g_autofree gchar *fileType = g_content_type_get_description(g_file_info_get_content_type(fileInfo));
|
||||
|
||||
item.type = QString((char *)fileType);
|
||||
}
|
||||
|
||||
if (FT_IS_SFNT(ft_retval)) {
|
||||
gint i;
|
||||
gint len;
|
||||
g_autofree gchar *version = NULL;
|
||||
g_autofree gchar *copyright = NULL;
|
||||
g_autofree gchar *description = NULL;
|
||||
g_autofree gchar *designer = NULL;
|
||||
g_autofree gchar *manufacturer = NULL;
|
||||
g_autofree gchar *license = NULL;
|
||||
|
||||
len = FT_Get_Sfnt_Name_Count(ft_retval);
|
||||
|
||||
for (i = 0 ; i < len ; i++) {
|
||||
FT_SfntName ft_sname;
|
||||
|
||||
if (FT_Get_Sfnt_Name(ft_retval , i , &ft_sname) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(ft_sname.platform_id == TT_PLATFORM_MICROSOFT &&
|
||||
ft_sname.encoding_id == TT_MS_ID_UNICODE_CS &&
|
||||
ft_sname.language_id == TT_MS_LANGID_ENGLISH_UNITED_STATES))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (ft_sname.name_id) {
|
||||
case TT_NAME_ID_COPYRIGHT :
|
||||
if (!copyright) {
|
||||
copyright = g_convert((gchar *)ft_sname.string , ft_sname.string_len , "UTF-8" , "UTF-16BE" , NULL , NULL , NULL);
|
||||
}
|
||||
break;
|
||||
case TT_NAME_ID_VERSION_STRING :
|
||||
if (!version) {
|
||||
version = g_convert((gchar *)ft_sname.string , ft_sname.string_len , "UTF-8" , "UTF-16BE" , NULL , NULL , NULL);
|
||||
}
|
||||
break;
|
||||
case TT_NAME_ID_DESCRIPTION :
|
||||
if (!description) {
|
||||
description = g_convert((gchar *)ft_sname.string , ft_sname.string_len , "UTF-8" , "UTF-16BE" , NULL , NULL , NULL);
|
||||
}
|
||||
break;
|
||||
case TT_NAME_ID_MANUFACTURER :
|
||||
if (!manufacturer) {
|
||||
manufacturer = g_convert((gchar *)ft_sname.string , ft_sname.string_len , "UTF-8" , "UTF-16BE" , NULL , NULL , NULL);
|
||||
}
|
||||
break;
|
||||
case TT_NAME_ID_DESIGNER :
|
||||
if (!designer) {
|
||||
designer = g_convert((gchar *)ft_sname.string , ft_sname.string_len , "UTF-8" , "UTF-16BE" , NULL , NULL , NULL);
|
||||
}
|
||||
break;
|
||||
case TT_NAME_ID_LICENSE :
|
||||
if (!license) {
|
||||
license = g_convert((gchar *)ft_sname.string , ft_sname.string_len , "UTF-8" , "UTF-16BE" , NULL , NULL , NULL);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* 版本 */
|
||||
if (version) {
|
||||
remove_version(&version);
|
||||
item.version = QString((char *)version);
|
||||
}
|
||||
|
||||
/* 版权 */
|
||||
if (copyright) {
|
||||
remove_whitespace(©right);
|
||||
item.copyright = QString((char *)copyright);
|
||||
}
|
||||
|
||||
/* 描述 */
|
||||
if (description) {
|
||||
remove_whitespace(&description);
|
||||
item.description = QString((char *)description);
|
||||
}
|
||||
|
||||
/* 商标 */
|
||||
if (manufacturer) {
|
||||
remove_whitespace(&manufacturer);
|
||||
item.manufacturer = QString((char *)manufacturer);
|
||||
}
|
||||
|
||||
/* 设计师 */
|
||||
if (designer) {
|
||||
remove_whitespace(&designer);
|
||||
item.designer = QString((char *)designer);
|
||||
}
|
||||
|
||||
/* 许可证 */
|
||||
if (license) {
|
||||
remove_whitespace(&license);
|
||||
item.license = QString((char *)license);
|
||||
}
|
||||
}
|
||||
ret << item;
|
||||
|
||||
FT_Done_Face(ft_retval);
|
||||
g_object_unref(fd);
|
||||
g_free(fontData);
|
||||
}
|
||||
|
||||
if (pat) {
|
||||
FcPatternDestroy(pat);
|
||||
}
|
||||
|
||||
if (os) {
|
||||
FcObjectSetDestroy(os);
|
||||
}
|
||||
|
||||
if (fs) {
|
||||
FcFontSetDestroy(fs);
|
||||
}
|
||||
|
||||
qSort(ret.begin(), ret.end(), caseInsensitiveLessThan);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool LibFun::installFont(QString path)
|
||||
{
|
||||
if (path.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString installPath = QString(getenv("HOME")) + QString(INSTALL_PATH);
|
||||
|
||||
QDir dir(installPath);
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkpath(installPath)) {
|
||||
qCritical() << "Error : LibFun , installFont , install path create fail";
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QFileInfo fileInfo(path);
|
||||
QString installFilePath = installPath + fileInfo.fileName();
|
||||
|
||||
QFile file(installFilePath);
|
||||
if (!file.exists()) {
|
||||
if (!QFile::copy(path , installFilePath)) {
|
||||
qCritical() << "Error : LibFun , installFont , copy font file fail";
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (system("fc-cache")) {
|
||||
qWarning() << "Waring : LibFun , installFont , update cache fail";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LibFun::uninstallFont(QString path)
|
||||
{
|
||||
if (path.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile file(path);
|
||||
if (file.exists()) {
|
||||
if (!file.remove()) {
|
||||
qCritical() << "Error : LibFun , uninstallFont , remove font file fail";
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (system("fc-cache")) {
|
||||
qWarning() << "Waring : LibFun , uninstall , update font cache fail";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LibFun::copyFont(QString src , QString dst)
|
||||
{
|
||||
if (src.isEmpty() || dst.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString dstName;
|
||||
QFileInfo fileInfo(src);
|
||||
if (dst.back() == QChar('/')) {
|
||||
dstName = dst + fileInfo.fileName();
|
||||
} else {
|
||||
dstName = dst + "/" + fileInfo.fileName();
|
||||
}
|
||||
|
||||
if (!QFile::copy(src , dstName)) {
|
||||
qCritical() << "Error : LibFun , copyFont , font file copy fail";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LibFun::chooseFontFile(QString path)
|
||||
{
|
||||
QStringList list = path.split(".");
|
||||
QString fontTypeTTF = "ttf";
|
||||
QString fontTypeOTF = "otf";
|
||||
QString fontType = list.at(list.size()-1);
|
||||
|
||||
if (fontType.compare(fontTypeTTF, Qt::CaseInsensitive) == 0) {
|
||||
return true;
|
||||
} else if (fontType.compare(fontTypeOTF, Qt::CaseInsensitive) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LibFun::caseInsensitiveLessThan(const FontInformation &s1, const FontInformation &s2)
|
||||
{
|
||||
if (s1.family == s2.family){
|
||||
return s1.style > s2.style;
|
||||
}
|
||||
return s1.family > s2.family;
|
||||
}
|
||||
|
||||
QString LibFun::getFontInfo(QString path)
|
||||
{
|
||||
QString ret;
|
||||
ret.clear();
|
||||
|
||||
// 判断后缀
|
||||
if (!chooseFontFile(path)) {
|
||||
qDebug() << "判断字体文件后缀,字体文件损坏:" <<__FILE__<< ","<<__FUNCTION__<<","<<__LINE__;
|
||||
ret = path;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 判断文件type类型
|
||||
if (isFontFile(path) != true) {
|
||||
qDebug() << "判断字体文件type类型,字体文件损坏:" <<__FILE__<< ","<<__FUNCTION__<<","<<__LINE__;
|
||||
ret = path;
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string str = path.toStdString();
|
||||
FcChar8* file = (FcChar8*)(str.c_str());
|
||||
FcPattern* pat = nullptr;
|
||||
int count;
|
||||
FcBlanks* blanks = FcConfigGetBlanks(NULL);
|
||||
pat = FcFreeTypeQuery((FcChar8 *)file, 0, blanks, &count);
|
||||
|
||||
// 判断是否从字体文件中获取到字体数据
|
||||
if (pat == nullptr) {
|
||||
qDebug() << "判断字体文件,字体文件损坏:" <<__FILE__<< ","<<__FUNCTION__<<","<<__LINE__;
|
||||
ret = path;
|
||||
}
|
||||
|
||||
FcPatternDestroy(pat);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool LibFun::isFontFile(QString path)
|
||||
{
|
||||
QString command = QString("file -i ") + '"' + path + '"';
|
||||
|
||||
QProcess process;
|
||||
process.start(command);
|
||||
|
||||
if (!process.waitForFinished()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString ret = process.readAll();
|
||||
|
||||
if (ret.contains("font/sfnt") || ret.contains("application/vnd.ms-opentype")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
#include <fcntl.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QStandardPaths>
|
||||
#include <QLibraryInfo>
|
||||
#include <QTranslator>
|
||||
#include <QObject>
|
||||
|
||||
/* 适配SDK */
|
||||
#include <singleapplication.h>
|
||||
#include "log.hpp"
|
||||
#include "windowmanage.hpp"
|
||||
|
||||
#include "src/view/mainview.h"
|
||||
|
||||
int main(int argc , char *argv[])
|
||||
{
|
||||
/* 使用sdk管理日志 */
|
||||
qInstallMessageHandler(::kabase::Log::logOutput);
|
||||
|
||||
/* 适配4K屏以及分数缩放 */
|
||||
::kabase::WindowManage::setScalingProperties();
|
||||
|
||||
//加在最上面的原因:防止QApplication将(-title)参数吞掉,导致拿不到
|
||||
QString fontFileName;
|
||||
if (argc > 1) {
|
||||
fontFileName = argv[1];
|
||||
}
|
||||
|
||||
/* 适配4K屏以及分数缩放 */
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
#endif
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
#endif
|
||||
|
||||
kdk::QtSingleApplication app(argc, argv);
|
||||
app.setApplicationVersion("1.1.0");
|
||||
app.setWindowIcon(QIcon::fromTheme("kylin-font"));
|
||||
|
||||
if (app.isRunning()) {
|
||||
qDebug() << "is running";
|
||||
app.sendMessage(fontFileName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 设置不使用gtk3平台文件对话框 */
|
||||
app.setProperty("useFileDialog", false);
|
||||
|
||||
/* 文件锁实现VNC单例 */
|
||||
QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
||||
int fd = open(QString(homePath.at(0) + "/.config/kylin-font-viewer%1.lock").arg(getenv("DISPLAY")).toUtf8().data() , O_WRONLY | O_CREAT | O_TRUNC , S_IRUSR | S_IWUSR);
|
||||
if (fd < 0) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (lockf(fd , F_TLOCK , 0)) {
|
||||
syslog(LOG_ERR , "Can't lock single file, kylin-font-viewer is already running!");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* 加载翻译文件 */
|
||||
QString kylinFontViewerTransPath = "/usr/share/kylin-font-viewer/data/translations";
|
||||
QString qtTransPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
||||
QString locale = QLocale::system().name();
|
||||
|
||||
QTranslator trans_global , trans_qt;
|
||||
QTranslator trans_SDK;
|
||||
|
||||
if (!trans_global.load(QLocale(), "kylin-font-viewer", "_", kylinFontViewerTransPath)) {
|
||||
qWarning() << "Load global translations file" <<QLocale() << "failed!";
|
||||
} else {
|
||||
app.installTranslator(&trans_global);
|
||||
}
|
||||
|
||||
if (!trans_qt.load(QLocale(), "qt", "_", qtTransPath)) {
|
||||
qWarning() << "Load qt translations file" <<QLocale() << "failed!";
|
||||
} else {
|
||||
app.installTranslator(&trans_qt);
|
||||
}
|
||||
|
||||
QString path = QString(":/translations/gui_%1.qm").arg(locale);
|
||||
if (trans_SDK.load(path)) {
|
||||
app.installTranslator(&trans_SDK);
|
||||
}
|
||||
|
||||
/* 移除标题栏 */
|
||||
::kabase::WindowManage::removeHeader(MainView::getInstance());
|
||||
|
||||
/* 最小化拉起 */
|
||||
app.setActivationWindow(MainView::getInstance());
|
||||
|
||||
/* wayland 下最小化拉起 */
|
||||
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
|
||||
QObject::connect(&app, &kdk::QtSingleApplication::messageReceived, [=]() {
|
||||
kabase::WindowManage::activateWindow(MainView::getInstance()->m_windowId);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
MainView::getInstance()->show();
|
||||
::kabase::WindowManage::setMiddleOfScreen(MainView::getInstance());
|
||||
|
||||
MainView::getInstance()->getFontFileFromClick(fontFileName);
|
||||
|
||||
QObject::connect(&app, &kdk::QtSingleApplication::messageReceived, MainView::getInstance(), &MainView::getFontFileFromClickAferOpen);
|
||||
|
||||
return app.exec();
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
#include <QPalette>
|
||||
|
||||
#include "baseiconbutton.h"
|
||||
#include "globalsizedata.h"
|
||||
|
||||
BaseIconButton::BaseIconButton(QString iconPath, QString value, bool state)
|
||||
{
|
||||
m_iconPath = iconPath;
|
||||
m_value = value;
|
||||
m_state = state;
|
||||
m_width = 180;
|
||||
m_height = 45;
|
||||
m_space = 16;
|
||||
|
||||
this->init();
|
||||
this->slotChangeState(state);
|
||||
this->changeFontSize();
|
||||
}
|
||||
|
||||
BaseIconButton::~BaseIconButton()
|
||||
{
|
||||
}
|
||||
|
||||
void BaseIconButton::init(void)
|
||||
{
|
||||
this->setFlat(true);
|
||||
this->setFocusPolicy(Qt::NoFocus);
|
||||
this->setMinimumSize(m_width , m_height);
|
||||
|
||||
m_iconLab = new QLabel(this); /* 按钮图标 */
|
||||
m_iconLab->setPixmap(QIcon::fromTheme(m_iconPath).pixmap(QSize(20, 20)));
|
||||
|
||||
m_valueLab = new QLabel(this); /* 按钮内容 */
|
||||
m_valueLab->setText(m_value);
|
||||
|
||||
QFont font;
|
||||
font.setPixelSize(14);
|
||||
m_valueLab->setFont(font);
|
||||
|
||||
m_pictureToWhite = new PictureToWhite(this); /* 图标泛白类 */
|
||||
|
||||
m_hlayout = new QHBoxLayout();
|
||||
m_hlayout->addSpacing(m_space);
|
||||
m_hlayout->addWidget(m_iconLab);
|
||||
m_hlayout->addSpacing(m_space / 2);
|
||||
m_hlayout->addWidget(m_valueLab);
|
||||
m_hlayout->addStretch();
|
||||
|
||||
this->setLayout(m_hlayout);
|
||||
|
||||
this->setAutoExclusive(true); /* 启用互斥 */
|
||||
this->setCheckable(true); /* 启用checked功能 */
|
||||
this->changeStyle();
|
||||
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontChange, this, &BaseIconButton::changeFontSize);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontNameChange, this, &BaseIconButton::slotChangeFontName);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void BaseIconButton::changeStyle()
|
||||
{
|
||||
/* 深浅主题控件样式 */
|
||||
/* 浅色主题且按钮未点击,按钮内容黑色 */
|
||||
if (GlobalSizeData::THEME_COLOR == GlobalSizeData::UKUILight && m_state == false) {
|
||||
m_iconLab->setPixmap(QIcon::fromTheme(m_iconPath).pixmap(QSize(20, 20)));
|
||||
m_valueLab->setStyleSheet("color:#000000");
|
||||
} else {
|
||||
m_iconLab->setPixmap(m_pictureToWhite->drawSymbolicColoredPixmap(QIcon::fromTheme(m_iconPath).pixmap(QSize(20, 20))));
|
||||
m_valueLab->setStyleSheet("color:#FFFFFF");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void BaseIconButton::changeFontSize()
|
||||
{
|
||||
QFont font14;
|
||||
font14.setPointSizeF(GlobalSizeData::getInstance()->g_font14pxToPt);
|
||||
m_valueLab->setFont(font14);
|
||||
return;
|
||||
}
|
||||
|
||||
void BaseIconButton::slotChangeState(bool state)
|
||||
{
|
||||
m_state = state;
|
||||
this->changeStyle();
|
||||
return;
|
||||
}
|
||||
|
||||
void BaseIconButton::slotChangeFontName()
|
||||
{
|
||||
this->update();
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
#ifndef BASEICONBUTTON_H
|
||||
#define BASEICONBUTTON_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QEvent>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "picturetowhite.h"
|
||||
|
||||
/* 功能按钮 */
|
||||
class BaseIconButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/* 图标路径, 按钮名称, 按钮状态, 图标按钮间距, 宽度, 高度 */
|
||||
BaseIconButton(QString iconPath, QString value = "", bool state = false);
|
||||
~BaseIconButton();
|
||||
void init(void); /* 初始化组件 */
|
||||
void changeStyle(); /* 主题改变 */
|
||||
void changeFontSize(); /* 字号改变 */
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
QString m_iconPath;
|
||||
QString m_value;
|
||||
bool m_state;
|
||||
int m_space;
|
||||
int m_width;
|
||||
int m_height;
|
||||
|
||||
PictureToWhite *m_pictureToWhite = nullptr; /* 图标泛白类 */
|
||||
QLabel *m_iconLab = nullptr; /* 图标 */
|
||||
QLabel *m_valueLab = nullptr; /* 名称 */
|
||||
QHBoxLayout *m_hlayout = nullptr;
|
||||
|
||||
public slots:
|
||||
void slotChangeState(bool state); /* 设置互斥(根据state) */
|
||||
void slotChangeFontName();
|
||||
|
||||
};
|
||||
|
||||
#endif // BASEICONBUTTON_H
|
|
@ -0,0 +1,116 @@
|
|||
#include <QDebug>
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
#include <QPalette>
|
||||
|
||||
#include "basepopuptitle.h"
|
||||
#include "globalsizedata.h"
|
||||
|
||||
const QSize ICON_SIZE_PC = QSize(24, 24);
|
||||
const QSize ICON_SIZE_PAD = QSize(26, 26);
|
||||
const QSize CLOSE_SIZE_PC = QSize(30, 30);
|
||||
const QSize CLOSE_SIZE_PAD = QSize(48, 48);
|
||||
const int WIDGET_WIDTH_PC = 180;
|
||||
const int WIDGET_WIDTH_PAD = 254;
|
||||
const int WIDGET_HEIGHT_PC = 40;
|
||||
const int WIDGET_HEIGHT_PAD = 64;
|
||||
|
||||
BasePopupTitle::BasePopupTitle(bool isClose, QString value)
|
||||
{
|
||||
m_value = value;
|
||||
m_iconAppPath = "kylin-font-viewer";
|
||||
m_iconClosePath = "window-close-symbolic";
|
||||
m_space = 4;
|
||||
m_isClose = isClose;
|
||||
this->init();
|
||||
}
|
||||
|
||||
BasePopupTitle::~BasePopupTitle()
|
||||
{
|
||||
}
|
||||
|
||||
void BasePopupTitle::init(void)
|
||||
{
|
||||
m_iconBtn = new QPushButton(this);
|
||||
m_iconBtn->setIcon(QIcon::fromTheme(m_iconAppPath));
|
||||
QString btnStyle = "QPushButton{border:0px;border-radius:4px;background:transparent;}"
|
||||
"QPushButton:Hover{border:0px;border-radius:4px;background:transparent;}"
|
||||
"QPushButton:Pressed{border:0px;border-radius:4px;background:transparent;}";
|
||||
m_iconBtn->setStyleSheet(btnStyle);
|
||||
|
||||
m_valueLab = new QLabel(this);
|
||||
m_valueLab->setText(m_value);
|
||||
|
||||
m_closeBtn = new QPushButton(this);
|
||||
m_closeBtn->setIcon(QIcon::fromTheme(m_iconClosePath));
|
||||
m_closeBtn->setProperty("isWindowButton", 0x2);
|
||||
m_closeBtn->setProperty("useIconHighlightEffect", 0x8);
|
||||
m_closeBtn->setFlat(true);
|
||||
m_closeBtn->setToolTip(tr("Close"));
|
||||
if (!m_isClose) {
|
||||
m_closeBtn->hide();
|
||||
}
|
||||
|
||||
m_hlayout = new QHBoxLayout();
|
||||
m_hlayout->setContentsMargins(4, 4, 4, 4);
|
||||
m_hlayout->setSpacing(0);
|
||||
m_hlayout->addSpacing(m_space);
|
||||
m_hlayout->addWidget(m_iconBtn);
|
||||
m_hlayout->addSpacing(m_space);
|
||||
m_hlayout->addWidget(m_valueLab);
|
||||
m_hlayout->addStretch();
|
||||
m_hlayout->addWidget(m_closeBtn);
|
||||
|
||||
this->setLayout(m_hlayout);
|
||||
|
||||
setWidgetStyle();
|
||||
|
||||
connect(m_closeBtn , &QPushButton::clicked , this , &BasePopupTitle::slotCloseWid);
|
||||
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigPCMode, this, &BasePopupTitle::slotChangePCModeSize);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigHFlatMode, this, &BasePopupTitle::slotChangePadModeSize);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigVFlatMode, this, &BasePopupTitle::slotChangePadModeSize);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void BasePopupTitle::setWidgetStyle()
|
||||
{
|
||||
switch (GlobalSizeData::getInstance()->m_currentMode)
|
||||
{
|
||||
case CurrentMode::PCMode:
|
||||
slotChangePCModeSize();
|
||||
break;
|
||||
case CurrentMode::HMode:
|
||||
slotChangePadModeSize();
|
||||
break;
|
||||
case CurrentMode::VMode:
|
||||
slotChangePadModeSize();
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void BasePopupTitle::slotCloseWid()
|
||||
{
|
||||
this->window()->close();
|
||||
return;
|
||||
}
|
||||
|
||||
void BasePopupTitle::slotChangePCModeSize()
|
||||
{
|
||||
this->setMinimumWidth(WIDGET_WIDTH_PC);
|
||||
this->setFixedHeight(WIDGET_HEIGHT_PC);
|
||||
m_iconBtn->setIconSize(ICON_SIZE_PC);
|
||||
m_closeBtn->setFixedSize(CLOSE_SIZE_PC);
|
||||
return;
|
||||
}
|
||||
|
||||
void BasePopupTitle::slotChangePadModeSize()
|
||||
{
|
||||
this->setMinimumWidth(WIDGET_WIDTH_PAD);
|
||||
this->setFixedHeight(WIDGET_HEIGHT_PAD);
|
||||
m_iconBtn->setIconSize(ICON_SIZE_PAD);
|
||||
m_closeBtn->setFixedSize(CLOSE_SIZE_PAD);
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef BASEPOPUPTITLE_H
|
||||
#define BASEPOPUPTITLE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
/* 弹窗标题栏 */
|
||||
class BasePopupTitle : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/* 是否使用关闭按钮,标题名 */
|
||||
BasePopupTitle(bool isClose = true, QString value = tr("Font Viewer"));
|
||||
~BasePopupTitle();
|
||||
|
||||
private:
|
||||
void init(void);
|
||||
void setWidgetStyle();
|
||||
|
||||
private:
|
||||
QString m_iconAppPath;
|
||||
QString m_iconClosePath;
|
||||
QString m_value;
|
||||
int m_space;
|
||||
bool m_isClose;
|
||||
|
||||
QPushButton *m_iconBtn = nullptr; /* 放置图标 */
|
||||
QLabel *m_valueLab = nullptr; /* 放置值 */
|
||||
QPushButton *m_closeBtn = nullptr;
|
||||
|
||||
QHBoxLayout *m_hlayout = nullptr;
|
||||
|
||||
private slots:
|
||||
void slotCloseWid(void);
|
||||
void slotChangePCModeSize();
|
||||
void slotChangePadModeSize();
|
||||
};
|
||||
|
||||
#endif // BASEPOPUPTITLE_H
|
|
@ -0,0 +1,148 @@
|
|||
#include <QDebug>
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
#include <QPalette>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
#include <QApplication>
|
||||
|
||||
#include "basepreviewarea.h"
|
||||
|
||||
BasePreviewArea::BasePreviewArea(QString value, int width, int height, int space)
|
||||
{
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
m_value = value;
|
||||
m_space = space;
|
||||
m_size = value.toInt();
|
||||
|
||||
this->init();
|
||||
}
|
||||
|
||||
BasePreviewArea::~BasePreviewArea()
|
||||
{
|
||||
}
|
||||
|
||||
void BasePreviewArea::init()
|
||||
{
|
||||
this->setMinimumWidth(m_width);
|
||||
this->setMinimumHeight(m_height);
|
||||
this->setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
m_previewEdit = new QLineEdit(this); /* 预览编辑框 */
|
||||
m_previewEdit->setFixedHeight(40);
|
||||
m_previewEdit->setPlaceholderText(tr("Enter Text Content For Preview")); /* 提示文字 */
|
||||
m_previewEdit->setMaxLength(30); /* 字数限制 */
|
||||
m_previewEdit->clearFocus();
|
||||
|
||||
m_fontSizeSlider = new QSlider(this); /* 字号滑动条 */
|
||||
m_fontSizeSlider->setOrientation(Qt::Horizontal); /* 水平方向 */
|
||||
m_fontSizeSlider->setMinimum(14); /* 最小值 */
|
||||
m_fontSizeSlider->setMaximum(60); /* 最大值 */
|
||||
m_fontSizeSlider->setSingleStep(1); /* 步长 */
|
||||
m_fontSizeSlider->setValue(m_size); /* 设置初始值: 24 */
|
||||
|
||||
m_valueLab = new QLabel(this); /* 滑动条当前值 */
|
||||
m_valueLab->setText(m_value);
|
||||
m_valueLab->setStyleSheet("color:#8C8C8C;");
|
||||
|
||||
m_hlayout = new QHBoxLayout();
|
||||
m_hlayout->addSpacing(m_space / 2);
|
||||
m_hlayout->addWidget(m_previewEdit, 6);
|
||||
m_hlayout->addSpacing(m_space * 2);
|
||||
m_hlayout->addWidget(m_fontSizeSlider, 1);
|
||||
m_hlayout->addSpacing(m_space);
|
||||
m_hlayout->addWidget(m_valueLab);
|
||||
m_hlayout->addSpacing(m_space * 2);
|
||||
m_hlayout->setSpacing(0);
|
||||
m_hlayout->setMargin(0);
|
||||
|
||||
this->setLayout(m_hlayout);
|
||||
|
||||
m_fontSizeSlider->installEventFilter(this);
|
||||
|
||||
connect(m_fontSizeSlider, &QSlider::valueChanged, this, &BasePreviewArea::slotChangSize);
|
||||
connect(m_previewEdit, &QLineEdit::textChanged, this, &BasePreviewArea::slotPreviewValue);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontNameChange, this, &BasePreviewArea::slotChangeFontName);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void BasePreviewArea::previewFocusOut()
|
||||
{
|
||||
m_previewEdit->clearFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
bool BasePreviewArea::eventFilter(QObject* watched, QEvent* event)
|
||||
{
|
||||
if (watched == m_fontSizeSlider) {
|
||||
if (event->type()==QEvent::MouseButtonPress) { /* 判断类型 */
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseEvent->button() == Qt::LeftButton) /* 判断左键 */
|
||||
{
|
||||
QSlider* pSlider = (QSlider*)watched;
|
||||
int dur = pSlider->maximum() - pSlider->minimum();
|
||||
int pos = pSlider->minimum() + dur * ((double)mouseEvent->x() / pSlider->width());
|
||||
if(pos != pSlider->sliderPosition())
|
||||
{
|
||||
pSlider->setValue(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QObject::eventFilter(watched,event);
|
||||
}
|
||||
void BasePreviewArea::slotChangSize(int size)
|
||||
{
|
||||
m_size = size;
|
||||
QString fontSize = QString("%1").arg(size);
|
||||
m_valueLab->setText(fontSize);
|
||||
emit sigFontSize(size);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void BasePreviewArea::slotPreviewValue(QString text)
|
||||
{
|
||||
emit sigPreviewValue(text);
|
||||
return;
|
||||
}
|
||||
|
||||
void BasePreviewArea::slotChangFont(QString fontName)
|
||||
{
|
||||
m_valueLab->setFont(QFont(fontName));
|
||||
return;
|
||||
}
|
||||
|
||||
void BasePreviewArea::slotChangeFontName()
|
||||
{
|
||||
m_valueLab->setFont(QFont(GlobalSizeData::getInstance()->m_fontName));
|
||||
return;
|
||||
}
|
||||
|
||||
void BasePreviewArea::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
||||
|
||||
QPainterPath rectPath;
|
||||
rectPath.addRoundedRect(rect(), 0, 0);
|
||||
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
p.setPen(Qt::NoPen);
|
||||
QColor color = qApp->palette().color(QPalette::Window);
|
||||
QPalette pal(this->palette());
|
||||
pal.setColor(QPalette::Window, QColor(color));
|
||||
this->setPalette(pal);
|
||||
QBrush brush = QBrush(color);
|
||||
p.setBrush(brush);
|
||||
p.drawRoundedRect(opt.rect, 0, 0);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
p.fillPath(rectPath, brush);
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
#ifndef BASEWIDGET_H
|
||||
#define BASEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QEvent>
|
||||
#include <QLabel>
|
||||
#include <QSlider>
|
||||
#include <QLineEdit>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "globalsizedata.h"
|
||||
|
||||
/* 预览区域 */
|
||||
class BasePreviewArea : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/* 默认显示字体大小 ,宽度 ,高度 ,间距 */
|
||||
BasePreviewArea(QString value = "24", int width = 620, int height = 50, int space = 16);
|
||||
~BasePreviewArea();
|
||||
|
||||
void init(void);
|
||||
void previewFocusOut(); /* 输入框失去焦点 */
|
||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
QString m_value;
|
||||
int m_width;
|
||||
int m_height;
|
||||
int m_size;
|
||||
int m_space;
|
||||
|
||||
QLineEdit *m_previewEdit = nullptr; /* 预览消息编辑框 */
|
||||
QSlider *m_fontSizeSlider = nullptr; /* 横向进度条 */
|
||||
QLabel *m_valueLab = nullptr; /* 显示当前字体大小 */
|
||||
QHBoxLayout *m_hlayout = nullptr;
|
||||
|
||||
signals:
|
||||
void sigFontSize(int size);
|
||||
void sigPreviewValue(QString text);
|
||||
|
||||
private slots:
|
||||
void slotChangSize(int size); /* 字号发生改变 */
|
||||
void slotPreviewValue(QString text); /* 预览信息改变 */
|
||||
|
||||
public slots:
|
||||
void slotChangFont(QString fontName); /* 改变字体 */
|
||||
void slotChangeFontName(); /* 改变字体名称 */
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // BASEWIDGET_H
|
|
@ -0,0 +1,103 @@
|
|||
#include <QDebug>
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "basesearchedit.h"
|
||||
#include "globalsizedata.h"
|
||||
|
||||
BaseSearchEdit::BaseSearchEdit(QString iconPath, QString value)
|
||||
{
|
||||
m_width = 240;
|
||||
m_height = 32;
|
||||
m_iconPath = iconPath;
|
||||
m_value = value;
|
||||
|
||||
this->init();
|
||||
this->changeFontSize();
|
||||
}
|
||||
|
||||
BaseSearchEdit::~BaseSearchEdit()
|
||||
{
|
||||
}
|
||||
|
||||
void BaseSearchEdit::init(void)
|
||||
{
|
||||
this->setMinimumSize(m_width, m_height);
|
||||
|
||||
m_searchFontEdit = new QLineEdit(this);
|
||||
m_iconLab = new QLabel(m_searchFontEdit);
|
||||
|
||||
QIcon searchIcon = QIcon::fromTheme(m_iconPath);
|
||||
m_iconLab->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(20 , 20))));
|
||||
m_iconLab->setProperty("isWindowButton", 0x1);
|
||||
m_iconLab->setProperty("useIconHighlightEffect", 0x2);
|
||||
m_iconLab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||
m_iconLab->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
|
||||
m_searchFontEdit->setMinimumSize(240, 32);
|
||||
m_searchFontEdit->setMaximumSize(240, 37);
|
||||
m_searchFontEdit->setPlaceholderText(m_value); /* 提示文字 */
|
||||
m_searchFontEdit->setMaxLength(30); /* 字数限制 */
|
||||
m_searchFontEdit->setTextMargins(m_iconLab->width(), 1, 1 , 1); /* 设置输入区 */
|
||||
m_searchFontEdit->setContextMenuPolicy(Qt::NoContextMenu); /* 禁用右键 */
|
||||
|
||||
this->installEventFilter(this);
|
||||
m_searchFontEdit->installEventFilter(this);
|
||||
m_searchFontEdit->clearFocus();
|
||||
|
||||
connect(m_searchFontEdit, &QLineEdit::textChanged, this, &BaseSearchEdit::slotSearchFont);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontChange, this, &BaseSearchEdit::changeFontSize);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool BaseSearchEdit::eventFilter(QObject *watch, QEvent *e)
|
||||
{
|
||||
if ((e->type() == QEvent::MouseButtonPress && watch != m_searchFontEdit) ||
|
||||
(e->type() == QEvent::FocusOut && watch == m_searchFontEdit)) {
|
||||
if (m_searchFontEdit->text() == "") {
|
||||
QFontMetrics lineFontMetr = QFontMetrics(m_searchFontEdit->font());
|
||||
m_iconLab->setFixedSize(m_searchFontEdit->width() / 2 - lineFontMetr.width(tr("Search")) / 2 , 32);
|
||||
m_iconLab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||
m_searchFontEdit->setTextMargins(m_iconLab->width() , 1 , 1 , 1);
|
||||
m_searchFontEdit->setPlaceholderText(m_value); /* 提示文字 */
|
||||
}
|
||||
m_searchFontEdit->clearFocus();
|
||||
} else if ((e->type() == QEvent::MouseButtonPress && watch == m_searchFontEdit) ||
|
||||
(e->type() == QEvent::FocusIn && watch == m_searchFontEdit)){
|
||||
m_iconLab->setFixedSize(25, 32);
|
||||
m_searchFontEdit->setTextMargins(m_iconLab->width() , 1 , 1 , 1);
|
||||
m_searchFontEdit->setFocus();
|
||||
m_searchFontEdit->setPlaceholderText(m_value);
|
||||
}
|
||||
return QObject::eventFilter(watch , e);
|
||||
}
|
||||
|
||||
void BaseSearchEdit::changeFontSize()
|
||||
{
|
||||
QFont font14;
|
||||
font14.setPointSizeF(GlobalSizeData::getInstance()->g_font14pxToPt);
|
||||
m_searchFontEdit->setFont(font14);
|
||||
if (m_searchFontEdit->text() == "") {
|
||||
QFontMetrics lineFontMetr = QFontMetrics(font14);
|
||||
m_iconLab->setFixedSize(m_searchFontEdit->width() / 2 - lineFontMetr.width(tr("Search")) / 2 , 32);
|
||||
m_searchFontEdit->setTextMargins(m_iconLab->width() , 1 , 1 , 1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void BaseSearchEdit::searchFocusOut()
|
||||
{
|
||||
m_searchFontEdit->clearFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
void BaseSearchEdit::slotSearchFont(QString searchText)
|
||||
{
|
||||
/* 添加 搜索字体 SDK的打点 */
|
||||
GlobalSizeData::getInstance()->searchFontSDKPoint();
|
||||
|
||||
emit sigSearchFont(searchText);
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
#ifndef BASESEARCHEDIT_H
|
||||
#define BASESEARCHEDIT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QEvent>
|
||||
#include <QLabel>
|
||||
#include <QSlider>
|
||||
#include <QLineEdit>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
/* 标题栏搜索 */
|
||||
class BaseSearchEdit : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/* 图标路径, 提示信息, 间距, 宽度, 高度 */
|
||||
BaseSearchEdit(QString iconPath = "edit-find-symbolic", QString value = tr("Search"));
|
||||
~BaseSearchEdit();
|
||||
void init(void);
|
||||
bool eventFilter(QObject *watch,QEvent *e) override;
|
||||
void changeFontSize(); /* 改变字体大小 */
|
||||
void searchFocusOut(); /* 输入框失去焦点 */
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
QString m_iconPath;
|
||||
QString m_value;
|
||||
int m_width;
|
||||
int m_height;
|
||||
int m_space;
|
||||
|
||||
QLabel *m_iconLab = nullptr; /* 放置图标 */
|
||||
QLineEdit *m_searchFontEdit = nullptr;
|
||||
QHBoxLayout *m_hlayout = nullptr;
|
||||
|
||||
signals:
|
||||
void sigSearchFont(QString searchText);
|
||||
public slots:
|
||||
void slotSearchFont(QString searchText); /* 搜索字体 */
|
||||
};
|
||||
|
||||
|
||||
#endif // BASESEARCHEDIT_H
|
|
@ -0,0 +1,110 @@
|
|||
#include <QMimeData>
|
||||
#include <QUrl>
|
||||
#include <QFileInfo>
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
|
||||
#include "blankpage.h"
|
||||
#include "globalsizedata.h"
|
||||
|
||||
/* 适配组内SDK */
|
||||
#include <gsettingmonitor.h>
|
||||
#include <usermanual.h>
|
||||
#include "windowmanage.hpp"
|
||||
|
||||
const QSize IMAGESIZE = QSize(128, 128);
|
||||
|
||||
BlankPage::BlankPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setWidgetUi();
|
||||
initLayout();
|
||||
initGsetting();
|
||||
changeTheme();
|
||||
}
|
||||
|
||||
BlankPage::~BlankPage()
|
||||
{
|
||||
}
|
||||
|
||||
void BlankPage::setWidgetUi()
|
||||
{
|
||||
m_blankLabel = new QLabel(this);
|
||||
|
||||
m_blankTextLabel = new QLabel(this);
|
||||
|
||||
m_blankTextLabel->setText(tr("No Font"));
|
||||
QString labGrayStyle = "color:#8C8C8C;";
|
||||
m_blankTextLabel->setStyleSheet(labGrayStyle);
|
||||
m_blankTextLabel->setFixedWidth(128);
|
||||
m_blankTextLabel->setAlignment(Qt::AlignHCenter);
|
||||
|
||||
QFont font14;
|
||||
font14.setPointSizeF(GlobalSizeData::getInstance()->g_font14pxToPt);
|
||||
m_blankTextLabel->setFont(font14);
|
||||
|
||||
m_vLayout = new QVBoxLayout();
|
||||
m_hLayout = new QHBoxLayout();
|
||||
return;
|
||||
}
|
||||
|
||||
void BlankPage::initLayout()
|
||||
{
|
||||
this->setMinimumSize(588, 440);
|
||||
this->setBackgroundRole(QPalette::Base);
|
||||
|
||||
m_vLayout->addStretch();
|
||||
m_vLayout->addWidget(m_blankLabel);
|
||||
m_vLayout->addWidget(m_blankTextLabel);
|
||||
m_vLayout->addStretch();
|
||||
m_vLayout->setSpacing(0);
|
||||
m_vLayout->setMargin(0);
|
||||
|
||||
m_hLayout->addStretch();
|
||||
m_hLayout->addLayout(m_vLayout);
|
||||
m_hLayout->addSpacing(IMAGESIZE.width() / 2);
|
||||
m_hLayout->addStretch();
|
||||
m_hLayout->setSpacing(0);
|
||||
m_hLayout->setMargin(0);
|
||||
|
||||
this->setLayout(m_hLayout);
|
||||
|
||||
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontChange, [=](){
|
||||
QFont font14;
|
||||
font14.setPointSizeF(GlobalSizeData::getInstance()->g_font14pxToPt);
|
||||
m_blankTextLabel->setFont(font14);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
void BlankPage::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
QPainter p(this);
|
||||
QPainterPath rectPath;
|
||||
p.fillPath(rectPath,palette().color(QPalette::Base));
|
||||
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
||||
return;
|
||||
}
|
||||
|
||||
void BlankPage::initGsetting()
|
||||
{
|
||||
// 主题颜色
|
||||
this->connect(kdk::GsettingMonitor::getInstance(), &kdk::GsettingMonitor::systemThemeChange, this, [=]() {
|
||||
GlobalSizeData::getInstance()->getSystemTheme();
|
||||
changeTheme();
|
||||
});
|
||||
}
|
||||
|
||||
void BlankPage::changeTheme()
|
||||
{
|
||||
if (GlobalSizeData::THEME_COLOR == GlobalSizeData::UKUILight) {
|
||||
QIcon blankIcon = QIcon(":/data/image/light.svg");
|
||||
m_blankLabel->setPixmap(blankIcon.pixmap(blankIcon.actualSize(IMAGESIZE)));
|
||||
} else {
|
||||
QIcon blankIcon = QIcon(":/data/image/dark.svg");
|
||||
m_blankLabel->setPixmap(blankIcon.pixmap(blankIcon.actualSize(IMAGESIZE)));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef BLANKPAGE_H
|
||||
#define BLANKPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDropEvent>
|
||||
|
||||
#include "blankpage.h"
|
||||
|
||||
class BlankPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BlankPage(QWidget *parent = nullptr);
|
||||
~BlankPage();
|
||||
|
||||
void setWidgetUi(); /* 初始化组件 */
|
||||
void initLayout(); /* 设置组件样式 */
|
||||
void initGsetting();
|
||||
void changeTheme();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override; /* 绘制事件 */
|
||||
|
||||
private:
|
||||
QLabel *m_blankLabel;
|
||||
QLabel *m_blankTextLabel;
|
||||
QVBoxLayout *m_vLayout = nullptr;
|
||||
QHBoxLayout *m_hLayout = nullptr;
|
||||
|
||||
};
|
||||
#endif // FONTWIDGET_H
|
|
@ -0,0 +1,254 @@
|
|||
#include <QFont>
|
||||
#include <QPixmap>
|
||||
#include <QRectF>
|
||||
#include <QRect>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
|
||||
#include "fontlistdelegate.h"
|
||||
#include "globalsizedata.h"
|
||||
|
||||
QPoint FontListDelegate::m_collectPoint = QPoint(0, 0);
|
||||
QSize FontListDelegate::m_collectSize = QSize(0, 0);
|
||||
|
||||
FontListDelegate::FontListDelegate(FontListView *fontList)
|
||||
{
|
||||
m_fontList = fontList;
|
||||
m_fontSize = m_fontList->getFontSize();
|
||||
}
|
||||
|
||||
FontListDelegate::~FontListDelegate() {}
|
||||
|
||||
QSize FontListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
|
||||
/* 获取默认字体,在当前字号的高度 */
|
||||
QFont familyFont = QFont();
|
||||
QFontMetrics fontm = QFontMetrics(familyFont);
|
||||
int fontHeight = fontm.lineSpacing();
|
||||
fontHeight = 24 > fontHeight ? 24 : fontHeight;
|
||||
familyFont.setPointSizeF(m_fontSize);
|
||||
QFontMetrics fontmet = QFontMetrics(familyFont);
|
||||
int maxHigh = fontmet.lineSpacing();
|
||||
|
||||
int fontHigh = index.data(GlobalSizeData::FontHeight).toInt();
|
||||
if (maxHigh < fontHigh) {
|
||||
maxHigh = fontHigh;
|
||||
}
|
||||
|
||||
maxHigh = maxHigh + fontHeight + 40; /* maxHigh:预览信息高度 fontHeight:字体信息高度 30:间距 */
|
||||
|
||||
return QSize(588, maxHigh);
|
||||
}
|
||||
|
||||
void FontListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
if (index.isValid()) {
|
||||
painter->save();
|
||||
|
||||
// 反锯齿
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
// 获取数据
|
||||
QString fontName = index.data(GlobalSizeData::FontName).toString();
|
||||
QString fontStyle = index.data(GlobalSizeData::FontStyle).toString();
|
||||
int fontCollect = index.data(GlobalSizeData::CollectState).toInt();
|
||||
bool fontInstall = index.data(GlobalSizeData::FontInstall).toBool();
|
||||
|
||||
QString fontInformation = fontName + " " + fontStyle;
|
||||
QString fontDisplay = m_fontList->getPreviewValue();
|
||||
|
||||
// 整体item 矩形区域
|
||||
QRectF itemRect;
|
||||
itemRect.setX(option.rect.x());
|
||||
itemRect.setY(option.rect.y());
|
||||
itemRect.setWidth(option.rect.width() - 1);
|
||||
itemRect.setHeight(option.rect.height() - 1);
|
||||
|
||||
painter->save();
|
||||
|
||||
//画笔设置透明(边框)
|
||||
painter->setPen(Qt::transparent);
|
||||
// QPainterPath画圆角矩形
|
||||
const qreal radius = 7;
|
||||
QPainterPath path;
|
||||
path.moveTo(itemRect.topRight() - QPointF(radius, 0));
|
||||
path.lineTo(itemRect.topLeft() + QPointF(radius, 0));
|
||||
path.quadTo(itemRect.topLeft(), itemRect.topLeft() + QPointF(0, radius));
|
||||
path.lineTo(itemRect.bottomLeft() + QPointF(0, -radius));
|
||||
path.quadTo(itemRect.bottomLeft(), itemRect.bottomLeft() + QPointF(radius, 0));
|
||||
path.lineTo(itemRect.bottomRight() - QPointF(radius, 0));
|
||||
path.quadTo(itemRect.bottomRight(), itemRect.bottomRight() + QPointF(0, -radius));
|
||||
path.lineTo(itemRect.topRight() + QPointF(0, radius));
|
||||
path.quadTo(itemRect.topRight(), itemRect.topRight() + QPointF(-radius, 0));
|
||||
painter->drawPath(path);
|
||||
|
||||
painter->restore();
|
||||
|
||||
//绘制文字
|
||||
QTextOption optionText;
|
||||
QFont infoFont = painter->font();
|
||||
infoFont.setPointSizeF(14);
|
||||
QFontMetrics fontmet = QFontMetrics(infoFont);
|
||||
int high = fontmet.lineSpacing();
|
||||
|
||||
// 字体信息
|
||||
painter->save();
|
||||
QPoint infomationPoint(itemRect.left() + 16, itemRect.top() + 8);
|
||||
high = 24 > high ? 24 : high;
|
||||
QSize infomationSize(option.rect.width() * 0.6, high);
|
||||
QRectF infomationRect = QRect(infomationPoint, infomationSize);
|
||||
|
||||
optionText.setAlignment(Qt::AlignLeft | Qt::AlignBottom); // 文字消息内容绘制
|
||||
optionText.setWrapMode(QTextOption::WrapAnywhere);
|
||||
|
||||
// 防止应用字体出现截断
|
||||
QFontMetrics fontmtsFontInfo = QFontMetrics(infoFont);
|
||||
if (fontmtsFontInfo.width(fontInformation) > infomationRect.width()) {
|
||||
fontInformation = fontmtsFontInfo.elidedText(fontInformation, Qt::ElideRight, infomationRect.width());
|
||||
}
|
||||
|
||||
painter->setFont(infoFont);
|
||||
painter->drawText(infomationRect, fontInformation, optionText);
|
||||
painter->restore();
|
||||
|
||||
// 展示字体
|
||||
painter->save();
|
||||
optionText.setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
|
||||
bool isFontItalic = false;
|
||||
QFont textFont = QFont();
|
||||
textFont.setFamily(fontName);
|
||||
textFont.setPointSizeF(m_fontSize);
|
||||
QStringList style = fontStyle.split(' ');
|
||||
for (int i = 0; i < style.size(); i++) {
|
||||
if (style.at(i) == "Bold") {
|
||||
textFont.setBold(true);
|
||||
} else if (style.at(i) == "Italic") {
|
||||
textFont.setItalic(true);
|
||||
isFontItalic = true;
|
||||
} else if (style.at(i) == "Oblique") {
|
||||
textFont.setStyle(QFont::StyleOblique);
|
||||
}
|
||||
}
|
||||
|
||||
infoFont.setPointSizeF(m_fontSize);
|
||||
fontmet = QFontMetrics(infoFont);
|
||||
high = fontmet.lineSpacing();
|
||||
|
||||
QPoint displayPoint(itemRect.left() + 16, infomationRect.bottom() + 10); /* 确定点 */
|
||||
QSize displaySize = getTextRectSize(fontDisplay, textFont, option.rect.width() * 0.85, high); /* 确定大小 */
|
||||
QRectF displayRect = QRect(displayPoint, displaySize); /* 绘制矩形 */
|
||||
|
||||
QFontMetrics fontmts = QFontMetrics(textFont);
|
||||
|
||||
int disPalayWidth = displaySize.width();
|
||||
if (isFontItalic) {
|
||||
if (displaySize.width() > fontmts.width(fontDisplay)) {
|
||||
if ((displaySize.width() - fontmts.width(fontDisplay)) < 10) {
|
||||
fontDisplay = fontmts.elidedText(fontDisplay, Qt::ElideRight, displayRect.width() - 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fontmts.width(fontDisplay) > disPalayWidth) {
|
||||
fontDisplay = fontmts.elidedText(fontDisplay, Qt::ElideRight, displayRect.width());
|
||||
}
|
||||
painter->setFont(textFont);
|
||||
painter->drawText(displayRect, fontDisplay, optionText);
|
||||
painter->restore();
|
||||
|
||||
// 收藏图标
|
||||
QPoint collectPoint = QPoint(itemRect.right() - 35, itemRect.top() + 15);
|
||||
QSize collectSize = QSize(18, 16);
|
||||
QPixmap collectePixmap;
|
||||
QRect collecteRect = QRect(collectPoint, collectSize);
|
||||
QRectF collecteRectF = collecteRect;
|
||||
|
||||
if (fontCollect == GlobalSizeData::CollectType::NotCollected) {
|
||||
/* 深浅主题控件样式 */
|
||||
if (GlobalSizeData::THEME_COLOR == GlobalSizeData::UKUILight) {
|
||||
collectePixmap =
|
||||
QPixmap(QIcon(":/data/image/ukui-play-love-symbolic-b.svg").pixmap(collecteRect.size()));
|
||||
} else {
|
||||
collectePixmap =
|
||||
QPixmap(QIcon(":/data/image/ukui-play-love-symbolic-w.svg").pixmap(collecteRect.size()));
|
||||
}
|
||||
|
||||
} else {
|
||||
collectePixmap = QPixmap(QIcon(":/data/image/ukui-play-love-red.svg").pixmap(collecteRect.size()));
|
||||
}
|
||||
|
||||
painter->drawPixmap(collecteRect, collectePixmap);
|
||||
QColor highLightColor = QApplication::palette().highlight().color();
|
||||
|
||||
// 鼠标悬停/选中,改变背景颜色
|
||||
if (option.state.testFlag(QStyle::State_MouseOver)) {
|
||||
FontListDelegate::m_collectPoint = collecteRectF.topLeft().toPoint();
|
||||
FontListDelegate::m_collectSize = collecteRectF.size().toSize();
|
||||
|
||||
painter->fillPath(path, QBrush(highLightColor));
|
||||
painter->setPen(QPen(Qt::white));
|
||||
|
||||
painter->setFont(QFont(painter->fontInfo().family(), 14));
|
||||
optionText.setAlignment(Qt::AlignLeft | Qt::AlignBottom);
|
||||
painter->drawText(infomationRect, fontInformation, optionText);
|
||||
|
||||
painter->setFont(textFont);
|
||||
optionText.setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
painter->drawText(displayRect, fontDisplay, optionText);
|
||||
|
||||
if (fontCollect == GlobalSizeData::CollectType::NotCollected) {
|
||||
collectePixmap =
|
||||
QPixmap(QIcon(":/data/image/ukui-play-love-symbolic-w.svg").pixmap(collecteRect.size()));
|
||||
} else {
|
||||
collectePixmap = QPixmap(QIcon(":/data/image/ukui-play-love-red.svg").pixmap(collecteRect.size()));
|
||||
}
|
||||
painter->drawPixmap(collecteRect, collectePixmap);
|
||||
|
||||
path.setFillRule(Qt::WindingFill);
|
||||
path.addRoundedRect(itemRect, 0, 0);
|
||||
|
||||
} else if (option.state.testFlag(QStyle::State_HasFocus) || fontInstall) {
|
||||
painter->fillPath(path, QBrush(highLightColor));
|
||||
painter->setPen(QPen(Qt::white));
|
||||
|
||||
painter->setFont(QFont(painter->fontInfo().family(), 14));
|
||||
optionText.setAlignment(Qt::AlignLeft | Qt::AlignBottom);
|
||||
painter->drawText(infomationRect, fontInformation, optionText);
|
||||
|
||||
painter->setFont(textFont);
|
||||
optionText.setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
painter->drawText(displayRect, fontDisplay, optionText);
|
||||
|
||||
if (fontCollect == GlobalSizeData::CollectType::NotCollected) {
|
||||
collectePixmap =
|
||||
QPixmap(QIcon(":/data/image/ukui-play-love-symbolic-w.svg").pixmap(collecteRect.size()));
|
||||
} else {
|
||||
collectePixmap = QPixmap(QIcon(":/data/image/ukui-play-love-red.svg").pixmap(collecteRect.size()));
|
||||
}
|
||||
painter->drawPixmap(collecteRect, collectePixmap);
|
||||
|
||||
path.setFillRule(Qt::WindingFill);
|
||||
path.addRoundedRect(itemRect, 0, 0);
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QSize FontListDelegate::getTextRectSize(QString text, QFont font, int textWidth, int familyFontH)
|
||||
{
|
||||
QSize resSize = QSize();
|
||||
QFontMetrics fontmts = QFontMetrics(font);
|
||||
int fontHeight = fontmts.lineSpacing(); /* 展示字体的高度 */
|
||||
int fontWidth = fontmts.width(text); /* 展示信息的宽度 */
|
||||
|
||||
fontHeight = fontHeight > familyFontH ? fontHeight : familyFontH;
|
||||
fontWidth = textWidth;
|
||||
|
||||
resSize.setHeight(fontHeight + 10);
|
||||
resSize.setWidth(fontWidth + 10);
|
||||
return resSize;
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef FONTLISTDELEGATE_H
|
||||
#define FONTLISTDELEGATE_H
|
||||
|
||||
#include <QAbstractItemDelegate>
|
||||
#include <QPoint>
|
||||
#include <QPainter>
|
||||
|
||||
#include "fontlistmodel.h"
|
||||
#include "fontlistview.h"
|
||||
class FontListView;
|
||||
|
||||
class FontListDelegate : public QAbstractItemDelegate
|
||||
{
|
||||
public:
|
||||
FontListDelegate(FontListView *fontList);
|
||||
~FontListDelegate();
|
||||
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
|
||||
// 根据消息内容获取消息框大小
|
||||
static QSize getTextRectSize(QString text, QFont font, int textWidth, int familyFontH);
|
||||
int m_fontSize;
|
||||
|
||||
static QPoint m_collectPoint;
|
||||
static QSize m_collectSize;
|
||||
|
||||
private:
|
||||
FontListView *m_fontList = nullptr;
|
||||
};
|
||||
|
||||
#endif // FONTLISTDELEGATE_H
|
|
@ -0,0 +1,100 @@
|
|||
#include <QDebug>
|
||||
#include <QCollator>
|
||||
|
||||
#include "fontlistfilter.h"
|
||||
#include "fontlistmodel.h"
|
||||
#include "globalsizedata.h"
|
||||
|
||||
FontListFilter::FontListFilter(QSortFilterProxyModel *parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
{
|
||||
}
|
||||
FontListFilter::~FontListFilter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool FontListFilter::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
{
|
||||
/* 按照首字母 a-z 顺序 */
|
||||
QString nameLeft = source_left.data(GlobalSizeData::FontRoles::FontName).toString();
|
||||
QString nameRight = source_right.data(GlobalSizeData::FontRoles::FontName).toString();
|
||||
QString styleLeft = source_left.data(GlobalSizeData::FontRoles::FontStyle).toString();
|
||||
QString styleRight = source_right.data(GlobalSizeData::FontRoles::FontStyle).toString();
|
||||
|
||||
QString dateLeft = nameLeft + " " + styleLeft;
|
||||
QString dateRight = nameRight + " " + styleRight;
|
||||
|
||||
if (compareString(dateRight, dateLeft)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FontListFilter::filterAcceptsRow(int sourceRow , const QModelIndex &sourceParent) const
|
||||
{
|
||||
QModelIndex index = sourceModel()->index(sourceRow , 0 , sourceParent);
|
||||
QString fontName = index.data(GlobalSizeData::FontRoles::FontName).toString();
|
||||
QString fontStyle = index.data(GlobalSizeData::FontRoles::FontStyle).toString();
|
||||
QString fontInfo = fontName + " " + fontStyle;
|
||||
|
||||
int fontFamily = index.data(GlobalSizeData::FontRoles::FontFamily).toInt();
|
||||
int fontCollect = index.data(GlobalSizeData::FontRoles::CollectState).toInt();
|
||||
|
||||
/* 判断当前查看字体类别 */
|
||||
switch (GlobalSizeData::getInstance()->g_fontType) {
|
||||
case FontType::AllFont :
|
||||
if (fontInfo.contains(filterRegExp())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case FontType::SystemFont :
|
||||
if (fontFamily == GlobalSizeData::FamilyType::SystemFont) {
|
||||
if (fontInfo.contains(filterRegExp())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case FontType::MyFont :
|
||||
if (fontFamily == GlobalSizeData::FamilyType::MyFont) {
|
||||
if (fontInfo.contains(filterRegExp())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case FontType::CollectFont :
|
||||
if (fontCollect == GlobalSizeData::CollectType::IsCollected) {
|
||||
if (fontInfo.contains(filterRegExp())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default :
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FontListFilter::compareString(QString rightStr, QString leftStr) const
|
||||
{
|
||||
QLocale local(QLocale::Chinese);
|
||||
QCollator collator(local);
|
||||
collator.setNumericMode(true);
|
||||
collator.setCaseSensitivity(Qt::CaseInsensitive);
|
||||
|
||||
QStringList stringList;
|
||||
stringList << leftStr << rightStr;
|
||||
qSort(stringList.begin(), stringList.end(), collator);
|
||||
|
||||
if (stringList[0] != leftStr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef FONTLISTFILTER_H
|
||||
#define FONTLISTFILTER_H
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
class FontListFilter: public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FontListFilter(QSortFilterProxyModel *parent = nullptr);
|
||||
~FontListFilter();
|
||||
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
|
||||
bool filterAcceptsRow(int source_row , const QModelIndex &source_parent) const;
|
||||
bool compareString(QString rightStr, QString leftStr) const;
|
||||
};
|
||||
|
||||
#endif // FONTLISTFILTER_H
|
|
@ -0,0 +1,340 @@
|
|||
#include <QFileInfo>
|
||||
#include <QFontDatabase>
|
||||
#include <QFontMetrics>
|
||||
#include <QDebug>
|
||||
#include <QProcess>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include "fontlistmodel.h"
|
||||
#include "include/core.h"
|
||||
#include "globalsizedata.h"
|
||||
#include "getfontthread.h"
|
||||
|
||||
FontListModel::FontListModel() :
|
||||
QStandardItemModel(NULL)
|
||||
{
|
||||
QHash<int, QByteArray> roleNames;
|
||||
roleNames[GlobalSizeData::FontPath] = "fontPath";
|
||||
roleNames[GlobalSizeData::FontName] = "fontName";
|
||||
roleNames[GlobalSizeData::FontStyle] = "fontStyle";
|
||||
roleNames[GlobalSizeData::FontFamily] = "fontFamily";
|
||||
roleNames[GlobalSizeData::CollectState] = "collectState";
|
||||
roleNames[GlobalSizeData::FontHeight] = "fontHeight";
|
||||
setItemRoleNames(roleNames);
|
||||
|
||||
// m_timer = new QTimer(this);
|
||||
|
||||
getFontModel();
|
||||
|
||||
}
|
||||
|
||||
FontListModel::~FontListModel()
|
||||
{
|
||||
if (m_timer != nullptr) {
|
||||
m_timer->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
FontListModel *FontListModel::getInstance()
|
||||
{
|
||||
static FontListModel instance;
|
||||
|
||||
return &instance;
|
||||
}
|
||||
|
||||
void FontListModel::getFontModel()
|
||||
{
|
||||
m_newFont.clear();
|
||||
|
||||
m_allFontData.clear();
|
||||
m_allFontData = Core::getInstance()->getViewData(); /* 获取全部字体信息 */
|
||||
|
||||
m_collectFontData.clear();
|
||||
m_collectFontData = Core::getInstance()->getCollectFont(); /* 获取收藏字体信息 */
|
||||
|
||||
GetFontThread *thread = new GetFontThread(m_allFontData, m_collectFontData, m_fontSize, m_fontItemsHash);
|
||||
connect(thread, &GetFontThread::sigCreatItem, this, &FontListModel::slotAddItem);
|
||||
if (m_isAddFont) {
|
||||
connect(thread, &GetFontThread::finished, this, &FontListModel::slotAddNewItem);
|
||||
} else {
|
||||
connect(thread, &GetFontThread::finished, this, &FontListModel::slotAGetAllFontOver);
|
||||
}
|
||||
|
||||
thread->start();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList FontListModel::addFont(QStringList fontList)
|
||||
{
|
||||
m_isAddFont = true;
|
||||
QString installFontPath = QStandardPaths::writableLocation(QStandardPaths::FontsLocation) + FONT_PATH;
|
||||
m_installSuccess.clear();
|
||||
|
||||
QStringList uninstallFont;
|
||||
uninstallFont.clear();
|
||||
int num = 0;
|
||||
|
||||
for (int i = 0; i < fontList.size(); i++) {
|
||||
QString path = fontList[i];
|
||||
|
||||
QFileInfo fileinfo;
|
||||
fileinfo = QFileInfo(path);
|
||||
QString fileName = fileinfo.fileName(); /* 文件名 */
|
||||
|
||||
if (Core::getInstance()->judgeBadFontFile(path)) {
|
||||
uninstallFont.insert(num, fileName);
|
||||
num++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Core::getInstance()->installFont(path)) {
|
||||
uninstallFont.insert(num, fileName);
|
||||
num++;
|
||||
} else {
|
||||
QString filePath = installFontPath + fileName;
|
||||
QFontDatabase::addApplicationFont(filePath);
|
||||
m_installSuccess.append(filePath);
|
||||
}
|
||||
}
|
||||
Core::getInstance()->updateFontList();
|
||||
|
||||
this->getFontModel();
|
||||
|
||||
m_isAddFont = false;
|
||||
|
||||
return uninstallFont;
|
||||
}
|
||||
|
||||
QStandardItem *FontListModel::getItemByPath(QString path)
|
||||
{
|
||||
QStandardItem *resItem = nullptr;
|
||||
|
||||
if (m_fontItemsHash.contains(path)) {
|
||||
resItem = m_fontItemsHash.value(path);
|
||||
}
|
||||
|
||||
return resItem;
|
||||
}
|
||||
|
||||
void FontListModel::removeFont(QString path, int row)
|
||||
{
|
||||
QStandardItem *item = this->getItemByPath(path);
|
||||
if (item != nullptr) {
|
||||
QString fontName = item->data(GlobalSizeData::FontName).toString();
|
||||
if (Core::getInstance()->uninstallFont(path, fontName)) {
|
||||
this->removeRow(row);
|
||||
m_fontItemsHash.remove(path);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListModel::collectFont(QString path)
|
||||
{
|
||||
QStandardItem *item = this->getItemByPath(path);
|
||||
|
||||
if (item != nullptr) {
|
||||
int fontCollect = item->data(GlobalSizeData::CollectState).toInt();
|
||||
|
||||
if (fontCollect == GlobalSizeData::CollectType::NotCollected) {
|
||||
/* 添加 收藏字体 SDK的打点 */
|
||||
GlobalSizeData::getInstance()->collectionFontSDKPoint();
|
||||
|
||||
if (Core::getInstance()->collectFont(path)) {
|
||||
item->setData(GlobalSizeData::CollectType::IsCollected, GlobalSizeData::CollectState);
|
||||
}
|
||||
} else {
|
||||
/* 添加 取消收藏字体 SDK的打点 */
|
||||
GlobalSizeData::getInstance()->cancelCollectionFontSDKPoint();
|
||||
|
||||
if (Core::getInstance()->unCollectFont(path)){
|
||||
item->setData(GlobalSizeData::CollectType::NotCollected, GlobalSizeData::CollectState);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListModel::previewChangeSize(int size)
|
||||
{
|
||||
m_fontSize = size;
|
||||
if ( m_timer == nullptr) {
|
||||
m_timer = new QTimer();
|
||||
}
|
||||
|
||||
/* 判断当前字号是否存在 */
|
||||
if (fontSizeExist()) {
|
||||
changeFontSize();
|
||||
} else {
|
||||
m_timer->stop();
|
||||
connect(m_timer, &QTimer::timeout, this, &FontListModel::getFontSize);
|
||||
connect(m_timer, &QTimer::timeout, m_timer, &QTimer::stop);
|
||||
m_timer->start(200);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListModel::changeFontSize()
|
||||
{
|
||||
QHash<QString, QStandardItem*>::iterator fontIt = m_fontItemsHash.begin();
|
||||
|
||||
while (fontIt != m_fontItemsHash.end()) {
|
||||
QStandardItem *fontItem = fontIt.value();
|
||||
QHash<int, int> fontSizeHieght; /* 字体不同字号的高度 <字号,字体高度> */
|
||||
|
||||
fontSizeHieght = m_fontSizeHash.value(fontIt.key());
|
||||
fontItem->setData(fontSizeHieght.value(m_fontSize), GlobalSizeData::FontHeight);
|
||||
fontIt++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bool FontListModel::fontSizeExist()
|
||||
{
|
||||
QHash<QString, QStandardItem*>::iterator fontIt = m_fontItemsHash.begin();
|
||||
|
||||
while (fontIt != m_fontItemsHash.end()) {
|
||||
QHash<int, int> fontSizeHieght; /* <字号,字体高度> */
|
||||
fontSizeHieght = m_fontSizeHash.value(fontIt.key());
|
||||
if (!fontSizeHieght.contains(m_fontSize)) {
|
||||
return false;
|
||||
}
|
||||
fontIt++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void FontListModel::getFontSize()
|
||||
{
|
||||
// m_timer->stop();
|
||||
|
||||
QHash<QString, QStandardItem*>::iterator fontIt = m_fontItemsHash.begin();
|
||||
|
||||
while (fontIt != m_fontItemsHash.end()) {
|
||||
|
||||
QStandardItem *fontItem = fontIt.value();
|
||||
QHash<int, int> fontSizeHieght; /* 字体不同字号的高度 <字号,字体高度> */
|
||||
|
||||
/* 判断字体hash表中是否有字体 */
|
||||
if (m_fontSizeHash.contains(fontIt.key())) {
|
||||
|
||||
fontSizeHieght = m_fontSizeHash.value(fontIt.key());
|
||||
|
||||
/* 在字号高度hash表中查找当前号的高度 */
|
||||
if (fontSizeHieght.contains(m_fontSize)) {
|
||||
fontItem->setData(fontSizeHieght.value(m_fontSize), GlobalSizeData::FontHeight);
|
||||
} else {
|
||||
QFont textFont = QFont(fontItem->data(GlobalSizeData::FontName).toString(), m_fontSize);
|
||||
QFontMetrics fontmet = QFontMetrics(textFont);
|
||||
int fontHeight = fontmet.height();
|
||||
|
||||
fontSizeHieght.insert(m_fontSize, fontHeight);
|
||||
|
||||
m_fontSizeHash[fontIt.key()] = fontSizeHieght;
|
||||
|
||||
fontItem->setData(fontHeight, GlobalSizeData::FontHeight);
|
||||
}
|
||||
} else {
|
||||
QFont textFont = QFont(fontItem->data(GlobalSizeData::FontName).toString(), m_fontSize);
|
||||
QFontMetrics fontmet = QFontMetrics(textFont);
|
||||
int fontHeight = fontmet.height();
|
||||
|
||||
fontSizeHieght.insert(m_fontSize, fontHeight);
|
||||
|
||||
m_fontSizeHash.insert(fontIt.key(), fontSizeHieght);
|
||||
|
||||
fontItem->setData(fontHeight, GlobalSizeData::FontHeight);
|
||||
}
|
||||
fontIt++;
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void FontListModel::newFontGetSize(QString fontPath)
|
||||
{
|
||||
QStandardItem *fontItem = this->getItemByPath(fontPath);
|
||||
QHash<int, int> fontSizeHieght;
|
||||
|
||||
/* 获取新字体从14-60号字体的高度 */
|
||||
for (int size = 14; size <= 60; size++) {
|
||||
QFont textFont = QFont(fontItem->data(GlobalSizeData::FontName).toString(), size);
|
||||
QFontMetrics fontmet = QFontMetrics(textFont);
|
||||
int fontHeight = fontmet.lineSpacing(); /* 展示字体的高度 */
|
||||
|
||||
fontSizeHieght.insert(size, fontHeight);
|
||||
}
|
||||
m_fontSizeHash.insert(fontPath, fontSizeHieght);
|
||||
|
||||
fontItem->setData(fontSizeHieght.value(m_fontSize), GlobalSizeData::FontHeight);
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListModel::slotAddItem(QString path, QStandardItem *item)
|
||||
{
|
||||
if (m_isFirstAddItem == false) {
|
||||
this->appendRow(item);
|
||||
}
|
||||
m_fontItemsHash.insert(path, item);
|
||||
m_newFont.push_back(path);
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListModel::slotAddNewItem()
|
||||
{
|
||||
for (int i = 0; i < m_newFont.size(); ++i) {
|
||||
this->newFontGetSize(m_newFont[i]);
|
||||
}
|
||||
emit sigInstallFontOver();
|
||||
return;
|
||||
}
|
||||
|
||||
bool FontListModel::isFontFile(QString path)
|
||||
{
|
||||
QString command = QString("file -i ") + '"' + path + '"';
|
||||
|
||||
QProcess process;
|
||||
process.start(command);
|
||||
|
||||
if (!process.waitForFinished()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString ret = process.readAll();
|
||||
|
||||
if (ret.contains("font/sfnt") || ret.contains("application/vnd.ms-opentype")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void FontListModel::slotAGetAllFontOver()
|
||||
{
|
||||
if (m_isFirstAddItem) {
|
||||
updateListViewItem();
|
||||
m_isFirstAddItem = false;
|
||||
}
|
||||
emit sigGetAllFontOver();
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListModel::updateListViewItem()
|
||||
{
|
||||
QHash<QString, QStandardItem*>::iterator fontIt = m_fontItemsHash.begin();
|
||||
|
||||
while (fontIt != m_fontItemsHash.end()) {
|
||||
QStandardItem *fontItem = fontIt.value();
|
||||
this->appendRow(fontItem);
|
||||
fontIt++;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList FontListModel::getInstallSuccessList()
|
||||
{
|
||||
return m_installSuccess;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
#ifndef FONTLISTMODEL_H
|
||||
#define FONTLISTMODEL_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTimer>
|
||||
|
||||
#include "include/core.h"
|
||||
|
||||
class FontListModel : public QStandardItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
~FontListModel();
|
||||
static FontListModel* getInstance(); /* 单例,初始化返回指针 */
|
||||
void getFontModel(); /* 获取所有字体 */
|
||||
bool isCorrectFontFile(QString path); /* 判断字体文件类型 */
|
||||
QStringList addFont(QStringList fontList); /* 添加字体 */
|
||||
QStandardItem *getItemByPath(QString path); /* 获取字体item */
|
||||
void removeFont(QString path, int row); /* 卸载字体 */
|
||||
void collectFont(QString path); /* 收藏字体 */
|
||||
void previewChangeSize(int size); /* 预览字号改变 */
|
||||
void changeFontSize(); /* 改变字号高度 */
|
||||
bool fontSizeExist(); /* 当前字号高度是否存在 */
|
||||
void getFontSize(); /* 计算字号高度 */
|
||||
void newFontGetSize(QString fontPath); /* 新字体获取字体大小 */
|
||||
QStringList getInstallSuccessList(); /* 获取安装成功的字体path列表 */
|
||||
|
||||
private:
|
||||
FontListModel();
|
||||
bool isFontFile(QString path);
|
||||
void updateListViewItem();
|
||||
|
||||
Core *m_core = nullptr;
|
||||
|
||||
QTimer *m_timer = nullptr;
|
||||
|
||||
int m_fontSize = 24;
|
||||
|
||||
QList<ViewData> m_allFontData; /* 全部字体 */
|
||||
QList<ViewData> m_collectFontData; /* 收藏字体 */
|
||||
|
||||
QHash<QString, QString> m_incorrectFontFileHash; /* 不正确的字体文件 */
|
||||
QHash<QString, QStandardItem*> m_fontItemsHash; /* 字体hash <字体path, list的item>*/
|
||||
QHash<QString, QHash<int,int>> m_fontSizeHash; /* <字体path, 字体高度hash<字号, 字体高度>> */
|
||||
QVector<QString> m_newFont; /* 安装新字体数组 */
|
||||
|
||||
bool m_isAddFont = false;
|
||||
bool m_isFirstAddItem = true;
|
||||
|
||||
QStringList m_installSuccess;
|
||||
|
||||
signals:
|
||||
void sigGetFontSize();
|
||||
void sigGetAllFontOver();
|
||||
void sigInstallFontOver();
|
||||
|
||||
private slots:
|
||||
void slotAddItem(QString path, QStandardItem* item);
|
||||
void slotAddNewItem();
|
||||
void slotAGetAllFontOver();
|
||||
};
|
||||
|
||||
#endif // FONTLISTMODEL_H
|
|
@ -0,0 +1,491 @@
|
|||
#include <QFileDialog>
|
||||
#include <QDir>
|
||||
#include <QScrollBar>
|
||||
#include <QRegExp>
|
||||
#include <QDebug>
|
||||
|
||||
/* 适配SDK */
|
||||
#include "windowmanage.hpp"
|
||||
|
||||
#include "fontlistview.h"
|
||||
#include "include/core.h"
|
||||
|
||||
FontListView::FontListView(QListView *parent) :
|
||||
QListView(parent)
|
||||
{
|
||||
setWidgetUi();
|
||||
setSlotConnet();
|
||||
}
|
||||
|
||||
FontListView::~FontListView()
|
||||
{
|
||||
}
|
||||
|
||||
void FontListView::setWidgetUi()
|
||||
{
|
||||
this->setMinimumSize(588, 440);
|
||||
// 右键菜单
|
||||
m_funcMenu = new QMenu();
|
||||
m_addFontAction = m_funcMenu->addAction(tr("Add Font"));
|
||||
m_applyFontAction = m_funcMenu->addAction(tr("Apply Font"));
|
||||
m_removeFontAction = m_funcMenu->addAction(tr("Remove Font"));
|
||||
m_exportFontAction = m_funcMenu->addAction(tr("Export Font"));
|
||||
m_collectFontAction = m_funcMenu->addAction(tr("Cancel Collection"));
|
||||
m_checkFontAction = m_funcMenu->addAction(tr("Check Font"));
|
||||
|
||||
m_fontModel = FontListModel::getInstance(); /* 获取model */
|
||||
|
||||
m_fontDelegate = new FontListDelegate(this); /* 设置代理 */
|
||||
this->setItemDelegate(m_fontDelegate);
|
||||
|
||||
m_fontFilter = new FontListFilter();
|
||||
connect(m_fontModel, &FontListModel::sigGetAllFontOver, this, &FontListView::setModelAfterGetAllData);
|
||||
|
||||
this->setSpacing(0);
|
||||
this->setDragEnabled(false);
|
||||
this->setFrameShape(QListView::NoFrame);
|
||||
this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
this->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
this->verticalScrollBar()->setProperty("drawScrollBarGroove", false);
|
||||
this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
this->setAlternatingRowColors(true); /* 奇偶行颜色不同 */
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::setSlotConnet()
|
||||
{
|
||||
/* 收藏字体 */
|
||||
connect(this, &FontListView::clicked, this, &FontListView::slotClickCollect);
|
||||
/* 右键菜单 */
|
||||
connect(this, &FontListView::customContextMenuRequested, this, &FontListView::showContextMenu);
|
||||
/* 右键功能 */
|
||||
// connect(m_addFontAction, &QAction::triggered, this, &FontListView::slotAddFont);
|
||||
connect(m_addFontAction, &QAction::triggered, this, &FontListView::showFontTips);
|
||||
connect(m_applyFontAction, &QAction::triggered, this, &FontListView::slotApplyFont);
|
||||
connect(m_removeFontAction, &QAction::triggered, this, &FontListView::slotRemoveFont);
|
||||
connect(m_exportFontAction, &QAction::triggered, this, &FontListView::slotExportFont);
|
||||
connect(m_collectFontAction, &QAction::triggered, this, &FontListView::slotCollectFont);
|
||||
connect(m_checkFontAction, &QAction::triggered, this, &FontListView::slotCheckFont);
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::showContextMenu(const QPoint &pos)
|
||||
{
|
||||
if (m_fontInstallList.size() != 0) {
|
||||
changeItemInstallStyle(false); // 界面有安装字体被选中时,清空UI界面选中字体
|
||||
}
|
||||
|
||||
QModelIndex selectIndex = this->indexAt(pos);
|
||||
if (!selectIndex.isValid()) {
|
||||
return ;
|
||||
}
|
||||
|
||||
this->setCurrentIndex(selectIndex);
|
||||
if (!((this->selectionModel()->selectedIndexes()).empty())) {
|
||||
|
||||
/* 将代理index转换为消息index */
|
||||
QModelIndex fontIndex = m_fontFilter->mapToSource(this->currentIndex());
|
||||
int fontFamily = fontIndex.data(GlobalSizeData::FontFamily).toInt();
|
||||
int fontCollect = fontIndex.data(GlobalSizeData::CollectState).toInt();
|
||||
|
||||
m_addFontAction->setVisible(true);
|
||||
m_applyFontAction->setVisible(true);
|
||||
m_removeFontAction->setVisible(true);
|
||||
m_exportFontAction->setVisible(true);
|
||||
m_collectFontAction->setVisible(true);
|
||||
m_checkFontAction->setVisible(true);
|
||||
|
||||
if (fontFamily == GlobalSizeData::FamilyType::SystemFont) {
|
||||
m_removeFontAction->setEnabled(false); /* 系统文件不可被导出,卸载 */
|
||||
m_exportFontAction->setEnabled(false);
|
||||
} else {
|
||||
if (isControlApplyFont()) {
|
||||
|
||||
m_removeFontAction->setEnabled(false);
|
||||
}else {
|
||||
m_removeFontAction->setEnabled(true);
|
||||
m_exportFontAction->setEnabled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (fontCollect == GlobalSizeData::CollectType::NotCollected) { /* 如果字体未被收藏 */
|
||||
m_collectFontAction->setText(tr("Collection"));
|
||||
|
||||
} else if (fontCollect == GlobalSizeData::CollectType::IsCollected) { /* 如果字体被收藏 */
|
||||
m_collectFontAction->setText(tr("Cancel Collection"));
|
||||
}
|
||||
|
||||
m_funcMenu->exec(QCursor::pos());
|
||||
this->selectionModel()->clear();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::removeFont(QString path)
|
||||
{
|
||||
/* 循环找到在model中的索引 */
|
||||
for (int i = 0; i < this->m_fontModel->rowCount(); i++) {
|
||||
QModelIndex index = this->m_fontModel->index(i, 0);
|
||||
QString fontPath = index.data(GlobalSizeData::FontPath).toString();
|
||||
|
||||
if(fontPath == path){
|
||||
this->m_fontModel->removeFont(fontPath, index.row());
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_popupRemove->close();
|
||||
return;
|
||||
}
|
||||
|
||||
int FontListView::getFontSize()
|
||||
{
|
||||
return m_fontSize;
|
||||
}
|
||||
|
||||
QString FontListView::getPreviewValue()
|
||||
{
|
||||
return m_previewValue;
|
||||
}
|
||||
|
||||
void FontListView::getFilterType(FontType type)
|
||||
{
|
||||
m_filterType = type;
|
||||
if (m_fontSearch != "") {
|
||||
this->slotFilterFontByReg(m_fontSearch);
|
||||
} else {
|
||||
this->slotFilterFontByReg("");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::dragEnterAddFont(QStringList fontList)
|
||||
{
|
||||
/* 添加 安装字体 SDK的打点 */
|
||||
GlobalSizeData::getInstance()->addFontSDKPoint();
|
||||
|
||||
checkFontFile(fontList);
|
||||
|
||||
this->update();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::updateDelegate()
|
||||
{
|
||||
delete m_fontDelegate;
|
||||
m_fontDelegate = new FontListDelegate(this);
|
||||
this->setItemDelegate(m_fontDelegate);
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::slotFilterFontByReg(QString fontSearch)
|
||||
{
|
||||
m_fontSearch = fontSearch;
|
||||
m_fontFilter->setFilterRegExp(QRegExp(fontSearch, Qt::CaseInsensitive, QRegExp::FixedString));
|
||||
|
||||
if (m_fontFilter->rowCount() == 0) {
|
||||
emit sigBlankPage();
|
||||
} else {
|
||||
emit sigFontPage();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::slotAddFont()
|
||||
{
|
||||
qDebug() << "安装字体" <<__FILE__<< ","<<__FUNCTION__<<","<<__LINE__;
|
||||
/* 添加 安装字体 SDK的打点 */
|
||||
GlobalSizeData::getInstance()->addFontSDKPoint();
|
||||
|
||||
QFileDialog *fileDialog = new QFileDialog();
|
||||
|
||||
fileDialog->setWindowTitle(tr("Add Fonts"));
|
||||
fileDialog->setFileMode(QFileDialog::ExistingFiles);
|
||||
fileDialog->setNameFilter(tr("font(*.ttf *.otf)"));
|
||||
|
||||
if (fileDialog->exec() == QFileDialog::Accepted) {
|
||||
QStringList selectFileList = fileDialog->selectedFiles();
|
||||
|
||||
checkFontFile(selectFileList);
|
||||
}
|
||||
|
||||
if (fileDialog != nullptr) {
|
||||
delete fileDialog;
|
||||
fileDialog = nullptr;
|
||||
}
|
||||
|
||||
this->update();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::slotApplyFont()
|
||||
{
|
||||
/* 添加 应用字体 SDK的打点 */
|
||||
GlobalSizeData::getInstance()->applyFontSDKPoint();
|
||||
|
||||
// 将过滤index转换为model的index
|
||||
QModelIndex fontIndex = m_fontFilter->mapToSource(this->currentIndex());
|
||||
QString fontName = fontIndex.data(GlobalSizeData::FontName).toString(); /* 获取字体Path */
|
||||
Core::getInstance()->applyFont(fontName);
|
||||
|
||||
this->update();
|
||||
|
||||
emit sigChangeFont(fontName);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::slotRemoveFont()
|
||||
{
|
||||
/* 添加 卸载字体 SDK的打点 */
|
||||
GlobalSizeData::getInstance()->removeFontSDKPoint();
|
||||
|
||||
QModelIndex fontIndex = m_fontFilter->mapToSource(this->currentIndex());
|
||||
QString deleFontPath = fontIndex.data(GlobalSizeData::FontPath).toString(); /* 获取字体Path */
|
||||
|
||||
m_popupRemove = new PopupRemove(deleFontPath);
|
||||
m_popupRemove->show();
|
||||
|
||||
connect(m_popupRemove, &PopupRemove::sigSureClick, this, &FontListView::removeFont);
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::slotExportFont()
|
||||
{
|
||||
/* 添加 导出字体 SDK的打点 */
|
||||
GlobalSizeData::getInstance()->exportFontSDKPoint();
|
||||
|
||||
QModelIndex fontIndex = m_fontFilter->mapToSource(this->currentIndex());
|
||||
QString fontPath = fontIndex.data(GlobalSizeData::FontPath).toString(); /* 获取字体Path */
|
||||
|
||||
QString path = QDir::toNativeSeparators(QFileDialog::getExistingDirectory(this,tr("Export Fonts"), QString(getenv("HOME"))));
|
||||
if(!path.isEmpty()) {
|
||||
Core::getInstance()->copyFont(fontPath, path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::slotCollectFont()
|
||||
{
|
||||
QModelIndex fontIndex = m_fontFilter->mapToSource(this->currentIndex());
|
||||
QString fontPath = fontIndex.data(GlobalSizeData::FontPath).toString(); /* 获取字体path */
|
||||
m_fontModel->collectFont(fontPath);
|
||||
if (m_fontFilter->rowCount() == 0) {
|
||||
emit sigBlankPage();
|
||||
} else {
|
||||
emit sigFontPage();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::slotCheckFont()
|
||||
{
|
||||
/* 添加 查看字体信息 SDK的打点 */
|
||||
GlobalSizeData::getInstance()->fontInfoSDKPoint();
|
||||
|
||||
QModelIndex fontIndex = m_fontFilter->mapToSource(this->currentIndex());
|
||||
QString fontPath = fontIndex.data(GlobalSizeData::FontPath).toString(); /* 获取字体path */
|
||||
m_popupFontInfo = new PopupFontInfo(fontPath);
|
||||
m_popupFontInfo->show();
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::slotGetFontSize(int size)
|
||||
{
|
||||
/* 添加 更改预览字号 SDK的打点 */
|
||||
GlobalSizeData::getInstance()->changeFontSizeSDKPoint();
|
||||
|
||||
m_fontModel->previewChangeSize(size);
|
||||
|
||||
m_fontSize = size;
|
||||
|
||||
updateDelegate();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::slotUpdatePreView(QString value)
|
||||
{
|
||||
/* 添加 更改预览信息 SDK的打点 */
|
||||
GlobalSizeData::getInstance()->changecopywritingSDKPoint();
|
||||
|
||||
this->setUpdatesEnabled(false);
|
||||
if (value == "") {
|
||||
m_previewValue = tr("Build the core strength of Chinese operating system");
|
||||
} else {
|
||||
m_previewValue = value;
|
||||
}
|
||||
this->setUpdatesEnabled(true);
|
||||
this->update();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::slotClickCollect()
|
||||
{
|
||||
QPoint pressPoint = this->mapFromGlobal(QCursor::pos());
|
||||
|
||||
QPoint statePoint;
|
||||
statePoint.setX(FontListDelegate::m_collectPoint.x());
|
||||
statePoint.setY(FontListDelegate::m_collectPoint.y());
|
||||
|
||||
QPoint diffPoint = QPoint(pressPoint.x() - statePoint.x(), pressPoint.y() - statePoint.y());
|
||||
|
||||
// 点击区域范围
|
||||
if (diffPoint.x() >= 0 && diffPoint.x() < 15 &&
|
||||
diffPoint.y() >= 0 && diffPoint.y() < 15) {
|
||||
slotCollectFont();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool FontListView::isControlApplyFont()
|
||||
{
|
||||
QModelIndex fontIndex = m_fontFilter->mapToSource(this->currentIndex());
|
||||
QString fontName = fontIndex.data(GlobalSizeData::FontName).toString();
|
||||
|
||||
QString font = Core::getInstance()->ControlUsingFont();
|
||||
qDebug() << font << fontName;
|
||||
if (font == fontName) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void FontListView::clickFontFileInstall(QStringList fontList)
|
||||
{
|
||||
m_fontList = fontList;
|
||||
|
||||
connect(m_fontModel, &FontListModel::sigGetAllFontOver,this, &FontListView::slotClickFontFile);
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::clickFontFileInstallAfterOpen(QStringList fontList)
|
||||
{
|
||||
m_fontList = fontList;
|
||||
slotClickFontFile();
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::slotClickFontFile()
|
||||
{
|
||||
if (m_fontList.size() != 0) {
|
||||
dragEnterAddFont(m_fontList);
|
||||
}
|
||||
m_fontList.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::setModelAfterGetAllData()
|
||||
{
|
||||
m_fontFilter->setSourceModel(m_fontModel); /* 将model放到过滤其中 */
|
||||
m_fontFilter->setDynamicSortFilter(true);
|
||||
m_fontFilter->sort(0);
|
||||
m_fontFilter->setFilterKeyColumn(0);
|
||||
this->setModel(m_fontFilter);
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::checkFontFile(QStringList list)
|
||||
{
|
||||
qDebug() << "判断文件状态:" <<__FILE__<< ","<<__FUNCTION__<<","<<__LINE__;
|
||||
int installNum = 0;
|
||||
int uninstallNum = 0;
|
||||
QStringList uninstallFont;
|
||||
uninstallFont.clear();
|
||||
|
||||
uninstallFont = m_fontModel->addFont(list);
|
||||
uninstallNum = uninstallFont.size();
|
||||
|
||||
if (uninstallNum == 0) {
|
||||
installNum = list.size();
|
||||
|
||||
m_popupInstallSuccess = new PopupInstallSuccess(installNum);
|
||||
m_popupInstallSuccess->show();
|
||||
} else {
|
||||
installNum = list.size() - uninstallNum;
|
||||
m_popupInstallFail = new PopupInstallFail(uninstallFont, this);
|
||||
m_popupInstallFail->show();
|
||||
if (installNum != 0) {
|
||||
connect(m_popupInstallFail, &PopupInstallFail::signalWidgetClose, [=](){
|
||||
m_popupInstallSuccess = new PopupInstallSuccess(installNum);
|
||||
m_popupInstallSuccess->show();
|
||||
delete m_popupInstallFail;
|
||||
m_popupInstallFail = nullptr;
|
||||
});
|
||||
} else {
|
||||
connect(m_popupInstallFail, &PopupInstallFail::signalWidgetClose, [=](){
|
||||
delete m_popupInstallFail;
|
||||
m_popupInstallFail = nullptr;
|
||||
});
|
||||
}
|
||||
}
|
||||
if (m_fontInstallList.size() != 0) {
|
||||
changeItemInstallStyle(false);
|
||||
}
|
||||
connect(m_fontModel, &FontListModel::sigInstallFontOver,this, &FontListView::chooseFontInstallItem);
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::chooseFontInstallItem()
|
||||
{
|
||||
m_fontInstallList.clear();
|
||||
m_fontInstallList = m_fontModel->getInstallSuccessList();
|
||||
changeItemInstallStyle(true);
|
||||
connect(this, &FontListView::clicked, [=](){
|
||||
if (m_fontInstallList.size() != 0) {
|
||||
changeItemInstallStyle(false);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::changeItemInstallStyle(bool style)
|
||||
{
|
||||
for (int i = 0; i < m_fontInstallList.size(); i++) {
|
||||
if ( m_fontModel->getItemByPath(m_fontInstallList[i]) == nullptr) {
|
||||
continue;
|
||||
}
|
||||
m_fontModel->getItemByPath(m_fontInstallList[i])->setData(style, GlobalSizeData::FontInstall);
|
||||
}
|
||||
if (style == false) {
|
||||
m_fontInstallList.clear();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::showFontTips()
|
||||
{
|
||||
if (Core::getInstance()->getSettingFontTips()) {
|
||||
m_popupTips = new PopupTips(this);
|
||||
m_popupTips->show();
|
||||
m_popupTips->disconnect();
|
||||
connect(m_popupTips, &PopupTips::signalWidgetClose, this, &FontListView::slotAddFont);
|
||||
} else {
|
||||
slotAddFont();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void FontListView::addFontByOtherWay(QStringList list)
|
||||
{
|
||||
if (Core::getInstance()->getSettingFontTips()) {
|
||||
if (m_popupTips == nullptr) {
|
||||
m_popupTips = new PopupTips(this);
|
||||
}
|
||||
m_popupTips->show();
|
||||
m_popupTips->disconnect();
|
||||
connect(m_popupTips, &PopupTips::signalWidgetClose, [=](){
|
||||
checkFontFile(list);
|
||||
});
|
||||
} else {
|
||||
checkFontFile(list);
|
||||
}
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
#ifndef FONTLISTVIEW_H
|
||||
#define FONTLISTVIEW_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QListView>
|
||||
#include <QPoint>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
|
||||
#include "fontlistdelegate.h"
|
||||
#include "fontlistfilter.h"
|
||||
#include "fontlistmodel.h"
|
||||
#include "basepreviewarea.h"
|
||||
#include "popupremove.h"
|
||||
#include "popupinstallsuccess.h"
|
||||
#include "popupinstallfail.h"
|
||||
#include "popupfontinfo.h"
|
||||
#include "popuptips.h"
|
||||
|
||||
class FontListDelegate;
|
||||
class FontListView : public QListView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FontListView(QListView *parent = nullptr);
|
||||
~FontListView();
|
||||
|
||||
void setWidgetUi(); /* 初始化组件 */
|
||||
void setSlotConnet(); /* 关联信号和槽 */
|
||||
void showContextMenu(const QPoint &pos); /* 显示右键菜单 */
|
||||
void removeFont(QString path); /* 卸载字体 */
|
||||
int getFontSize(); /* 获取预览字号 */
|
||||
QString getPreviewValue(); /* 获取预览文字 */
|
||||
void getFilterType(FontType type); /* 更改过滤类型 */
|
||||
void dragEnterAddFont(QStringList fontList); /* 拖拽安装字体 */
|
||||
void updateDelegate(); /* 更新代理绘制每项高度 */
|
||||
bool isControlApplyFont(); /* 判断当前字体是否为控制面板应用字体 */
|
||||
void clickFontFileInstall(QStringList fontLis); /* 双击字体文件安装字体 */
|
||||
void clickFontFileInstallAfterOpen(QStringList fontList); /* 双击字体文件安装字体 */
|
||||
void setModelAfterGetAllData(); /* 设置model */
|
||||
void checkFontFile(QStringList list); /* 安装字体并检测字体是否被损坏 */
|
||||
void chooseFontInstallItem();
|
||||
void changeItemInstallStyle(bool style); /* 修改item中的fontinstall的状态 */
|
||||
void showFontTips();
|
||||
void setFontTips(QStringList list);
|
||||
void addFontByOtherWay(QStringList list);
|
||||
|
||||
private:
|
||||
QMenu *m_funcMenu = nullptr; /* 右键菜单 */
|
||||
QAction *m_addFontAction = nullptr; /* 添加 */
|
||||
QAction *m_applyFontAction = nullptr; /* 应用 */
|
||||
QAction *m_removeFontAction = nullptr; /* 卸载 */
|
||||
QAction *m_exportFontAction = nullptr; /* 导出 */
|
||||
QAction *m_collectFontAction = nullptr; /* 收藏 */
|
||||
QAction *m_checkFontAction = nullptr; /* 字体信息 */
|
||||
|
||||
FontListModel *m_fontModel = nullptr;
|
||||
FontListDelegate *m_fontDelegate = nullptr;
|
||||
FontListFilter *m_fontFilter = nullptr;
|
||||
|
||||
PopupRemove *m_popupRemove = nullptr; /* 卸载弹窗 */
|
||||
PopupInstallSuccess *m_popupInstallSuccess = nullptr; /* 安装成功 */
|
||||
PopupInstallFail *m_popupInstallFail = nullptr; /* 安装失败 */
|
||||
PopupFontInfo *m_popupFontInfo = nullptr; /* 字体信息 */
|
||||
PopupTips *m_popupTips = nullptr; /* 字体提示 */
|
||||
|
||||
int m_fontSize = 24; /* 预览初始字号 */
|
||||
QString m_previewValue = tr("Build the core strength of Chinese operating system");
|
||||
FontType m_filterType = FontType::AllFont; /* 过滤类型 */
|
||||
QString m_fontSearch = "";
|
||||
QStringList m_fontList;
|
||||
|
||||
QStringList m_fontInstallList;
|
||||
|
||||
signals:
|
||||
void sigGetAllFont();
|
||||
void sigChangeFont(QString fontName);
|
||||
void sigBlankPage();
|
||||
void sigFontPage();
|
||||
|
||||
public slots:
|
||||
void slotFilterFontByReg(QString fontSearch); /* 根据字符串过滤字体 */
|
||||
void slotAddFont(); /* 添加字体 */
|
||||
void slotApplyFont(); /* 应用字体 */
|
||||
void slotRemoveFont(); /* 卸载字体 */
|
||||
void slotExportFont(); /* 导出字体 */
|
||||
void slotCollectFont(); /* 收藏字体 */
|
||||
void slotCheckFont(); /* 字体信息 */
|
||||
void slotGetFontSize(int size); /* 改变字号 */
|
||||
void slotUpdatePreView(QString value); /* 修改预览内容 */
|
||||
void slotClickCollect(); /* 点击图标收藏 */
|
||||
void slotClickFontFile(); /* 点击字体文件进行安装 */
|
||||
|
||||
};
|
||||
|
||||
#endif // FONTLISTVIEW_H
|
|
@ -0,0 +1,273 @@
|
|||
#include <QMimeData>
|
||||
#include <QUrl>
|
||||
#include <QFileInfo>
|
||||
#include <QDebug>
|
||||
#include <QProcess>
|
||||
|
||||
#include "fontwid.h"
|
||||
#include "popupinstallfail.h"
|
||||
|
||||
/* 适配SDK */
|
||||
#include "windowmanage.hpp"
|
||||
|
||||
FontWidget::FontWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setWidgetUi();
|
||||
initLayout();
|
||||
setSlotConnet();
|
||||
}
|
||||
|
||||
FontWidget::~FontWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void FontWidget::setWidgetUi()
|
||||
{
|
||||
this->setAcceptDrops(true); /* 接受拖拽事件 */
|
||||
|
||||
// 堆栈窗口
|
||||
m_stackedWid = new QStackedWidget(this);
|
||||
m_blankPage = new BlankPage(this);
|
||||
|
||||
m_fontView = new FontListView();
|
||||
|
||||
m_titleBar = new TitleBar(this);
|
||||
|
||||
m_previewArea = new BasePreviewArea();
|
||||
|
||||
m_vLayout = new QVBoxLayout();
|
||||
m_hLayout = new QHBoxLayout();
|
||||
|
||||
m_stackedWid->addWidget(m_blankPage);
|
||||
m_stackedWid->addWidget(m_fontView);
|
||||
|
||||
m_stackedWid->setCurrentIndex(1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void FontWidget::initLayout()
|
||||
{
|
||||
this->setMinimumSize(620 , 560);
|
||||
this->setBackgroundRole(QPalette::Base);
|
||||
|
||||
m_hLayout->addSpacing(10);
|
||||
m_hLayout->addWidget(m_stackedWid);
|
||||
m_hLayout->addSpacing(10);
|
||||
m_hLayout->setSpacing(0);
|
||||
m_hLayout->setMargin(0);
|
||||
|
||||
m_vLayout->addWidget(m_titleBar);
|
||||
m_vLayout->addLayout(m_hLayout);
|
||||
m_vLayout->addWidget(m_previewArea);
|
||||
m_vLayout->setSpacing(0);
|
||||
m_vLayout->setMargin(0);
|
||||
|
||||
this->setLayout(m_vLayout);
|
||||
return;
|
||||
}
|
||||
|
||||
void FontWidget::setSlotConnet()
|
||||
{
|
||||
/* 预览区域 内容/字号 改变 */
|
||||
connect(m_previewArea, &BasePreviewArea::sigFontSize, m_fontView, &FontListView::slotGetFontSize);
|
||||
connect(m_previewArea, &BasePreviewArea::sigPreviewValue, m_fontView, &FontListView::slotUpdatePreView);
|
||||
|
||||
/* 标题栏 搜索/添加字体 */
|
||||
connect(m_titleBar, &TitleBar::sigTitleSearch, m_fontView, &FontListView::slotFilterFontByReg);
|
||||
// connect(m_titleBar, &TitleBar::sigAddFont, m_fontView, &FontListView::slotAddFont);
|
||||
connect(m_titleBar, &TitleBar::sigAddFont, m_fontView, &FontListView::showFontTips);
|
||||
|
||||
/* 主窗体改变 */
|
||||
connect(this, &FontWidget::sigWindowState, m_titleBar, &TitleBar::slotWindowState);
|
||||
|
||||
/* 应用字体 */
|
||||
connect(m_fontView, &FontListView::sigChangeFont, m_previewArea, &BasePreviewArea::slotChangFont);
|
||||
connect(m_fontView, &FontListView::sigBlankPage, this, &FontWidget::slotShowBlankPage);
|
||||
connect(m_fontView, &FontListView::sigFontPage, this, &FontWidget::slotShowFontPage);
|
||||
return;
|
||||
}
|
||||
|
||||
bool FontWidget::isFontFile(QString path)
|
||||
{
|
||||
QString command = QString("file -i ") + '"' + path + '"';
|
||||
|
||||
QProcess process;
|
||||
process.start(command);
|
||||
|
||||
if (!process.waitForFinished()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString ret = process.readAll();
|
||||
|
||||
if (ret.contains("font/sfnt") || ret.contains("application/vnd.ms-opentype")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FontWidget::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (m_titleBar->eventFilter(watched, event)) {
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void FontWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
QPainter p(this);
|
||||
QPainterPath rectPath;
|
||||
p.fillPath(rectPath,palette().color(QPalette::Base));
|
||||
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
||||
return;
|
||||
}
|
||||
|
||||
void FontWidget::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (event->mimeData()->hasUrls()) {
|
||||
event->acceptProposedAction();
|
||||
} else {
|
||||
event->ignore();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void FontWidget::dropEvent(QDropEvent *event)
|
||||
{
|
||||
qDebug() << "拖拽安装:" <<__FILE__<< ","<<__FUNCTION__<<","<<__LINE__;
|
||||
const QMimeData *mimeData = event->mimeData();
|
||||
|
||||
if(!mimeData->hasUrls())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QList<QUrl> urlList = mimeData->urls();
|
||||
int num = 0;
|
||||
QStringList installFontList;
|
||||
|
||||
for (int i = 0; i < urlList.size(); i++) {
|
||||
QString dropFileName = urlList.at(i).toLocalFile();
|
||||
|
||||
installFontList.insert(num, dropFileName);
|
||||
}
|
||||
// m_fontView->checkFontFile(installFontList);
|
||||
m_fontView->addFontByOtherWay(installFontList);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void FontWidget::slotChangeFilterType(FontType type)
|
||||
{
|
||||
qDebug() << "fontType : " << type;
|
||||
m_fontView->getFilterType(type);
|
||||
m_titleBar->SearchFocusOut();
|
||||
m_previewArea->previewFocusOut();
|
||||
return;
|
||||
}
|
||||
|
||||
void FontWidget::slotWindowState(QString state)
|
||||
{
|
||||
emit sigWindowState(state);
|
||||
return;
|
||||
}
|
||||
|
||||
void FontWidget::useFontFileOpen(QString fontFile)
|
||||
{
|
||||
qDebug() << "使用字体文件打开:" <<__FILE__<< ","<<__FUNCTION__<<","<<__LINE__;
|
||||
/* 添加 安装字体 SDK的打点 */
|
||||
GlobalSizeData::getInstance()->addFontSDKPoint();
|
||||
|
||||
QStringList fontList;
|
||||
fontList.clear();
|
||||
QStringList unFontList;
|
||||
unFontList.clear();
|
||||
int num = 0;
|
||||
|
||||
if (fontFile.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QFileInfo fileinfo;
|
||||
fileinfo = QFileInfo(fontFile);
|
||||
QString fileName = fileinfo.fileName(); /* 文件名 */
|
||||
|
||||
if (getFontFile(fontFile)) {
|
||||
if (Core::getInstance()->judgeBadFontFile(fontFile)) {
|
||||
unFontList.insert(num, fileName);
|
||||
} else {
|
||||
fontList.insert(num, fontFile);
|
||||
}
|
||||
} else {
|
||||
unFontList.insert(num, fileName);
|
||||
}
|
||||
|
||||
if (unFontList.size() != 0) {
|
||||
PopupInstallFail *m_popupInstallFail = new PopupInstallFail(unFontList, this);
|
||||
m_popupInstallFail->show();
|
||||
} else {
|
||||
m_fontView->clickFontFileInstall(fontList);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool FontWidget::getFontFile(QString fileName)
|
||||
{
|
||||
if (fileName.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
QFileInfo fileInfo(fileName);
|
||||
|
||||
if (fileInfo.exists()) {
|
||||
if (fileInfo.isFile()) {
|
||||
if (isFontFile(fileName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void FontWidget::cilckFontFile(QString fontFile)
|
||||
{
|
||||
qDebug() << "点击字体文件安装" <<__FILE__<< ","<<__FUNCTION__<<","<<__LINE__;
|
||||
|
||||
/* 添加 安装字体 SDK的打点 */
|
||||
GlobalSizeData::getInstance()->addFontSDKPoint();
|
||||
|
||||
QStringList fontList;
|
||||
fontList.clear();
|
||||
QStringList unFontList;
|
||||
unFontList.clear();
|
||||
int num = 0;
|
||||
|
||||
if (fontFile.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
QStringList installFontList;
|
||||
installFontList.insert(num, fontFile);
|
||||
|
||||
// m_fontView->checkFontFile(installFontList);
|
||||
m_fontView->addFontByOtherWay(installFontList);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void FontWidget::slotShowBlankPage()
|
||||
{
|
||||
m_stackedWid->setCurrentIndex(0);
|
||||
return;
|
||||
}
|
||||
|
||||
void FontWidget::slotShowFontPage()
|
||||
{
|
||||
m_stackedWid->setCurrentIndex(1);
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
#ifndef FONTWIDGET_H
|
||||
#define FONTWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDropEvent>
|
||||
#include <QStackedWidget>
|
||||
|
||||
#include "titlebar.h"
|
||||
#include "basepreviewarea.h"
|
||||
#include "fontlistview.h"
|
||||
#include "blankpage.h"
|
||||
|
||||
class FontWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FontWidget(QWidget *parent = nullptr);
|
||||
~FontWidget();
|
||||
|
||||
void setWidgetUi(); /* 初始化组件 */
|
||||
void initLayout(); /* 设置组件样式 */
|
||||
void setSlotConnet();
|
||||
bool isFontFile(QString path); /* 判断文件类型 */
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
void useFontFileOpen(QString fontFile);
|
||||
bool getFontFile(QString fileName);
|
||||
void cilckFontFile(QString fontFile);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override; /* 绘制事件 */
|
||||
void dragEnterEvent(QDragEnterEvent *event) override; /* 鼠标拖拽事件 */
|
||||
void dropEvent(QDropEvent *event) override; /* 鼠标放下事件 */
|
||||
|
||||
private:
|
||||
TitleBar *m_titleBar = nullptr;
|
||||
FontListView *m_fontView = nullptr;
|
||||
BasePreviewArea *m_previewArea = nullptr;
|
||||
QVBoxLayout *m_vLayout = nullptr;
|
||||
QHBoxLayout *m_hLayout = nullptr;
|
||||
|
||||
//堆栈窗体
|
||||
QStackedWidget *m_stackedWid;
|
||||
BlankPage *m_blankPage = nullptr;
|
||||
|
||||
int m_fontSize;
|
||||
|
||||
signals:
|
||||
void sigWindowState(QString state);
|
||||
|
||||
public slots:
|
||||
void slotChangeFilterType(FontType type);
|
||||
void slotWindowState(QString state);
|
||||
void slotShowBlankPage();
|
||||
void slotShowFontPage();
|
||||
};
|
||||
#endif // FONTWIDGET_H
|
|
@ -0,0 +1,124 @@
|
|||
#include <QDebug>
|
||||
#include "functionwid.h"
|
||||
|
||||
FunctionWid::FunctionWid(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
setWidgetUi();
|
||||
setWidgetStyle();
|
||||
initLayout();
|
||||
setSlotConnet();
|
||||
}
|
||||
|
||||
FunctionWid::~FunctionWid()
|
||||
{
|
||||
}
|
||||
|
||||
/* 初始化 */
|
||||
void FunctionWid::setWidgetUi()
|
||||
{
|
||||
m_leftTitle = new BasePopupTitle(false);
|
||||
|
||||
m_funBar = new KNavigationBar(this);
|
||||
|
||||
QStandardItem *itemAll = new QStandardItem(QIcon::fromTheme("font-select-symbolic"),tr("All Font"));
|
||||
QStandardItem *itemSys = new QStandardItem(QIcon::fromTheme("system-computer-symbolic"),tr("System Font"));
|
||||
QStandardItem *itemUser = new QStandardItem(QIcon::fromTheme("avatar-default-symbolic"),tr("User Font"));
|
||||
QStandardItem *itemColl = new QStandardItem(QIcon::fromTheme("ukui-love-symbolic"),tr("Collection Font"));
|
||||
|
||||
m_funBar->addItem(itemAll);
|
||||
m_funBar->addItem(itemSys);
|
||||
m_funBar->addItem(itemUser);
|
||||
m_funBar->addItem(itemColl);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* 布局 */
|
||||
void FunctionWid::initLayout()
|
||||
{
|
||||
this->setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
m_vLayout = new QVBoxLayout();
|
||||
m_vLayout->addWidget(m_funBar);
|
||||
|
||||
m_hLayout = new QHBoxLayout();
|
||||
m_hLayout->addSpacing(10);
|
||||
m_hLayout->addLayout(m_vLayout);
|
||||
|
||||
m_mainVLayout = new QVBoxLayout();
|
||||
m_mainVLayout->addWidget(m_leftTitle);
|
||||
m_mainVLayout->addSpacing(8);
|
||||
m_mainVLayout->addLayout(m_hLayout);
|
||||
m_mainVLayout->addStretch();
|
||||
m_mainVLayout->setMargin(0);
|
||||
m_mainVLayout->setSpacing(0);
|
||||
|
||||
this->setLayout(m_mainVLayout);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* 关联信号与槽 */
|
||||
void FunctionWid::setSlotConnet()
|
||||
{
|
||||
/* 切换列表内容 */
|
||||
connect(m_funBar->listview(), &QListView::clicked, this, &FunctionWid::slotNaviClicked);
|
||||
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigPCMode, this, &FunctionWid::slotChangePCMode);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigHFlatMode, this, &FunctionWid::slotChangeFaltMode);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigVFlatMode, this, &FunctionWid::slotChangeFaltMode);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* 切换字体列表 */
|
||||
void FunctionWid::slotNaviClicked(const QModelIndex &index)
|
||||
{
|
||||
QString str;
|
||||
QString data = index.data().toString();
|
||||
|
||||
if (data == tr("All Font")) {
|
||||
m_fontType = FontType::AllFont;
|
||||
} else if(data == tr("Collection Font")) {
|
||||
m_fontType = FontType::CollectFont;
|
||||
} else if(data == tr("System Font")) {
|
||||
m_fontType = FontType::SystemFont;
|
||||
} else {
|
||||
m_fontType = FontType::MyFont;
|
||||
}
|
||||
GlobalSizeData::getInstance()->g_fontType = m_fontType;
|
||||
emit sigChangeFontType(m_fontType);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void FunctionWid::setWidgetStyle()
|
||||
{
|
||||
switch (GlobalSizeData::getInstance()->m_currentMode)
|
||||
{
|
||||
case CurrentMode::PCMode:
|
||||
slotChangePCMode();
|
||||
break;
|
||||
case CurrentMode::HMode:
|
||||
slotChangeFaltMode();
|
||||
break;
|
||||
case CurrentMode::VMode:
|
||||
slotChangeFaltMode();
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void FunctionWid::slotChangePCMode()
|
||||
{
|
||||
m_leftTitle->setFixedHeight(46);
|
||||
this->setFixedWidth(190);
|
||||
return;
|
||||
}
|
||||
|
||||
void FunctionWid::slotChangeFaltMode()
|
||||
{
|
||||
m_leftTitle->setFixedHeight(64);
|
||||
this->setFixedWidth(244);
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
#ifndef FUNCTIONWID_H
|
||||
#define FUNCTIONWID_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QListView>
|
||||
|
||||
#include "basepopuptitle.h"
|
||||
#include "basepreviewarea.h"
|
||||
#include "globalsizedata.h"
|
||||
|
||||
#include "knavigationbar.h"
|
||||
using namespace kdk;
|
||||
|
||||
class FunctionWid : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FunctionWid(QWidget *parent = nullptr);
|
||||
~FunctionWid();
|
||||
|
||||
void setWidgetUi(); /* 初始化组件 */
|
||||
void initLayout(); /* 初始化布局 */
|
||||
void setSlotConnet(); /* 关联信号与槽 */
|
||||
void setWidgetStyle(); /* 设置尺寸 */
|
||||
|
||||
private:
|
||||
BasePopupTitle *m_leftTitle = nullptr; /* 标题栏 */
|
||||
|
||||
KNavigationBar *m_funBar;
|
||||
|
||||
QVBoxLayout *m_vLayout = nullptr;
|
||||
QHBoxLayout *m_hLayout = nullptr;
|
||||
QVBoxLayout *m_mainVLayout = nullptr;
|
||||
|
||||
FontType m_fontType;
|
||||
|
||||
signals:
|
||||
void sigChangeFontType(FontType type); /* 切换字体列表类型 */
|
||||
|
||||
private slots:
|
||||
void slotNaviClicked(const QModelIndex &index); /* 切换字体列表 */
|
||||
|
||||
void slotChangePCMode();
|
||||
void slotChangeFaltMode();
|
||||
};
|
||||
|
||||
#endif // FUNCTIONWID_H
|
|
@ -0,0 +1,51 @@
|
|||
#include<QFontMetrics>
|
||||
|
||||
#include "getfontthread.h"
|
||||
#include "globalsizedata.h"
|
||||
|
||||
GetFontThread::GetFontThread(QList<ViewData> allFontData, QList<ViewData> collectFontData, int fontSize, QHash<QString, QStandardItem*> fontItemsHash)
|
||||
{
|
||||
m_allFontData = allFontData;
|
||||
m_collectFontData = collectFontData;
|
||||
m_fontItemsHash = fontItemsHash;
|
||||
m_fontSize = fontSize;
|
||||
|
||||
connect(this, &GetFontThread::finished, this, &GetFontThread::deleteLater);
|
||||
}
|
||||
|
||||
void GetFontThread::run()
|
||||
{
|
||||
for (int i = 0; i < m_allFontData.size(); i++) {
|
||||
|
||||
if (m_fontItemsHash.contains(m_allFontData[i].path)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QStandardItem *newItem = new QStandardItem();
|
||||
|
||||
newItem->setData(m_allFontData[i].path, GlobalSizeData::FontPath);
|
||||
newItem->setData(m_allFontData[i].family, GlobalSizeData::FontName);
|
||||
newItem->setData(m_allFontData[i].style, GlobalSizeData::FontStyle);
|
||||
newItem->setData(GlobalSizeData::FamilyType::SystemFont, GlobalSizeData::FontFamily);
|
||||
newItem->setData(GlobalSizeData::CollectType::NotCollected, GlobalSizeData::CollectState);
|
||||
|
||||
QFont textFont = QFont(m_allFontData[i].family, m_fontSize);
|
||||
QFontMetrics fontmet = QFontMetrics(textFont);
|
||||
int fontHeight = fontmet.lineSpacing(); /* 展示字体的高度 */
|
||||
newItem->setData(fontHeight, GlobalSizeData::FontHeight);
|
||||
|
||||
if (!Core::getInstance()->isSystemFont(m_allFontData[i].path)) {
|
||||
newItem->setData(GlobalSizeData::FamilyType::MyFont, GlobalSizeData::FontFamily);
|
||||
}
|
||||
|
||||
for (int n = 0; n < m_collectFontData.size(); n++) {
|
||||
if (m_allFontData[i].path == m_collectFontData[n].path) {
|
||||
newItem->setData(GlobalSizeData::CollectType::IsCollected, GlobalSizeData::CollectState);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
emit sigCreatItem(m_allFontData[i].path, newItem);
|
||||
}
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef GETFONTTHREAD_H
|
||||
#define GETFONTTHREAD_H
|
||||
|
||||
#include <QThread>
|
||||
#include <QStandardItem>
|
||||
|
||||
#include "include/core.h"
|
||||
|
||||
class GetFontThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GetFontThread(QList<ViewData> allFontData, QList<ViewData> collectFontData, int fontSize, QHash<QString, QStandardItem*> fontItemsHash);
|
||||
void run();
|
||||
|
||||
private:
|
||||
QList<ViewData> m_allFontData; /* 全部字体 */
|
||||
QList<ViewData> m_collectFontData; /* 收藏字体 */
|
||||
QHash<QString, QStandardItem*> m_fontItemsHash; /* 字体hash <字体path, list的item>*/
|
||||
int m_fontSize;
|
||||
|
||||
signals:
|
||||
void sigCreatItem(QString path, QStandardItem *newItem);
|
||||
|
||||
private slots:
|
||||
};
|
||||
|
||||
#endif // GETFONTTHREAD_H
|
|
@ -0,0 +1,257 @@
|
|||
#include <QVariant>
|
||||
#include <QDebug>
|
||||
|
||||
/* SDK gsetting */
|
||||
#include <gsettingmonitor.h>
|
||||
#include "buriedpoint.hpp"
|
||||
|
||||
#include "globalsizedata.h"
|
||||
|
||||
#define THEME_GSETTINGS "org.ukui.style"
|
||||
#define APPLY_FONT_KEY "system-font"
|
||||
|
||||
// 主题色
|
||||
int GlobalSizeData::THEME_COLOR = GlobalSizeData::UKUILight;
|
||||
FontType GlobalSizeData::g_fontType = FontType::AllFont;
|
||||
|
||||
GlobalSizeData::GlobalSizeData()
|
||||
{
|
||||
getSystemFontSize();
|
||||
getSystemTheme();
|
||||
getSystemTransparency();
|
||||
changeFontSize();
|
||||
getSystemFontName();
|
||||
changeFontName();
|
||||
getSystemDBusInfo();
|
||||
}
|
||||
|
||||
GlobalSizeData *GlobalSizeData::getInstance()
|
||||
{
|
||||
static GlobalSizeData globalData;
|
||||
return &globalData;
|
||||
}
|
||||
|
||||
GlobalSizeData::~GlobalSizeData()
|
||||
{
|
||||
}
|
||||
|
||||
void GlobalSizeData::changeFontSize()
|
||||
{
|
||||
this->connect(kdk::GsettingMonitor::getInstance(), &kdk::GsettingMonitor::systemFontSizeChange, this, [=]() {
|
||||
getSystemFontSize();
|
||||
emit this->sigFontChange();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::getSystemFontName()
|
||||
{
|
||||
if (QGSettings::isSchemaInstalled(THEME_GSETTINGS)) {
|
||||
/* 主题 */
|
||||
m_themeGsettings = new QGSettings(THEME_GSETTINGS, QByteArray(), this);
|
||||
m_fontName = m_themeGsettings->get(APPLY_FONT_KEY).toString();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::changeFontName()
|
||||
{
|
||||
connect(m_themeGsettings, &QGSettings::changed, this, [=]() {
|
||||
if (m_themeGsettings->get("style-name").toString() != m_fontName) {
|
||||
m_fontName = m_themeGsettings->get(APPLY_FONT_KEY).toString();
|
||||
emit this->sigFontNameChange();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::getSystemTheme()
|
||||
{
|
||||
QString systemTheme = kdk::GsettingMonitor::getSystemTheme().toString();
|
||||
|
||||
qInfo() << "system item : " << systemTheme;
|
||||
if (systemTheme == BLACK_THEME) {
|
||||
GlobalSizeData::THEME_COLOR = GlobalSizeData::UKUIDark;
|
||||
} else {
|
||||
GlobalSizeData::THEME_COLOR = GlobalSizeData::UKUILight;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::getSystemFontSize()
|
||||
{
|
||||
/* 获取系统初始字体 */
|
||||
double systemFontSize = kdk::GsettingMonitor::getSystemFontSize().toDouble();
|
||||
qInfo() << "system systemFontSize : " << systemFontSize;
|
||||
|
||||
g_font14pxToPt = (systemFontSize * (14.00 / 11)) - 3;
|
||||
g_font16pxToPt = (systemFontSize * (16.00 / 11)) - 3;
|
||||
g_font18pxToPt = (systemFontSize * (18.00 / 11)) - 3;
|
||||
|
||||
qDebug() << "Info : system init font : 14 ---> " << g_font14pxToPt << "16 ---> " << g_font16pxToPt << "18 ---> " << g_font16pxToPt;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::getSystemTransparency()
|
||||
{
|
||||
double systemTransparency = kdk::GsettingMonitor::getSystemTransparency().toDouble();
|
||||
|
||||
qInfo() << "system systemTransparency : " << systemTransparency;
|
||||
GlobalSizeData::g_transparency = systemTransparency * 255;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::addFontSDKPoint()
|
||||
{
|
||||
::kabase::BuriedPoint buriedPointTest;
|
||||
|
||||
if (!buriedPointTest.functionBuriedPoint(::kabase::AppName::KylinFontViewer , ::kabase::BuriedPoint::PT::KylinFontViewInstallFont)) {
|
||||
qCritical() << "Error : buried point fail !" << __FILE__ << "," << __FUNCTION__ << "," << __LINE__;
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::removeFontSDKPoint()
|
||||
{
|
||||
::kabase::BuriedPoint buriedPointTest;
|
||||
|
||||
if (!buriedPointTest.functionBuriedPoint(::kabase::AppName::KylinFontViewer , ::kabase::BuriedPoint::PT::KylinPrinterManuallyInstallPrinter)) {
|
||||
qCritical() << "Error : buried point fail !" << __FILE__ << "," << __FUNCTION__ << "," << __LINE__;
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::searchFontSDKPoint()
|
||||
{
|
||||
::kabase::BuriedPoint buriedPointTest;
|
||||
|
||||
if (!buriedPointTest.functionBuriedPoint(::kabase::AppName::KylinFontViewer , ::kabase::BuriedPoint::PT::KylinFontViewSearchFont)) {
|
||||
qCritical() << "Error : buried point fail !" << __FILE__ << "," << __FUNCTION__ << "," << __LINE__;
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::applyFontSDKPoint()
|
||||
{
|
||||
::kabase::BuriedPoint buriedPointTest;
|
||||
|
||||
if (!buriedPointTest.functionBuriedPoint(::kabase::AppName::KylinFontViewer , ::kabase::BuriedPoint::PT::KylinFontViewApplyFont)) {
|
||||
qCritical() << "Error : buried point fail !" << __FILE__ << "," << __FUNCTION__ << "," << __LINE__;
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::exportFontSDKPoint()
|
||||
{
|
||||
::kabase::BuriedPoint buriedPointTest;
|
||||
|
||||
if (!buriedPointTest.functionBuriedPoint(::kabase::AppName::KylinFontViewer , ::kabase::BuriedPoint::PT::KylinFontViewExportFont)) {
|
||||
qCritical() << "Error : buried point fail !" << __FILE__ << "," << __FUNCTION__ << "," << __LINE__;
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::collectionFontSDKPoint()
|
||||
{
|
||||
::kabase::BuriedPoint buriedPointTest;
|
||||
|
||||
if (!buriedPointTest.functionBuriedPoint(::kabase::AppName::KylinFontViewer , ::kabase::BuriedPoint::PT::KylinFontViewCollectionFont)) {
|
||||
qCritical() << "Error : buried point fail !" << __FILE__ << "," << __FUNCTION__ << "," << __LINE__;
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::cancelCollectionFontSDKPoint()
|
||||
{
|
||||
::kabase::BuriedPoint buriedPointTest;
|
||||
|
||||
if (!buriedPointTest.functionBuriedPoint(::kabase::AppName::KylinFontViewer , ::kabase::BuriedPoint::PT::KylinFontViewCancelCollectionFont)) {
|
||||
qCritical() << "Error : buried point fail !" << __FILE__ << "," << __FUNCTION__ << "," << __LINE__;
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::fontInfoSDKPoint()
|
||||
{
|
||||
::kabase::BuriedPoint buriedPointTest;
|
||||
|
||||
if (!buriedPointTest.functionBuriedPoint(::kabase::AppName::KylinFontViewer , ::kabase::BuriedPoint::PT::KylinFontViewFontInformation)) {
|
||||
qCritical() << "Error : buried point fail !" << __FILE__ << "," << __FUNCTION__ << "," << __LINE__;
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::changecopywritingSDKPoint()
|
||||
{
|
||||
::kabase::BuriedPoint buriedPointTest;
|
||||
|
||||
if (!buriedPointTest.functionBuriedPoint(::kabase::AppName::KylinFontViewer , ::kabase::BuriedPoint::PT::KylinFontViewCopywritingChange)) {
|
||||
qCritical() << "Error : buried point fail !" << __FILE__ << "," << __FUNCTION__ << "," << __LINE__;
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::changeFontSizeSDKPoint()
|
||||
{
|
||||
::kabase::BuriedPoint buriedPointTest;
|
||||
|
||||
if (!buriedPointTest.functionBuriedPoint(::kabase::AppName::KylinFontViewer , ::kabase::BuriedPoint::PT::KylinFontViewFontSizeChange)) {
|
||||
qCritical() << "Error : buried point fail !" << __FILE__ << "," << __FUNCTION__ << "," << __LINE__;
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::getSystemDBusInfo()
|
||||
{
|
||||
m_rotateChange = new RotateChangeInfo(this);
|
||||
connect(m_rotateChange, &RotateChangeInfo::sigRotationChanged, this, &GlobalSizeData::slotChangeModel);
|
||||
return;
|
||||
}
|
||||
|
||||
void GlobalSizeData::slotChangeModel(bool isPCMode, int width, int height)
|
||||
{
|
||||
m_currentSize.first = width;
|
||||
m_currentSize.second = height;
|
||||
if (isPCMode) {
|
||||
m_currentMode = CurrentMode::PCMode;
|
||||
emit sigPCMode();
|
||||
} else {
|
||||
if (width > height) {
|
||||
m_currentMode = CurrentMode::HMode;
|
||||
emit sigHFlatMode();
|
||||
} else {
|
||||
m_currentMode = CurrentMode::VMode;
|
||||
emit sigVFlatMode();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentMode GlobalSizeData::getCurrentMode()
|
||||
{
|
||||
bool isPCMode = m_rotateChange->getCurrentMode();
|
||||
QPair<int, int> currentSize = m_rotateChange->getCurrentScale();
|
||||
m_currentSize = currentSize;
|
||||
if (isPCMode) {
|
||||
m_currentMode = CurrentMode::PCMode;
|
||||
} else {
|
||||
if (currentSize.first > currentSize.second) {
|
||||
m_currentMode = CurrentMode::HMode;
|
||||
} else {
|
||||
m_currentMode = CurrentMode::VMode;
|
||||
}
|
||||
}
|
||||
return m_currentMode;
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
#ifndef GLOBALSIZEDATA_H
|
||||
#define GLOBALSIZEDATA_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QGSettings>
|
||||
#include "rotatechangeinfo.h"
|
||||
|
||||
#define LIGHT_THEME "ukui-default"
|
||||
#define BLACK_THEME "ukui-dark"
|
||||
#define FONT_PATH "/kylin-font-viewer/"
|
||||
|
||||
/* 字体类型 */
|
||||
enum FontType {
|
||||
AllFont = 0,
|
||||
SystemFont,
|
||||
MyFont,
|
||||
CollectFont,
|
||||
};
|
||||
|
||||
enum CurrentMode {
|
||||
PCMode = 0,
|
||||
HMode,
|
||||
VMode,
|
||||
};
|
||||
|
||||
class GlobalSizeData : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static GlobalSizeData *getInstance();
|
||||
~GlobalSizeData();
|
||||
|
||||
/* 获取主题的样式,字号,透明度 */
|
||||
void getSystemTheme();
|
||||
void getSystemFontSize();
|
||||
void getSystemTransparency();
|
||||
void getSystemFontName();
|
||||
|
||||
/* 获取dbus平板/pc数据 */
|
||||
void getSystemDBusInfo();
|
||||
QPair<int,int> getCurrentScale();
|
||||
bool getIsPCMode();
|
||||
|
||||
/* SDK功能打点 */
|
||||
void addFontSDKPoint();
|
||||
void removeFontSDKPoint();
|
||||
void searchFontSDKPoint();
|
||||
void applyFontSDKPoint();
|
||||
void exportFontSDKPoint();
|
||||
void collectionFontSDKPoint();
|
||||
void cancelCollectionFontSDKPoint();
|
||||
void fontInfoSDKPoint();
|
||||
void changecopywritingSDKPoint();
|
||||
void changeFontSizeSDKPoint();
|
||||
|
||||
// 主题色
|
||||
static int THEME_COLOR;
|
||||
|
||||
enum ThemeColor {
|
||||
UKUILight = 0,
|
||||
UKUIDark,
|
||||
};
|
||||
|
||||
double g_transparency; /* 毛玻璃透明度 */
|
||||
int g_fontSize; /* 字号 */
|
||||
|
||||
/* 字体监控 */
|
||||
double g_font14pxToPt;
|
||||
double g_font16pxToPt; /* 弹窗标题 */
|
||||
double g_font18pxToPt; /* 关于标题 */
|
||||
|
||||
static FontType g_fontType; /* 当前查看字体类型 */
|
||||
QString m_fontName = "";
|
||||
QGSettings *m_themeGsettings = nullptr;
|
||||
|
||||
enum FontRoles {
|
||||
FontPath = Qt::UserRole,
|
||||
FontName,
|
||||
FontStyle,
|
||||
FontFamily,
|
||||
CollectState,
|
||||
FontHeight,
|
||||
FontInstall,
|
||||
};
|
||||
|
||||
enum FamilyType {
|
||||
SystemFont = 0,
|
||||
MyFont,
|
||||
};
|
||||
|
||||
enum CollectType {
|
||||
IsCollected = 0,
|
||||
NotCollected
|
||||
};
|
||||
|
||||
RotateChangeInfo *m_rotateChange = nullptr;
|
||||
|
||||
// 获取当前模式
|
||||
CurrentMode getCurrentMode();
|
||||
CurrentMode m_currentMode = CurrentMode::PCMode;
|
||||
QPair<int, int> m_currentSize;
|
||||
signals:
|
||||
void sigFontChange();
|
||||
void sigFontNameChange();
|
||||
void sigPCMode();
|
||||
void sigVFlatMode();
|
||||
void sigHFlatMode();
|
||||
private:
|
||||
GlobalSizeData();
|
||||
void changeFontSize();
|
||||
void changeFontName();
|
||||
void slotChangeModel(bool mode, int width, int height);
|
||||
};
|
||||
|
||||
#endif // GLOBALSIZEDATA_H
|
|
@ -0,0 +1,196 @@
|
|||
#include <QScreen>
|
||||
#include <QPainter>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QStackedWidget>
|
||||
|
||||
/* 适配组内SDK */
|
||||
#include <gsettingmonitor.h>
|
||||
#include <usermanual.h>
|
||||
#include "windowmanage.hpp"
|
||||
|
||||
|
||||
#include "mainview.h"
|
||||
|
||||
MainView::MainView(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
kabase::WindowManage::getWindowId(&m_windowId);
|
||||
|
||||
setWidgetUi();
|
||||
initLayout();
|
||||
setSlotConnet();
|
||||
}
|
||||
|
||||
MainView::~MainView()
|
||||
{
|
||||
}
|
||||
|
||||
MainView *MainView::getInstance()
|
||||
{
|
||||
static MainView instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
void MainView::setWidgetUi()
|
||||
{
|
||||
initGsetting();
|
||||
|
||||
m_functionWid = new FunctionWid(this);
|
||||
m_fontWid = new FontWidget(this);
|
||||
|
||||
this->installEventFilter(this);
|
||||
m_functionWid->installEventFilter(this);
|
||||
m_fontWid->installEventFilter(this);
|
||||
return;
|
||||
}
|
||||
|
||||
void MainView::initLayout()
|
||||
{
|
||||
//毛玻璃
|
||||
this->setProperty("useSystemStyleBlur",true);
|
||||
this->setAttribute(Qt::WA_TranslucentBackground,true);
|
||||
|
||||
this->setMinimumSize(880 , 570);
|
||||
this->setWindowTitle(tr("Font Viewer"));
|
||||
|
||||
m_hLayout = new QHBoxLayout();
|
||||
m_hLayout->addWidget(m_functionWid);
|
||||
m_hLayout->addSpacing(10);
|
||||
m_hLayout->addWidget(m_fontWid);
|
||||
m_hLayout->setSpacing(0);
|
||||
m_hLayout->setMargin(0);
|
||||
|
||||
this->setLayout(m_hLayout);
|
||||
|
||||
// 应用居中
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
this->move(screen->geometry().center() - this->rect().center());
|
||||
|
||||
this->changeStyle();
|
||||
return;
|
||||
}
|
||||
|
||||
void MainView::setSlotConnet()
|
||||
{
|
||||
connect(m_functionWid, &FunctionWid::sigChangeFontType, m_fontWid, &FontWidget::slotChangeFilterType);
|
||||
connect(this, &MainView::sigWindowState, m_fontWid, &FontWidget::slotWindowState);
|
||||
return;
|
||||
}
|
||||
|
||||
void MainView::pullUpWindow()
|
||||
{
|
||||
this->show();
|
||||
::kabase::WindowManage::setMiddleOfScreen(this);
|
||||
return;
|
||||
}
|
||||
|
||||
void MainView::initGsetting()
|
||||
{
|
||||
GlobalSizeData::getInstance();
|
||||
/* 主题 */
|
||||
this->connect(kdk::GsettingMonitor::getInstance(), &kdk::GsettingMonitor::systemThemeChange, this, [=]() {
|
||||
GlobalSizeData::getInstance()->getSystemTheme();
|
||||
// m_functionWid->changeTheme();
|
||||
this->changeStyle();
|
||||
this->update();
|
||||
});
|
||||
|
||||
/* 透明度 */
|
||||
this->connect(kdk::GsettingMonitor::getInstance(), &kdk::GsettingMonitor::systemTransparencyChange, this, [=]() {
|
||||
GlobalSizeData::getInstance()->getSystemTransparency();
|
||||
this->update();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void MainView::changeStyle()
|
||||
{
|
||||
// 设置背景色
|
||||
m_fontWid->setAutoFillBackground(true);
|
||||
|
||||
QPalette pal;
|
||||
if (GlobalSizeData::THEME_COLOR == GlobalSizeData::UKUILight) {
|
||||
pal.setColor(QPalette::Background, QColor(QString("#FFFFFF")));
|
||||
m_fontWid->setPalette(pal);
|
||||
} else {
|
||||
pal.setColor(QPalette::Background, QColor(QString("#000000")));
|
||||
m_fontWid->setPalette(pal);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void MainView::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
/* 反锯齿 */
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
QPainterPath rectPath;
|
||||
rectPath.addRoundedRect(rect(), 0, 0);
|
||||
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
|
||||
p.setPen(Qt::NoPen);
|
||||
QColor color = qApp->palette().color(QPalette::Window);
|
||||
color.setAlpha(GlobalSizeData::getInstance()->g_transparency);
|
||||
QPalette pal(this->palette());
|
||||
pal.setColor(QPalette::Window,QColor(color));
|
||||
this->setPalette(pal);
|
||||
QBrush brush =QBrush(color);
|
||||
p.setBrush(brush);
|
||||
p.drawRoundedRect(opt.rect,0,0);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
p.fillPath(rectPath, brush);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool MainView::eventFilter(QObject *watch, QEvent *event)
|
||||
{
|
||||
if (m_fontWid->eventFilter(watch, event)) {
|
||||
return QObject::eventFilter(watch, event);
|
||||
}
|
||||
return QObject::eventFilter(watch, event);
|
||||
}
|
||||
|
||||
void MainView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() == Qt::Key_F1) {
|
||||
// 帮助点击事件处理
|
||||
kdk::UserManual userManual;
|
||||
if (!userManual.callUserManual("kylin-font-viewer")) {
|
||||
qCritical() << "user manual call fail!";
|
||||
}
|
||||
}
|
||||
return QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void MainView::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::WindowStateChange) {
|
||||
if (this->windowState() == Qt::WindowMaximized) {
|
||||
QString state = "maxWindow";
|
||||
emit sigWindowState(state);
|
||||
} else {
|
||||
QString state = "normalWindow";
|
||||
emit sigWindowState(state);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void MainView::getFontFileFromClick(QString fontFile)
|
||||
{
|
||||
m_fontWid->useFontFileOpen(fontFile);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void MainView::getFontFileFromClickAferOpen(QString fontFile)
|
||||
{
|
||||
m_fontWid->cilckFontFile(fontFile);
|
||||
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
#ifndef MAINVIEW_H
|
||||
#define MAINVIEW_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "functionwid.h"
|
||||
#include "fontwid.h"
|
||||
#include "globalsizedata.h"
|
||||
|
||||
class MainView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
~MainView();
|
||||
static MainView *getInstance();
|
||||
|
||||
void setWidgetUi(); /* 初始化组件 */
|
||||
void initLayout(); /* 初始化布局 */
|
||||
void setSlotConnet(); /* 信号和槽 */
|
||||
void pullUpWindow(); /* 最小化状态下拉起主界面 */
|
||||
|
||||
void initGsetting(void); /* 监听主题变化 */
|
||||
void changeStyle(void); /* 切换深浅主题 */
|
||||
|
||||
void getFontFileFromClick(QString fileName);
|
||||
void getFontFileFromClickAferOpen(QString fileName);
|
||||
|
||||
quint32 m_windowId = 0; /* wayland 的 窗口ID */
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
bool eventFilter(QObject *watch, QEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override; /* 键盘响应事件 */
|
||||
void changeEvent(QEvent *event) override; /* 窗体改变 */
|
||||
|
||||
private:
|
||||
MainView(QWidget *parent = nullptr);
|
||||
|
||||
private:
|
||||
FunctionWid *m_functionWid = nullptr; /* 左侧功能界面 */
|
||||
FontWidget *m_fontWid = nullptr; /* 右侧显示界面 */
|
||||
|
||||
QHBoxLayout *m_hLayout = nullptr;
|
||||
|
||||
signals:
|
||||
void sigWindowState(QString state);
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // MAINVIEW_H
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "picturetowhite.h"
|
||||
|
||||
PictureToWhite::PictureToWhite(QObject *parent) : QObject(parent)
|
||||
{
|
||||
initGsettingValue();
|
||||
}
|
||||
|
||||
void PictureToWhite::initGsettingValue()
|
||||
{
|
||||
const QByteArray id(ORG_UKUI_STYLE);
|
||||
QStringList stylelist;
|
||||
stylelist << STYLE_NAME_KEY_DARK << STYLE_NAME_KEY_LIGHT << STYLE_NAME_KEY_DEFAULT;
|
||||
if (QGSettings::isSchemaInstalled(id)) {
|
||||
m_pgsettings = new QGSettings(id);
|
||||
if (stylelist.contains(m_pgsettings->get(STYLE_NAME).toString()) && m_pgsettings->get(STYLE_NAME).toString() == STYLE_NAME_KEY_LIGHT)
|
||||
tray_icon_color = TRAY_ICON_COLOR_LOGHT;
|
||||
else
|
||||
tray_icon_color = TRAY_ICON_COLOR_DRAK;
|
||||
}
|
||||
connect(m_pgsettings, &QGSettings::changed, this, [=] (const QString &key) {
|
||||
if (key==STYLE_NAME) {
|
||||
if (stylelist.contains(m_pgsettings->get(STYLE_NAME).toString()) && m_pgsettings->get(STYLE_NAME).toString() == STYLE_NAME_KEY_LIGHT)
|
||||
tray_icon_color = TRAY_ICON_COLOR_LOGHT;
|
||||
else
|
||||
tray_icon_color = TRAY_ICON_COLOR_DRAK;
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QPixmap PictureToWhite::drawSymbolicColoredPixmap(const QPixmap &source)
|
||||
{
|
||||
QColor gray(128,128,128);
|
||||
QColor standard (31,32,34);
|
||||
QImage img = source.toImage();
|
||||
for (int x = 0; x < img.width(); x++) {
|
||||
for (int y = 0; y < img.height(); y++) {
|
||||
auto color = img.pixelColor(x, y);
|
||||
if (color.alpha() > 0) {
|
||||
if (qAbs(color.red()-gray.red()) < 255 && qAbs(color.green()-gray.green()) < 255 && qAbs(color.blue()-gray.blue()) < 255) {
|
||||
color.setRed(tray_icon_color);
|
||||
color.setGreen(tray_icon_color);
|
||||
color.setBlue(tray_icon_color);
|
||||
img.setPixelColor(x, y, color);
|
||||
} else if (qAbs(color.red()-standard.red()) < 255 && qAbs(color.green()-standard.green()) < 255 && qAbs(color.blue()-standard.blue()) < 255) {
|
||||
color.setRed(tray_icon_color);
|
||||
color.setGreen(tray_icon_color);
|
||||
color.setBlue(tray_icon_color);
|
||||
img.setPixelColor(x, y, color);
|
||||
} else
|
||||
img.setPixelColor(x, y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
return QPixmap::fromImage(img);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef PICTURETOWHITE_H
|
||||
#define PICTURETOWHITE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QGSettings>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <QPixmap>
|
||||
#include <QDebug>
|
||||
|
||||
#define ORG_UKUI_STYLE "org.ukui.style"
|
||||
#define STYLE_NAME "styleName"
|
||||
#define STYLE_NAME_KEY_DARK "ukui-dark"
|
||||
#define STYLE_NAME_KEY_DEFAULT "ukui-default"
|
||||
//#define STYLE_NAME_KEY_BLACK "ukui-black"
|
||||
#define STYLE_NAME_KEY_LIGHT "ukui-light"
|
||||
#define STYLE_NAME_KEY_WHITE "ukui-white"
|
||||
#define TRAY_ICON_COLOR_LOGHT 0
|
||||
#define TRAY_ICON_COLOR_DRAK 255
|
||||
|
||||
class PictureToWhite : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PictureToWhite(QObject *parent = nullptr);
|
||||
void initGsettingValue();
|
||||
QPixmap drawSymbolicColoredPixmap(const QPixmap &source);
|
||||
|
||||
public:
|
||||
QGSettings *m_pgsettings = nullptr;
|
||||
int tray_icon_color;
|
||||
|
||||
};
|
||||
|
||||
#endif // PICTURETOWHITE_H
|
|
@ -0,0 +1,343 @@
|
|||
/* 适配组内SDK */
|
||||
#include"windowmanage.hpp"
|
||||
|
||||
#include "popupfontinfo.h"
|
||||
#include "globalsizedata.h"
|
||||
#include "mainview.h"
|
||||
|
||||
PopupFontInfo::PopupFontInfo(QString fontPath)
|
||||
{
|
||||
m_font = Core::getInstance()->getFontDetails(fontPath);
|
||||
setWidegtUi();
|
||||
setWidLayout();
|
||||
changeFontSize();
|
||||
}
|
||||
|
||||
PopupFontInfo::~PopupFontInfo()
|
||||
{
|
||||
}
|
||||
|
||||
void PopupFontInfo::setWidegtUi()
|
||||
{
|
||||
this->setFixedSize(410, 470);
|
||||
this->setWindowFlag(Qt::Tool);
|
||||
this->setWindowModality(Qt::WindowModal);
|
||||
this->setWindowModality(Qt::ApplicationModal);
|
||||
this->setAutoFillBackground(true);
|
||||
this->setBackgroundRole(QPalette::Base);
|
||||
this->setAttribute(Qt::WA_DeleteOnClose,true);
|
||||
|
||||
/* 适配kysdk的窗管 */
|
||||
::kabase::WindowManage::removeHeader(this);
|
||||
|
||||
m_titleBar = new BasePopupTitle();
|
||||
|
||||
m_tipText = new QLabel(this);
|
||||
m_fontName = new QLabel(this);
|
||||
m_nameValue = new QLabel(this);
|
||||
m_fontSeries = new QLabel(this);
|
||||
m_seriesValue = new QLabel(this);
|
||||
m_fontStyle = new QLabel(this);
|
||||
m_styleValue = new QLabel(this);
|
||||
m_fontType = new QLabel(this);
|
||||
m_typeValue = new QLabel(this);
|
||||
m_fontVersion = new QLabel(this);
|
||||
m_versionValue = new QLabel(this);
|
||||
m_fontPath = new QLabel(this);
|
||||
m_pathValue = new QLabel(this);
|
||||
m_fontCopyright = new QLabel(this);
|
||||
m_copyrightValue = new QLabel(this);
|
||||
m_fontTrademark = new QLabel(this);
|
||||
m_trademarkValue = new QLabel(this);
|
||||
|
||||
m_tipText->setFixedHeight(35);
|
||||
m_tipText->setText(m_font.family);
|
||||
m_tipText->adjustSize();
|
||||
m_tipText->setWordWrap(true);
|
||||
m_tipText->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
m_fontName->setFixedHeight(30);
|
||||
m_fontName->setText(tr("FontName"));
|
||||
m_fontName->setStyleSheet("color:#8C8C8C");
|
||||
m_fontName->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
m_nameValue->setFixedHeight(30);
|
||||
m_nameValue->setText(m_font.name);
|
||||
m_nameValue->adjustSize();
|
||||
m_nameValue->setWordWrap(true);
|
||||
m_nameValue->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
if (m_font.name == "") {
|
||||
m_fontName->hide();
|
||||
m_nameValue->hide();
|
||||
}
|
||||
|
||||
m_fontSeries->setFixedHeight(30);
|
||||
m_fontSeries->setText(tr("FontSeries"));
|
||||
m_fontSeries->setStyleSheet("color:#8C8C8C");
|
||||
m_fontSeries->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
m_seriesValue->setFixedHeight(30);
|
||||
m_seriesValue->setText(m_font.family);
|
||||
m_seriesValue->adjustSize();
|
||||
m_seriesValue->setWordWrap(true);
|
||||
m_seriesValue->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
if (m_font.family == "") {
|
||||
m_fontSeries->hide();
|
||||
m_seriesValue->hide();
|
||||
}
|
||||
|
||||
m_fontStyle->setFixedHeight(30);
|
||||
m_fontStyle->setText(tr("FontStyle"));
|
||||
m_fontStyle->setStyleSheet("color:#8C8C8C");
|
||||
m_fontStyle->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
m_styleValue->setFixedHeight(30);
|
||||
m_styleValue->setText(m_font.style);
|
||||
m_styleValue->adjustSize();
|
||||
m_styleValue->setWordWrap(true);
|
||||
m_styleValue->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
if (m_font.style == "") {
|
||||
m_fontStyle->hide();
|
||||
m_styleValue->hide();
|
||||
}
|
||||
|
||||
m_fontType->setFixedHeight(30);
|
||||
m_fontType->setText(tr("FontType"));
|
||||
m_fontType->setStyleSheet("color:#8C8C8C");
|
||||
m_fontType->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
m_typeValue->setFixedHeight(30);
|
||||
m_typeValue->setText(m_font.type);
|
||||
m_typeValue->adjustSize();
|
||||
m_typeValue->setWordWrap(true);
|
||||
m_typeValue->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
if (m_font.type == "") {
|
||||
m_fontType->hide();
|
||||
m_typeValue->hide();
|
||||
}
|
||||
|
||||
m_fontVersion->setFixedHeight(30);
|
||||
m_fontVersion->setText(tr("FontVersion"));
|
||||
m_fontVersion->setStyleSheet("color:#8C8C8C");
|
||||
m_fontVersion->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
m_versionValue->setText(m_font.version);
|
||||
m_versionValue->adjustSize();
|
||||
m_versionValue->setWordWrap(true);
|
||||
m_versionValue->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
if (m_font.version == "") {
|
||||
m_fontVersion->hide();
|
||||
m_versionValue->hide();
|
||||
}
|
||||
|
||||
m_fontPath->setFixedHeight(30);
|
||||
m_fontPath->setText(tr("FontPath"));
|
||||
m_fontPath->setStyleSheet("color:#8C8C8C");
|
||||
m_fontPath->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
m_pathValue->setText(m_font.path);
|
||||
m_pathValue->adjustSize();
|
||||
m_pathValue->setWordWrap(true);
|
||||
m_pathValue->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
if (m_font.path == "") {
|
||||
m_pathValue->hide();
|
||||
m_pathValue->hide();
|
||||
}
|
||||
|
||||
m_fontCopyright->setFixedHeight(30);
|
||||
m_fontCopyright->setText(tr("FontCopyright"));
|
||||
m_fontCopyright->setStyleSheet("color:#8C8C8C");
|
||||
m_fontCopyright->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
m_copyrightValue->setText(m_font.copyright);
|
||||
m_copyrightValue->adjustSize();
|
||||
m_copyrightValue->setWordWrap(true);
|
||||
m_copyrightValue->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
if (m_font.copyright == "") {
|
||||
m_fontCopyright->hide();
|
||||
m_copyrightValue->hide();
|
||||
}
|
||||
|
||||
m_fontTrademark->setFixedHeight(30);
|
||||
m_fontTrademark->setText(tr("FontTrademark"));
|
||||
m_fontTrademark->setStyleSheet("color:#8C8C8C");
|
||||
m_fontTrademark->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
m_trademarkValue->setText(m_font.manufacturer);
|
||||
m_trademarkValue->adjustSize();
|
||||
m_trademarkValue->setWordWrap(true);
|
||||
m_trademarkValue->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
if (m_font.manufacturer == "") {
|
||||
m_fontTrademark->hide();
|
||||
m_trademarkValue->hide();
|
||||
}
|
||||
|
||||
m_continueBtn = new QPushButton();
|
||||
m_continueBtn->setFixedHeight(36);
|
||||
m_continueBtn->setText(tr("Confirm"));
|
||||
m_continueBtn->setProperty("isImportant", true);
|
||||
|
||||
m_cancelBtn = new QPushButton();
|
||||
m_cancelBtn->setFixedHeight(36);
|
||||
m_cancelBtn->setText(tr("Cancel"));
|
||||
|
||||
connect(m_cancelBtn, &QPushButton::clicked, this, &PopupFontInfo::slotCancelClick);
|
||||
connect(m_continueBtn, &QPushButton::clicked, this, &PopupFontInfo::slotContinueClick);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontChange, this, &PopupFontInfo::changeFontSize);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontNameChange, this, &PopupFontInfo::slotChangeFontName);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupFontInfo::setWidLayout()
|
||||
{
|
||||
/* 字体信息网格布局 */
|
||||
m_gridLayout = new QGridLayout();
|
||||
|
||||
m_gridLayout->setHorizontalSpacing(10); // 设置水平间距
|
||||
m_gridLayout->setVerticalSpacing(4); // 设置垂直间距
|
||||
m_gridLayout->setContentsMargins(0, 0, 0, 0); // 设置外间距
|
||||
|
||||
/* 字体名称 */
|
||||
m_gridLayout->addWidget(m_fontName, 0, 0, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
m_gridLayout->addWidget(m_nameValue, 0, 1, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
/* 系列 */
|
||||
m_gridLayout->addWidget(m_fontSeries, 1, 0, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
m_gridLayout->addWidget(m_seriesValue, 1, 1, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
/* 样式 */
|
||||
m_gridLayout->addWidget(m_fontStyle, 2, 0, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
m_gridLayout->addWidget(m_styleValue, 2, 1, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
/* 种类 */
|
||||
m_gridLayout->addWidget(m_fontType, 3, 0, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
m_gridLayout->addWidget(m_typeValue, 3, 1, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
/* 版本 */
|
||||
m_gridLayout->addWidget(m_fontVersion, 4, 0, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
m_gridLayout->addWidget(m_versionValue, 4, 1, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
/* 位置 */
|
||||
m_gridLayout->addWidget(m_fontPath, 5, 0, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
m_gridLayout->addWidget(m_pathValue, 5, 1, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
/* 版权 */
|
||||
m_gridLayout->addWidget(m_fontCopyright, 6, 0, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
m_gridLayout->addWidget(m_copyrightValue, 6, 1, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
/* 商标 */
|
||||
m_gridLayout->addWidget(m_fontTrademark, 7, 0, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
m_gridLayout->addWidget(m_trademarkValue, 7, 1, 1, 1, Qt::AlignLeft | Qt::AlignTop);
|
||||
|
||||
m_vGridLayout = new QVBoxLayout();
|
||||
m_vGridLayout->addLayout(m_gridLayout);
|
||||
m_vGridLayout->addStretch();
|
||||
m_vGridLayout->setMargin(0);
|
||||
|
||||
m_widget = new QWidget(this);
|
||||
m_widget->setFixedWidth(350);
|
||||
m_widget->setLayout(m_vGridLayout);
|
||||
|
||||
m_scrollArea = new QScrollArea(this);
|
||||
m_scrollArea->setFixedSize(370, 300);
|
||||
m_scrollArea->setWidget(m_widget);
|
||||
m_scrollArea->setWidgetResizable(true);
|
||||
m_scrollArea->setFrameShape(QFrame::NoFrame);
|
||||
m_scrollArea->setStyleSheet("QScrollArea {background-color:transparent;}");
|
||||
m_scrollArea->viewport()->setStyleSheet("background-color:transparent;");
|
||||
m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_scrollArea->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
|
||||
/* 按钮横向布局 */
|
||||
m_hBtnLayout = new QHBoxLayout();
|
||||
m_hBtnLayout->addStretch();
|
||||
m_hBtnLayout->addWidget(m_cancelBtn);
|
||||
m_hBtnLayout->addSpacing(10);
|
||||
m_hBtnLayout->addWidget(m_continueBtn);
|
||||
m_hBtnLayout->setMargin(0);
|
||||
|
||||
/* 按钮和组件纵向布局 */
|
||||
m_vLayout = new QVBoxLayout();
|
||||
m_vLayout->addWidget(m_tipText);
|
||||
m_vLayout->addSpacing(10);
|
||||
m_vLayout->addWidget(m_scrollArea);
|
||||
m_vLayout->addSpacing(24);
|
||||
m_vLayout->addLayout(m_hBtnLayout);
|
||||
m_vLayout->addStretch();
|
||||
m_vLayout->setMargin(0);
|
||||
|
||||
/* 组件居中 */
|
||||
m_hMainLayout = new QHBoxLayout();
|
||||
m_hMainLayout->addSpacing(24);
|
||||
m_hMainLayout->addLayout(m_vLayout);
|
||||
m_hMainLayout->addSpacing(24);
|
||||
|
||||
/* 整个窗体布局 */
|
||||
m_vMainLayout = new QVBoxLayout();
|
||||
m_vMainLayout->setSpacing(0);
|
||||
m_vMainLayout->addWidget(m_titleBar);
|
||||
m_vMainLayout->addSpacing(10);
|
||||
m_vMainLayout->addLayout(m_hMainLayout);
|
||||
m_vMainLayout->addStretch();
|
||||
m_vMainLayout->setMargin(0);
|
||||
this->setLayout(m_vMainLayout);
|
||||
|
||||
/* 应用内居中 */
|
||||
this->move(MainView::getInstance()->geometry().center() - this->rect().center());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupFontInfo::changeFontSize()
|
||||
{
|
||||
QFont font16;
|
||||
font16.setPointSizeF(GlobalSizeData::getInstance()->g_font16pxToPt);
|
||||
font16.setBold(true);
|
||||
font16.setWeight(60);
|
||||
QFont font14;
|
||||
font14.setPointSizeF(GlobalSizeData::getInstance()->g_font14pxToPt);
|
||||
|
||||
m_tipText->setFont(font16);
|
||||
|
||||
m_fontName->setFont(font14);
|
||||
m_nameValue->setFont(font14);
|
||||
m_fontSeries->setFont(font14);
|
||||
m_seriesValue->setFont(font14);
|
||||
m_fontStyle->setFont(font14);
|
||||
m_styleValue->setFont(font14);
|
||||
m_fontType->setFont(font14);
|
||||
m_typeValue->setFont(font14);
|
||||
m_fontVersion->setFont(font14);
|
||||
m_versionValue->setFont(font14);
|
||||
m_fontPath->setFont(font14);
|
||||
m_pathValue->setFont(font14);
|
||||
m_fontCopyright->setFont(font14);
|
||||
m_copyrightValue->setFont(font14);
|
||||
m_fontTrademark->setFont(font14);
|
||||
m_trademarkValue->setFont(font14);
|
||||
|
||||
m_continueBtn->setFont(font14);
|
||||
m_cancelBtn->setFont(font14);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupFontInfo::slotContinueClick()
|
||||
{
|
||||
this->window()->close();
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupFontInfo::slotCancelClick()
|
||||
{
|
||||
this->window()->close();
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupFontInfo::slotChangeFontName()
|
||||
{
|
||||
this->update();
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
#ifndef POPUPFONTINFO_H
|
||||
#define POPUPFONTINFO_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QScrollArea>
|
||||
#include <QScrollBar>
|
||||
#include <QGridLayout>
|
||||
|
||||
#include "basepopuptitle.h"
|
||||
#include "include/core.h"
|
||||
|
||||
/* 字体信息弹窗 */
|
||||
class PopupFontInfo : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PopupFontInfo(QString fontPath);
|
||||
~PopupFontInfo();
|
||||
void setWidegtUi();
|
||||
void setWidLayout();
|
||||
void changeFontSize();
|
||||
|
||||
private:
|
||||
BasePopupTitle *m_titleBar = nullptr;
|
||||
QLabel *m_tipText = nullptr;
|
||||
QWidget *m_widget = nullptr;
|
||||
QScrollArea *m_scrollArea = nullptr;
|
||||
|
||||
QLabel *m_fontName = nullptr; /* 属性:名称 */
|
||||
QLabel *m_nameValue = nullptr; /* 名称 */
|
||||
|
||||
QLabel *m_fontSeries = nullptr; /* 属性:系列 */
|
||||
QLabel *m_seriesValue = nullptr; /* 系列 */
|
||||
|
||||
QLabel *m_fontStyle = nullptr; /* 属性:样式 */
|
||||
QLabel *m_styleValue = nullptr; /* 样式 */
|
||||
|
||||
QLabel *m_fontType = nullptr; /* 属性:种类 */
|
||||
QLabel *m_typeValue = nullptr; /* 种类 */
|
||||
|
||||
QLabel *m_fontVersion = nullptr; /* 属性:版本 */
|
||||
QLabel *m_versionValue = nullptr; /* 版本 */
|
||||
|
||||
QLabel *m_fontPath = nullptr; /* 属性:位置 */
|
||||
QLabel *m_pathValue = nullptr; /* 位置 */
|
||||
|
||||
QLabel *m_fontCopyright = nullptr; /* 属性:版权 */
|
||||
QLabel *m_copyrightValue = nullptr; /* 版权 */
|
||||
|
||||
QLabel *m_fontTrademark = nullptr; /* 属性:商标 */
|
||||
QLabel *m_trademarkValue = nullptr; /* 商标 */
|
||||
|
||||
QPushButton *m_continueBtn = nullptr;
|
||||
QPushButton *m_cancelBtn = nullptr;
|
||||
|
||||
QVBoxLayout *m_vLayout = nullptr;
|
||||
QGridLayout *m_gridLayout = nullptr; /* 字体信息内容网格布局 */
|
||||
QVBoxLayout *m_vGridLayout = nullptr;
|
||||
QHBoxLayout *m_hBtnLayout = nullptr;
|
||||
QHBoxLayout *m_hMainLayout = nullptr;
|
||||
QVBoxLayout *m_vMainLayout = nullptr;
|
||||
|
||||
FontInformation m_font; /* 字体信息结构体 */
|
||||
|
||||
signals:
|
||||
public slots:
|
||||
void slotContinueClick();
|
||||
void slotCancelClick();
|
||||
void slotChangeFontName();
|
||||
};
|
||||
|
||||
#endif // POPUPFONTINFO_H
|
|
@ -0,0 +1,185 @@
|
|||
#include <QScrollBar>
|
||||
|
||||
/* 适配组内SDK */
|
||||
#include "windowmanage.hpp"
|
||||
|
||||
#include "popupinstallfail.h"
|
||||
#include "globalsizedata.h"
|
||||
#include "mainview.h"
|
||||
|
||||
PopupInstallFail::PopupInstallFail(QStringList fontList, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
m_uninstallFont = fontList;
|
||||
setWidgetUi();
|
||||
setWidLayout();
|
||||
changeFontSize();
|
||||
}
|
||||
|
||||
PopupInstallFail::~PopupInstallFail()
|
||||
{
|
||||
}
|
||||
|
||||
void PopupInstallFail::setWidgetUi()
|
||||
{
|
||||
this->setWindowFlag(Qt::Tool);
|
||||
this->setWindowModality(Qt::WindowModal);
|
||||
this->setWindowModality(Qt::ApplicationModal);
|
||||
this->setAutoFillBackground(true);
|
||||
this->setBackgroundRole(QPalette::Base);
|
||||
this->setAttribute(Qt::WA_DeleteOnClose,true);
|
||||
|
||||
/* 适配kysdk的窗管 */
|
||||
::kabase::WindowManage::removeHeader(this);
|
||||
|
||||
m_titleBar = new BasePopupTitle();
|
||||
m_tipIcon = new QPushButton(this);
|
||||
m_tipText = new QLabel(this);
|
||||
m_fontListWid = new QListWidget(this);
|
||||
m_continueBtn = new QPushButton(this);
|
||||
|
||||
//设置图标
|
||||
m_tipIcon->setIcon(QIcon::fromTheme("dialog-error"));
|
||||
m_tipIcon->setIconSize(QSize(24, 24));
|
||||
m_tipIcon->setProperty("isWindowButton", 0x1);
|
||||
m_tipIcon->setProperty("useIconHighlightEffect", 0x2);
|
||||
m_tipIcon->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
QString btnStyle = "QPushButton{border:0px;border-radius:4px;background:transparent;}"
|
||||
"QPushButton:Hover{border:0px;border-radius:4px;background:transparent;}"
|
||||
"QPushButton:Pressed{border:0px;border-radius:4px;background:transparent;}";
|
||||
m_tipIcon->setStyleSheet(btnStyle);
|
||||
|
||||
m_tipText->setFixedSize(300, 55);
|
||||
m_tipText->setText(tr("There is a problem with the font file. Installation failed!"));
|
||||
m_tipText->adjustSize();
|
||||
m_tipText->setWordWrap(true);
|
||||
m_tipText->setAlignment(Qt::AlignTop);
|
||||
|
||||
m_continueBtn->setFixedHeight(36);
|
||||
m_continueBtn->setText(tr("confirm"));
|
||||
m_continueBtn->setProperty("isImportant", true);
|
||||
|
||||
int num = 0;
|
||||
|
||||
for (int i = 0; i < m_uninstallFont.size(); ++i) {
|
||||
QListWidgetItem *item = new QListWidgetItem();
|
||||
item->setSizeHint(QSize(328, 36));
|
||||
item->setFlags(Qt::ItemIsEnabled);
|
||||
item->setTextAlignment(Qt::AlignVCenter);
|
||||
|
||||
QWidget *fontNameWid = new QWidget();
|
||||
QLabel *fontNameLab = new QLabel(fontNameWid);
|
||||
fontNameLab->setText(m_uninstallFont[i]);
|
||||
|
||||
QHBoxLayout *hLayout;
|
||||
hLayout = new QHBoxLayout();
|
||||
hLayout->addSpacing(10);
|
||||
hLayout->addWidget(fontNameLab);
|
||||
hLayout->setMargin(0);
|
||||
QVBoxLayout *vLayout;
|
||||
vLayout = new QVBoxLayout();
|
||||
vLayout->addStretch();
|
||||
vLayout->addLayout(hLayout);
|
||||
vLayout->addStretch();
|
||||
vLayout->setMargin(0);
|
||||
fontNameWid->setLayout(vLayout);
|
||||
|
||||
m_fontListWid->addItem(item);
|
||||
m_fontListWid->setItemWidget(item, fontNameWid);
|
||||
|
||||
num++;
|
||||
}
|
||||
if (num > 4) {
|
||||
m_fontListWid->setFixedHeight(4 * 40);
|
||||
} else {
|
||||
m_fontListWid->setFixedHeight(num * 40);
|
||||
}
|
||||
m_fontListWid->setFixedWidth(328);
|
||||
|
||||
m_fontListWid->setFrameShape(QListView::NoFrame); /* 去除边框 */
|
||||
m_fontListWid->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); /* 取消横向滚动 */
|
||||
m_fontListWid->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); /* 滚动条禁用右键 */
|
||||
m_fontListWid->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
m_fontListWid->verticalScrollBar()->setProperty("drawScrollBarGroove", false);
|
||||
m_fontListWid->setAlternatingRowColors(true); /* 奇偶行颜色不同 */
|
||||
m_fontListWid->setDragEnabled(false);
|
||||
|
||||
this->setFixedWidth(380);
|
||||
this->setFixedHeight(200 + m_fontListWid->height());
|
||||
|
||||
connect(m_continueBtn, &QPushButton::clicked, this, &PopupInstallFail::slotContinueClick);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontChange, this, &PopupInstallFail::changeFontSize);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupInstallFail::setWidLayout()
|
||||
{
|
||||
m_vMainLayout = new QVBoxLayout();
|
||||
m_hMainLayout = new QHBoxLayout();
|
||||
m_hBtnLayout = new QHBoxLayout();
|
||||
m_hTipLayout = new QHBoxLayout();
|
||||
m_vLayout = new QVBoxLayout();
|
||||
|
||||
/* 提示横向布局 */
|
||||
m_hTipLayout->addWidget(m_tipIcon);
|
||||
m_hTipLayout->addSpacing(10);
|
||||
m_hTipLayout->addWidget(m_tipText);
|
||||
m_hTipLayout->addStretch();
|
||||
|
||||
/* 按钮横向布局 */
|
||||
m_hBtnLayout->addStretch();
|
||||
m_hBtnLayout->addWidget(m_continueBtn);
|
||||
m_hBtnLayout->setMargin(0);
|
||||
|
||||
/* 按钮和组件纵向布局 */
|
||||
m_vLayout->addLayout(m_hTipLayout);
|
||||
m_vLayout->addSpacing(7);
|
||||
m_vLayout->addWidget(m_fontListWid);
|
||||
m_vLayout->addSpacing(24);
|
||||
m_vLayout->addLayout(m_hBtnLayout);
|
||||
m_vLayout->addStretch();
|
||||
m_vLayout->setMargin(0);
|
||||
|
||||
/* 组件居中 */
|
||||
m_hMainLayout->addStretch();
|
||||
m_hMainLayout->addLayout(m_vLayout);
|
||||
m_hMainLayout->addStretch();
|
||||
|
||||
/* 整个窗体布局 */
|
||||
m_vMainLayout->setSpacing(0);
|
||||
m_vMainLayout->addWidget(m_titleBar);
|
||||
m_vMainLayout->addSpacing(10);
|
||||
m_vMainLayout->addLayout(m_hMainLayout);
|
||||
m_vMainLayout->addStretch();
|
||||
m_vMainLayout->setMargin(0);
|
||||
this->setLayout(m_vMainLayout);
|
||||
|
||||
// 应用内居中
|
||||
this->move(MainView::getInstance()->geometry().center() - this->rect().center());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupInstallFail::changeFontSize()
|
||||
{
|
||||
QFont font14;
|
||||
font14.setPointSizeF(GlobalSizeData::getInstance()->g_font14pxToPt);
|
||||
m_tipText->setFont(font14);
|
||||
m_continueBtn->setFont(font14);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupInstallFail::slotContinueClick()
|
||||
{
|
||||
this->window()->close();
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupInstallFail::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
this->hide();
|
||||
emit signalWidgetClose();
|
||||
event->ignore(); // 忽略不结束进程
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
#ifndef POPUPINSTALLFAIL_H
|
||||
#define POPUPINSTALLFAIL_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QListWidget>
|
||||
|
||||
#include "basepopuptitle.h"
|
||||
#include "include/core.h"
|
||||
|
||||
/* 字体安装失败弹窗 */
|
||||
class PopupInstallFail : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PopupInstallFail(QStringList fontList , QWidget *parent = nullptr);
|
||||
~PopupInstallFail();
|
||||
void setWidgetUi();
|
||||
void setWidLayout();
|
||||
void changeFontSize();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
BasePopupTitle *m_titleBar = nullptr;
|
||||
QPushButton *m_tipIcon = nullptr;
|
||||
QLabel *m_tipText = nullptr;
|
||||
QListWidget *m_fontListWid = nullptr;
|
||||
QPushButton *m_continueBtn = nullptr;
|
||||
|
||||
QVBoxLayout *m_vLayout = nullptr;
|
||||
QHBoxLayout *m_hTipLayout = nullptr;
|
||||
QHBoxLayout *m_hBtnLayout = nullptr;
|
||||
QVBoxLayout *m_vMainLayout = nullptr;
|
||||
QHBoxLayout *m_hMainLayout = nullptr;
|
||||
|
||||
QStringList m_uninstallFont;
|
||||
signals:
|
||||
void signalWidgetClose();
|
||||
public slots:
|
||||
void slotContinueClick();
|
||||
};
|
||||
|
||||
#endif // POPUPINSTALLFAIL_H
|
|
@ -0,0 +1,106 @@
|
|||
#include <QTimer>
|
||||
|
||||
/* 适配组内SDK */
|
||||
#include "windowmanage.hpp"
|
||||
|
||||
#include "popupinstallsuccess.h"
|
||||
#include "globalsizedata.h"
|
||||
#include "mainview.h"
|
||||
|
||||
PopupInstallSuccess::PopupInstallSuccess(int num)
|
||||
{
|
||||
m_num = num;
|
||||
setWidgetUi();
|
||||
changeFontSize();
|
||||
}
|
||||
|
||||
PopupInstallSuccess::~PopupInstallSuccess()
|
||||
{
|
||||
}
|
||||
|
||||
void PopupInstallSuccess::setWidgetUi()
|
||||
{
|
||||
this->setWindowFlag(Qt::Tool);
|
||||
this->setWindowModality(Qt::WindowModal);
|
||||
this->setWindowModality(Qt::ApplicationModal);
|
||||
this->setAutoFillBackground(true);
|
||||
this->setBackgroundRole(QPalette::Base);
|
||||
|
||||
/* 适配kysdk的窗管 */
|
||||
::kabase::WindowManage::removeHeader(this);
|
||||
|
||||
m_tipIcon = new QPushButton(this);
|
||||
m_tipText = new QLabel(this);
|
||||
|
||||
m_vLayout = new QVBoxLayout();
|
||||
m_hLayout = new QHBoxLayout();
|
||||
|
||||
m_hLayout->setSpacing(0);
|
||||
m_hLayout->addStretch();
|
||||
m_hLayout->addWidget(m_tipIcon);
|
||||
m_hLayout->addSpacing(9);
|
||||
m_hLayout->addWidget(m_tipText);
|
||||
m_hLayout->addStretch();
|
||||
m_hLayout->setMargin(0);
|
||||
|
||||
m_vLayout->setContentsMargins(0,0,0,0);
|
||||
m_vLayout->setSpacing(0);
|
||||
m_vLayout->addStretch();
|
||||
m_vLayout->addLayout(m_hLayout);
|
||||
m_vLayout->addStretch();
|
||||
this->setLayout(m_vLayout);
|
||||
|
||||
//设置图标
|
||||
m_tipIcon->setIcon(QIcon::fromTheme("ukui-dialog-success"));
|
||||
m_tipIcon->setIconSize(QSize(24, 24));
|
||||
m_tipIcon->setProperty("isWindowButton", 0x1);
|
||||
m_tipIcon->setProperty("useIconHighlightEffect", 0x2);
|
||||
m_tipIcon->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
QString btnStyle = "QPushButton{border:0px;border-radius:4px;background:transparent;}"
|
||||
"QPushButton:Hover{border:0px;border-radius:4px;background:transparent;}"
|
||||
"QPushButton:Pressed{border:0px;border-radius:4px;background:transparent;}";
|
||||
m_tipIcon->setStyleSheet(btnStyle);
|
||||
|
||||
/* m_tipText为要显示的信息 */
|
||||
QFont font14;
|
||||
font14.setPointSizeF(GlobalSizeData::getInstance()->g_font14pxToPt);
|
||||
m_tipText->setFont(font14);
|
||||
QString tipText = tr("already installed ") + QString::number(m_num) + tr(" fonts!");
|
||||
m_tipText->setText(tipText);
|
||||
|
||||
QFontMetrics fontmts = QFontMetrics(font14);
|
||||
int width = fontmts.width(tipText) + 55;
|
||||
this->setFixedWidth(width);
|
||||
this->setFixedHeight(60);
|
||||
|
||||
// 关于弹窗应用内居中
|
||||
QRect availableGeometry = this->geometry();
|
||||
this->move(availableGeometry.center() - this->rect().center());
|
||||
|
||||
/* 设置定时器,到时自我销毁 */
|
||||
QTimer* timer = new QTimer(this);
|
||||
timer->start(2000); /* 时间2秒 */
|
||||
timer->setSingleShot(true); /* 仅触发一次 */
|
||||
|
||||
connect(timer, &QTimer::timeout, this, &PopupInstallSuccess::slotTimeDestroy);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontChange, this, &PopupInstallSuccess::changeFontSize);
|
||||
|
||||
// 应用内居中
|
||||
this->move(MainView::getInstance()->geometry().center() - this->rect().center());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupInstallSuccess::changeFontSize()
|
||||
{
|
||||
QFont font14;
|
||||
font14.setPointSizeF(GlobalSizeData::getInstance()->g_font14pxToPt);
|
||||
m_tipText->setFont(font14);
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupInstallSuccess::slotTimeDestroy()
|
||||
{
|
||||
this->window()->close();
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef POPUPINSTALLSUCCESS_H
|
||||
#define POPUPINSTALLSUCCESS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "basepopuptitle.h"
|
||||
#include "include/core.h"
|
||||
|
||||
/* 字体安装成功弹窗 */
|
||||
class PopupInstallSuccess: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PopupInstallSuccess(int num);
|
||||
~PopupInstallSuccess();
|
||||
void setWidgetUi();
|
||||
void changeFontSize();
|
||||
|
||||
private:
|
||||
QLabel *m_tipText = nullptr; /* 提示框内的信息 */
|
||||
QPushButton *m_tipIcon = nullptr; /* 提示图标 */
|
||||
|
||||
QVBoxLayout *m_vLayout = nullptr; /* 提示弹窗纵向布局 */
|
||||
QHBoxLayout *m_hLayout = nullptr; /* 提示弹窗横向布局 */
|
||||
|
||||
int m_num = 0;
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void slotTimeDestroy(); /* 销毁安装成功弹窗 */
|
||||
|
||||
};
|
||||
|
||||
#endif // POPUPINSTALLSUCCESS_H
|
|
@ -0,0 +1,112 @@
|
|||
/* 适配组内SDK */
|
||||
#include "windowmanage.hpp"
|
||||
|
||||
#include "popupremove.h"
|
||||
#include "globalsizedata.h"
|
||||
#include "mainview.h"
|
||||
|
||||
PopupRemove::PopupRemove(QString path)
|
||||
{
|
||||
m_path = path;
|
||||
setWidgetUi();
|
||||
changeFontSize();
|
||||
}
|
||||
|
||||
PopupRemove::~PopupRemove()
|
||||
{
|
||||
}
|
||||
|
||||
void PopupRemove::setWidgetUi()
|
||||
{
|
||||
this->setFixedSize(400, 200);
|
||||
this->setWindowFlag(Qt::Tool);
|
||||
this->setWindowModality(Qt::WindowModal);
|
||||
this->setWindowModality(Qt::ApplicationModal);
|
||||
this->setAutoFillBackground(true);
|
||||
this->setBackgroundRole(QPalette::Base);
|
||||
this->setAttribute(Qt::WA_DeleteOnClose,true);
|
||||
|
||||
/* 适配kysdk的窗管 */
|
||||
::kabase::WindowManage::removeHeader(this);
|
||||
|
||||
m_titleBar = new BasePopupTitle();
|
||||
m_tipText = new QLabel(this);
|
||||
m_sureBtn = new QPushButton(this);
|
||||
m_cancelBtn = new QPushButton(this);
|
||||
m_vMainLayout = new QVBoxLayout();
|
||||
m_hMainLayout = new QHBoxLayout();
|
||||
m_vLayout = new QVBoxLayout();
|
||||
m_hLayout = new QHBoxLayout();
|
||||
|
||||
/* 按钮横向布局 */
|
||||
m_hLayout->addStretch();
|
||||
m_hLayout->addWidget(m_cancelBtn);
|
||||
m_hLayout->setSpacing(10);
|
||||
m_hLayout->addWidget(m_sureBtn);
|
||||
|
||||
/* 按钮和组件纵向布局 */
|
||||
m_vLayout->addWidget(m_tipText);
|
||||
m_vLayout->setSpacing(5);
|
||||
m_vLayout->addLayout(m_hLayout);
|
||||
m_vLayout->addStretch();
|
||||
m_vLayout->setMargin(0);
|
||||
|
||||
/* 组件居中 */
|
||||
m_hMainLayout->addStretch();
|
||||
m_hMainLayout->addLayout(m_vLayout);
|
||||
m_hMainLayout->addStretch();
|
||||
|
||||
/* 整个窗体布局 */
|
||||
m_vMainLayout->setSpacing(0);
|
||||
m_vMainLayout->addWidget(m_titleBar);
|
||||
m_vMainLayout->addSpacing(16);
|
||||
m_vMainLayout->addLayout(m_hMainLayout);
|
||||
m_vMainLayout->addStretch();
|
||||
m_vMainLayout->setMargin(0);
|
||||
this->setLayout(m_vMainLayout);
|
||||
|
||||
m_tipText->setFixedSize(332, 65);
|
||||
m_tipText->setText(tr("Are you sure you want to remove this font?"));
|
||||
|
||||
m_tipText->adjustSize(); /* 当内容过长自动换行 */
|
||||
m_tipText->setWordWrap(true);
|
||||
m_tipText->setAlignment(Qt::AlignTop);
|
||||
|
||||
m_sureBtn->setFixedHeight(36);
|
||||
m_sureBtn->setText(tr("Confirm"));
|
||||
m_sureBtn->setProperty("isImportant", true);
|
||||
|
||||
m_cancelBtn->setFixedHeight(36);
|
||||
m_cancelBtn->setText(tr("Cancel"));
|
||||
|
||||
// 应用内居中
|
||||
this->move(MainView::getInstance()->geometry().center() - this->rect().center());
|
||||
|
||||
connect(m_sureBtn, &QPushButton::clicked, this, &PopupRemove::slotSureClick);
|
||||
connect(m_cancelBtn, &QPushButton::clicked, this, &PopupRemove::slotCancelClick);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontChange, this, &PopupRemove::changeFontSize);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupRemove::changeFontSize()
|
||||
{
|
||||
QFont font14;
|
||||
font14.setPointSizeF(GlobalSizeData::getInstance()->g_font14pxToPt);
|
||||
m_tipText->setFont(font14);
|
||||
m_sureBtn->setFont(font14);
|
||||
m_cancelBtn->setFont(font14);
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupRemove::slotSureClick()
|
||||
{
|
||||
emit sigSureClick(m_path);
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupRemove::slotCancelClick()
|
||||
{
|
||||
this->window()->close();
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
#ifndef POPUPREMOVE_H
|
||||
#define POPUPREMOVE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "basepopuptitle.h"
|
||||
#include "include/core.h"
|
||||
|
||||
/* 字体卸载弹窗 */
|
||||
class PopupRemove: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PopupRemove(QString path);
|
||||
~PopupRemove();
|
||||
void setWidgetUi();
|
||||
void changeFontSize();
|
||||
|
||||
private:
|
||||
BasePopupTitle *m_titleBar = nullptr; /* 标题栏 */
|
||||
QLabel *m_tipText = nullptr; /* 提示信息 */
|
||||
QPushButton *m_sureBtn = nullptr; /* 确认按钮 */
|
||||
QPushButton *m_cancelBtn = nullptr; /* 取消按钮 */
|
||||
|
||||
QVBoxLayout *m_vMainLayout = nullptr;
|
||||
QHBoxLayout *m_hMainLayout = nullptr;
|
||||
QVBoxLayout *m_vLayout = nullptr;
|
||||
QHBoxLayout *m_hLayout = nullptr;
|
||||
|
||||
QString m_path;
|
||||
|
||||
signals:
|
||||
void sigSureClick(QString path);
|
||||
|
||||
public slots:
|
||||
void slotSureClick();
|
||||
void slotCancelClick();
|
||||
};
|
||||
|
||||
#endif // POPUPREMOVE_H
|
|
@ -0,0 +1,127 @@
|
|||
/* 适配组内SDK */
|
||||
#include "windowmanage.hpp"
|
||||
|
||||
#include "popupremove.h"
|
||||
#include "globalsizedata.h"
|
||||
#include "mainview.h"
|
||||
|
||||
PopupTips::PopupTips(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
setWidgetUi();
|
||||
changeFontSize();
|
||||
}
|
||||
|
||||
PopupTips::~PopupTips()
|
||||
{
|
||||
if (m_titleBar != nullptr) {
|
||||
delete m_titleBar;
|
||||
m_titleBar = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void PopupTips::setWidgetUi()
|
||||
{
|
||||
this->setFixedSize(400, 230);
|
||||
this->setWindowFlag(Qt::Tool);
|
||||
this->setWindowModality(Qt::WindowModal);
|
||||
this->setWindowModality(Qt::ApplicationModal);
|
||||
this->setAutoFillBackground(true);
|
||||
this->setBackgroundRole(QPalette::Base);
|
||||
this->setAttribute(Qt::WA_DeleteOnClose,true);
|
||||
|
||||
/* 适配kysdk的窗管 */
|
||||
::kabase::WindowManage::removeHeader(this);
|
||||
|
||||
m_titleBar = new BasePopupTitle();
|
||||
m_tipText = new QLabel(this);
|
||||
m_sureBtn = new QPushButton(this);
|
||||
m_checkBox = new QCheckBox(this);
|
||||
m_vMainLayout = new QVBoxLayout();
|
||||
m_hMainLayout = new QHBoxLayout();
|
||||
m_vLayout = new QVBoxLayout();
|
||||
m_hLayout = new QHBoxLayout();
|
||||
|
||||
/* 按钮横向布局 */
|
||||
m_hLayout->addStretch();
|
||||
m_hLayout->addWidget(m_sureBtn);
|
||||
|
||||
/* 按钮和组件纵向布局 */
|
||||
m_vLayout->addWidget(m_tipText);
|
||||
m_vLayout->addWidget(m_checkBox);
|
||||
m_vLayout->addStretch();
|
||||
m_vLayout->addLayout(m_hLayout);
|
||||
m_vLayout->setSpacing(20);
|
||||
m_vLayout->setMargin(0);
|
||||
|
||||
/* 组件居中 */
|
||||
m_hMainLayout->addStretch();
|
||||
m_hMainLayout->addLayout(m_vLayout);
|
||||
m_hMainLayout->addStretch();
|
||||
|
||||
/* 整个窗体布局 */
|
||||
m_vMainLayout->setSpacing(0);
|
||||
m_vMainLayout->addWidget(m_titleBar);
|
||||
m_vMainLayout->addSpacing(16);
|
||||
m_vMainLayout->addLayout(m_hMainLayout);
|
||||
m_vMainLayout->addStretch();
|
||||
m_vMainLayout->setMargin(0);
|
||||
this->setLayout(m_vMainLayout);
|
||||
|
||||
m_tips = tr("Installing new fonts takes effect after restarting!");
|
||||
m_tipText->setFixedWidth(332);
|
||||
m_tipText->setText(m_tips);
|
||||
m_tipText->setMargin(0);
|
||||
m_tipText->setAlignment(Qt::AlignTop);
|
||||
|
||||
m_sureBtn->setFixedHeight(45);
|
||||
m_sureBtn->setText(tr("Confirm"));
|
||||
m_sureBtn->setProperty("isImportant", true);
|
||||
|
||||
m_checkBox->setText(tr("Do not show again"));
|
||||
|
||||
// 应用内居中
|
||||
this->move(MainView::getInstance()->geometry().center() - this->rect().center());
|
||||
|
||||
connect(m_sureBtn, &QPushButton::clicked, this, &PopupTips::slotSureClick);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontChange, this, &PopupTips::changeFontSize);
|
||||
|
||||
changeFontSize();
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupTips::changeFontSize()
|
||||
{
|
||||
QFont font14;
|
||||
font14.setPointSizeF(GlobalSizeData::getInstance()->g_font14pxToPt);
|
||||
m_tipText->setFont(font14);
|
||||
m_sureBtn->setFont(font14);
|
||||
|
||||
QFontMetrics fontmts = QFontMetrics(font14);
|
||||
QString text = m_tips;
|
||||
if (fontmts.width(m_tips) > m_tipText->width()) {
|
||||
m_tipText->setToolTip(m_tips);
|
||||
text = fontmts.elidedText(text, Qt::ElideRight, m_tipText->width());
|
||||
}
|
||||
m_tipText->setText(text);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupTips::slotSureClick()
|
||||
{
|
||||
this->window()->close();
|
||||
return;
|
||||
}
|
||||
|
||||
void PopupTips::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
this->hide();
|
||||
emit signalWidgetClose();
|
||||
event->ignore(); // 忽略不结束进程
|
||||
if (m_checkBox->checkState() == Qt::Checked) {
|
||||
Core::getInstance()->settingFontTips(false);
|
||||
} else if (m_checkBox->checkState() == Qt::Unchecked) {
|
||||
Core::getInstance()->settingFontTips(true);
|
||||
}
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef POPUPTIPS_H
|
||||
#define POPUPTIPS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QCheckBox>
|
||||
|
||||
#include "basepopuptitle.h"
|
||||
#include "include/core.h"
|
||||
|
||||
/* 字体提示弹窗 */
|
||||
class PopupTips: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PopupTips(QWidget *parent = nullptr);
|
||||
~PopupTips();
|
||||
void setWidgetUi();
|
||||
void changeFontSize();
|
||||
|
||||
private:
|
||||
BasePopupTitle *m_titleBar = nullptr; /* 标题栏 */
|
||||
QLabel *m_tipText = nullptr; /* 提示信息 */
|
||||
QPushButton *m_sureBtn = nullptr; /* 确认按钮 */
|
||||
QCheckBox *m_checkBox = nullptr; /* 复选框 */
|
||||
QVBoxLayout *m_vMainLayout = nullptr;
|
||||
QHBoxLayout *m_hMainLayout = nullptr;
|
||||
QVBoxLayout *m_vLayout = nullptr;
|
||||
QHBoxLayout *m_hLayout = nullptr;
|
||||
|
||||
QString m_tips;
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
signals:
|
||||
void signalWidgetClose();
|
||||
|
||||
public slots:
|
||||
void slotSureClick();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,55 @@
|
|||
#include "rotatechangeinfo.h"
|
||||
|
||||
RotateChangeInfo::RotateChangeInfo(QObject *parent) : QObject(parent)
|
||||
{
|
||||
qDebug() << "rotate object has created!";
|
||||
|
||||
connect(QApplication::primaryScreen(), &QScreen::primaryOrientationChanged, this, &RotateChangeInfo::slotRotateChanged);
|
||||
QDBusConnection::sessionBus().connect(KYLIN_ROTATION_SERVICE, KYLIN_ROTATION_PATH, KYLIN_ROTATION_INTERFACE,
|
||||
QString("mode_change_signal"), this, SLOT(slotModeChanged(bool)));
|
||||
getCurrentScale();
|
||||
getCurrentMode();
|
||||
}
|
||||
|
||||
void RotateChangeInfo::slotRotateChanged(){
|
||||
QPair<int,int> scale = getCurrentScale();
|
||||
qDebug() << "horizontal & vertical mode changed sig has received! current scale: " << scale.first << "*" ;
|
||||
emit sigRotationChanged(m_isPCMode, scale.first, scale.second);
|
||||
}
|
||||
|
||||
void RotateChangeInfo::slotModeChanged(bool isPadMode){
|
||||
if (isPadMode) {
|
||||
m_isPCMode = false;
|
||||
} else {
|
||||
m_isPCMode = true;
|
||||
}
|
||||
qDebug() << "pc & pad mode changed sig has received! current mode: " << m_isPCMode;
|
||||
emit sigRotationChanged(m_isPCMode, m_screenWidth, m_screenHeight);
|
||||
}
|
||||
|
||||
QPair<int, int> RotateChangeInfo::getCurrentScale(){
|
||||
QScreen *screen = qApp->primaryScreen();
|
||||
m_screenWidth = screen->size().width();
|
||||
m_screenHeight = screen->size().height();
|
||||
QPair<int,int> scale;
|
||||
scale.first = m_screenWidth;
|
||||
scale.second = m_screenHeight;
|
||||
qDebug() << "screen size: " << m_screenWidth << "*" << m_screenHeight;
|
||||
return scale;
|
||||
}
|
||||
|
||||
bool RotateChangeInfo::getCurrentMode(){
|
||||
QDBusMessage message_pcORpad = QDBusMessage::createMethodCall(KYLIN_ROTATION_SERVICE, KYLIN_ROTATION_PATH,
|
||||
KYLIN_ROTATION_INTERFACE, QString("get_current_tabletmode"));
|
||||
QDBusPendingReply<bool> reply_pcORpad = QDBusConnection::sessionBus().call(message_pcORpad);
|
||||
if (!reply_pcORpad.isValid()) {
|
||||
m_isPCMode = true;
|
||||
return m_isPCMode;
|
||||
}
|
||||
if (reply_pcORpad.value()) {
|
||||
m_isPCMode = false;
|
||||
} else {
|
||||
m_isPCMode = true;
|
||||
}
|
||||
return m_isPCMode;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef ROTATECHANGEINFO_H
|
||||
#define ROTATECHANGEINFO_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QApplication>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusConnectionInterface>
|
||||
#include <QtDBus/QDBusMessage>
|
||||
#include <QtDBus/QDBusReply>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <QScreen>
|
||||
#include <QPair>
|
||||
|
||||
static const QString KYLIN_ROTATION_PATH = "/";
|
||||
static const QString KYLIN_ROTATION_SERVICE = "com.kylin.statusmanager.interface";
|
||||
static const QString KYLIN_ROTATION_INTERFACE = "com.kylin.statusmanager.interface";
|
||||
|
||||
class RotateChangeInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RotateChangeInfo(QObject *parent = nullptr);
|
||||
QPair<int,int> getCurrentScale();
|
||||
bool getCurrentMode();
|
||||
private:
|
||||
int m_screenWidth;
|
||||
int m_screenHeight;
|
||||
bool m_isPCMode;
|
||||
|
||||
signals:
|
||||
void sigRotationChanged(bool mode, int scale_W, int scale_H); // 信号发出模式,宽大小,高大小
|
||||
|
||||
public slots:
|
||||
void slotRotateChanged();
|
||||
void slotModeChanged(bool isPadMode);
|
||||
|
||||
};
|
||||
|
||||
#endif // ROTATECHANGEINFO_H
|
|
@ -0,0 +1,321 @@
|
|||
#include <QDebug>
|
||||
|
||||
#include <usermanual.h>
|
||||
|
||||
#include "titlebar.h"
|
||||
#include "globalsizedata.h"
|
||||
|
||||
const QSize BTN_SIZE = QSize(30, 30);
|
||||
const QSize BTN_SIZE_MAX = QSize(48, 48);
|
||||
const QSize SEARCH_SIZE = QSize(240, 37);
|
||||
const QSize SEARCH_SIZE_MAX = QSize(300, 40);
|
||||
|
||||
TitleBar::TitleBar(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
this->init();
|
||||
this->initMenu();
|
||||
this->initLayout();
|
||||
this->conn();
|
||||
}
|
||||
|
||||
TitleBar::~TitleBar() {}
|
||||
|
||||
void TitleBar::init()
|
||||
{
|
||||
this->setMinimumHeight(46);
|
||||
|
||||
m_addFontBtn = new QPushButton(this);
|
||||
// m_searchArea = new BaseSearchEdit();
|
||||
m_searchArea = new KSearchLineEdit(this);
|
||||
m_menuBtn = new QToolButton(this);
|
||||
m_menu = new QMenu();
|
||||
m_minBtn = new QPushButton(this);
|
||||
m_maxBtn = new QPushButton(this);
|
||||
m_closeBtn = new QPushButton(this);
|
||||
|
||||
// 添加字体按钮
|
||||
m_addFontBtn->setIcon(QIcon::fromTheme("list-add-symbolic"));
|
||||
m_addFontBtn->setIconSize(QSize(16, 16));
|
||||
m_addFontBtn->setProperty("isWindowButton", 0x1);
|
||||
m_addFontBtn->setProperty("useIconHighlightEffect", 0x2);
|
||||
m_addFontBtn->setContentsMargins(4, 0, 4, 0);
|
||||
m_addFontBtn->setToolTip(tr("Add Font"));
|
||||
|
||||
// 最小化按钮
|
||||
m_minBtn->setIcon(QIcon::fromTheme("window-minimize-symbolic"));
|
||||
m_minBtn->setIconSize(QSize(16, 16));
|
||||
m_minBtn->setProperty("isWindowButton", 0x1);
|
||||
m_minBtn->setProperty("useIconHighlightEffect", 0x2);
|
||||
m_minBtn->setFlat(true);
|
||||
m_minBtn->setContentsMargins(4, 0, 4, 0);
|
||||
m_minBtn->setToolTip(tr("Minimize"));
|
||||
|
||||
// 最大化按钮
|
||||
m_maxBtn->setIcon(QIcon::fromTheme("window-maximize-symbolic"));
|
||||
m_maxBtn->setIconSize(QSize(16, 16));
|
||||
m_maxBtn->setProperty("isWindowButton", 0x1);
|
||||
m_maxBtn->setProperty("useIconHighlightEffect", 0x2);
|
||||
m_maxBtn->setFlat(true);
|
||||
m_maxBtn->setContentsMargins(4, 0, 4, 0);
|
||||
m_maxBtn->setToolTip(tr("Maximize"));
|
||||
|
||||
// 关闭按钮
|
||||
m_closeBtn->setIcon(QIcon::fromTheme("window-close-symbolic"));
|
||||
m_closeBtn->setIconSize(QSize(16, 16));
|
||||
m_closeBtn->setProperty("isWindowButton", 0x2);
|
||||
m_closeBtn->setProperty("useIconHighlightEffect", 0x8);
|
||||
m_closeBtn->setFlat(true);
|
||||
m_closeBtn->setContentsMargins(4, 0, 4, 0);
|
||||
m_closeBtn->setToolTip(tr("Close"));
|
||||
|
||||
m_searchArea->setClearButtonEnabled(false);
|
||||
this->setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
this->installEventFilter(this);
|
||||
m_addFontBtn->installEventFilter(this);
|
||||
m_minBtn->installEventFilter(this);
|
||||
m_maxBtn->installEventFilter(this);
|
||||
m_closeBtn->installEventFilter(this);
|
||||
m_menuBtn->installEventFilter(this);
|
||||
m_searchArea->installEventFilter(this);
|
||||
|
||||
initWidgetStyle();
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::initWidgetStyle()
|
||||
{
|
||||
switch (GlobalSizeData::getInstance()->m_currentMode)
|
||||
{
|
||||
case CurrentMode::PCMode:
|
||||
slotChangePCSize();
|
||||
break;
|
||||
case CurrentMode::HMode:
|
||||
slotChangeFaltSize();
|
||||
break;
|
||||
case CurrentMode::VMode:
|
||||
slotChangeFaltSize();
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::initMenu()
|
||||
{
|
||||
// 菜单按钮
|
||||
m_menuBtn->setFixedSize(BTN_SIZE);
|
||||
m_menuBtn->setIcon(QIcon::fromTheme("open-menu-symbolic"));
|
||||
m_menuBtn->setIconSize(QSize(16, 16));
|
||||
m_menuBtn->setProperty("isWindowButton", 0x1);
|
||||
m_menuBtn->setProperty("useIconHighlightEffect", 0x2);
|
||||
m_menuBtn->setPopupMode(QToolButton::InstantPopup);
|
||||
m_menuBtn->setAutoRaise(true);
|
||||
m_menuBtn->setContentsMargins(4, 0, 4, 0);
|
||||
m_menuBtn->setToolTip(tr("Menu"));
|
||||
|
||||
// 创建Action
|
||||
QAction *actionHelp = new QAction(m_menu);
|
||||
QAction *actionAbout = new QAction(m_menu);
|
||||
QAction *actionQuit = new QAction(m_menu);
|
||||
actionHelp->setText(tr("Help"));
|
||||
actionAbout->setText(tr("About"));
|
||||
actionQuit->setText(tr("Quit"));
|
||||
|
||||
// 将Action添加到菜单中
|
||||
m_actions << actionHelp << actionAbout<< actionQuit;
|
||||
m_menu->addActions(m_actions);
|
||||
|
||||
m_menuBtn->setMenu(m_menu);
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::initLayout()
|
||||
{
|
||||
// 整体布局
|
||||
m_hlayout = new QHBoxLayout();
|
||||
m_hlayout->setContentsMargins(4, 4, 4, 4);
|
||||
m_hlayout->setSpacing(0);
|
||||
m_hlayout->addSpacing(6);
|
||||
m_hlayout->addWidget(m_addFontBtn);
|
||||
m_hlayout->addStretch();
|
||||
m_hlayout->addWidget(m_searchArea);
|
||||
m_hlayout->addStretch();
|
||||
m_hlayout->addWidget(m_menuBtn);
|
||||
m_hlayout->addWidget(m_minBtn);
|
||||
m_hlayout->addWidget(m_maxBtn);
|
||||
m_hlayout->addWidget(m_closeBtn);
|
||||
|
||||
this->setLayout(m_hlayout);
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::initAbout()
|
||||
{
|
||||
kdk::KAboutDialog aboutWindow(this,QIcon::fromTheme("kylin-font-viewer"),tr(appShowingName.toLocal8Bit()),tr("Version: ") + APP_VERSION);
|
||||
|
||||
aboutWindow.setBodyText(tr("Font Viewer is a tool to help users install and organize management; "
|
||||
"After installation, the font can be applied to self-developed applications, "
|
||||
"third-party pre installed applications and user self installed applications."));
|
||||
aboutWindow.setBodyTextVisiable(false);
|
||||
|
||||
aboutWindow.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::initHelp()
|
||||
{
|
||||
// 帮助点击事件处理
|
||||
kdk::UserManual userManualTest;
|
||||
if (!userManualTest.callUserManual("kylin-font-viewer")) {
|
||||
qCritical() << "user manual call fail!";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::conn()
|
||||
{
|
||||
connect(m_addFontBtn, &QPushButton::clicked, this, &TitleBar::slotAddFont);
|
||||
connect(m_minBtn, &QPushButton::clicked, this, &TitleBar::slotMinWid);
|
||||
connect(m_maxBtn, &QPushButton::clicked, this, &TitleBar::slotMaxWid);
|
||||
connect(m_closeBtn, &QPushButton::clicked, this, &TitleBar::slotCloseWid);
|
||||
|
||||
connect(m_menu, &QMenu::triggered, this, &TitleBar::slotTriggerMenu);
|
||||
// connect(m_searchArea, &BaseSearchEdit::sigSearchFont, this, &TitleBar::slotTitleSearch);
|
||||
connect(m_searchArea, &KSearchLineEdit::textChanged, this, &TitleBar::slotTitleSearch);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontNameChange, this, &TitleBar::slotChangeFontName);
|
||||
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigPCMode, this, &TitleBar::slotChangePCSize);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigHFlatMode, this, &TitleBar::slotChangeFaltSize);
|
||||
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigVFlatMode, this, &TitleBar::slotChangeFaltSize);
|
||||
return;
|
||||
}
|
||||
|
||||
bool TitleBar::eventFilter(QObject *watch, QEvent *e)
|
||||
{
|
||||
// if (m_searchArea->eventFilter(watch, e)) {
|
||||
// return QObject::eventFilter(watch, e);
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
|
||||
void TitleBar::SearchFocusOut()
|
||||
{
|
||||
// m_searchArea->searchFocusOut();
|
||||
m_searchArea->clearFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() == Qt::Key_F1) {
|
||||
initHelp();
|
||||
}
|
||||
return QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void TitleBar::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
slotMaxWid();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::slotAddFont()
|
||||
{
|
||||
emit sigAddFont();
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::slotMinWid()
|
||||
{
|
||||
this->window()->showMinimized();
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::slotMaxWid()
|
||||
{
|
||||
if (this->window()->windowState() == Qt::WindowMaximized) {
|
||||
this->window()->showNormal();
|
||||
m_maxBtn->setIcon(QIcon::fromTheme("window-maximize-symbolic"));
|
||||
m_maxBtn->setToolTip(tr("Maximize"));
|
||||
} else {
|
||||
this->window()->showMaximized();
|
||||
m_maxBtn->setIcon(QIcon::fromTheme("window-restore-symbolic"));
|
||||
m_maxBtn->setToolTip(tr("Normal"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::slotCloseWid()
|
||||
{
|
||||
this->window()->close();
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::slotTriggerMenu(QAction *act)
|
||||
{
|
||||
QString str = act->text();
|
||||
if (tr("About") == str) {
|
||||
initAbout();
|
||||
} else if (tr("Help") == str) {
|
||||
initHelp();
|
||||
} else if (tr("Quit") == str) {
|
||||
slotCloseWid();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::slotTitleSearch(QString search)
|
||||
{
|
||||
/* 添加 搜索字体 SDK的打点 */
|
||||
GlobalSizeData::getInstance()->searchFontSDKPoint();
|
||||
emit sigTitleSearch(search);
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::slotWindowState(QString state)
|
||||
{
|
||||
if (state == "maxWindow") {
|
||||
m_maxBtn->setIcon(QIcon::fromTheme("window-restore-symbolic"));
|
||||
m_maxBtn->setToolTip(tr("Normal"));
|
||||
} else {
|
||||
m_maxBtn->setIcon(QIcon::fromTheme("window-maximize-symbolic"));
|
||||
m_maxBtn->setToolTip(tr("Maximize"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::slotChangeFontName()
|
||||
{
|
||||
m_searchArea->update();
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::slotChangeFaltSize()
|
||||
{
|
||||
this->setMinimumHeight(64);
|
||||
|
||||
m_addFontBtn->setFixedSize(BTN_SIZE_MAX);
|
||||
m_minBtn->setFixedSize(BTN_SIZE_MAX);
|
||||
m_maxBtn->setFixedSize(BTN_SIZE_MAX);
|
||||
m_closeBtn->setFixedSize(BTN_SIZE_MAX);
|
||||
m_menuBtn->setFixedSize(BTN_SIZE_MAX);
|
||||
m_searchArea->setFixedSize(SEARCH_SIZE_MAX);
|
||||
m_maxBtn->hide();
|
||||
return;
|
||||
}
|
||||
|
||||
void TitleBar::slotChangePCSize()
|
||||
{
|
||||
this->setMinimumHeight(46);
|
||||
|
||||
m_addFontBtn->setFixedSize(BTN_SIZE);
|
||||
m_minBtn->setFixedSize(BTN_SIZE);
|
||||
m_maxBtn->setFixedSize(BTN_SIZE);
|
||||
m_closeBtn->setFixedSize(BTN_SIZE);
|
||||
m_menuBtn->setFixedSize(BTN_SIZE);
|
||||
m_searchArea->setFixedSize(SEARCH_SIZE);
|
||||
m_maxBtn->show();
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
#ifndef TITLEBAR_H
|
||||
#define TITLEBAR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QPushButton>
|
||||
#include <QToolButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QKeyEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QApplication>
|
||||
|
||||
#include "basesearchedit.h"
|
||||
// 主题sdk关于,搜索框
|
||||
#include "kaboutdialog.h"
|
||||
#include "ksearchlineedit.h"
|
||||
using namespace kdk;
|
||||
class TitleBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TitleBar(QWidget *parent = nullptr);
|
||||
~TitleBar();
|
||||
|
||||
// 初始化控件
|
||||
void init();
|
||||
void initMenu();
|
||||
void initLayout();
|
||||
void initAbout();
|
||||
void initHelp();
|
||||
void conn();
|
||||
bool eventFilter(QObject *watch,QEvent *e) override;
|
||||
void SearchFocusOut();
|
||||
void initWidgetStyle();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event) override; /* 键盘响应事件 */
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) override; /* 鼠标双击标题栏 */
|
||||
|
||||
private:
|
||||
/* 标题栏控件 */
|
||||
QPushButton *m_addFontBtn = nullptr; /* 添加字体按钮 */
|
||||
// BaseSearchEdit *m_searchArea = nullptr; /* 搜索字体文本框 */
|
||||
KSearchLineEdit *m_searchArea = nullptr; /* 搜索字体文本框 */
|
||||
QToolButton *m_menuBtn = nullptr; /* 菜单按钮 */
|
||||
QMenu *m_menu = nullptr;
|
||||
QList<QAction*> m_actions;
|
||||
QPushButton *m_minBtn = nullptr; /* 最小化 */
|
||||
QPushButton *m_maxBtn = nullptr; /* 最大化 */
|
||||
QPushButton *m_closeBtn = nullptr; /* 关闭 */
|
||||
QHBoxLayout *m_hlayout = nullptr; /* 布局 */
|
||||
|
||||
kdk::KAboutDialog *m_aboutWindow = nullptr; // 关于界面
|
||||
|
||||
QString appName = "FontViewer"; //格式kylin-usb-creator
|
||||
QString appShowingName = tr("Font Viewer"); //格式kylin usb creator ,用来在前端展示
|
||||
QString appVersion = qApp->applicationVersion();
|
||||
|
||||
signals:
|
||||
void sigTitleSearch(QString search);
|
||||
void sigAddFont();
|
||||
|
||||
private slots:
|
||||
void slotAddFont(void); /* 添加字体 */
|
||||
void slotMaxWid(void); /* 最大化 */
|
||||
void slotMinWid(void); /* 最小化 */
|
||||
void slotCloseWid(void); /* 关闭 */
|
||||
void slotTriggerMenu(QAction *act); /* 菜单 */
|
||||
void slotTitleSearch(QString search);
|
||||
|
||||
public slots:
|
||||
void slotWindowState(QString state); /* 窗体状态 */
|
||||
void slotChangeFontName(); /* 改变字体名称 */
|
||||
|
||||
void slotChangeFaltSize();
|
||||
void slotChangePCSize();
|
||||
|
||||
};
|
||||
|
||||
#endif // TITLEBAR_H
|