void-packages icon indicating copy to clipboard operation
void-packages copied to clipboard

Package request: qtwebengine_dictionaries

Open Eloitor opened this issue 1 year ago • 11 comments

Package name

qtwebengine_dictionaries

Package homepage

https://doc.qt.io/qt-6.6/qt-add-webengine-dictionary.html

Description

I'm not sure about this. The use case is to provide spell checking for the dooble Browser.

  1. Install and launch the dooble browser.
  2. Edit -> Settings -> Web -> Spell Checkers

You get a warning that qtwebengines_dictionary cannot be accessed. I searched using xlocate "\.bdic" and didn't find any package that provided such (only Grammalecte for french).

Reading from https://doc.qt.io/qt-6.6/qt-add-webengine-dictionary.html

A spell checker in Qt Web Engine needs dictionaries in a specific binary format. This CMake command converts dictionaries from the Hunspell project. into the bdict binary format.

Does the requested package meet the package requirements?

System, Compiled

Is the requested package released?

Yes

Eloitor avatar Mar 02 '24 15:03 Eloitor

I'm not sure about this.

You missed a rather important bit: all the *.bdict dictionaries are generate automatically by dooble build system.

Modify the template by adding this to do_install()

vcopy qtwebengine_dictionaries usr/share/dooble

then add this patch

--- a/Source/dooble_settings.cc
+++ b/Source/dooble_settings.cc
@@ -2271,7 +2271,7 @@ void dooble_settings::show_qtwebengine_dictionaries_warning_label(void)
 
   if(bytes.trimmed().isEmpty())
     {
-      bytes = "qtwebengine_dictionaries";
+      bytes = "/usr/share/dooble/qtwebengine_dictionaries";
 
       if(!QFileInfo(bytes).isReadable())
 	{

chrysos349 avatar Mar 04 '24 10:03 chrysos349

Wow thank you! I didn't realized that :)

Eloitor avatar Mar 04 '24 10:03 Eloitor

Looking at https://doc.qt.io/qt-6/qtwebengine-features.html#spellchecker maybe it is better to add the qtwebengine_dictionaries as a separate package and install them to QT_INSTALL_PREFIX/qtwebengine_dictionaries...

Is QT_INSTALL_PREFIX just /usr/share/qt6 ? I think not... I think it is just /usr?? But installing the dictionaries in /usr/qtwebengine_dictionaries is odd....

Eloitor avatar Mar 04 '24 18:03 Eloitor

https://groups.google.com/g/linux.debian.bugs.dist/c/dvznQNLhfIQ

sgn avatar Mar 05 '24 02:03 sgn

$ qmake6 -query | grep QT_INSTALL_DATA 
QT_INSTALL_DATA:/usr/share/qt6

So the dictionaries could be placed in /usr/share/qt6/qtwebengine_dictionaries.

Do we have any package with qt5 which could potentially use those dictionaries? If not, we could not care about symlinking them to the qt5 folder.

Should we name the packages like qtwebengine-dict-en-us?

Eloitor avatar Mar 05 '24 08:03 Eloitor

archlinux has *.bdic in hunspell-<LANG> packages: See here - https://gitlab.archlinux.org/archlinux/packaging/packages/hunspell-de/-/blob/main/PKGBUILD?ref_type=heads#L64

# Install webengine dictionaries
  install -d "$pkgdir"/usr/share/qt{,6}/qtwebengine_dictionaries/
  for _file in "$pkgdir"/usr/share/hunspell/*.dic; do
  _filename=$(basename $_file)
    /usr/lib/qt6/qwebengine_convert_dict $_file "$pkgdir"/usr/share/qt6/qtwebengine_dictionaries/${_filename/\.dic/\.bdic}
  ln -rs "$pkgdir"/usr/share/qt6/qtwebengine_dictionaries/${_filename/\.dic/\.bdic} "$pkgdir"/usr/share/qt/qtwebengine_dictionaries/
  done

chrysos349 avatar Mar 05 '24 09:03 chrysos349

In a similar manner hunspell-<LANG> templates can be modified, e.g. hunspell-en_US:

diff --git a/srcpkgs/hunspell-en_US/template b/srcpkgs/hunspell-en_US/template
index ce4df5e1a..2d60aa496 100644
--- a/srcpkgs/hunspell-en_US/template
+++ b/srcpkgs/hunspell-en_US/template
@@ -3,7 +3,7 @@ pkgname=hunspell-en_US
 version=2020.12.07
 revision=1
 create_wrksrc=yes
-hostmakedepends="unzip"
+hostmakedepends="unzip qt6-webengine"
 short_desc="American English en_US dictionary for hunspell"
 maintainer="Leah Neukirchen <[email protected]>"
 license="SCOWL" # not in SPDX
@@ -15,4 +15,15 @@ do_install() {
 	vinstall en_US.aff 644 /usr/share/hunspell
 	vinstall en_US.dic 644 /usr/share/hunspell
 	vlicense README_en_US.txt SCOWL
+	
+	# add qtwebengine_dictionaries
+	vmkdir /usr/share/qt6/qtwebengine_dictionaries
+	vmkdir /usr/share/qt5/qtwebengine_dictionaries
+	for f in ${DESTDIR}/usr/share/hunspell/*.dic; do
+		fa=$(basename $f .dic)
+		/usr/lib/qt6/libexec/qwebengine_convert_dict $f \
+			${DESTDIR}/usr/share/qt6/qtwebengine_dictionaries/${fa}.bdic
+		ln -s /usr/share/qt6/qtwebengine_dictionaries/${fa}.bdic \
+			${DESTDIR}/usr/share/qt5/qtwebengine_dictionaries
+	done
 }

chrysos349 avatar Mar 05 '24 10:03 chrysos349

it can't be exactly like that, as that would make it impossible to build on architectures that can't have qt6-webengine

classabbyamp avatar Mar 05 '24 10:03 classabbyamp

you are correct. forgot about those architectures.

UPD. What about enabling only when crossbuilding?

if [ "$CROSS_BUILD" ]; then
        ...
fi

chrysos349 avatar Mar 05 '24 10:03 chrysos349

Can be built by qt5-webengine (it's only needed in host).

sgn avatar Mar 05 '24 14:03 sgn

Another possible approach is xbps-triggers that will regenerate .bdic files upon installation into /usr/share/hunspell and/or qt5-webengine and/or qt6-webengine.

sgn avatar Mar 05 '24 14:03 sgn

https://github.com/void-linux/void-packages/pull/49189

sgn avatar Mar 08 '24 13:03 sgn