Use single tesseract library
Link with it during compilation. Bump to 5.2.0.
This commit is contained in:
		
							parent
							
								
									cb203b912e
								
							
						
					
					
						commit
						7be070744b
					
				@ -8,7 +8,7 @@ DEPS_DIR=$$(ST_DEPS_DIR)
 | 
				
			|||||||
isEmpty(DEPS_DIR):DEPS_DIR=$$PWD/../deps
 | 
					isEmpty(DEPS_DIR):DEPS_DIR=$$PWD/../deps
 | 
				
			||||||
INCLUDEPATH += $$DEPS_DIR/include
 | 
					INCLUDEPATH += $$DEPS_DIR/include
 | 
				
			||||||
LIBS += -L$$DEPS_DIR/lib
 | 
					LIBS += -L$$DEPS_DIR/lib
 | 
				
			||||||
LIBS += -lhunspell -lleptonica
 | 
					LIBS += -lhunspell -lleptonica -ltesseract
 | 
				
			||||||
 | 
					
 | 
				
			||||||
win32{
 | 
					win32{
 | 
				
			||||||
  LIBS += -lUser32
 | 
					  LIBS += -lUser32
 | 
				
			||||||
 | 
				
			|||||||
@ -47,8 +47,7 @@ os.environ['VERSION'] = app_version
 | 
				
			|||||||
flags = '' if os.getenv("DEBUG") is None else '-unsupported-allow-new-glibc'
 | 
					flags = '' if os.getenv("DEBUG") is None else '-unsupported-allow-new-glibc'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
additional_files = glob(ssl_dir + '/lib/lib*.so.*') + \
 | 
					additional_files = glob(ssl_dir + '/lib/lib*.so.*') + \
 | 
				
			||||||
    glob('/usr/lib/x86_64-linux-gnu/nss/*') + \
 | 
					    glob('/usr/lib/x86_64-linux-gnu/nss/*')
 | 
				
			||||||
    glob(dependencies_dir + '/lib/libtesseract-*.so')
 | 
					 | 
				
			||||||
out_lib_dir = install_dir + '/usr/lib'
 | 
					out_lib_dir = install_dir + '/usr/lib'
 | 
				
			||||||
os.makedirs(out_lib_dir, exist_ok=True)
 | 
					os.makedirs(out_lib_dir, exist_ok=True)
 | 
				
			||||||
for f in additional_files:
 | 
					for f in additional_files:
 | 
				
			||||||
 | 
				
			|||||||
@ -6,27 +6,12 @@ import platform
 | 
				
			|||||||
c.print('>> Installing tesseract')
 | 
					c.print('>> Installing tesseract')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
install_dir = dependencies_dir
 | 
					install_dir = dependencies_dir
 | 
				
			||||||
url = 'https://github.com/tesseract-ocr/tesseract/archive/5.1.0.tar.gz'
 | 
					required_version = '5.2.0'
 | 
				
			||||||
required_version = '5.1.0'
 | 
					url = 'https://github.com/tesseract-ocr/tesseract/archive/{}.tar.gz'.format(required_version)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
build_type_flag = 'Debug' if build_type == 'debug' else 'Release'
 | 
					build_type_flag = 'Debug' if build_type == 'debug' else 'Release'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# compatibility flags
 | 
					cache_file = install_dir + '/tesseract.cache'
 | 
				
			||||||
compat_flags = ''
 | 
					 | 
				
			||||||
compat_flags += ' -D DISABLE_LEGACY_ENGINE=ON '
 | 
					 | 
				
			||||||
compat_flags += ' -D DISABLE_ARCHIVE=ON '
 | 
					 | 
				
			||||||
compat_flags += ' -D DISABLE_CURL=ON '
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
version_tag = os.environ.get('TAG', '')
 | 
					 | 
				
			||||||
if version_tag == 'compatible':
 | 
					 | 
				
			||||||
    compat_flags += ' -D HAVE_AVX2=0 '
 | 
					 | 
				
			||||||
    compat_flags += ' -D HAVE_FMA=0 '
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
lib_suffix = version_tag
 | 
					 | 
				
			||||||
if len(lib_suffix) > 0:
 | 
					 | 
				
			||||||
    lib_suffix = '-' + lib_suffix
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cache_file = install_dir + '/tesseract{}.cache'.format(lib_suffix)
 | 
					 | 
				
			||||||
cache_file_data = required_version + build_type_flag
 | 
					cache_file_data = required_version + build_type_flag
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def check_existing():
 | 
					def check_existing():
 | 
				
			||||||
@ -42,22 +27,25 @@ def check_existing():
 | 
				
			|||||||
        return False
 | 
					        return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if platform.system() == "Windows":
 | 
					    if platform.system() == "Windows":
 | 
				
			||||||
        lib = install_dir + '/bin/tesseract{}.dll'.format(lib_suffix)
 | 
					        file_name_ver = required_version[0] + required_version[2]
 | 
				
			||||||
        orig_lib = install_dir + '/bin/tesseract51.dll'
 | 
					        dll = install_dir + '/bin/tesseract{}.dll'.format(file_name_ver)
 | 
				
			||||||
    elif platform.system() == "Darwin":
 | 
					        lib = install_dir + '/lib/tesseract{}.lib'.format(file_name_ver)
 | 
				
			||||||
        lib = install_dir + '/lib/libtesseract{}.dylib'.format(lib_suffix)
 | 
					        if not os.path.exists(dll) or not os.path.exists(lib):
 | 
				
			||||||
        orig_lib = install_dir + '/lib/libtesseract.{}.dylib'.format(required_version)
 | 
					 | 
				
			||||||
    else:
 | 
					 | 
				
			||||||
        lib = install_dir + '/lib/libtesseract{}.so'.format(lib_suffix)
 | 
					 | 
				
			||||||
        orig_lib = install_dir + '/lib/libtesseract.so.{}'.format(required_version)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if os.path.exists(lib):
 | 
					 | 
				
			||||||
        return True
 | 
					 | 
				
			||||||
    if os.path.exists(orig_lib):
 | 
					 | 
				
			||||||
        os.rename(orig_lib, lib)
 | 
					 | 
				
			||||||
        return True
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            return False
 | 
					            return False
 | 
				
			||||||
 | 
					        c.symlink(dll, install_dir + '/bin/tesseract.dll')
 | 
				
			||||||
 | 
					        c.symlink(lib, install_dir + '/lib/tesseract.lib')
 | 
				
			||||||
 | 
					    elif platform.system() == "Darwin":
 | 
				
			||||||
 | 
					        lib = install_dir + '/lib/libtesseract.{}.dylib'.format(required_version)
 | 
				
			||||||
 | 
					        if not os.path.exists(lib):
 | 
				
			||||||
 | 
					            return False
 | 
				
			||||||
 | 
					        c.symlink(lib, install_dir + '/lib/libtesseract.dylib')
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        lib = install_dir + '/lib/libtesseract.so.{}'.format(required_version)
 | 
				
			||||||
 | 
					        if not os.path.exists(lib):
 | 
				
			||||||
 | 
					            return False
 | 
				
			||||||
 | 
					        c.symlink(lib, install_dir + '/lib/libtesseract.so')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if check_existing() and not 'FORCE' in os.environ:
 | 
					if check_existing() and not 'FORCE' in os.environ:
 | 
				
			||||||
@ -71,60 +59,24 @@ src_dir = os.path.abspath('tesseract_src')
 | 
				
			|||||||
c.extract(archive, '.')
 | 
					c.extract(archive, '.')
 | 
				
			||||||
c.symlink(c.get_archive_top_dir(archive), src_dir)
 | 
					c.symlink(c.get_archive_top_dir(archive), src_dir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if platform.system() == "Windows":
 | 
					 | 
				
			||||||
    # workaround for not found 'max'
 | 
					 | 
				
			||||||
    modify_data = ''
 | 
					 | 
				
			||||||
    modify_file = '{}/src/ccmain/thresholder.cpp'.format(src_dir)
 | 
					 | 
				
			||||||
    with open(modify_file, 'r') as f:
 | 
					 | 
				
			||||||
        modify_data = f.read()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if modify_data.find('<algorithm>') == -1:
 | 
					 | 
				
			||||||
        modify_data = modify_data.replace(
 | 
					 | 
				
			||||||
        '''<tuple>''',
 | 
					 | 
				
			||||||
        '''<tuple>\n#include <algorithm>''')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    with open(modify_file, 'w') as f:
 | 
					 | 
				
			||||||
        f.write(modify_data)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # ignore libtiff
 | 
					 | 
				
			||||||
    modify_data = ''
 | 
					 | 
				
			||||||
    modify_file = '{}/CMakeLists.txt'.format(src_dir)
 | 
					 | 
				
			||||||
    with open(modify_file, 'r') as f:
 | 
					 | 
				
			||||||
        modify_data = f.read()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if modify_data.find('#pkg_check_modules(TIFF libtiff-4)') == -1:
 | 
					 | 
				
			||||||
        modify_data = modify_data.replace(
 | 
					 | 
				
			||||||
        '''pkg_check_modules(TIFF libtiff-4)''',
 | 
					 | 
				
			||||||
        '''#pkg_check_modules(TIFF libtiff-4)''')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    with open(modify_file, 'w') as f:
 | 
					 | 
				
			||||||
        f.write(modify_data)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if platform.system() == "Linux":
 | 
					 | 
				
			||||||
    # FIXME fix crash on ubuntu
 | 
					 | 
				
			||||||
    modify_data = ''
 | 
					 | 
				
			||||||
    modify_file = '{}/src/ccmain/tessedit.cpp'.format(src_dir)
 | 
					 | 
				
			||||||
    with open(modify_file, 'r') as f:
 | 
					 | 
				
			||||||
        modify_data = f.read()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    lines = modify_data.split('\n')
 | 
					 | 
				
			||||||
    for line in [250,253,255,256]:
 | 
					 | 
				
			||||||
        if not lines[line].startswith('//'):
 | 
					 | 
				
			||||||
            lines[line] = '// ' + lines[line]
 | 
					 | 
				
			||||||
    modify_data = '\n'.join(lines)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    with open(modify_file, 'w') as f:
 | 
					 | 
				
			||||||
        f.write(modify_data)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
c.ensure_got_path(install_dir)
 | 
					c.ensure_got_path(install_dir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
c.recreate_dir(build_dir)
 | 
					c.recreate_dir(build_dir)
 | 
				
			||||||
os.chdir(build_dir)
 | 
					os.chdir(build_dir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cmake_args = '"{0}" -DCMAKE_INSTALL_PREFIX="{1}" -DLeptonica_DIR="{1}/cmake" \
 | 
					cmake_args = '"{0}" \
 | 
				
			||||||
-DBUILD_TRAINING_TOOLS=OFF -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON -DSW_BUILD=OFF \
 | 
					-DCMAKE_INSTALL_PREFIX="{1}" \
 | 
				
			||||||
 | 
					-DLeptonica_DIR="{1}/cmake" \
 | 
				
			||||||
 | 
					-DSW_BUILD=OFF \
 | 
				
			||||||
 | 
					-DBUILD_TRAINING_TOOLS=OFF \
 | 
				
			||||||
 | 
					-DBUILD_TESTS=OFF \
 | 
				
			||||||
 | 
					-DBUILD_SHARED_LIBS=ON \
 | 
				
			||||||
 | 
					-DDISABLE_CURL=ON \
 | 
				
			||||||
 | 
					-DDISABLE_ARCHIVE=ON \
 | 
				
			||||||
 | 
					-DUSE_SYSTEM_ICU=ON \
 | 
				
			||||||
 | 
					-DENABLE_LTO=ON \
 | 
				
			||||||
 | 
					-DGRAPHICS_DISABLED=ON \
 | 
				
			||||||
 | 
					-DDISABLED_LEGACY_ENGINE=ON \
 | 
				
			||||||
'.format(src_dir, install_dir)
 | 
					'.format(src_dir, install_dir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if platform.system() == "Windows":
 | 
					if platform.system() == "Windows":
 | 
				
			||||||
@ -135,10 +87,6 @@ if platform.system() == "Windows":
 | 
				
			|||||||
c.set_make_threaded()
 | 
					c.set_make_threaded()
 | 
				
			||||||
c.run('cmake {}'.format(cmake_args))
 | 
					c.run('cmake {}'.format(cmake_args))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if len(compat_flags) > 0:
 | 
					 | 
				
			||||||
    c.run('cmake {} .'.format(compat_flags))
 | 
					 | 
				
			||||||
    c.run('cmake {} .'.format(compat_flags))  # for sure :)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
c.run('cmake --build . --config {}'.format(build_type_flag))
 | 
					c.run('cmake --build . --config {}'.format(build_type_flag))
 | 
				
			||||||
c.run('cmake --build . --target install --config {}'.format(build_type_flag))
 | 
					c.run('cmake --build . --target install --config {}'.format(build_type_flag))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -29,15 +29,8 @@ def r(script):
 | 
				
			|||||||
r('get_qt.py')
 | 
					r('get_qt.py')
 | 
				
			||||||
r('get_qt_ssl.py')
 | 
					r('get_qt_ssl.py')
 | 
				
			||||||
r('get_leptonica.py')
 | 
					r('get_leptonica.py')
 | 
				
			||||||
 | 
					 | 
				
			||||||
os.environ['TAG'] = 'optimized'
 | 
					 | 
				
			||||||
r('get_tesseract.py')
 | 
					r('get_tesseract.py')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
os.environ['TAG'] = 'compatible'
 | 
					 | 
				
			||||||
r('get_tesseract.py')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
del os.environ['TAG']
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
r('get_hunspell.py')
 | 
					r('get_hunspell.py')
 | 
				
			||||||
r('test.py')
 | 
					r('test.py')
 | 
				
			||||||
r('build.py')
 | 
					r('build.py')
 | 
				
			||||||
 | 
				
			|||||||
@ -673,12 +673,12 @@ Check for updates to silence this warning</source>
 | 
				
			|||||||
        <translation>неизвестные языки для перевода: %1 или %2</translation>
 | 
					        <translation>неизвестные языки для перевода: %1 или %2</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/ocr/tesseract.cpp" line="255"/>
 | 
					        <location filename="../../src/ocr/tesseract.cpp" line="234"/>
 | 
				
			||||||
        <source>init failed</source>
 | 
					        <source>init failed</source>
 | 
				
			||||||
        <translation>ошибка инициалиизации</translation>
 | 
					        <translation>ошибка инициалиизации</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/ocr/tesseract.cpp" line="306"/>
 | 
					        <location filename="../../src/ocr/tesseract.cpp" line="294"/>
 | 
				
			||||||
        <source>Failed to recognize text or no text selected</source>
 | 
					        <source>Failed to recognize text or no text selected</source>
 | 
				
			||||||
        <translation>Ошибка распознавания текста или нет текста в выделенной зоне</translation>
 | 
					        <translation>Ошибка распознавания текста или нет текста в выделенной зоне</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
@ -697,12 +697,12 @@ in %1</source>
 | 
				
			|||||||
в %1</translation>
 | 
					в %1</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/capture/capturearea.cpp" line="27"/>
 | 
					        <location filename="../../src/capture/capturearea.cpp" line="28"/>
 | 
				
			||||||
        <source>No source language set</source>
 | 
					        <source>No source language set</source>
 | 
				
			||||||
        <translation>Не задан исходный язык</translation>
 | 
					        <translation>Не задан исходный язык</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/capture/capturearea.cpp" line="34"/>
 | 
					        <location filename="../../src/capture/capturearea.cpp" line="35"/>
 | 
				
			||||||
        <source>No target language set</source>
 | 
					        <source>No target language set</source>
 | 
				
			||||||
        <translation>Не задан язык результата</translation>
 | 
					        <translation>Не задан язык результата</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
@ -712,37 +712,37 @@ in %1</source>
 | 
				
			|||||||
        <translation>Не восстанавливать интерфейс пользователя (размер и положения окна и т.д.)</translation>
 | 
					        <translation>Не восстанавливать интерфейс пользователя (размер и положения окна и т.д.)</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.cpp" line="197"/>
 | 
					        <location filename="../../src/settingseditor.cpp" line="189"/>
 | 
				
			||||||
        <source><p>Optical character recognition (OCR) and translation tool</p></source>
 | 
					        <source><p>Optical character recognition (OCR) and translation tool</p></source>
 | 
				
			||||||
        <translation><p>Инструмент оптического распознавания текста (OCR) и перевода</p></translation>
 | 
					        <translation><p>Инструмент оптического распознавания текста (OCR) и перевода</p></translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.cpp" line="199"/>
 | 
					        <location filename="../../src/settingseditor.cpp" line="191"/>
 | 
				
			||||||
        <source><p>Version: %1</p></source>
 | 
					        <source><p>Version: %1</p></source>
 | 
				
			||||||
        <translation><p>Версия: %1</p></translation>
 | 
					        <translation><p>Версия: %1</p></translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.cpp" line="201"/>
 | 
					        <location filename="../../src/settingseditor.cpp" line="193"/>
 | 
				
			||||||
        <source><p>Setup instructions: <a href="%1">%1</a></p></source>
 | 
					        <source><p>Setup instructions: <a href="%1">%1</a></p></source>
 | 
				
			||||||
        <translation><p>Инструкции по установке: <a href="%1">%1</a></p></translation>
 | 
					        <translation><p>Инструкции по установке: <a href="%1">%1</a></p></translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.cpp" line="202"/>
 | 
					        <location filename="../../src/settingseditor.cpp" line="195"/>
 | 
				
			||||||
        <source><p>Changelog: <a href="%1">%2</a></p></source>
 | 
					        <source><p>Changelog: <a href="%1">%2</a></p></source>
 | 
				
			||||||
        <translation><p>Список изменений: <a href="%1">%2</a></p></translation>
 | 
					        <translation><p>Список изменений: <a href="%1">%2</a></p></translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.cpp" line="204"/>
 | 
					        <location filename="../../src/settingseditor.cpp" line="197"/>
 | 
				
			||||||
        <source><p>License: <a href="%3">MIT</a></p></source>
 | 
					        <source><p>License: <a href="%3">MIT</a></p></source>
 | 
				
			||||||
        <translation><p>Лицензия: <a href="%3">MIT</a></p></translation>
 | 
					        <translation><p>Лицензия: <a href="%3">MIT</a></p></translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.cpp" line="205"/>
 | 
					        <location filename="../../src/settingseditor.cpp" line="198"/>
 | 
				
			||||||
        <source><p>Author: Gres (<a href="mailto:%1">%1</a>)</p></source>
 | 
					        <source><p>Author: Gres (<a href="mailto:%1">%1</a>)</p></source>
 | 
				
			||||||
        <translation><p>Автор: Gres (<a href="mailto:%1">%1</a>)</p></translation>
 | 
					        <translation><p>Автор: Gres (<a href="mailto:%1">%1</a>)</p></translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.cpp" line="207"/>
 | 
					        <location filename="../../src/settingseditor.cpp" line="200"/>
 | 
				
			||||||
        <source><p>Issues: <a href="%1">%1</a></p></source>
 | 
					        <source><p>Issues: <a href="%1">%1</a></p></source>
 | 
				
			||||||
        <translation><p>Поддержка: <a href="%1">%1</a></p></translation>
 | 
					        <translation><p>Поддержка: <a href="%1">%1</a></p></translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
@ -844,7 +844,7 @@ in %1</source>
 | 
				
			|||||||
        <translation>Повторить захват</translation>
 | 
					        <translation>Повторить захват</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/represent/resultwidget.cpp" line="93"/>
 | 
					        <location filename="../../src/represent/resultwidget.cpp" line="95"/>
 | 
				
			||||||
        <source>Without correction:
 | 
					        <source>Without correction:
 | 
				
			||||||
</source>
 | 
					</source>
 | 
				
			||||||
        <translation>Без коррекции:
 | 
					        <translation>Без коррекции:
 | 
				
			||||||
@ -919,42 +919,41 @@ in %1</source>
 | 
				
			|||||||
        <translation>сохранять пароль (небезопасно)</translation>
 | 
					        <translation>сохранять пароль (небезопасно)</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="355"/>
 | 
					 | 
				
			||||||
        <source>Library version</source>
 | 
					        <source>Library version</source>
 | 
				
			||||||
        <translation>Версия</translation>
 | 
					        <translation type="vanished">Версия</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="369"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="359"/>
 | 
				
			||||||
        <source>User substitutions</source>
 | 
					        <source>User substitutions</source>
 | 
				
			||||||
        <translation>Пользовательская коррекция</translation>
 | 
					        <translation>Пользовательская коррекция</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="392"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="382"/>
 | 
				
			||||||
        <source>Use auto corrections (hunspell)</source>
 | 
					        <source>Use auto corrections (hunspell)</source>
 | 
				
			||||||
        <translation>Использовать автокоррекцию (hunspell)</translation>
 | 
					        <translation>Использовать автокоррекцию (hunspell)</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="399"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="389"/>
 | 
				
			||||||
        <source>Use user substitutions</source>
 | 
					        <source>Use user substitutions</source>
 | 
				
			||||||
        <translation>Использовать пользовательскую коррекцию</translation>
 | 
					        <translation>Использовать пользовательскую коррекцию</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="406"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="396"/>
 | 
				
			||||||
        <source>Hunspell dictionaries path:</source>
 | 
					        <source>Hunspell dictionaries path:</source>
 | 
				
			||||||
        <translation>Путь к словарям Hunspell:</translation>
 | 
					        <translation>Путь к словарям Hunspell:</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="468"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="458"/>
 | 
				
			||||||
        <source>Language:</source>
 | 
					        <source>Language:</source>
 | 
				
			||||||
        <translation>Язык:</translation>
 | 
					        <translation>Язык:</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="504"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="494"/>
 | 
				
			||||||
        <source> secs</source>
 | 
					        <source> secs</source>
 | 
				
			||||||
        <translation> сек</translation>
 | 
					        <translation> сек</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="444"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="434"/>
 | 
				
			||||||
        <source>Ignore SSL errors</source>
 | 
					        <source>Ignore SSL errors</source>
 | 
				
			||||||
        <translation>Игнорировать ошибки SSL</translation>
 | 
					        <translation>Игнорировать ошибки SSL</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
@ -984,102 +983,102 @@ in %1</source>
 | 
				
			|||||||
        <translation>Писать логи в файл (отладка)</translation>
 | 
					        <translation>Писать логи в файл (отладка)</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="342"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="345"/>
 | 
				
			||||||
        <source>Default language:</source>
 | 
					        <source>Default language:</source>
 | 
				
			||||||
        <translation>Язык по умолчанию:</translation>
 | 
					        <translation>Язык по умолчанию:</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="329"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="303"/>
 | 
				
			||||||
        <source>Tessdata path:</source>
 | 
					        <source>Tessdata path:</source>
 | 
				
			||||||
        <translation>Путь к языкам (tessdata):</translation>
 | 
					        <translation>Путь к языкам (tessdata):</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="379"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="369"/>
 | 
				
			||||||
        <source>\\ for \ symbol, \n for newline</source>
 | 
					        <source>\\ for \ symbol, \n for newline</source>
 | 
				
			||||||
        <translation>\\ для символа \ , \n для символа новой строки</translation>
 | 
					        <translation>\\ для символа \ , \n для символа новой строки</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="427"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="417"/>
 | 
				
			||||||
        <source>Translators path:</source>
 | 
					        <source>Translators path:</source>
 | 
				
			||||||
        <translation>Путь к переводчикам:</translation>
 | 
					        <translation>Путь к переводчикам:</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="434"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="424"/>
 | 
				
			||||||
        <source>Translators</source>
 | 
					        <source>Translators</source>
 | 
				
			||||||
        <translation>Переводчики</translation>
 | 
					        <translation>Переводчики</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="569"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="559"/>
 | 
				
			||||||
        <source>Result window</source>
 | 
					        <source>Result window</source>
 | 
				
			||||||
        <translation>Окно результата</translation>
 | 
					        <translation>Окно результата</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="575"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="565"/>
 | 
				
			||||||
        <source>Font:</source>
 | 
					        <source>Font:</source>
 | 
				
			||||||
        <translation>Шрифт:</translation>
 | 
					        <translation>Шрифт:</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="585"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="575"/>
 | 
				
			||||||
        <source>Font size:</source>
 | 
					        <source>Font size:</source>
 | 
				
			||||||
        <translation>Размер шрифта:</translation>
 | 
					        <translation>Размер шрифта:</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="602"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="592"/>
 | 
				
			||||||
        <source>Font color:</source>
 | 
					        <source>Font color:</source>
 | 
				
			||||||
        <translation>Цвет шрифта:</translation>
 | 
					        <translation>Цвет шрифта:</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="616"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="606"/>
 | 
				
			||||||
        <source>Background:</source>
 | 
					        <source>Background:</source>
 | 
				
			||||||
        <translation>Фон:</translation>
 | 
					        <translation>Фон:</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="630"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="620"/>
 | 
				
			||||||
        <source>Show image</source>
 | 
					        <source>Show image</source>
 | 
				
			||||||
        <translation>Показывать изображение</translation>
 | 
					        <translation>Показывать изображение</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="637"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="627"/>
 | 
				
			||||||
        <source>Show recognized</source>
 | 
					        <source>Show recognized</source>
 | 
				
			||||||
        <translation>Показывать распознанное</translation>
 | 
					        <translation>Показывать распознанное</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="687"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="677"/>
 | 
				
			||||||
        <source>Update check interval (days):</source>
 | 
					        <source>Update check interval (days):</source>
 | 
				
			||||||
        <translation>Интервал проверки обновления (дней):</translation>
 | 
					        <translation>Интервал проверки обновления (дней):</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="694"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="684"/>
 | 
				
			||||||
        <source>0 - disabled</source>
 | 
					        <source>0 - disabled</source>
 | 
				
			||||||
        <translation>- отключено</translation>
 | 
					        <translation>- отключено</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="454"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="444"/>
 | 
				
			||||||
        <source>Translate text</source>
 | 
					        <source>Translate text</source>
 | 
				
			||||||
        <translation>Переводить текст</translation>
 | 
					        <translation>Переводить текст</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="461"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="451"/>
 | 
				
			||||||
        <source>Single translator timeout:</source>
 | 
					        <source>Single translator timeout:</source>
 | 
				
			||||||
        <translation>Переходить к следующему переводчику после:</translation>
 | 
					        <translation>Переходить к следующему переводчику после:</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="531"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="521"/>
 | 
				
			||||||
        <source>Result type</source>
 | 
					        <source>Result type</source>
 | 
				
			||||||
        <translation>Тип результата</translation>
 | 
					        <translation>Тип результата</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="543"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="533"/>
 | 
				
			||||||
        <source>Tray</source>
 | 
					        <source>Tray</source>
 | 
				
			||||||
        <translation>Трей</translation>
 | 
					        <translation>Трей</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="556"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="546"/>
 | 
				
			||||||
        <source>Window</source>
 | 
					        <source>Window</source>
 | 
				
			||||||
        <translation>Окно</translation>
 | 
					        <translation>Окно</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.ui" line="710"/>
 | 
					        <location filename="../../src/settingseditor.ui" line="700"/>
 | 
				
			||||||
        <source>Check now</source>
 | 
					        <source>Check now</source>
 | 
				
			||||||
        <translation>Проверить сейчас</translation>
 | 
					        <translation>Проверить сейчас</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
@ -1175,32 +1174,29 @@ Hunspell ищет в своем словаре слова, похожие на 
 | 
				
			|||||||
        <translation>HTTP</translation>
 | 
					        <translation>HTTP</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.cpp" line="126"/>
 | 
					 | 
				
			||||||
        <source>Optimized</source>
 | 
					        <source>Optimized</source>
 | 
				
			||||||
        <translation>Оптимизированная</translation>
 | 
					        <translation type="vanished">Оптимизированная</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.cpp" line="127"/>
 | 
					 | 
				
			||||||
        <source>Compatible</source>
 | 
					        <source>Compatible</source>
 | 
				
			||||||
        <translation>Совместимая</translation>
 | 
					        <translation type="vanished">Совместимая</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.cpp" line="131"/>
 | 
					 | 
				
			||||||
        <source>Use compatible version if you are experiencing crashes during recognition</source>
 | 
					        <source>Use compatible version if you are experiencing crashes during recognition</source>
 | 
				
			||||||
        <translation>Используйте совместимую версию если программа неожиданно завершается во время распознавания</translation>
 | 
					        <translation type="vanished">Используйте совместимую версию если программа неожиданно завершается во время распознавания</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.cpp" line="143"/>
 | 
					        <location filename="../../src/settingseditor.cpp" line="135"/>
 | 
				
			||||||
        <source><b>NOTE! Some translators might require the translation window to be visible. You can make it using the "Show translator" entry in the tray icon's context menu</b></source>
 | 
					        <source><b>NOTE! Some translators might require the translation window to be visible. You can make it using the "Show translator" entry in the tray icon's context menu</b></source>
 | 
				
			||||||
        <translation><b>ПРИМЕЧАНИЕ! Для работы некоторых переводчиков может потребоваться активное окно перевода. Его можно отобразить при помощи пункта "Показать окно перевода" контекстного меню иконки в трее</b></translation>
 | 
					        <translation><b>ПРИМЕЧАНИЕ! Для работы некоторых переводчиков может потребоваться активное окно перевода. Его можно отобразить при помощи пункта "Показать окно перевода" контекстного меню иконки в трее</b></translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.cpp" line="151"/>
 | 
					        <location filename="../../src/settingseditor.cpp" line="143"/>
 | 
				
			||||||
        <source>Sample text</source>
 | 
					        <source>Sample text</source>
 | 
				
			||||||
        <translation>Текст для проверки</translation>
 | 
					        <translation>Текст для проверки</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.cpp" line="215"/>
 | 
					        <location filename="../../src/settingseditor.cpp" line="208"/>
 | 
				
			||||||
        <source>The program workflow consists of the following steps:
 | 
					        <source>The program workflow consists of the following steps:
 | 
				
			||||||
1. Selection on the screen area
 | 
					1. Selection on the screen area
 | 
				
			||||||
2. Recognition of the selected area
 | 
					2. Recognition of the selected area
 | 
				
			||||||
@ -1223,7 +1219,7 @@ Then set default recognition and translation languages, enable some (or all) tra
 | 
				
			|||||||
Далее установите языки распознавания и перевода по умолчанию, активируйте некоторые (или все) переводчики и настройку "переводить текст", если нужно.</translation>
 | 
					Далее установите языки распознавания и перевода по умолчанию, активируйте некоторые (или все) переводчики и настройку "переводить текст", если нужно.</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
    <message>
 | 
					    <message>
 | 
				
			||||||
        <location filename="../../src/settingseditor.cpp" line="380"/>
 | 
					        <location filename="../../src/settingseditor.cpp" line="371"/>
 | 
				
			||||||
        <source>Portable changed. Apply settings first</source>
 | 
					        <source>Portable changed. Apply settings first</source>
 | 
				
			||||||
        <translation>Portable режим изменен. Сначала примените настройки</translation>
 | 
					        <translation>Portable режим изменен. Сначала примените настройки</translation>
 | 
				
			||||||
    </message>
 | 
					    </message>
 | 
				
			||||||
 | 
				
			|||||||
@ -79,9 +79,5 @@ void Recognizer::updateSettings()
 | 
				
			|||||||
  SOFT_ASSERT(!settings_.tessdataPath.isEmpty(), return );
 | 
					  SOFT_ASSERT(!settings_.tessdataPath.isEmpty(), return );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  queue_.clear();
 | 
					  queue_.clear();
 | 
				
			||||||
  const auto libName =
 | 
					  emit reset(settings_.tessdataPath);
 | 
				
			||||||
      (settings_.tesseractVersion == TesseractVersion::Optimized
 | 
					 | 
				
			||||||
           ? "tesseract-optimized"
 | 
					 | 
				
			||||||
           : "tesseract-compatible");
 | 
					 | 
				
			||||||
  emit reset(settings_.tessdataPath, libName);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -18,7 +18,7 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
signals:
 | 
					signals:
 | 
				
			||||||
  void recognizeImpl(const TaskPtr &task);
 | 
					  void recognizeImpl(const TaskPtr &task);
 | 
				
			||||||
  void reset(const QString &tessdataPath, const QString &tesseractLibrary);
 | 
					  void reset(const QString &tessdataPath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
  void recognized(const TaskPtr &task);
 | 
					  void recognized(const TaskPtr &task);
 | 
				
			||||||
 | 
				
			|||||||
@ -17,8 +17,8 @@ void RecognizeWorker::handle(const TaskPtr &task)
 | 
				
			|||||||
  if (!engines_.count(task->sourceLanguage)) {
 | 
					  if (!engines_.count(task->sourceLanguage)) {
 | 
				
			||||||
    LTRACE() << "Create OCR engine" << task->sourceLanguage;
 | 
					    LTRACE() << "Create OCR engine" << task->sourceLanguage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    auto engine = std::make_unique<Tesseract>(task->sourceLanguage,
 | 
					    auto engine =
 | 
				
			||||||
                                              tessdataPath_, tesseractLibrary_);
 | 
					        std::make_unique<Tesseract>(task->sourceLanguage, tessdataPath_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!engine->isValid()) {
 | 
					    if (!engine->isValid()) {
 | 
				
			||||||
      result->error = tr("Failed to init OCR engine: %1").arg(engine->error());
 | 
					      result->error = tr("Failed to init OCR engine: %1").arg(engine->error());
 | 
				
			||||||
@ -43,14 +43,12 @@ void RecognizeWorker::handle(const TaskPtr &task)
 | 
				
			|||||||
  emit finished(result);
 | 
					  emit finished(result);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void RecognizeWorker::reset(const QString &tessdataPath,
 | 
					void RecognizeWorker::reset(const QString &tessdataPath)
 | 
				
			||||||
                            const QString &tesseractLibrary)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (tessdataPath_ == tessdataPath && tesseractLibrary_ == tesseractLibrary)
 | 
					  if (tessdataPath_ == tessdataPath)
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  tessdataPath_ = tessdataPath;
 | 
					  tessdataPath_ = tessdataPath;
 | 
				
			||||||
  tesseractLibrary_ = tesseractLibrary;
 | 
					 | 
				
			||||||
  engines_.clear();
 | 
					  engines_.clear();
 | 
				
			||||||
  LTRACE() << "Cleared OCR engines";
 | 
					  LTRACE() << "Cleared OCR engines";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,7 @@ public:
 | 
				
			|||||||
  ~RecognizeWorker();
 | 
					  ~RecognizeWorker();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void handle(const TaskPtr &task);
 | 
					  void handle(const TaskPtr &task);
 | 
				
			||||||
  void reset(const QString &tessdataPath, const QString &tesseractLibrary);
 | 
					  void reset(const QString &tessdataPath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
signals:
 | 
					signals:
 | 
				
			||||||
  void finished(const TaskPtr &task);
 | 
					  void finished(const TaskPtr &task);
 | 
				
			||||||
@ -24,5 +24,4 @@ private:
 | 
				
			|||||||
  std::map<QString, std::unique_ptr<Tesseract>> engines_;
 | 
					  std::map<QString, std::unique_ptr<Tesseract>> engines_;
 | 
				
			||||||
  std::map<QString, Generation> lastGenerations_;
 | 
					  std::map<QString, Generation> lastGenerations_;
 | 
				
			||||||
  QString tessdataPath_;
 | 
					  QString tessdataPath_;
 | 
				
			||||||
  QString tesseractLibrary_;
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,7 @@
 | 
				
			|||||||
#include "task.h"
 | 
					#include "task.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <leptonica/allheaders.h>
 | 
					#include <leptonica/allheaders.h>
 | 
				
			||||||
 | 
					#include <tesseract/baseapi.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QBuffer>
 | 
					#include <QBuffer>
 | 
				
			||||||
#include <QDir>
 | 
					#include <QDir>
 | 
				
			||||||
@ -204,115 +205,7 @@ static Pix *prepareImage(const QImage &image)
 | 
				
			|||||||
  return pix.take();
 | 
					  return pix.take();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void cleanupImage(Pix **image)
 | 
					Tesseract::Tesseract(const LanguageId &language, const QString &tessdataPath)
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  pixDestroy(image);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// do not include capi.h from tesseract because it defined BOOL that breaks msvc
 | 
					 | 
				
			||||||
struct TessBaseAPI;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class Tesseract::Wrapper
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  using CreateApi = TessBaseAPI *(*)();
 | 
					 | 
				
			||||||
  using DeleteApi = void (*)(TessBaseAPI *);
 | 
					 | 
				
			||||||
  using InitApi = int (*)(TessBaseAPI *, const char *, const char *, int);
 | 
					 | 
				
			||||||
  using SetImage = void (*)(TessBaseAPI *, struct Pix *);
 | 
					 | 
				
			||||||
  using GetUtf8 = char *(*)(TessBaseAPI *);
 | 
					 | 
				
			||||||
  using ClearApi = void (*)(TessBaseAPI *);
 | 
					 | 
				
			||||||
  using DeleteUtf8 = void (*)(const char *);
 | 
					 | 
				
			||||||
  using SetPageMode = void (*)(TessBaseAPI *, int);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
  explicit Wrapper(const QString &libraryName)
 | 
					 | 
				
			||||||
    : lib(libraryName)
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    if (!lib.load()) {
 | 
					 | 
				
			||||||
      LERROR() << "Failed to load tesseract library" << libraryName;
 | 
					 | 
				
			||||||
      return;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    LTRACE() << "Loaded tesseract library" << lib.fileName();
 | 
					 | 
				
			||||||
    auto ok = true;
 | 
					 | 
				
			||||||
    ok &= bool(createApi_ = (CreateApi)lib.resolve("TessBaseAPICreate"));
 | 
					 | 
				
			||||||
    ok &= bool(deleteApi_ = (DeleteApi)lib.resolve("TessBaseAPIDelete"));
 | 
					 | 
				
			||||||
    ok &= bool(initApi_ = (InitApi)lib.resolve("TessBaseAPIInit2"));
 | 
					 | 
				
			||||||
    ok &= bool(setImage_ = (SetImage)lib.resolve("TessBaseAPISetImage2"));
 | 
					 | 
				
			||||||
    ok &= bool(getUtf8_ = (GetUtf8)lib.resolve("TessBaseAPIGetUTF8Text"));
 | 
					 | 
				
			||||||
    ok &= bool(clearApi_ = (ClearApi)lib.resolve("TessBaseAPIClear"));
 | 
					 | 
				
			||||||
    ok &= bool(deleteUtf8_ = (DeleteUtf8)lib.resolve("TessDeleteText"));
 | 
					 | 
				
			||||||
    ok &= bool(setPageMode_ =
 | 
					 | 
				
			||||||
                   (SetPageMode)lib.resolve("TessBaseAPISetPageSegMode"));
 | 
					 | 
				
			||||||
    if (!ok) {
 | 
					 | 
				
			||||||
      LERROR() << "Failed to resolve tesseract functions from" << libraryName;
 | 
					 | 
				
			||||||
      return;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    handle_ = createApi_();
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ~Wrapper()
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    if (handle_ && deleteApi_) {
 | 
					 | 
				
			||||||
      deleteApi_(handle_);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    lib.unload();
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  int Init(const char *datapath, const char *language)
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    SOFT_ASSERT(handle_, return -1);
 | 
					 | 
				
			||||||
    SOFT_ASSERT(initApi_, return -1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    const auto mode = 3;  // TessOcrEngineMode::OEM_DEFAULT
 | 
					 | 
				
			||||||
    return initApi_(handle_, datapath, language, mode);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  QString GetText(Pix *pix)
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    SOFT_ASSERT(handle_, return {});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    SOFT_ASSERT(setPageMode_, return {});
 | 
					 | 
				
			||||||
    setPageMode_(handle_, 3);  //    PSM_AUTO
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    SOFT_ASSERT(setImage_, return {});
 | 
					 | 
				
			||||||
    setImage_(handle_, pix);
 | 
					 | 
				
			||||||
    LTRACE() << "Set Pix to engine";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    char *outText = nullptr;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    SOFT_ASSERT(getUtf8_, return {});
 | 
					 | 
				
			||||||
    outText = getUtf8_(handle_);
 | 
					 | 
				
			||||||
    LTRACE() << "Received recognized text";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    SOFT_ASSERT(clearApi_, return {});
 | 
					 | 
				
			||||||
    clearApi_(handle_);
 | 
					 | 
				
			||||||
    LTRACE() << "Cleared engine";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    const auto result = QString(outText).trimmed();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    SOFT_ASSERT(deleteUtf8_, return {});
 | 
					 | 
				
			||||||
    deleteUtf8_(outText);
 | 
					 | 
				
			||||||
    LTRACE() << "Cleared recognized text buffer";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return result;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
  QLibrary lib;
 | 
					 | 
				
			||||||
  CreateApi createApi_{nullptr};
 | 
					 | 
				
			||||||
  DeleteApi deleteApi_{nullptr};
 | 
					 | 
				
			||||||
  InitApi initApi_{nullptr};
 | 
					 | 
				
			||||||
  SetImage setImage_{nullptr};
 | 
					 | 
				
			||||||
  GetUtf8 getUtf8_{nullptr};
 | 
					 | 
				
			||||||
  ClearApi clearApi_{nullptr};
 | 
					 | 
				
			||||||
  DeleteUtf8 deleteUtf8_{nullptr};
 | 
					 | 
				
			||||||
  SetPageMode setPageMode_{nullptr};
 | 
					 | 
				
			||||||
  TessBaseAPI *handle_{nullptr};
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Tesseract::Tesseract(const LanguageId &language, const QString &tessdataPath,
 | 
					 | 
				
			||||||
                     const QString &tesseractLibrary)
 | 
					 | 
				
			||||||
  : tesseractLibrary_(tesseractLibrary)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  SOFT_ASSERT(!tessdataPath.isEmpty(), return );
 | 
					  SOFT_ASSERT(!tessdataPath.isEmpty(), return );
 | 
				
			||||||
  SOFT_ASSERT(!language.isEmpty(), return );
 | 
					  SOFT_ASSERT(!language.isEmpty(), return );
 | 
				
			||||||
@ -324,20 +217,22 @@ Tesseract::~Tesseract() = default;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void Tesseract::init(const LanguageId &language, const QString &tessdataPath)
 | 
					void Tesseract::init(const LanguageId &language, const QString &tessdataPath)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  SOFT_ASSERT(!engine_, return );
 | 
					  SOFT_ASSERT(!api_, return );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  engine_ = std::make_unique<Wrapper>(tesseractLibrary_);
 | 
					  api_ = std::make_unique<tesseract::TessBaseAPI>();
 | 
				
			||||||
  LTRACE() << "Created Tesseract api" << engine_.get();
 | 
					  LTRACE() << "Created Tesseract api" << api_.get();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const auto tesseractName = LanguageCodes::tesseract(language);
 | 
					  const auto tesseractName = LanguageCodes::tesseract(language);
 | 
				
			||||||
  auto result =
 | 
					  auto result = api_->Init(qPrintable(tessdataPath), qPrintable(tesseractName),
 | 
				
			||||||
      engine_->Init(qPrintable(tessdataPath), qPrintable(tesseractName));
 | 
					                           tesseract::OcrEngineMode::OEM_DEFAULT);
 | 
				
			||||||
  LTRACE() << "Inited Tesseract api" << result;
 | 
					  LTRACE() << "Inited Tesseract api" << result;
 | 
				
			||||||
  if (result == 0)
 | 
					  if (result == 0)
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  api_->SetPageSegMode(tesseract::PageSegMode::PSM_AUTO);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  error_ = QObject::tr("init failed");
 | 
					  error_ = QObject::tr("init failed");
 | 
				
			||||||
  engine_.reset();
 | 
					  api_.reset();
 | 
				
			||||||
  LTRACE() << "Cleared Tesseract api";
 | 
					  LTRACE() << "Cleared Tesseract api";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -372,19 +267,28 @@ QStringList Tesseract::availableLanguageNames(const QString &path)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
QString Tesseract::recognize(const QPixmap &source)
 | 
					QString Tesseract::recognize(const QPixmap &source)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  SOFT_ASSERT(engine_, return {});
 | 
					  SOFT_ASSERT(api_, return {});
 | 
				
			||||||
  SOFT_ASSERT(!source.isNull(), return {});
 | 
					  SOFT_ASSERT(!source.isNull(), return {});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  error_.clear();
 | 
					  error_.clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Pix *image = prepareImage(source.toImage());
 | 
					  PixGuard image(prepareImage(source.toImage()));
 | 
				
			||||||
  SOFT_ASSERT(image, return {});
 | 
					  SOFT_ASSERT(image, return {});
 | 
				
			||||||
  LTRACE() << "Preprocessed Pix for OCR" << image;
 | 
					  LTRACE() << "Preprocessed Pix for OCR" << image;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  auto result = engine_->GetText(image);
 | 
					  api_->SetImage(image);
 | 
				
			||||||
 | 
					  LTRACE() << "Set Pix to engine";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  cleanupImage(&image);
 | 
					  const auto outText = api_->GetUTF8Text();
 | 
				
			||||||
  LTRACE() << "Cleared preprocessed Pix";
 | 
					  LTRACE() << "Received recognized text";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  api_->Clear();
 | 
				
			||||||
 | 
					  LTRACE() << "Cleared engine";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const auto result = QString(outText).trimmed();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  delete[] outText;
 | 
				
			||||||
 | 
					  LTRACE() << "Cleared recognized text buffer";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (result.isEmpty())
 | 
					  if (result.isEmpty())
 | 
				
			||||||
    error_ = QObject::tr("Failed to recognize text or no text selected");
 | 
					    error_ = QObject::tr("Failed to recognize text or no text selected");
 | 
				
			||||||
@ -393,5 +297,5 @@ QString Tesseract::recognize(const QPixmap &source)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
bool Tesseract::isValid() const
 | 
					bool Tesseract::isValid() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  return engine_.get();
 | 
					  return api_.get();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -8,12 +8,15 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class QPixmap;
 | 
					class QPixmap;
 | 
				
			||||||
class Task;
 | 
					class Task;
 | 
				
			||||||
 | 
					namespace tesseract
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					class TessBaseAPI;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Tesseract
 | 
					class Tesseract
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  Tesseract(const LanguageId& language, const QString& tessdataPath,
 | 
					  Tesseract(const LanguageId& language, const QString& tessdataPath);
 | 
				
			||||||
            const QString& tesseractLibrary);
 | 
					 | 
				
			||||||
  ~Tesseract();
 | 
					  ~Tesseract();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  QString recognize(const QPixmap& source);
 | 
					  QString recognize(const QPixmap& source);
 | 
				
			||||||
@ -23,10 +26,8 @@ public:
 | 
				
			|||||||
  static QStringList availableLanguageNames(const QString& path);
 | 
					  static QStringList availableLanguageNames(const QString& path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
  class Wrapper;
 | 
					 | 
				
			||||||
  void init(const LanguageId& language, const QString& tessdataPath);
 | 
					  void init(const LanguageId& language, const QString& tessdataPath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const QString tesseractLibrary_;
 | 
					  std::unique_ptr<tesseract::TessBaseAPI> api_;
 | 
				
			||||||
  std::unique_ptr<Wrapper> engine_;
 | 
					 | 
				
			||||||
  QString error_;
 | 
					  QString error_;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -35,7 +35,6 @@ const QString qs_showMessageOnStart = "showMessageOnStart";
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const QString qs_recogntionGroup = "Recognition";
 | 
					const QString qs_recogntionGroup = "Recognition";
 | 
				
			||||||
const QString qs_ocrLanguage = "language";
 | 
					const QString qs_ocrLanguage = "language";
 | 
				
			||||||
const QString qs_tesseractVersion = "tesseractVersion";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const QString qs_correctionGroup = "Correction";
 | 
					const QString qs_correctionGroup = "Correction";
 | 
				
			||||||
const QString qs_userSubstitutions = "userSubstitutions";
 | 
					const QString qs_userSubstitutions = "userSubstitutions";
 | 
				
			||||||
@ -133,36 +132,6 @@ void cleanupOutdated(QSettings& settings)
 | 
				
			|||||||
  settings.endGroup();
 | 
					  settings.endGroup();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef _MSC_VER
 | 
					 | 
				
			||||||
#include <intrin.h>
 | 
					 | 
				
			||||||
void cpuid(int leaf, int subleaf, std::array<uint, 4>& cpuinfo)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  __cpuidex(reinterpret_cast<int*>(cpuinfo.data()), leaf, subleaf);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
#include <cpuid.h>
 | 
					 | 
				
			||||||
void cpuid(int leaf, int subleaf, std::array<uint, 4>& cpuinfo)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  __get_cpuid_count(leaf, subleaf, &cpuinfo[0], &cpuinfo[1], &cpuinfo[2],
 | 
					 | 
				
			||||||
                    &cpuinfo[3]);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
bool checkOptimizedTesseractSupport()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  std::array<uint, 4> cpuinfo{0};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  cpuid(1, 0, cpuinfo);
 | 
					 | 
				
			||||||
  const bool sse4_1 = cpuinfo[2] & (1 << 19);
 | 
					 | 
				
			||||||
  const bool sse4_2 = cpuinfo[2] & (1 << 20);
 | 
					 | 
				
			||||||
  const bool avx = cpuinfo[2] & (1 << 28);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  cpuid(7, 0, cpuinfo);
 | 
					 | 
				
			||||||
  const bool avx2 = cpuinfo[1] & (1 << 5);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  return sse4_1 && sse4_2 && avx && avx2;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}  // namespace
 | 
					}  // namespace
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Settings::save() const
 | 
					void Settings::save() const
 | 
				
			||||||
@ -207,7 +176,6 @@ void Settings::save() const
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  settings.beginGroup(qs_recogntionGroup);
 | 
					  settings.beginGroup(qs_recogntionGroup);
 | 
				
			||||||
  settings.setValue(qs_ocrLanguage, sourceLanguage);
 | 
					  settings.setValue(qs_ocrLanguage, sourceLanguage);
 | 
				
			||||||
  settings.setValue(qs_tesseractVersion, int(tesseractVersion));
 | 
					 | 
				
			||||||
  settings.endGroup();
 | 
					  settings.endGroup();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  settings.beginGroup(qs_correctionGroup);
 | 
					  settings.beginGroup(qs_correctionGroup);
 | 
				
			||||||
@ -295,15 +263,6 @@ void Settings::load()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  settings.beginGroup(qs_recogntionGroup);
 | 
					  settings.beginGroup(qs_recogntionGroup);
 | 
				
			||||||
  sourceLanguage = settings.value(qs_ocrLanguage, sourceLanguage).toString();
 | 
					  sourceLanguage = settings.value(qs_ocrLanguage, sourceLanguage).toString();
 | 
				
			||||||
  if (!settings.contains(qs_tesseractVersion)) {
 | 
					 | 
				
			||||||
    tesseractVersion = checkOptimizedTesseractSupport()
 | 
					 | 
				
			||||||
                           ? TesseractVersion::Optimized
 | 
					 | 
				
			||||||
                           : TesseractVersion::Compatible;
 | 
					 | 
				
			||||||
  } else {
 | 
					 | 
				
			||||||
    tesseractVersion = TesseractVersion(std::clamp(
 | 
					 | 
				
			||||||
        settings.value(qs_tesseractVersion, int(tesseractVersion)).toInt(),
 | 
					 | 
				
			||||||
        int(TesseractVersion::Optimized), int(TesseractVersion::Compatible)));
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  settings.endGroup();
 | 
					  settings.endGroup();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  settings.beginGroup(qs_correctionGroup);
 | 
					  settings.beginGroup(qs_correctionGroup);
 | 
				
			||||||
 | 
				
			|||||||
@ -19,8 +19,6 @@ using Substitutions = std::multimap<LanguageId, Substitution>;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
enum class ProxyType { Disabled, System, Socks5, Http };
 | 
					enum class ProxyType { Disabled, System, Socks5, Http };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum class TesseractVersion { Optimized, Compatible };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class Settings
 | 
					class Settings
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
@ -60,7 +58,6 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  QString tessdataPath;
 | 
					  QString tessdataPath;
 | 
				
			||||||
  QString sourceLanguage{"eng"};
 | 
					  QString sourceLanguage{"eng"};
 | 
				
			||||||
  TesseractVersion tesseractVersion{TesseractVersion::Optimized};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  bool doTranslation{true};
 | 
					  bool doTranslation{true};
 | 
				
			||||||
  bool ignoreSslErrors{false};
 | 
					  bool ignoreSslErrors{false};
 | 
				
			||||||
 | 
				
			|||||||
@ -122,14 +122,6 @@ SettingsEditor::SettingsEditor(Manager &manager, update::Updater &updater)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // recognition
 | 
					  // recognition
 | 
				
			||||||
  ui->tesseractLangCombo->setModel(models_.sourceLanguageModel());
 | 
					  ui->tesseractLangCombo->setModel(models_.sourceLanguageModel());
 | 
				
			||||||
  const QMap<TesseractVersion, QString> tesseractVersions{
 | 
					 | 
				
			||||||
      {TesseractVersion::Optimized, tr("Optimized")},
 | 
					 | 
				
			||||||
      {TesseractVersion::Compatible, tr("Compatible")},
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
  ui->tesseractVersion->addItems(tesseractVersions.values());
 | 
					 | 
				
			||||||
  ui->tesseractVersion->setToolTip(
 | 
					 | 
				
			||||||
      tr("Use compatible version if you are experiencing crashes during "
 | 
					 | 
				
			||||||
         "recognition"));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // correction
 | 
					  // correction
 | 
				
			||||||
  ui->userSubstitutionsTable->setEnabled(ui->useUserSubstitutions->isChecked());
 | 
					  ui->userSubstitutionsTable->setEnabled(ui->useUserSubstitutions->isChecked());
 | 
				
			||||||
@ -198,7 +190,8 @@ SettingsEditor::SettingsEditor(Manager &manager, update::Updater &updater)
 | 
				
			|||||||
            R"(<p>Optical character recognition (OCR) and translation tool</p>)"),
 | 
					            R"(<p>Optical character recognition (OCR) and translation tool</p>)"),
 | 
				
			||||||
        QObject::tr(R"(<p>Version: %1</p>)")
 | 
					        QObject::tr(R"(<p>Version: %1</p>)")
 | 
				
			||||||
            .arg(QApplication::applicationVersion()),
 | 
					            .arg(QApplication::applicationVersion()),
 | 
				
			||||||
        QObject::tr(R"(<p>Setup instructions: <a href="%1">%1</a></p>)").arg(help),
 | 
					        QObject::tr(R"(<p>Setup instructions: <a href="%1">%1</a></p>)")
 | 
				
			||||||
 | 
					            .arg(help),
 | 
				
			||||||
        QObject::tr(R"(<p>Changelog: <a href="%1">%2</a></p>)")
 | 
					        QObject::tr(R"(<p>Changelog: <a href="%1">%2</a></p>)")
 | 
				
			||||||
            .arg(changelog, QUrl(changelog).fileName()),
 | 
					            .arg(changelog, QUrl(changelog).fileName()),
 | 
				
			||||||
        QObject::tr(R"(<p>License: <a href="%3">MIT</a></p>)").arg(license),
 | 
					        QObject::tr(R"(<p>License: <a href="%3">MIT</a></p>)").arg(license),
 | 
				
			||||||
@ -267,8 +260,6 @@ Settings SettingsEditor::settings() const
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  settings.sourceLanguage =
 | 
					  settings.sourceLanguage =
 | 
				
			||||||
      LanguageCodes::idForName(ui->tesseractLangCombo->currentText());
 | 
					      LanguageCodes::idForName(ui->tesseractLangCombo->currentText());
 | 
				
			||||||
  settings.tesseractVersion =
 | 
					 | 
				
			||||||
      TesseractVersion(ui->tesseractVersion->currentIndex());
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  settings.useHunspell = ui->useHunspell->isChecked();
 | 
					  settings.useHunspell = ui->useHunspell->isChecked();
 | 
				
			||||||
  settings.useUserSubstitutions = ui->useUserSubstitutions->isChecked();
 | 
					  settings.useUserSubstitutions = ui->useUserSubstitutions->isChecked();
 | 
				
			||||||
@ -328,7 +319,6 @@ void SettingsEditor::setSettings(const Settings &settings)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  ui->tesseractLangCombo->setCurrentText(
 | 
					  ui->tesseractLangCombo->setCurrentText(
 | 
				
			||||||
      LanguageCodes::name(settings.sourceLanguage));
 | 
					      LanguageCodes::name(settings.sourceLanguage));
 | 
				
			||||||
  ui->tesseractVersion->setCurrentIndex(int(settings.tesseractVersion));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ui->useHunspell->setChecked(settings.useHunspell);
 | 
					  ui->useHunspell->setChecked(settings.useHunspell);
 | 
				
			||||||
  ui->hunspellDir->setText(settings.hunspellPath);
 | 
					  ui->hunspellDir->setText(settings.hunspellPath);
 | 
				
			||||||
 | 
				
			|||||||
@ -221,7 +221,7 @@
 | 
				
			|||||||
           </property>
 | 
					           </property>
 | 
				
			||||||
           <layout class="QGridLayout" name="gridLayout">
 | 
					           <layout class="QGridLayout" name="gridLayout">
 | 
				
			||||||
            <item row="4" column="1">
 | 
					            <item row="4" column="1">
 | 
				
			||||||
             <widget class="service::KeySequenceEdit" name="clipboardEdit"/>
 | 
					             <widget class="service::KeySequenceEdit" name="clipboardEdit" native="true"/>
 | 
				
			||||||
            </item>
 | 
					            </item>
 | 
				
			||||||
            <item row="2" column="0">
 | 
					            <item row="2" column="0">
 | 
				
			||||||
             <widget class="QLabel" name="label_8">
 | 
					             <widget class="QLabel" name="label_8">
 | 
				
			||||||
@ -231,7 +231,7 @@
 | 
				
			|||||||
             </widget>
 | 
					             </widget>
 | 
				
			||||||
            </item>
 | 
					            </item>
 | 
				
			||||||
            <item row="2" column="1">
 | 
					            <item row="2" column="1">
 | 
				
			||||||
             <widget class="service::KeySequenceEdit" name="repeatCaptureEdit"/>
 | 
					             <widget class="service::KeySequenceEdit" name="repeatCaptureEdit" native="true"/>
 | 
				
			||||||
            </item>
 | 
					            </item>
 | 
				
			||||||
            <item row="3" column="0">
 | 
					            <item row="3" column="0">
 | 
				
			||||||
             <widget class="QLabel" name="label_3">
 | 
					             <widget class="QLabel" name="label_3">
 | 
				
			||||||
@ -241,7 +241,7 @@
 | 
				
			|||||||
             </widget>
 | 
					             </widget>
 | 
				
			||||||
            </item>
 | 
					            </item>
 | 
				
			||||||
            <item row="0" column="1">
 | 
					            <item row="0" column="1">
 | 
				
			||||||
             <widget class="service::KeySequenceEdit" name="captureEdit"/>
 | 
					             <widget class="service::KeySequenceEdit" name="captureEdit" native="true"/>
 | 
				
			||||||
            </item>
 | 
					            </item>
 | 
				
			||||||
            <item row="4" column="0">
 | 
					            <item row="4" column="0">
 | 
				
			||||||
             <widget class="QLabel" name="label_7">
 | 
					             <widget class="QLabel" name="label_7">
 | 
				
			||||||
@ -251,7 +251,7 @@
 | 
				
			|||||||
             </widget>
 | 
					             </widget>
 | 
				
			||||||
            </item>
 | 
					            </item>
 | 
				
			||||||
            <item row="3" column="1">
 | 
					            <item row="3" column="1">
 | 
				
			||||||
             <widget class="service::KeySequenceEdit" name="repeatEdit"/>
 | 
					             <widget class="service::KeySequenceEdit" name="repeatEdit" native="true"/>
 | 
				
			||||||
            </item>
 | 
					            </item>
 | 
				
			||||||
            <item row="0" column="0">
 | 
					            <item row="0" column="0">
 | 
				
			||||||
             <widget class="QLabel" name="label">
 | 
					             <widget class="QLabel" name="label">
 | 
				
			||||||
@ -268,7 +268,7 @@
 | 
				
			|||||||
             </widget>
 | 
					             </widget>
 | 
				
			||||||
            </item>
 | 
					            </item>
 | 
				
			||||||
            <item row="1" column="1">
 | 
					            <item row="1" column="1">
 | 
				
			||||||
             <widget class="service::KeySequenceEdit" name="captureLockedEdit"/>
 | 
					             <widget class="service::KeySequenceEdit" name="captureLockedEdit" native="true"/>
 | 
				
			||||||
            </item>
 | 
					            </item>
 | 
				
			||||||
           </layout>
 | 
					           </layout>
 | 
				
			||||||
          </widget>
 | 
					          </widget>
 | 
				
			||||||
@ -291,7 +291,23 @@
 | 
				
			|||||||
       </widget>
 | 
					       </widget>
 | 
				
			||||||
       <widget class="QWidget" name="pageRecognize">
 | 
					       <widget class="QWidget" name="pageRecognize">
 | 
				
			||||||
        <layout class="QGridLayout" name="gridLayout_2">
 | 
					        <layout class="QGridLayout" name="gridLayout_2">
 | 
				
			||||||
         <item row="3" column="2">
 | 
					         <item row="0" column="0">
 | 
				
			||||||
 | 
					          <widget class="QLabel" name="label_2">
 | 
				
			||||||
 | 
					           <property name="sizePolicy">
 | 
				
			||||||
 | 
					            <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
 | 
				
			||||||
 | 
					             <horstretch>0</horstretch>
 | 
				
			||||||
 | 
					             <verstretch>0</verstretch>
 | 
				
			||||||
 | 
					            </sizepolicy>
 | 
				
			||||||
 | 
					           </property>
 | 
				
			||||||
 | 
					           <property name="text">
 | 
				
			||||||
 | 
					            <string>Tessdata path:</string>
 | 
				
			||||||
 | 
					           </property>
 | 
				
			||||||
 | 
					          </widget>
 | 
				
			||||||
 | 
					         </item>
 | 
				
			||||||
 | 
					         <item row="1" column="2">
 | 
				
			||||||
 | 
					          <widget class="QComboBox" name="tesseractLangCombo"/>
 | 
				
			||||||
 | 
					         </item>
 | 
				
			||||||
 | 
					         <item row="2" column="2">
 | 
				
			||||||
          <spacer name="verticalSpacer_2">
 | 
					          <spacer name="verticalSpacer_2">
 | 
				
			||||||
           <property name="orientation">
 | 
					           <property name="orientation">
 | 
				
			||||||
            <enum>Qt::Vertical</enum>
 | 
					            <enum>Qt::Vertical</enum>
 | 
				
			||||||
@ -317,19 +333,6 @@
 | 
				
			|||||||
           </property>
 | 
					           </property>
 | 
				
			||||||
          </widget>
 | 
					          </widget>
 | 
				
			||||||
         </item>
 | 
					         </item>
 | 
				
			||||||
         <item row="0" column="0">
 | 
					 | 
				
			||||||
          <widget class="QLabel" name="label_2">
 | 
					 | 
				
			||||||
           <property name="sizePolicy">
 | 
					 | 
				
			||||||
            <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
 | 
					 | 
				
			||||||
             <horstretch>0</horstretch>
 | 
					 | 
				
			||||||
             <verstretch>0</verstretch>
 | 
					 | 
				
			||||||
            </sizepolicy>
 | 
					 | 
				
			||||||
           </property>
 | 
					 | 
				
			||||||
           <property name="text">
 | 
					 | 
				
			||||||
            <string>Tessdata path:</string>
 | 
					 | 
				
			||||||
           </property>
 | 
					 | 
				
			||||||
          </widget>
 | 
					 | 
				
			||||||
         </item>
 | 
					 | 
				
			||||||
         <item row="1" column="0">
 | 
					         <item row="1" column="0">
 | 
				
			||||||
          <widget class="QLabel" name="label_4">
 | 
					          <widget class="QLabel" name="label_4">
 | 
				
			||||||
           <property name="sizePolicy">
 | 
					           <property name="sizePolicy">
 | 
				
			||||||
@ -346,19 +349,6 @@
 | 
				
			|||||||
           </property>
 | 
					           </property>
 | 
				
			||||||
          </widget>
 | 
					          </widget>
 | 
				
			||||||
         </item>
 | 
					         </item>
 | 
				
			||||||
         <item row="1" column="2">
 | 
					 | 
				
			||||||
          <widget class="QComboBox" name="tesseractLangCombo"/>
 | 
					 | 
				
			||||||
         </item>
 | 
					 | 
				
			||||||
         <item row="2" column="0">
 | 
					 | 
				
			||||||
          <widget class="QLabel" name="label_24">
 | 
					 | 
				
			||||||
           <property name="text">
 | 
					 | 
				
			||||||
            <string>Library version</string>
 | 
					 | 
				
			||||||
           </property>
 | 
					 | 
				
			||||||
          </widget>
 | 
					 | 
				
			||||||
         </item>
 | 
					 | 
				
			||||||
         <item row="2" column="2">
 | 
					 | 
				
			||||||
          <widget class="QComboBox" name="tesseractVersion"/>
 | 
					 | 
				
			||||||
         </item>
 | 
					 | 
				
			||||||
        </layout>
 | 
					        </layout>
 | 
				
			||||||
       </widget>
 | 
					       </widget>
 | 
				
			||||||
       <widget class="QWidget" name="pageCorrect">
 | 
					       <widget class="QWidget" name="pageCorrect">
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user