pbek / QOwnNotes

QOwnNotes is a plain-text file notepad and todo-list manager with Markdown support and Nextcloud / ownCloud integration.
https://www.qownnotes.org/
GNU General Public License v2.0
4.67k stars 413 forks source link

[Q] Request the auto-completion configure method #1817

Closed yuxiacn closed 4 years ago

yuxiacn commented 4 years ago

General question

Hi, I like to use QON and I think it is better than Joplin. However, I didn't find the auto-completion function for English writing. Can someone teach me in detail how to configure this, so that I can enjoy the fast writing experience. Thank you.

Relevant log output in the Log panel

Expand ``` How to configure auto-completion function for English writing. ```

Information about the application, settings and environment

Expand QOwnNotes Debug Information =========================== ## General Info **Current Date**: `Sunday July 5 19:28:28 2020` **Version**: `20.7.1` **Build date**: `Jul 5 2020` **Build number**: `735` **Platform**: `linux` **Operating System**: `Manjaro Linux` **Build architecture**: `x86_64` **Current architecture**: `x86_64` **Release**: `AUR` **Qt Version (build)**: `5.15.0` **Qt Version (runtime)**: `5.15.0` **Portable mode**: `no` **Settings path / key**: `/home/pop/.config/PBE/QOwnNotes.conf` **Application database path**: `/home/pop/.local/share/PBE/QOwnNotes/QOwnNotes.sqlite` **Application arguments**: `/usr/bin/QOwnNotes` **Qt Debug**: `0` **Locale (system)**: `zh_CN` **Locale (interface)**: `en` **Primary screen resolution**: `1280x720` **Icon theme**: `Papirus-Light` **Notes in current note folder**: `8` **Calendar items**: `0` **Enabled scripts**: `1` ## Server Info **serverUrl**: *empty* **appIsValid**: `yes` **notesPathExists**: *empty* **serverVersion**: *empty* **appVersion**: *empty* ## Spellchecking **Enabled**: `true` **Selected language**: `auto` **Language codes**: `en_US, en_US-large` **Language names**: `American English (United States), American English (United States) [large]` **Application dictionaries path**: `/home/pop/.local/share/PBE/QOwnNotes/dicts` ## Note folders **currentNoteFolderId**: `1` ## System environment **SHELL**: `/bin/bash` **XDG_SESSION_PATH**: `/org/freedesktop/DisplayManager/Session1` **GTK_IM_MODULE**: `fcitx` **LC_ADDRESS**: `zh_CN.UTF-8` **LC_NAME**: `zh_CN.UTF-8` **XMODIFIERS**: `@im=fcitx` **DESKTOP_SESSION**: `/usr/share/xsessions/plasma` **LC_MONETARY**: `zh_CN.UTF-8` **GTK_MODULES**: `canberra-gtk-module` **XDG_SEAT**: `seat0` **PWD**: `/home/pop` **XDG_SESSION_DESKTOP**: `KDE` **LOGNAME**: `pop` **XDG_SESSION_TYPE**: `x11` **XAUTHORITY**: `/home/pop/.Xauthority` **HOME**: `/home/pop` **LC_PAPER**: `zh_CN.UTF-8` **LANG**: `zh_CN.UTF-8` **XDG_CURRENT_DESKTOP**: `KDE` **XDG_SEAT_PATH**: `/org/freedesktop/DisplayManager/Seat0` **XDG_SESSION_CLASS**: `user` **LC_IDENTIFICATION**: `zh_CN.UTF-8` **USER**: `pop` **PAM_KWALLET5_LOGIN**: `/run/user/1000/kwallet5.socket` **DISPLAY**: `:0` **SHLVL**: `0` **LC_TELEPHONE**: `zh_CN.UTF-8` **QT_IM_MODULE**: `fcitx` **LC_MEASUREMENT**: `zh_CN.UTF-8` **XDG_VTNR**: `1` **XDG_SESSION_ID**: `2` **QT_LINUX_ACCESSIBILITY_ALWAYS_ON**: `1` **XDG_RUNTIME_DIR**: `/run/user/1000` **LC_TIME**: `zh_CN.UTF-8` **LC_ALL**: `zh_CN.UTF-8` **XDG_DATA_DIRS**: `/home/pop/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop` **PATH**: `/home/pop/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin` **DBUS_SESSION_BUS_ADDRESS**: `unix:path=/run/user/1000/bus` **MAIL**: `/var/spool/mail/pop` **LC_NUMERIC**: `zh_CN.UTF-8` **QT_SCREEN_SCALE_FACTORS**: `eDP-1=3;HDMI-1=3;DP-1=3;DP-2=3;` **GDK_SCALE**: `3` **GDK_DPI_SCALE**: `0.333` **XCURSOR_THEME**: `Oxygen_Zion` **XCURSOR_SIZE**: `72` **EDITOR**: `/usr/bin/nano` **BROWSER**: `/usr/bin/firefox` **QT_AUTO_SCREEN_SCALE_FACTOR**: `0` **KDE_FULL_SESSION**: `true` **KDE_SESSION_VERSION**: `5` **KDE_SESSION_UID**: `1000` **SESSION_MANAGER**: `local/pop-20mfa00pcd:@/tmp/.ICE-unix/1569,unix/pop-20mfa00pcd:/tmp/.ICE-unix/1569` **LANGUAGE**: *empty*
pbek commented 4 years ago

1) Read https://docs.qownnotes.org/en/latest/scripting/hooks/#autocompletionhook 2) Take the example script and store it locally 3) Add that script in the script settings 4) Add functionality to the script to load a file with your English words. Maybe try FileLoader like in https://stackoverflow.com/a/26298948/1581487 5) Search for the current word at the cursor (script.noteTextEditCurrentWord) in your "word list"

pbek commented 4 years ago

ad 4) You can also try https://forum.qt.io/topic/91205/reading-text-file-in-qml-file-and-display-it-in-the-scrolling-manner-for-some-time/14 or embed the word-list directly in your qml script.

yuxiacn commented 4 years ago

Thanks Patrizio. Although I can read the suggestions by you and the links you provided, however, I still don't know how to configure it.

I have added autocompletion.qml to script settings, but don't know how to do the step 4 to 5.

Can you give a complete example that already embeded the word-list in the "autocompletion.qml" file?

pbek commented 4 years ago

I'll write a script.

pbek commented 4 years ago

@yuxiacn, you can now install the script Dictionary Autocomplete from the script repository.

This script attempts to autocomplete the current word based on a dictionary file that contains a list of words, separated by a newline character. You can use the LibreOffice dictionary files, that can be downloaded in QOwnNotes as source (*.dic). You will get the dictionary path from the Debug settings.

You can also download the dictionaries from https://github.com/qownnotes/dictionaries directly.

@Waqar144, does this also work on slower hardware. 😉

pbek commented 4 years ago

image

Waqar144 commented 4 years ago

It's actually working surprisingly fast for en_US at least, but now I am carrying 800 more kilobytes in my memory. I wonder how fast it is with the bigger dictionaries (de_AT) that are > 4MB in size.

One suggestion, we should limit the number of words we return. Otherwise the resulting wordlist can be too big in some cases.

fabianski7 commented 4 years ago

I already have the script activated and the dictionary downloaded, for the list of words to be displayed it is necessary to press CTRL + Space?

some accents don't seem to be compatible 1

i'm using this dictionary

pbek commented 4 years ago

@Waqar144

It's actually working surprisingly fast for en_US at least, but now I am carrying 800 more kilobytes in my memory. I wonder how fast it is with the bigger dictionaries (de_AT) that are > 4MB in size.

only 800kB? that's nice, the file has 1MB!

One suggestion, we should limit the number of words we return. Otherwise the resulting wordlist can be too big in some cases.

I already implemented that as script setting. the default is 40.

pbek commented 4 years ago

@fabianski7, thank you for testing

I already have the script activated and the dictionary downloaded, for the list of words to be displayed it is necessary to press CTRL + Space?

yes, that's the shortcut for the auto complete...

some accents don't seem to be compatible

i'm using this dictionary

It seems the file has a different character-set than your computer or it gets destroyed when it is loaded or printed... I don't know if you can convert character sets easily in javascript...

Waqar144 commented 4 years ago

It seems the file has a different character-set than your computer or it gets destroyed when it is loaded or printed... I don't know if you can convert character sets easily in javascript...

should be automatically handled by qstring

pbek commented 4 years ago

should be automatically handled by qstring

one could think that that's the case...

fabianski7 commented 4 years ago

It seems the file has a different character-set than your computer

this dictionary is from the same language I use on my system. it is also displayed without problems in libreoffice

pbek commented 4 years ago

And I assume it also works when used as dictionary in QOwnNotes, right? Still all non-latin (?) characters seem to get destroyed somewhere..

pbek commented 4 years ago

The readFromFile command uses UTF-8: https://github.com/pbek/QOwnNotes/blob/f569e40ae261679914262b012bac91b153e15634/src/services/scriptingservice.cpp#L2130

pbek commented 4 years ago
> file -bi pt_BR.dic
text/plain; charset=unknown-8bit

Looks like those dictionaries are not utf8...

pbek commented 4 years ago
> file -bi de_AT_frami.dic 
text/plain; charset=iso-8859-1

Oh boy, every dictionary looks like to be in a different characterset.

fabianski7 commented 4 years ago

I tested another, but the problem remains https://github.com/uefs/dic-ptbr-latex

$  file -bi pt_BR.dic
text/plain; charset=iso-8859-1
pbek commented 4 years ago

I'll make the codec to decode the file a settings.

pbek commented 4 years ago

20.8.6

There now is a new release, could you please test it and report if it works for you?

fabianski7 commented 4 years ago

There now is a new release, could you please test it and report if it works for you?

Working fine now. Thanks!

pbek commented 4 years ago

Great, thank you for testing!