Giter Club home page Giter Club logo

qtspell's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

qtspell's Issues

QTextCursor::setPosition: Position 'xxxx' out of range (Warning)

... xxxx seems to be the number of characters in the edit widget.

The warning apparently is associated with clearing the text document, where QtSpell doesn't recognize that the document is empty. (This is a guess.)

Repro: in gImageReader scan a (simple) document in text (not HOCR) mode, and then clear the scan in the Output window. At least that works for me always.

Stack trace. Notes imbedded

#0 raise (sig=5) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x00005555556ff9b1 in myMessageOutput (type=QtWarningMsg, context=..., msg=...) at /home/donnt/gImageReader/qt/src/main.cc:117
#2 0x00007ffff6222e15 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#3 0x00007ffff6222fc8 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4 0x00007ffff61f524f in QMessageLogger::warning(char const*, ...) const () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5

----- The warning comes from here

#5 0x00007ffff68cc0ec in QTextCursor::setPosition(int, QTextCursor::MoveMode) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5

----- There are 2 pairs of calls to setPosition in handleContentsChange. I think the document has been cleared by this point,
and there should be only one change - the initial insert of text from the scan, so it's probably the pair in the undo stack.
An empty document implies that there's no legal value for 'pos'.

#6 0x00007ffff79c972c in QtSpell::UndoRedoStack::handleContentsChange(int, int, int) () from /usr/lib/x86_64-linux-gnu/libqtspell-qt5.so.0
#7 0x00007ffff79c8415 in QtSpell::TextEditChecker::slotCheckRange(int, int, int) () from /usr/lib/x86_64-linux-gnu/libqtspell-qt5.so.0

---- Above is called from QTextDocument (2 below), apparently as a response to clearing the document, via a connect().

#8 0x00007ffff64077f6 in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#9 0x00007ffff6b0a74a in QTextDocument::contentsChange(int, int, int) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#10 0x00007ffff689f60d in QTextDocumentPrivate::clear() () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#11 0x00007ffff6890324 in QTextDocument::clear() () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#12 0x00007ffff6f2d5da in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#13 0x00007ffff6f378b4 in QWidgetTextControl::clear() () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x000055555560a483 in OutputEditorText::clear (this=0x555555c16ee0, hide=false) at /home/donnt/gImageReader/qt/src/OutputEditorText.cc:347 (line number won't match exactly)

---- problem initiated here in OutputEditorText::clear, at the call to ui.plainTextOutput->clear()

#15 0x000055555560def0 in QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, QtPrivate::List, void, bool (OutputEditorText::)(bool)>::call (f=&virtual table offset 208, o=0x555555c16ee0, arg=0x7fffffffd000) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:134
#16 0x000055555560d9b4 in QtPrivate::FunctionPointer<bool (OutputEditorText::
)(bool)>::call<QtPrivate::List, void> (f=&virtual table offset 208, o=0x555555c16ee0, arg=0x7fffffffd000) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:167
#17 0x000055555560d16e in QtPrivate::QSlotObject<bool (OutputEditorText::)(bool), QtPrivate::List, void>::impl (which=1, this_=0x5555560942a0, r=0x555555c16ee0, a=0x7fffffffd000, ret=0x0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:396
#18 0x00007ffff6407933 in QMetaObject::activate(QObject
, int, int, void**) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#19 0x00007ffff6d52f02 in QAction::triggered(bool) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x00007ffff6d55520 in QAction::activate(QAction::ActionEvent) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

Is the off-by-one case noted in the comments in checkSlotRange either (now that that might be fixed?) the cause, or is there another special case to work around?

Workaround in gImageReader::OutputEditorText::clear (somewhere near line 330): add the setUndoRedoEnabled calls below:

			return false;
		}
	}
	m_spell.setUndoRedoEnabled(false); // added for workaround
	ui.plainTextEditOutput->clear();
	m_spell.setUndoRedoEnabled(true); // added for workaround
	m_spell.clearUndoRedo();
	ui.plainTextEditOutput->document()->setModified(false);

Spell check doesn't work

I'm using version 0.8.4 (a8f702b) on Debian and I can't get spell check to work. When I input words into a QTextEdit it doesn't highlight misspelled words. I have the needed dictionaries installed. Here is my code:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTextEdit>
#include <QtSpell.hpp>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // create a QtSpell::TextEdit instance
    QtSpell::TextEditChecker checker;

    // attach to a QTextEdit or QPlainTextEdit
    QTextEdit* textEdit = new QTextEdit(this);
    checker.setTextEdit(textEdit);
}

Feature(s) request

First of all, it works perfectly and I'm very happy with it. I would also like to be able to check if undo and redo are avaiable via isUndoAvaiable() and isRedoAvaiable(). I also noticed that with older Qt versions < 5.15 an error occurs when running cmake:

CMake Error at CMakeLists.txt:65 (QT_ADD_TRANSLATION):
  Unknown CMake command "QT_ADD_TRANSLATION".

After changing it to

IF(NOT Qt6_FOUND)
QT5_ADD_TRANSLATION(qtspell_QM ${qtspell_TS})
ELSE(NOT Qt6_FOUND)
QT6_ADD_TRANSLATION(qtspell_QM ${qtspell_TS})
ENDIF(NOT Qt6_FOUND)

it worked again. I would be very grateful if you could change that. Nevertheless, thank you in advance.

Deprecated QT5_USE_MODULES in CMakeLists.txt

In Qt 5.11, QT5_USE_MODULES macro is deprecated. This makes compilation to fail.

Not really making a pull request, but just a simple patch code to fix the issue. Feel free to merge.

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,7 +74,7 @@
 
 ADD_LIBRARY(qtspell SHARED ${qtspell_SRCS} ${qtspell_MOC} ${qtspell_HDRS} ${qtspell_MOC_HDRS} ${qtspell_QM})
 IF(USE_QT5)
-    QT5_USE_MODULES(qtspell Widgets)
+    TARGET_LINK_LIBRARIES(qtspell Qt5::Core Qt5::Widgets)
 ELSE(USE_QT5)
     QT4_USE_MODULES(qtspell Core Gui)
 ENDIF(USE_QT5)
@@ -92,7 +92,7 @@
 IF(${BUILD_STATIC_LIBS})
     ADD_LIBRARY(qtspell-static STATIC ${qtspell_SRCS} ${qtspell_MOC} ${qtspell_HDRS} ${qtspell_MOC_HDRS} ${qtspell_QM})
     IF(USE_QT5)
-        QT5_USE_MODULES(qtspell-static Widgets)
+        TARGET_LINK_LIBRARIES(qtspell-static Qt5::Core Qt5::Widgets)
     ELSE(USE_QT5)
         QT4_USE_MODULES(qtspell-static Core Gui)
     ENDIF(USE_QT5)
@@ -124,7 +124,7 @@
 ENDIF(USE_QT5)
 ADD_EXECUTABLE(example examples/example.cpp ${example_MOC})
 IF(USE_QT5)
-    QT5_USE_MODULES(example Widgets)
+    TARGET_LINK_LIBRARIES(example Qt5::Core Qt5::Widgets)
 ELSE(USE_QT5)
     QT4_USE_MODULES(example Core Gui)
 ENDIF(USE_QT5)

Reproducible builds fails due to Doxyfile FULL_PATH_NAMES

Please see https://tests.reproducible-builds.org/debian/issues/unstable/build_dir_in_documentation_generated_by_doxygen_issue.html

It is a simple fix.

``Index: qtspell-0.8.5/doc/Doxyfile.in

--- qtspell-0.8.5.orig/doc/Doxyfile.in 2018-06-15 04:20:29.000000000 -0700
+++ qtspell-0.8.5/doc/Doxyfile.in 2019-07-14 11:00:28.753465283 -0700
@@ -129,7 +129,7 @@

path before files name in the file list and in the header files. If set

to NO the shortest path that makes the file name unique will be used.

-FULL_PATH_NAMES = YES
+FULL_PATH_NAMES = NO

If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag

can be used to strip a user-defined part of the path. Stripping is

@@ -927,13 +927,13 @@

have to redo this when upgrading to a newer version of doxygen or when

changing the value of configuration settings such as GENERATE_TREEVIEW!

-HTML_HEADER =
+HTML_HEADER =

The HTML_FOOTER tag can be used to specify a personal HTML footer for

each generated HTML page. If it is left blank doxygen will generate a

standard footer.

-HTML_FOOTER =
+HTML_FOOTER =

The HTML_STYLESHEET tag can be used to specify a user-defined cascading

style sheet that is used by each HTML page. It can be used to

undefined reference error with enchant 1.6.1

OS:Windows10
Environment:Mingw64 in MSYS2 environment

When QtSpell is built with enchant 1.6.1, build fails due to undefined reference to 'libintl_*'.

[ 1%] Linking CXX shared library libqtspell-qt5-0.dll
/C/msys64/mingw64/bin/cmake.exe -E remove -f CMakeFiles/qtspell.dir/objects.a
/C/msys64/mingw64/bin/ar.exe cr CMakeFiles/qtspell.dir/objects.a "CMakeFiles/qtspell.dir/src/Checker.cpp.obj" "CMakeFiles/qtspell.dir/src/Codetable.cpp.obj" "CMakeFiles/qtspell.dir/src/TextEditChecker.cpp.obj" "CMakeFiles/qtspell.dir/src/UndoRedoStack.cpp.obj" "CMakeFiles/qtspell.dir/src/moc_QtSpell.cpp.obj" "CMakeFiles/qtspell.dir/src/moc_UndoRedoStack.cpp.obj"
/C/msys64/mingw64/bin/g++.exe -shared -o libqtspell-qt5-0.dll -Wl,--out-implib,libqtspell-qt5.dll.a -Wl,--major-image-version,0,--minor-image-version,3 -Wl,--whole-archive CMakeFiles/qtspell.dir/objects.a -Wl,--no-whole-archive /C/msys64/mingw64/local/qt5-shared/lib/libQt5Widgets.a -LC:/msys64/mingw64/lib -lenchant /C/msys64/mingw64/local/qt5-shared/lib/libQt5Gui.a /C/msys64/mingw64/local/qt5-shared/lib/libQt5Core.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
CMakeFiles/qtspell.dir/objects.a(Codetable.cpp.obj):Codetable.cpp:(.text+0x1c): undefined reference to libintl_dgettext' CMakeFiles/qtspell.dir/objects.a(Codetable.cpp.obj):Codetable.cpp:(.text+0x42): undefined reference to libintl_bindtextdomain'
CMakeFiles/qtspell.dir/objects.a(Codetable.cpp.obj):Codetable.cpp:(.text+0x68): undefined reference to `libintl_bind_textdomain_codeset'
collect2.exe: error: ld returned 1 exit status

In the past, problem did not occur because libintl is included in enchant's dependency.
enchant dropped that dependency in 1.6.1 so now nobody is looking for linintl.

Here is a part of build log with enchant 1.6.0.

[ 97%] Linking CXX shared library libqtspell-qt5-0.dll
/C/msys64/mingw64/bin/cmake.exe -E remove -f CMakeFiles/qtspell.dir/objects.a
/C/msys64/mingw64/bin/ar.exe cr CMakeFiles/qtspell.dir/objects.a "CMakeFiles/qtspell.dir/src/Checker.cpp.obj" "CMakeFiles/qtspell.dir/src/Codetable.cpp.obj" "CMakeFiles/qtspell.dir/src/TextEditChecker.cpp.obj" "CMakeFiles/qtspell.dir/src/UndoRedoStack.cpp.obj" "CMakeFiles/qtspell.dir/src/moc_QtSpell.cpp.obj" "CMakeFiles/qtspell.dir/src/moc_UndoRedoStack.cpp.obj"
/C/msys64/mingw64/bin/g++.exe -shared -o libqtspell-qt5-0.dll -Wl,--out-implib,libqtspell-qt5.dll.a -Wl,--major-image-version,0,--minor-image-version,3 -Wl,--whole-archive CMakeFiles/qtspell.dir/objects.a -Wl,--no-whole-archive /C/msys64/mingw64/local/qt5-shared/lib/libQt5Widgets.a -LC:/msys64/mingw64/lib -lenchant -lgmodule-2.0 -pthread -lglib-2.0 -lintl /C/msys64/mingw64/local/qt5-shared/lib/libQt5Gui.a /C/msys64/mingw64/local/qt5-shared/lib/libQt5Core.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32

QtSpell directly calls libintl so it should be explicitly linked in QtSpell's CMakeFiles.

Some language names do not display correctly

Description of problem:

Some language names do not display correctly.

Version-Release number of selected component:

  • qtspell-0.8.5
  • gImageReader-3.3.0 (Qt version)

Steps to Reproduce (Fedora 29):

  1. Install gimagereader-qt5.
  2. Install hunspell-*, or at least hunspell-oc.
  3. Open gimagereader-qt5.
  4. Add an image from file or take a screenshot.
  5. Select: OCR mode: Plain text.
  6. Click: Recognize all.
  7. Open the context menu in the text box in the output pane.
  8. Select Languages.

Actual results:

Occitan (post 1500); Proven�al

Expected results:

Occitan (post 1500); Provençal

Additional info:

Conversion to Latin1 causes loss of information about some characters.

name = QString::fromUtf8(dgettext(ISO_639_DOMAIN, name.toLatin1().data()));

name = QString::fromUtf8(dgettext(ISO_3166_DOMAIN, name.toLatin1().data()));;

Explanation:

You should replace these lines:

name = QString::fromUtf8(dgettext(ISO_639_DOMAIN, name.toLatin1().data()));
name = QString::fromUtf8(dgettext(ISO_3166_DOMAIN, name.toLatin1().data()));;

with these:

name = QString::fromUtf8(dgettext(ISO_639_DOMAIN, name.toUtf8().constData()));
name = QString::fromUtf8(dgettext(ISO_3166_DOMAIN, name.toUtf8().constData()));

or these:

name = QString::fromLocal8Bit(dgettext(ISO_639_DOMAIN, name.toLocal8Bit().constData()));
name = QString::fromLocal8Bit(dgettext(ISO_3166_DOMAIN, name.toLocal8Bit().constData()));

Temporary solution:

https://github.com/scx/flathub/blob/030990011b8622d86a478a3314c33592b2539aae/qtspell-0.8.5-utf8.patch
Pull request on the way.

This bug report is related to submitting my flatpak package to the Flathub repository.
manisandro/gImageReader#396
flathub/flathub#810

Codetable::lookup doesn't translate two-character codes

I noticed that two-character language codes ("en", "ru" ,etc.) are not translated in Qt version of gImageReader.

It seems like the problem is that Codetable::lookup, in contrast to gtksell, doesn't perform lookup for such codes at all.

Compare https://sourceforge.net/p/gtkspell/gtkspell/ci/master/tree/gtkspell/gtkspell-codetable.c#l199 with

void Codetable::lookup(const QString &language_code, QString &language_name, QString &country_name) const

Failed to load dictionary

I'm trying to add spell checking for qTox messenger with this library. When using QtSpell from master, on GNU/Linux, I'm getting this warning:

:0 : Warning: Failed to load dictionary: 
:0 : Warning: Failed to load dictionary: 
:0 : Warning: Failed to load dictionary: 

Code is very simple:

msgEdit = new ChatTextEdit();
QtSpell::TextEditChecker checker;
checker.setTextEdit(msgEdit);

What could be causing this?

Cannot build with enchant 2.1

I think that this is the same error as with enchant 1.6: https://github.com/manisandro/qtspell/issues/2
From console:
(...)[ 85%] Building CXX object CMakeFiles/qtspell.dir/src/Checker.cpp.o /home/pb/builds/gimagereader-qt5-git/qtspell-git/src/qtspell/src/Checker.cpp: In function 'bool QtSpell::checkLanguageInstalled(const QString&)': /home/pb/builds/gimagereader-qt5-git/qtspell-git/src/qtspell/src/Checker.cpp:60:26: error: 'instance' is not a member of 'enchant::Broker' return enchant::Broker::instance()->dict_exists(lang.toStdString()); ^~~~~~~~ /home/pb/builds/gimagereader-qt5-git/qtspell-git/src/qtspell/src/Checker.cpp: In member function 'bool QtSpell::Checker::setLanguageInternal(const QString&)': /home/pb/builds/gimagereader-qt5-git/qtspell-git/src/qtspell/src/Checker.cpp:109:32: error: 'instance' is not a member of 'enchant::Broker' m_speller = enchant::Broker::instance()->request_dict(m_lang.toStdString()); ^~~~~~~~ /home/pb/builds/gimagereader-qt5-git/qtspell-git/src/qtspell/src/Checker.cpp: In static member function 'static QList<QString> QtSpell::Checker::getLanguageList()': /home/pb/builds/gimagereader-qt5-git/qtspell-git/src/qtspell/src/Checker.cpp:162:45: error: 'instance' is not a member of 'enchant::Broker' enchant::Broker* broker = enchant::Broker::instance(); ^~~~~~~~ make[2]: *** [CMakeFiles/qtspell.dir/build.make:295: CMakeFiles/qtspell.dir/src/Checker.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:169: CMakeFiles/qtspell.dir/all] Error 2 make: *** [Makefile:130: all] Error 2 ==> ERROR: A failure occurred in build(). Aborting...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.