设置界面保存配置逻辑调整

This commit is contained in:
yangjiaxuan 2023-06-27 21:03:57 +08:00
parent d0d684a71b
commit 6c346a8770
10 changed files with 741 additions and 314 deletions

View File

@ -1,4 +1,4 @@
#include "HGIni.h"
#include "HGIni.h"
#include "HGInc.h"
#include "HGInfo.h"
#include <vector>
@ -21,8 +21,8 @@ static HGResult LoadIni(const char* file, SectionList& sectList)
while (feof(fp) == 0)
{
char lineContent[256] = { 0 };
if (NULL == fgets(lineContent, 256, fp))
char lineContent[2048] = { 0 };
if (NULL == fgets(lineContent, 2048, fp))
{
continue;
}

Binary file not shown.

View File

@ -2821,7 +2821,7 @@ Are you sure to close?</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="286"/>
<location filename="hg_settingdialog.cpp" line="301"/>
<source>existing configuration scheme</source>
<translation></translation>
</message>
@ -2842,143 +2842,144 @@ Are you sure to close?</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="319"/>
<source>confgiuration information:</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="335"/>
<location filename="hg_settingdialog.cpp" line="359"/>
<source>about...</source>
<translation>...</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="337"/>
<location filename="hg_settingdialog.cpp" line="361"/>
<source>scan</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="339"/>
<location filename="hg_settingdialog.cpp" line="1873"/>
<location filename="hg_settingdialog.cpp" line="363"/>
<location filename="hg_settingdialog.cpp" line="1927"/>
<source>ok</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="341"/>
<location filename="hg_settingdialog.cpp" line="365"/>
<source>cancel</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="366"/>
<location filename="hg_settingdialog.cpp" line="390"/>
<source>configuration scheme management</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="412"/>
<location filename="hg_settingdialog.cpp" line="436"/>
<source>regional crop</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="431"/>
<location filename="hg_settingdialog.cpp" line="455"/>
<source>custom tone curve</source>
<translation>线</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="999"/>
<location filename="hg_settingdialog.cpp" line="1077"/>
<location filename="hg_settingdialog.cpp" line="1100"/>
<location filename="hg_settingdialog.cpp" line="1114"/>
<location filename="hg_settingdialog.cpp" line="1355"/>
<location filename="hg_settingdialog.cpp" line="1422"/>
<location filename="hg_settingdialog.cpp" line="1497"/>
<location filename="hg_settingdialog.cpp" line="1555"/>
<location filename="hg_settingdialog.cpp" line="1038"/>
<location filename="hg_settingdialog.cpp" line="1065"/>
<location filename="hg_settingdialog.cpp" line="1127"/>
<location filename="hg_settingdialog.cpp" line="1150"/>
<location filename="hg_settingdialog.cpp" line="1170"/>
<location filename="hg_settingdialog.cpp" line="1416"/>
<location filename="hg_settingdialog.cpp" line="1502"/>
<location filename="hg_settingdialog.cpp" line="1588"/>
<location filename="hg_settingdialog.cpp" line="1646"/>
<source>Prompt</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="999"/>
<location filename="hg_settingdialog.cpp" line="1077"/>
<location filename="hg_settingdialog.cpp" line="1114"/>
<location filename="hg_settingdialog.cpp" line="1355"/>
<location filename="hg_settingdialog.cpp" line="1422"/>
<location filename="hg_settingdialog.cpp" line="1497"/>
<location filename="hg_settingdialog.cpp" line="1555"/>
<location filename="hg_settingdialog.cpp" line="1038"/>
<location filename="hg_settingdialog.cpp" line="1127"/>
<location filename="hg_settingdialog.cpp" line="1170"/>
<location filename="hg_settingdialog.cpp" line="1416"/>
<location filename="hg_settingdialog.cpp" line="1502"/>
<location filename="hg_settingdialog.cpp" line="1588"/>
<location filename="hg_settingdialog.cpp" line="1646"/>
<source>The funtion is unsupported</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1100"/>
<location filename="hg_settingdialog.cpp" line="1065"/>
<location filename="hg_settingdialog.cpp" line="1150"/>
<source>This function may cause a decrease in the speed of drawing.</source>
<translation>.</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1599"/>
<location filename="hg_settingdialog.cpp" line="1690"/>
<source>about </source>
<translation> </translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1604"/>
<location filename="hg_settingdialog.cpp" line="1612"/>
<location filename="hg_settingdialog.cpp" line="1620"/>
<location filename="hg_settingdialog.cpp" line="1628"/>
<location filename="hg_settingdialog.cpp" line="1637"/>
<location filename="hg_settingdialog.cpp" line="1650"/>
<location filename="hg_settingdialog.cpp" line="1695"/>
<location filename="hg_settingdialog.cpp" line="1703"/>
<location filename="hg_settingdialog.cpp" line="1711"/>
<location filename="hg_settingdialog.cpp" line="1719"/>
<location filename="hg_settingdialog.cpp" line="1728"/>
<location filename="hg_settingdialog.cpp" line="1741"/>
<source>Not supported</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1607"/>
<location filename="hg_settingdialog.cpp" line="1698"/>
<source>&lt;p&gt;Device model: %1&lt;/p&gt;</source>
<translation>&lt;p&gt;: %1&lt;/p&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1615"/>
<location filename="hg_settingdialog.cpp" line="1706"/>
<source>&lt;p&gt;Driver version: %1&lt;/p&gt;</source>
<translation>&lt;p&gt;: %1&lt;/p&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1623"/>
<location filename="hg_settingdialog.cpp" line="1714"/>
<source>&lt;p&gt;Firmware number: %1&lt;/p&gt;</source>
<translation>&lt;p&gt;: %1&lt;/p&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1631"/>
<location filename="hg_settingdialog.cpp" line="1722"/>
<source>&lt;p&gt;Serial number: %1&lt;/p&gt;</source>
<translation>&lt;p&gt;: %1&lt;/p&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1639"/>
<location filename="hg_settingdialog.cpp" line="1644"/>
<location filename="hg_settingdialog.cpp" line="1652"/>
<location filename="hg_settingdialog.cpp" line="1730"/>
<location filename="hg_settingdialog.cpp" line="1735"/>
<location filename="hg_settingdialog.cpp" line="1743"/>
<source>&lt;p&gt;Roller count: %1&lt;/p&gt;</source>
<translation>&lt;p&gt;: %1&lt;/p&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1657"/>
<location filename="hg_settingdialog.cpp" line="1748"/>
<source>&lt;p&gt;History count: %1&lt;/p&gt;</source>
<translation>&lt;p&gt;: %1&lt;/p&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1824"/>
<location filename="hg_settingdialog.cpp" line="1878"/>
<source>Please select to overwrite the original configuration:</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1826"/>
<location filename="hg_settingdialog.cpp" line="1880"/>
<source>,or add a new configuration</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1829"/>
<location filename="hg_settingdialog.cpp" line="1883"/>
<source>save the configuration</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2193"/>
<location filename="hg_settingdialog.cpp" line="2450"/>
<source>Add new scheme</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2201"/>
<location filename="hg_settingdialog.cpp" line="2458"/>
<source>The configuration scheme already exists</source>
<translation></translation>
</message>
@ -3012,80 +3013,85 @@ No: add new configuration</oldsource>
<translation type="vanished"></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2166"/>
<location filename="hg_settingdialog.cpp" line="2418"/>
<source>&lt;h6&gt;&lt;b&gt;</source>
<translation>&lt;h6&gt;&lt;b&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1834"/>
<location filename="hg_settingdialog.cpp" line="1888"/>
<source>cover original configuration:</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="268"/>
<location filename="hg_settingdialog.cpp" line="2261"/>
<location filename="hg_settingdialog.cpp" line="283"/>
<location filename="hg_settingdialog.cpp" line="2525"/>
<source>Default scheme</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="293"/>
<location filename="hg_settingdialog.cpp" line="308"/>
<source>Add new</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="301"/>
<location filename="hg_settingdialog.cpp" line="316"/>
<source>Save</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="324"/>
<source>Delete</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="310"/>
<location filename="hg_settingdialog.cpp" line="333"/>
<source>Delete all</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1838"/>
<location filename="hg_settingdialog.cpp" line="1892"/>
<source>add new configuration</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1842"/>
<location filename="hg_settingdialog.cpp" line="1896"/>
<source>rename:</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1884"/>
<location filename="hg_settingdialog.cpp" line="1898"/>
<location filename="hg_settingdialog.cpp" line="2201"/>
<location filename="hg_settingdialog.cpp" line="1938"/>
<location filename="hg_settingdialog.cpp" line="1952"/>
<location filename="hg_settingdialog.cpp" line="2458"/>
<source>tips</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1884"/>
<location filename="hg_settingdialog.cpp" line="1938"/>
<source>scheme name cannot be empty</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1898"/>
<location filename="hg_settingdialog.cpp" line="1952"/>
<source>scheme name: </source>
<translation> </translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1898"/>
<location filename="hg_settingdialog.cpp" line="1952"/>
<source> already exists</source>
<translation> </translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2166"/>
<location filename="hg_settingdialog.cpp" line="2418"/>
<source>:&lt;/b&gt;&lt;/h6&gt;</source>
<translation>:&lt;/b&gt;&lt;/h6&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2167"/>
<location filename="hg_settingdialog.cpp" line="2419"/>
<source>&lt;p&gt; </source>
<translation>&lt;p&gt; </translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2167"/>
<location filename="hg_settingdialog.cpp" line="2419"/>
<source>&lt;/p&gt;</source>
<translation>&lt;/p&gt;</translation>
</message>
@ -3094,18 +3100,18 @@ No: add new configuration</oldsource>
<translation type="vanished"></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2230"/>
<location filename="hg_settingdialog.cpp" line="2252"/>
<location filename="hg_settingdialog.cpp" line="2494"/>
<location filename="hg_settingdialog.cpp" line="2516"/>
<source>be sure to delete the configuration</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2231"/>
<location filename="hg_settingdialog.cpp" line="2495"/>
<source>Are you sure you want to delete the configuration &quot;</source>
<translation></translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2231"/>
<location filename="hg_settingdialog.cpp" line="2495"/>
<source>&quot; ?</source>
<translation></translation>
</message>
@ -3118,7 +3124,7 @@ No: add new configuration</oldsource>
<translation type="vanished"> </translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2253"/>
<location filename="hg_settingdialog.cpp" line="2517"/>
<source>Are you sure you want to delete the configuration?</source>
<translation></translation>
</message>

Binary file not shown.

View File

@ -2480,7 +2480,7 @@ Please go to “Scan to” and change the accessible scan folder and then perfor
<context>
<name>hg_settingdialog</name>
<message>
<location filename="hg_settingdialog.cpp" line="286"/>
<location filename="hg_settingdialog.cpp" line="301"/>
<source>existing configuration scheme</source>
<translation>Existing configuration plan:</translation>
</message>
@ -2501,221 +2501,227 @@ Please go to “Scan to” and change the accessible scan folder and then perfor
<translation type="vanished">Delete all configurations</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="268"/>
<location filename="hg_settingdialog.cpp" line="2261"/>
<location filename="hg_settingdialog.cpp" line="283"/>
<location filename="hg_settingdialog.cpp" line="2525"/>
<source>Default scheme</source>
<translation>Default scheme</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="293"/>
<location filename="hg_settingdialog.cpp" line="308"/>
<source>Add new</source>
<translation>Add new</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="301"/>
<location filename="hg_settingdialog.cpp" line="316"/>
<source>Save</source>
<translation>Save</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="324"/>
<source>Delete</source>
<translation>Delete</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="310"/>
<location filename="hg_settingdialog.cpp" line="333"/>
<source>Delete all</source>
<translation>Delete all</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="319"/>
<source>confgiuration information:</source>
<translation>Configuration information:</translation>
<translation type="vanished">Configuration information:</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="335"/>
<location filename="hg_settingdialog.cpp" line="359"/>
<source>about...</source>
<translation>About...</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="337"/>
<location filename="hg_settingdialog.cpp" line="361"/>
<source>scan</source>
<translation>Scan</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="339"/>
<location filename="hg_settingdialog.cpp" line="1873"/>
<location filename="hg_settingdialog.cpp" line="363"/>
<location filename="hg_settingdialog.cpp" line="1927"/>
<source>ok</source>
<translation>OK</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="341"/>
<location filename="hg_settingdialog.cpp" line="365"/>
<source>cancel</source>
<translation>Cancel</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="366"/>
<location filename="hg_settingdialog.cpp" line="390"/>
<source>configuration scheme management</source>
<translation>Configuration plan management</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="412"/>
<location filename="hg_settingdialog.cpp" line="436"/>
<source>regional crop</source>
<translation>Regional crop</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="431"/>
<location filename="hg_settingdialog.cpp" line="455"/>
<source>custom tone curve</source>
<translation>Custom tone curve</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="999"/>
<location filename="hg_settingdialog.cpp" line="1077"/>
<location filename="hg_settingdialog.cpp" line="1100"/>
<location filename="hg_settingdialog.cpp" line="1114"/>
<location filename="hg_settingdialog.cpp" line="1355"/>
<location filename="hg_settingdialog.cpp" line="1422"/>
<location filename="hg_settingdialog.cpp" line="1497"/>
<location filename="hg_settingdialog.cpp" line="1555"/>
<location filename="hg_settingdialog.cpp" line="1038"/>
<location filename="hg_settingdialog.cpp" line="1065"/>
<location filename="hg_settingdialog.cpp" line="1127"/>
<location filename="hg_settingdialog.cpp" line="1150"/>
<location filename="hg_settingdialog.cpp" line="1170"/>
<location filename="hg_settingdialog.cpp" line="1416"/>
<location filename="hg_settingdialog.cpp" line="1502"/>
<location filename="hg_settingdialog.cpp" line="1588"/>
<location filename="hg_settingdialog.cpp" line="1646"/>
<source>Prompt</source>
<translation>Prompt</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="999"/>
<location filename="hg_settingdialog.cpp" line="1077"/>
<location filename="hg_settingdialog.cpp" line="1114"/>
<location filename="hg_settingdialog.cpp" line="1355"/>
<location filename="hg_settingdialog.cpp" line="1422"/>
<location filename="hg_settingdialog.cpp" line="1497"/>
<location filename="hg_settingdialog.cpp" line="1555"/>
<location filename="hg_settingdialog.cpp" line="1038"/>
<location filename="hg_settingdialog.cpp" line="1127"/>
<location filename="hg_settingdialog.cpp" line="1170"/>
<location filename="hg_settingdialog.cpp" line="1416"/>
<location filename="hg_settingdialog.cpp" line="1502"/>
<location filename="hg_settingdialog.cpp" line="1588"/>
<location filename="hg_settingdialog.cpp" line="1646"/>
<source>The funtion is unsupported</source>
<translation>This version does not support this feature.</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1100"/>
<location filename="hg_settingdialog.cpp" line="1065"/>
<location filename="hg_settingdialog.cpp" line="1150"/>
<source>This function may cause a decrease in the speed of drawing.</source>
<translation>This function may cause a decrease in the speed of drawing.</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1599"/>
<location filename="hg_settingdialog.cpp" line="1690"/>
<source>about </source>
<translation>About </translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1604"/>
<location filename="hg_settingdialog.cpp" line="1612"/>
<location filename="hg_settingdialog.cpp" line="1620"/>
<location filename="hg_settingdialog.cpp" line="1628"/>
<location filename="hg_settingdialog.cpp" line="1637"/>
<location filename="hg_settingdialog.cpp" line="1650"/>
<location filename="hg_settingdialog.cpp" line="1695"/>
<location filename="hg_settingdialog.cpp" line="1703"/>
<location filename="hg_settingdialog.cpp" line="1711"/>
<location filename="hg_settingdialog.cpp" line="1719"/>
<location filename="hg_settingdialog.cpp" line="1728"/>
<location filename="hg_settingdialog.cpp" line="1741"/>
<source>Not supported</source>
<translation>Not supported</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1607"/>
<location filename="hg_settingdialog.cpp" line="1698"/>
<source>&lt;p&gt;Device model: %1&lt;/p&gt;</source>
<translation>&lt;p&gt;Device model: %1&lt;/p&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1615"/>
<location filename="hg_settingdialog.cpp" line="1706"/>
<source>&lt;p&gt;Driver version: %1&lt;/p&gt;</source>
<translation>&lt;p&gt;Driver version: %1&lt;/p&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1623"/>
<location filename="hg_settingdialog.cpp" line="1714"/>
<source>&lt;p&gt;Firmware number: %1&lt;/p&gt;</source>
<translation>&lt;p&gt;Firmware number: %1&lt;/p&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1631"/>
<location filename="hg_settingdialog.cpp" line="1722"/>
<source>&lt;p&gt;Serial number: %1&lt;/p&gt;</source>
<translation>&lt;p&gt;Serial number: %1&lt;/p&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1639"/>
<location filename="hg_settingdialog.cpp" line="1644"/>
<location filename="hg_settingdialog.cpp" line="1652"/>
<location filename="hg_settingdialog.cpp" line="1730"/>
<location filename="hg_settingdialog.cpp" line="1735"/>
<location filename="hg_settingdialog.cpp" line="1743"/>
<source>&lt;p&gt;Roller count: %1&lt;/p&gt;</source>
<translation>&lt;p&gt;Roller count: %1&lt;/p&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1657"/>
<location filename="hg_settingdialog.cpp" line="1748"/>
<source>&lt;p&gt;History count: %1&lt;/p&gt;</source>
<translation>&lt;p&gt;History count: %1&lt;/p&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1824"/>
<location filename="hg_settingdialog.cpp" line="1878"/>
<source>Please select to overwrite the original configuration:</source>
<translation>Please select overwrite original configuration:</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1826"/>
<location filename="hg_settingdialog.cpp" line="1880"/>
<source>,or add a new configuration</source>
<translation>, or add new configuration</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1829"/>
<location filename="hg_settingdialog.cpp" line="1883"/>
<source>save the configuration</source>
<translation>Save configuration</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1834"/>
<location filename="hg_settingdialog.cpp" line="1888"/>
<source>cover original configuration:</source>
<translation>Overwrite original configuration:</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1838"/>
<location filename="hg_settingdialog.cpp" line="1892"/>
<source>add new configuration</source>
<translation>Add new configuration</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1842"/>
<location filename="hg_settingdialog.cpp" line="1896"/>
<source>rename:</source>
<translation>Rename:</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1884"/>
<location filename="hg_settingdialog.cpp" line="1898"/>
<location filename="hg_settingdialog.cpp" line="2201"/>
<location filename="hg_settingdialog.cpp" line="1938"/>
<location filename="hg_settingdialog.cpp" line="1952"/>
<location filename="hg_settingdialog.cpp" line="2458"/>
<source>tips</source>
<translation>Prompt</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1884"/>
<location filename="hg_settingdialog.cpp" line="1938"/>
<source>scheme name cannot be empty</source>
<translation>Configuration name cannot be blank</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1898"/>
<location filename="hg_settingdialog.cpp" line="1952"/>
<source>scheme name: </source>
<translation>Configuration name: </translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1898"/>
<location filename="hg_settingdialog.cpp" line="1952"/>
<source> already exists</source>
<translation> already exists</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2166"/>
<location filename="hg_settingdialog.cpp" line="2418"/>
<source>&lt;h6&gt;&lt;b&gt;</source>
<translation>&lt;h6&gt;&lt;b&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2166"/>
<location filename="hg_settingdialog.cpp" line="2418"/>
<source>:&lt;/b&gt;&lt;/h6&gt;</source>
<translation>:&lt;/b&gt;&lt;/h6&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2167"/>
<location filename="hg_settingdialog.cpp" line="2419"/>
<source>&lt;p&gt; </source>
<translation>&lt;p&gt; </translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2167"/>
<location filename="hg_settingdialog.cpp" line="2419"/>
<source>&lt;/p&gt;</source>
<translation>&lt;/p&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2193"/>
<location filename="hg_settingdialog.cpp" line="2450"/>
<source>Add new scheme</source>
<translation>Add new scheme</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2201"/>
<location filename="hg_settingdialog.cpp" line="2458"/>
<source>The configuration scheme already exists</source>
<translation>The configuration scheme already exists</translation>
</message>
@ -2724,18 +2730,18 @@ Please go to “Scan to” and change the accessible scan folder and then perfor
<translation type="vanished">Rename configuration</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2230"/>
<location filename="hg_settingdialog.cpp" line="2252"/>
<location filename="hg_settingdialog.cpp" line="2494"/>
<location filename="hg_settingdialog.cpp" line="2516"/>
<source>be sure to delete the configuration</source>
<translation>Delete configuration</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2231"/>
<location filename="hg_settingdialog.cpp" line="2495"/>
<source>Are you sure you want to delete the configuration &quot;</source>
<translation>Are you sure you want to delete configuration </translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2231"/>
<location filename="hg_settingdialog.cpp" line="2495"/>
<source>&quot; ?</source>
<translation>?</translation>
</message>
@ -2748,7 +2754,7 @@ Please go to “Scan to” and change the accessible scan folder and then perfor
<translation type="vanished">No</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="2253"/>
<location filename="hg_settingdialog.cpp" line="2517"/>
<source>Are you sure you want to delete the configuration?</source>
<translation>Are you sure you want to delete all configurations?</translation>
</message>

View File

@ -1,11 +1,71 @@
#include "app_cfg.h"
#include "base/HGDef.h"
#include "base/HGInc.h"
#include "base/HGUtility.h"
#include "base/HGIni.h"
#include "HGUIGlobal.h"
#include "HGString.h"
#include <shlobj.h>
bool removeSection(const HGChar* appName)
{
HGChar cfgPath[512];
GetConfigPath(cfgPath, 512);
strcat(cfgPath, "default.ini");
HGResult ret = HGBase_RemoveProfileSection(cfgPath, appName);
if (ret == HGBASE_ERR_OK)
return true;
return false;
}
bool searchKeyName(const HGChar* appName, const HGChar* key)
{
HGChar cfgPath[512];
GetConfigPath(cfgPath, 512);
strcat(cfgPath, "default.ini");
HGResult ret = HGBase_SearchProfileConfig(cfgPath, appName, key);
if (ret == HGBASE_ERR_OK)
return true;
return false;
}
QString getDefaultCfgValue(const char* appName, const char* key, const QString& def)
{
HGChar cfgPath[512];
GetConfigPath(cfgPath, 512);
strcat(cfgPath, "default.ini");
HGChar value[2048] = { 0 };
HGBase_GetProfileString(cfgPath, appName, key, getStdString(def).c_str(), value, 2048);
return StdStringToUtf8(value).c_str();
}
int getDefaultCfgValue(const char* appName, const char* key, int def)
{
HGChar cfgPath[512];
GetConfigPath(cfgPath, 512);
strcat(cfgPath, "default.ini");
HGInt value = 0;
HGBase_GetProfileInt(cfgPath, appName, key, def, &value);
return value;
}
bool getDefaultCfgValue(const char* appName, const char* key, bool def)
{
HGChar cfgPath[512];
GetConfigPath(cfgPath, 512);
strcat(cfgPath, "default.ini");
HGInt value = 0;
HGBase_GetProfileInt(cfgPath, appName, key, (HGInt)def, &value);
return (bool)value;
}
QString getCfgValue(const char *appName, const char *key, const QString &def)
{
HGChar cfgPath[512];
@ -39,6 +99,46 @@ bool getCfgValue(const char *appName, const char *key, bool def)
return (bool)value;
}
void saveDefaultCfgValue(const char* appName, const char* key, const QString& value)
{
HGChar cfgPath[512];
GetConfigPath(cfgPath, 512);
HGBase_CreateDir(cfgPath);
strcat(cfgPath, "default.ini");
HGBase_SetProfileString(cfgPath, appName, key, getStdString(value).c_str());
}
void saveDefaultCfgValue(const char* appName, const char* key, int value)
{
HGChar cfgPath[512];
GetConfigPath(cfgPath, 512);
HGBase_CreateDir(cfgPath);
strcat(cfgPath, "default.ini");
HGBase_SetProfileInt(cfgPath, appName, key, value);
}
void saveDefaultCfgValue(const char* appName, const char* key, float value)
{
HGChar cfgPath[512];
GetConfigPath(cfgPath, 512);
HGBase_CreateDir(cfgPath);
strcat(cfgPath, "default.ini");
HGBase_SetProfileInt(cfgPath, appName, key, value);
}
void saveDefaultCfgValue(const char* appName, const char* key, bool value)
{
HGChar cfgPath[512];
GetConfigPath(cfgPath, 512);
HGBase_CreateDir(cfgPath);
strcat(cfgPath, "default.ini");
HGBase_SetProfileInt(cfgPath, appName, key, (HGInt)value);
}
void saveCfgValue(const char *appName, const char *key, const QString &value)
{
HGChar cfgPath[512];
@ -68,3 +168,51 @@ void saveCfgValue(const char *appName, const char *key, bool value)
HGBase_SetProfileInt(cfgPath, appName, key, (HGInt)value);
}
HGResult GetConfigPath(HGChar* configPath, HGUInt maxLen)
{
if (NULL == configPath || 0 == maxLen)
{
return HGBASE_ERR_INVALIDARG;
}
const char* appName = "HuaGoScan";
#if defined(OEM_HANWANG)
appName = "HanvonScan";
#elif defined(OEM_LISICHENG)
appName = "LanxumScan";
#elif defined(OEM_CANGTIAN)
appName = "CumtennScan";
#elif defined(OEM_ZHONGJING)
appName = "MicrotekScan";
#elif defined(OEM_ZIGUANG)
appName = "UniScan";
#endif
#if defined(HG_CMP_MSC)
CHAR cfgPath[MAX_PATH] = { 0 };
BOOL ret = SHGetSpecialFolderPathA(NULL, cfgPath, CSIDL_APPDATA, FALSE);
if (!ret)
return HGBASE_ERR_FAIL;
if (cfgPath[strlen(cfgPath) - 1] != '\\')
strcat(cfgPath, "\\");
strcat(cfgPath, appName);
strcat(cfgPath, "\\Cfg\\");
#else
char cfgPath[512] = { 0 };
struct passwd* pw = getpwuid(getuid());
strcpy(cfgPath, pw->pw_dir);
if (cfgPath[strlen(cfgPath) - 1] != '/')
strcat(cfgPath, "/");
strcat(cfgPath, ".");
strcat(cfgPath, appName);
strcat(cfgPath, "/Cfg/");
#endif
if (maxLen < strlen(cfgPath) + 1)
return HGBASE_ERR_FAIL;
strcpy(configPath, cfgPath);
return HGBASE_ERR_OK;
}

View File

@ -1,14 +1,27 @@
#ifndef __APP_CFG_H__
#ifndef __APP_CFG_H__
#define __APP_CFG_H__
#include <QString>
#include "base/HGDef.h"
bool removeSection(const HGChar* appName);
bool searchKeyName(const HGChar* appName, const HGChar* key);
QString getDefaultCfgValue(const char* appName, const char* key, const QString& def);
int getDefaultCfgValue(const char* appName, const char* key, int def);
bool getDefaultCfgValue(const char* appName, const char* key, bool def);
QString getCfgValue(const char *appName, const char *key, const QString &def);
int getCfgValue(const char *appName, const char *key, int def);
bool getCfgValue(const char *appName, const char *key, bool def);
void saveDefaultCfgValue(const char* appName, const char* key, const QString& value);
void saveDefaultCfgValue(const char* appName, const char* key, int value);
void saveDefaultCfgValue(const char* appName, const char* key, bool value);
void saveCfgValue(const char *appName, const char *key, const QString &value);
void saveCfgValue(const char *appName, const char *key, int value);
void saveCfgValue(const char *appName, const char *key, bool value);
HGResult GetConfigPath(HGChar* configPath, HGUInt maxLen);
#endif /* __APP_CFG_H__ */

View File

@ -13,6 +13,8 @@
#include <typeinfo>
#include "device_menu.h"
#include "dialog_device_scan.h"
#include "app_cfg.h"
#include "base/HGBase64.h"
hg_settingdialog * hg_settingdialog::hg_setting_ui_ =NULL;
std::string hg_settingdialog::property_combox_data_type_ = "combox_value_type";
@ -46,6 +48,7 @@ hg_settingdialog::hg_settingdialog(SANE_Handle handle, const SANEAPI* saneApi, b
setAttribute(Qt::WA_DeleteOnClose, true);
setIcon();
m_scheme = new gb::sane_config_schm();
HGChar cfgpath[512] = {0};
GetConfigPath(cfgpath, 512);
@ -111,7 +114,16 @@ hg_settingdialog::hg_settingdialog(SANE_Handle handle, const SANEAPI* saneApi, b
initUi();
on_current_scheme_changed();
//getAppVersion();
saveDefaultCfgValue("deviceName", "name", QString::fromStdString(m_devName));
HGChar cfgPath[512];
GetConfigPath(cfgPath, 512);
QString oldFile = QString::fromStdString(cfgPath) + "default.ini";
QString newFile = QString::fromStdString(cfgPath) + "olddefault.ini";
QFile::copy(oldFile, newFile);
comb_->setCurrentIndex(getDefaultCfgValue("current", "index", 0));
}
hg_settingdialog::~hg_settingdialog()
@ -297,32 +309,41 @@ void hg_settingdialog::create_scheme_management_ui(QVBoxLayout* layout)
layout->addSpacing(10);
del_this_ = new QPushButton(this);
del_this_->setText(tr("Delete"));
del_this_->setEnabled(enabled);
del_this_->setFixedWidth(width / 2);
layout->addWidget(del_this_);
connect(del_this_, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management()));
m_pbtn_Save = new QPushButton(this);
m_pbtn_Save->setText(tr("Save"));
m_pbtn_Save->setFixedWidth(width / 2);
layout->addWidget(m_pbtn_Save);
connect(m_pbtn_Save, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management()));
layout->addSpacing(10);
del_all_ = new QPushButton(this);
del_all_->setText(tr("Delete all"));
del_all_->setEnabled(enabled);
del_all_->setFixedWidth(width / 2);
layout->addWidget(del_all_);
connect(del_all_, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management()));
m_deleteCur = new QPushButton(this);
m_deleteCur->setText(tr("Delete"));
m_deleteCur->setEnabled(enabled);
m_deleteCur->setFixedWidth(width / 2);
layout->addWidget(m_deleteCur);
connect(m_deleteCur, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management()));
layout->addSpacing(10);
m_deleteAll = new QPushButton(this);
m_deleteAll->setText(tr("Delete all"));
m_deleteAll->setEnabled(enabled);
m_deleteAll->setFixedWidth(width / 2);
layout->addWidget(m_deleteAll);
connect(m_deleteAll, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management()));
layout->addStretch();
title = new QLabel(this);
title->setText(tr("confgiuration information:"));
layout->addWidget(title);
//title = new QLabel(this);
//title->setText(tr("confgiuration information:"));
//layout->addWidget(title);
sketch_ = new QTextEdit(this);
sketch_->setReadOnly(true);
sketch_->setFixedSize(width, 200);
layout->addWidget(sketch_);
// sketch_ = new QTextEdit(this);
// sketch_->setReadOnly(true);
// sketch_->setFixedSize(width, 200);
// sketch_->setVisible(false);
//layout->addWidget(sketch_);
connect(comb_, SIGNAL(currentTextChanged(const QString)), this, SLOT(on_current_scheme_changed()));
//on_current_scheme_changed();
@ -859,18 +880,19 @@ void hg_settingdialog::refresh_control_value(int op_id)
else if(!slider)
{
slider = qobject_cast<QSlider*>(ctrls[i]);
if(slider)
disconnect(slider, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int)));
// if(slider)
// disconnect(slider, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int)));
}
else if(!spin)
{
spin = qobject_cast<QDoubleSpinBox*>(ctrls[i]);
if(spin)
disconnect(spin, SIGNAL(valueChanged(double)), this, SLOT(slot_spinBoxClicked(double)));
// if(spin)
// disconnect(spin, SIGNAL(valueChanged(double)), this, SLOT(slot_spinBoxClicked(double)));
}
}
if (slider)
{
disconnect(slider, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int)));
if (opt->constraint_type == SANE_CONSTRAINT_RANGE)
slider->setRange(SANE_UNFIX(opt->constraint.range->min) * 100, SANE_UNFIX(opt->constraint.range->max) * 100);
slider->setValue(val * 100);
@ -879,6 +901,7 @@ void hg_settingdialog::refresh_control_value(int op_id)
if (spin)
{
disconnect(spin, SIGNAL(valueChanged(double)), this, SLOT(slot_spinBoxClicked(double)));
if (opt->constraint_type == SANE_CONSTRAINT_RANGE)
spin->setRange(SANE_UNFIX(opt->constraint.range->min), SANE_UNFIX(opt->constraint.range->max));
spin->setValue(val);
@ -1034,10 +1057,16 @@ void hg_settingdialog::slot_checkedClicked()
btn_gamma_->setEnabled(checkBoxcurrentState);
cur_scheme_->config_changed(id, (char*)&checkBoxcurrentState, sizeof(checkBoxcurrentState));
if (0 == strcmp(opt->name, SANE_STD_OPT_NAME_RID_MORR) || 0 == strcmp(opt->name, SANE_STD_OPT_NAME_RID_GRID))
if (checkBoxcurrentState && (0 == strcmp(opt->name, SANE_STD_OPT_NAME_RID_MORR) || 0 == strcmp(opt->name, SANE_STD_OPT_NAME_RID_GRID)))
{
QMessageBox::information(this, tr("Prompt"), tr("This function may cause a decrease in the speed of drawing."));
}
if (0 == comb_->currentIndex())
{
bool value = checkBoxcurrentState;
saveDefaultCfgValue("default", opt->name, value);
}
}
void hg_settingdialog::slot_string_list_comboBoxClicked()
@ -1117,6 +1146,12 @@ void hg_settingdialog::slot_string_list_comboBoxClicked()
if (comboBox->currentText() == OPTION_VALUE_WGFX_ZDWBFXSB)
QMessageBox::information(this, tr("Prompt"), tr("This function may cause a decrease in the speed of drawing."));
}
if (0 == comb_->currentIndex())
{
QString value = QString::fromStdString(comboBoxcurrentItem);
saveDefaultCfgValue("default", opt->name, value);
}
}
void hg_settingdialog::slot_pushButtonClicked()
@ -1178,6 +1213,11 @@ void hg_settingdialog::slot_cutButtonClicked()
value = SANE_FIX(m_cutBottomValue);
m_saneAPI.sane_control_option_api(m_devHandle, m_cutBottomId, SANE_ACTION_SET_VALUE, &value, &info);
cur_scheme_->config_changed(m_cutBottomId, (char*)&value, sizeof(value));
saveDefaultCfgValue("default", "cutLeftvalue", QString::number(m_cutLeftValue));
saveDefaultCfgValue("default", "cutTopValue", QString::number(m_cutTopValue));
saveDefaultCfgValue("default", "cutRightvalue", QString::number(m_cutRightValue));
saveDefaultCfgValue("default", "cutBottomvalue", QString::number(m_cutBottomValue));
}
}
@ -1339,6 +1379,16 @@ void hg_settingdialog::slot_gammaButtonClicked()
dev_que::set_custom_gamma(&m_saneAPI, m_devHandle, &m_gammaData);
cur_scheme_->config_changed(SANE_STD_OPT_NAME_IS_CUSTOM_GAMMA, (char*)&m_gammaData, sizeof(m_gammaData), true);
HGSize length = 0;
HGBase_Base64Encode((const HGByte*)&m_gammaData, sizeof(m_gammaData), NULL, &length);
HGByte* base64Str = new HGByte[length + 1];
HGBase_Base64Encode((const HGByte*)&m_gammaData, sizeof(m_gammaData), base64Str, &length);
base64Str[length] = 0;
QString value = QString::fromStdString((char*)base64Str);
saveDefaultCfgValue("default", "gamma", value);
delete[] base64Str;
}
}
@ -1383,6 +1433,9 @@ void hg_settingdialog::slot_word_list_comboBoxClicked(int value)
comboBox->setCurrentText(QString::fromStdString(buf));
}
cur_scheme_->config_changed(id, (char*)&temp, sizeof(temp));
if (0 == comb_->currentIndex())
saveDefaultCfgValue("default", opt->name, comboBox->currentText());
}
void hg_settingdialog::slot_sliderClicked(int value)
@ -1392,11 +1445,21 @@ void hg_settingdialog::slot_sliderClicked(int value)
QAbstractSpinBox* spin = nullptr;
for(int i = 0; i < m_list_sliderSpinbox.size(); i++)
if (m_list_sliderSpinbox.at(i).first == slider)
if (m_list_sliderSpinbox.at(i).first == slider)
{
spin = reinterpret_cast<QAbstractSpinBox*>(m_list_sliderSpinbox.at(i).second);
break;
}
const SANE_Option_Descriptor* opt = nullptr;
for (int i = 0; i < m_list_getOpt.size(); i++)
{
if (m_list_getOpt.at(i).first == id)
{
spin = reinterpret_cast<QAbstractSpinBox*>(m_list_sliderSpinbox.at(i).second);
opt = reinterpret_cast<const SANE_Option_Descriptor*>(m_list_getOpt.at(i).second);
break;
}
}
if (spin != nullptr)
{
@ -1407,7 +1470,8 @@ void hg_settingdialog::slot_sliderClicked(int value)
QSpinBox* spin_ = reinterpret_cast<QSpinBox*>(spin);
spin_->setValue(value);
// //m_list_IdValueTitle.append(QPair<QPair<int, QVariant>, QString>(QPair<int, QVariant>(id, val), md5(opt->title)));
if (0 == comb_->currentIndex())
saveDefaultCfgValue("default", opt->name, value);
}
else
{
@ -1419,8 +1483,13 @@ void hg_settingdialog::slot_sliderClicked(int value)
val = SANE_FIX(temp);
db_val = true;
////m_list_IdValueTitle.append(QPair<QPair<int, QVariant>, QString>(QPair<int, QVariant>(id, temp), md5(opt->title)));
if (0 == comb_->currentIndex())
{
QString value2 = QString::number(temp);
saveDefaultCfgValue("default", opt->name, value2);
}
}
SANE_Status ret = m_saneAPI.sane_control_option_api(m_devHandle, id, SANE_ACTION_SET_VALUE, &val, &method);
if (ret == SANE_STATUS_UNSUPPORTED)
{
@ -1451,11 +1520,22 @@ void hg_settingdialog::slot_sliderClicked(int value)
double v = SANE_UNFIX(val);
spin_->setValue(v);
slider->setValue(spin_->value() / spin_->singleStep());
if (0 == comb_->currentIndex())
{
QString value2 = QString::number(v);
saveDefaultCfgValue("default", opt->name, value2);
}
}
else {
else
{
QSpinBox* spin_ = reinterpret_cast<QSpinBox*>(spin);
spin_->setValue(val);
slider->setValue(spin_->value() / spin_->singleStep());
slider->setValue(spin_->value() / spin_->singleStep());
if (0 == comb_->currentIndex())
{
int value2 = val;
saveDefaultCfgValue("default", opt->name, value2);
}
}
}
cur_scheme_->config_changed(id, (char*)&val, sizeof(val));
@ -1491,6 +1571,14 @@ void hg_settingdialog::slot_spinBoxClicked(int value)
int id = spinBox->property("controls_id").toInt();
const SANE_Option_Descriptor* opt = nullptr;
for (int i = 0; i < m_list_getOpt.size(); i++)
{
if (m_list_getOpt.at(i).first == id)
{
opt = reinterpret_cast<const SANE_Option_Descriptor*>(m_list_getOpt.at(i).second);
break;
}
}
QAbstractSlider* slider = nullptr;
for (int i = 0; i < m_list_sliderSpinbox.size(); i++)
@ -1524,7 +1612,14 @@ void hg_settingdialog::slot_spinBoxClicked(int value)
connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(slot_spinBoxClicked(int)));
}
cur_scheme_->config_changed(id, (char*)&temp, sizeof(temp));
}else
if (0 == comb_->currentIndex())
{
int value2 = value;
saveDefaultCfgValue("default", opt->name, value2);
}
}
else
{
QSlider* slider_ = reinterpret_cast<QSlider*>(slider);
slider_->setValue(spinBox->value());
@ -1683,15 +1778,14 @@ void hg_settingdialog::slot_buttonAboutClicked()
void hg_settingdialog::slot_buttonScanClicked()
{
save_scheme();
//save_scheme();
m_closeButton = closeButtonScan;
if (!quit_)
m_callback(UI_RESULT_START_SCAN);
}
void hg_settingdialog::slot_buttonOkClicked()
{
save_ = true;
{
m_closeButton = closeButtonOk;
close();
}
@ -1727,54 +1821,6 @@ gb::sane_config_schm *hg_settingdialog::getCurScheme()
return cur_scheme_;
}
HGResult hg_settingdialog::GetConfigPath(HGChar* configPath, HGUInt maxLen)
{
if (NULL == configPath || 0 == maxLen)
{
return HGBASE_ERR_INVALIDARG;
}
const char *appName = "HuaGoScan";
#if defined(OEM_HANWANG)
appName = "HanvonScan";
#elif defined(OEM_LISICHENG)
appName = "LanxumScan";
#elif defined(OEM_CANGTIAN)
appName = "CumtennScan";
#elif defined(OEM_ZHONGJING)
appName = "MicrotekScan";
#elif defined(OEM_ZIGUANG)
appName = "UniScan";
#endif
#if defined(HG_CMP_MSC)
CHAR cfgPath[MAX_PATH] = { 0 };
BOOL ret = SHGetSpecialFolderPathA(NULL, cfgPath, CSIDL_APPDATA, FALSE);
if (!ret)
return HGBASE_ERR_FAIL;
if (cfgPath[strlen(cfgPath) - 1] != '\\')
strcat(cfgPath, "\\");
strcat(cfgPath, appName);
strcat(cfgPath, "\\Cfg\\");
#else
char cfgPath[512] = { 0 };
struct passwd* pw = getpwuid(getuid());
strcpy(cfgPath, pw->pw_dir);
if (cfgPath[strlen(cfgPath) - 1] != '/')
strcat(cfgPath, "/");
strcat(cfgPath, ".");
strcat(cfgPath, appName);
strcat(cfgPath, "/Cfg/");
#endif
if (maxLen < strlen(cfgPath) + 1)
return HGBASE_ERR_FAIL;
strcpy(configPath, cfgPath);
return HGBASE_ERR_OK;
}
//生成UTF-8编码的MD5值
QString hg_settingdialog::md5(QString key)
{
@ -1815,12 +1861,25 @@ void hg_settingdialog::closeEvent(QCloseEvent* e)
{
if(e->type() == QEvent::Close) // consider as cancel ...
{
if(save_)
save_scheme();
else
cancel_setting();
//if(save_)
// save_scheme();
//else
// cancel_setting();
}
HGChar cfgPath[512];
GetConfigPath(cfgPath, 512);
QString oldFile = QString::fromStdString(cfgPath) + "olddefault.ini";
QString newFile = QString::fromStdString(cfgPath) + "default.ini";
QFile::remove(newFile);
QFile file(oldFile);
file.rename(newFile);
int index = comb_->currentIndex();
if (m_closeButton == closeButtonOk)
saveDefaultCfgValue("current", "index", index);
e->accept();
}
@ -1992,6 +2051,9 @@ std::string hg_settingdialog::getCurUiShemeName(std::string name)
void hg_settingdialog::save_scheme(void)
{
if (comb_->currentIndex() == 0)
return;
std::string name(cur_scheme_->get_scheme_name());
bool add = name.empty();
@ -2041,13 +2103,14 @@ void hg_settingdialog::save_scheme(void)
if(ind > 0)
{
name.erase(pos);
sprintf(append, "-%d", ++ind);
// sprintf(append, "-%d", ++ind);
}
}
while (!cur_cfg_->add_scheme(cur_scheme_, (name + append).c_str()))
{
sprintf(append, "-%d", ++ind);
}
cur_cfg_->add_scheme(cur_scheme_, (name + append).c_str());
// while (!cur_cfg_->add_scheme(cur_scheme_, (name + append).c_str()))
// {
// sprintf(append, "-%d", ++ind);
// }
}
else
{
@ -2091,6 +2154,226 @@ void hg_settingdialog::setIcon()
this->setWindowIcon(QIcon(":logo/image_rsc/logo/uniscan.ico"));
#endif
}
void hg_settingdialog::updateDefaultScheme()
{
updateOpt();
SANE_Int dev_options = 0;
m_saneAPI.sane_control_option_api(m_devHandle, 0, SANE_ACTION_GET_VALUE, &dev_options, nullptr);
for(int id = 1, optons = dev_options; id < optons; id++)
{
QVector<QWidget*> ctrls = find_control(id);
if(ctrls.empty())
continue;
const SANE_Option_Descriptor* opt = (const SANE_Option_Descriptor*)m_list_defaultOptions.at(id - 1).first;
if(opt->type == SANE_TYPE_BOOL)
{
for(size_t i = 0; i < (size_t)ctrls.size(); ++i)
{
QCheckBox* cb = qobject_cast<QCheckBox*>(ctrls[i]);
if(cb)
{
//disconnect(cb, SIGNAL(stateChanged(int)), this, SLOT(slot_checkedClicked()));
if (comb_->currentIndex() == 0)
{
if (searchKeyName("default", opt->name))
{
cb->setCheckState(getDefaultCfgValue("default", opt->name, false) ? Qt::Checked : Qt::Unchecked);
}
}
//connect(cb, SIGNAL(stateChanged(int)), this, SLOT(slot_checkedClicked()));
break;
}
}
}
else if(opt->type == SANE_TYPE_INT)
{
for(size_t i = 0; i < (size_t)ctrls.size(); ++i)
{
QSlider* slider = qobject_cast<QSlider*>(ctrls[i]);
if(slider)
{
//disconnect(slider, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int)));
if (comb_->currentIndex() == 0)
{
if (searchKeyName("default", opt->name))
{
int value = getDefaultCfgValue("default", opt->name, 0);
slider->setValue(value);
}
}
//connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int)));
}
else
{
QSpinBox* spin = qobject_cast<QSpinBox*>(ctrls[i]);
if(spin)
{
//disconnect(spin, SIGNAL(valueChanged(int)), this, SLOT(slot_spinBoxClicked(int)));
if (comb_->currentIndex() == 0)
{
if (searchKeyName("default", opt->name))
{
int value = getDefaultCfgValue("default", opt->name, 0);
spin->setValue(value);
}
}
//connect(spin, SIGNAL(valueChanged(int)), this, SLOT(slot_spinBoxClicked(int)));
}
}
}
}
else if(opt->type == SANE_TYPE_FIXED)
{
QSlider *slider = NULL;
QDoubleSpinBox* spin = NULL;
for(size_t i = 0; i < (size_t)ctrls.size(); ++i)
{
if (!slider)
{
slider = qobject_cast<QSlider*>(ctrls[i]);
//if (slider)
//disconnect(slider, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int)));
}
else if (!spin)
{
spin = qobject_cast<QDoubleSpinBox*>(ctrls[i]);
//if (spin)
//disconnect(spin, SIGNAL(valueChanged(double)), this, SLOT(slot_spinBoxClicked(double)));
}
}
if (slider)
{
if (comb_->currentIndex() == 0)
{
if (searchKeyName("default", opt->name))
{
float value = getDefaultCfgValue("default", opt->name, QString("")).toFloat();
slider->setValue(value * 100);
}
//connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int)));
}
if (spin)
{
if (comb_->currentIndex() == 0)
{
if (searchKeyName("default", opt->name))
{
float value = getDefaultCfgValue("default", opt->name, QString("")).toFloat();
spin->setValue(value);
}
//connect(spin, SIGNAL(valueChanged(double)), this, SLOT(slot_spinBoxClicked(double)));
}
}
}
}
else if(opt->type == SANE_TYPE_STRING)
{
for(size_t i = 0; i < (size_t)ctrls.size(); ++i)
{
QComboBox* comb = qobject_cast<QComboBox*>(ctrls[i]);
if(comb)
{
//disconnect(comb, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked()));
if (comb_->currentIndex() == 0)
{
if (searchKeyName("default", opt->name))
{
QString value = getDefaultCfgValue("default", opt->name, QString(""));
comb->setCurrentText(value);
}
//connect(comb, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked()));
}
else
{
QLineEdit* edit = qobject_cast<QLineEdit*>(ctrls[i]);
if(edit)
{
//disconnect(edit, SIGNAL(textChanged(const QString&)), this, SLOT(slot_lineEditInput()));
edit->setText(m_list_defaultOptions.at(id - 1).second.toString());
//connect(edit, SIGNAL(textChanged(const QString&)), this, SLOT(slot_lineEditInput()));
}
}
}
}
}
if (comb_->currentIndex() == 0)
{
if (0 == strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_LEFT) && searchKeyName("default", "cutLeftvalue"))
{
double value = getDefaultCfgValue("default", "cutLeftvalue", QString("")).toDouble();
m_cutLeftValue = value;
}
if (0 == strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_LEFT) && searchKeyName("default", "cutLeftvalue"))
{
double value = getDefaultCfgValue("default", "cutTopValue", QString("")).toDouble();
m_cutTopValue = value;
}
if (0 == strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_RIGHT) && searchKeyName("default", "cutLeftvalue"))
{
double value = getDefaultCfgValue("default", "cutRightvalue", QString("")).toDouble();
m_cutRightValue = value;
}
if (0 == strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_LEFT) && searchKeyName("default", "cutLeftvalue"))
{
double value = getDefaultCfgValue("default", "cutBottomvalue", QString("")).toDouble();
m_cutBottomValue = value;
}
if (0 == strcmp(opt->name, SANE_STD_OPT_NAME_IS_CUSTOM_GAMMA) && searchKeyName("default", "gamma"))
{
QString value = getDefaultCfgValue("default", "gamma", QString(""));
if (!value.isEmpty())
{
HGSize length = 0;
std::string base64Data = value.toStdString();
HGBase_Base64Decode((const HGByte*)base64Data.c_str(), base64Data.size(), NULL, &length);
if (length == sizeof(SANE_Gamma))
{
HGBase_Base64Decode((const HGByte*)base64Data.c_str(), base64Data.size(), (HGByte*)&m_gammaData, &length);
}
}
}
}
}
}
void hg_settingdialog::processIniFile()
{
HGChar cfgPath[512];
GetConfigPath(cfgPath, 512);
QString oldFile = QString::fromStdString(cfgPath) + "olddefault.ini";
QString newFile = QString::fromStdString(cfgPath) + "default.ini";
QFile::remove(oldFile);
QFile::copy(newFile, oldFile);
}
void hg_settingdialog::setDefault()
{
SANE_Int dev_options = 0;
m_saneAPI.sane_control_option_api(m_devHandle, 0, SANE_ACTION_GET_VALUE, &dev_options, nullptr);
for (int i = 1; i < dev_options; ++i)
{
const SANE_Option_Descriptor* opt = m_saneAPI.sane_get_option_descriptor_api(m_devHandle, i);
if (!opt)
continue;
if (opt->type == SANE_TYPE_BUTTON || opt->type == SANE_TYPE_GROUP)
continue;
m_saneAPI.sane_control_option_api(m_devHandle, i, SANE_ACTION_SET_AUTO, NULL, NULL);
}
}
std::string sane_val_to_string(const char* val, SANE_Value_Type type)
{
char buf[128] = {0};
@ -2118,16 +2401,15 @@ std::string sane_val_to_string(const char* val, SANE_Value_Type type)
}
void hg_settingdialog::on_current_scheme_changed()
{
del_this_->setEnabled(true);
del_all_->setEnabled(false);
m_deleteCur->setEnabled(true);
m_deleteAll->setEnabled(true);
if (comb_->currentIndex() == 0)
{
del_this_->setEnabled(false);
m_deleteCur->setEnabled(false);
}
if (comb_->count() > 1)
if (comb_->count() == 1)
{
del_all_->setEnabled(true);
m_deleteAll->setEnabled(false);
}
QString text(find_current_scheme_menu());
@ -2193,7 +2475,12 @@ void hg_settingdialog::on_current_scheme_changed()
if(schm)
schm->release();
sketch_->setHtml(info);
if (comb_->currentIndex() == 0)
{
updateDefaultScheme();
}
// sketch_->setHtml(info);
}
void hg_settingdialog::slot_pushButton_scheme_management(void)
{
@ -2222,7 +2509,7 @@ void hg_settingdialog::slot_pushButton_scheme_management(void)
}
disconnect(comb_, SIGNAL(currentTextChanged(const QString)), this, SLOT(on_current_scheme_changed()));
comb_->insertItem(id, newCfgName);
comb_->insertItem(id + 1, newCfgName);
connect(comb_, SIGNAL(currentTextChanged(const QString)), this, SLOT(on_current_scheme_changed()));
gb::sane_config_schm *scheme = cur_scheme_->copy();
@ -2232,12 +2519,19 @@ void hg_settingdialog::slot_pushButton_scheme_management(void)
cur_cfg_->add_scheme(cur_scheme_, newCfgName.toStdString().c_str());
cur_cfg_->select_scheme(cur_scheme_->get_scheme_name().c_str());
cur_cfg_->save();
comb_->setCurrentIndex(id);
comb_->setCurrentIndex(id + 1);
changed_count_++;
}
}
}
else if(btn == del_this_)
else if (btn == m_pbtn_Save)
{
if (comb_->currentIndex() == 0)
processIniFile();
else
save_scheme();
}
else if(btn == m_deleteCur)
{
int id = -1;
QString text(find_current_scheme_menu(&id));
@ -2265,7 +2559,7 @@ void hg_settingdialog::slot_pushButton_scheme_management(void)
changed_count_++;
cur_cfg_->save();
}
else if(btn == del_all_)
else if(btn == m_deleteAll)
{
QMessageBox msg(QMessageBox::Question, tr("be sure to delete the configuration"),
tr("Are you sure you want to delete the configuration?"), QMessageBox::Yes | QMessageBox::No, this);
@ -2284,17 +2578,21 @@ void hg_settingdialog::slot_pushButton_scheme_management(void)
}
void hg_settingdialog::restore_2_default_settings(void)
{
cur_scheme_->end_setting(true);
cur_cfg_->select_scheme(nullptr);
dev_que_.apply_scheme(&m_saneAPI, nullptr);
cur_cfg_->save();
if (comb_->currentIndex() == 0)
{
removeSection("default");
}
else
{
cur_scheme_->end_setting(true);
cur_cfg_->select_scheme(nullptr);
dev_que_.apply_scheme(&m_saneAPI, nullptr);
cur_cfg_->save();
gb::sane_config_schm *s = new gb::sane_config_schm();
s->copy_default_value(cur_scheme_);
cur_scheme_->release();
cur_scheme_ = s;
cur_scheme_->begin_setting();
// on_current_scheme_changed();
comb_->setCurrentIndex(0);
gb::sane_config_schm *s = new gb::sane_config_schm();
s->copy_default_value(cur_scheme_);
cur_scheme_->release();
cur_scheme_ = s;
cur_scheme_->begin_setting();
}
}

View File

@ -27,8 +27,9 @@ class hg_settingdialog : public QDialog
QMenu *top_menu_;
QLineEdit *edit_name_;
QPushButton *m_pbtn_addNew;
QPushButton *del_this_;
QPushButton *del_all_;
QPushButton* m_pbtn_Save;
QPushButton *m_deleteCur;
QPushButton *m_deleteAll;
QLabel *custom_area_lable_;
QPushButton *btn_cut_area_;
QPushButton *btn_gamma_;
@ -79,6 +80,8 @@ public:
int m_closeButton;
private:
gb::sane_config_schm* m_scheme;
static hg_settingdialog *hg_setting_ui_;
SANEAPI m_saneAPI;
SANE_Handle m_devHandle;
@ -94,7 +97,6 @@ private:
QSettings *m_configIniRead;
private:
HGResult GetConfigPath(HGChar* configPath, HGUInt maxLen);
QString md5(QString key);
const void* find_option_description(int id); // return const SANE_Option_Descriptor* pointer
const void* find_option_description(const std::string& title, int* id); // return const SANE_Option_Descriptor* pointer
@ -108,6 +110,9 @@ private:
std::string getAppVersion();
void apply_current_scheme(void);
void setIcon();
void updateDefaultScheme();
void processIniFile();
void setDefault();
private:
QVector<QPair<QPair<int, QVariant>, QString>> m_list_IdValueTitle;

View File

@ -1,7 +1,6 @@
#include "twain_user/twainui.h"
#include <QMessageBox>
#include <string>
#include <shlobj.h>
#include "dialog_device_select.h"
#include "dialog_progress_ui.h"
#include "hg_settingdialog.h"
@ -51,54 +50,6 @@ int choose_scanner(const std::vector<DEVQUEUI> &devs)
return g_manager->showDeviceSelect(nullptr == g_hThread, devs);
}
static HGResult GetConfigPath(HGChar* configPath, HGUInt maxLen)
{
if (NULL == configPath || 0 == maxLen)
{
return HGBASE_ERR_INVALIDARG;
}
const char *appName = "HuaGoScan";
#if defined(OEM_HANWANG)
appName = "HanvonScan";
#elif defined(OEM_LISICHENG)
appName = "LanxumScan";
#elif defined(OEM_CANGTIAN)
appName = "CumtennScan";
#elif defined(OEM_ZHONGJING)
appName = "MicrotekScan";
#elif defined(OEM_ZIGUANG)
appName = "UniScan";
#endif
#if defined(HG_CMP_MSC)
CHAR cfgPath[MAX_PATH] = { 0 };
BOOL ret = SHGetSpecialFolderPathA(NULL, cfgPath, CSIDL_APPDATA, FALSE);
if (!ret)
return HGBASE_ERR_FAIL;
if (cfgPath[strlen(cfgPath) - 1] != '\\')
strcat(cfgPath, "\\");
strcat(cfgPath, appName);
strcat(cfgPath, "\\Cfg\\");
#else
char cfgPath[512] = { 0 };
struct passwd* pw = getpwuid(getuid());
strcpy(cfgPath, pw->pw_dir);
if (cfgPath[strlen(cfgPath) - 1] != '/')
strcat(cfgPath, "/");
strcat(cfgPath, ".");
strcat(cfgPath, appName);
strcat(cfgPath, "/Cfg/");
#endif
if (maxLen < strlen(cfgPath) + 1)
return HGBASE_ERR_FAIL;
strcpy(configPath, cfgPath);
return HGBASE_ERR_OK;
}
char *apply_current_config(const char *dev_name, SANE_Handle device, LPSANEAPI api)
{
dev_que devQue;