Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package request: qtwebengine_dictionaries #49030

Closed
Eloitor opened this issue Mar 2, 2024 · 12 comments · May be fixed by #49075
Closed

Package request: qtwebengine_dictionaries #49030

Eloitor opened this issue Mar 2, 2024 · 12 comments · May be fixed by #49075
Labels
request Package request

Comments

@Eloitor
Copy link
Contributor

Eloitor commented Mar 2, 2024

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 Eloitor added the request Package request label Mar 2, 2024
@chrysos349
Copy link
Contributor

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())
 	{

@Eloitor
Copy link
Contributor Author

Eloitor commented Mar 4, 2024

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

@Eloitor
Copy link
Contributor Author

Eloitor commented Mar 4, 2024

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....

@sgn
Copy link
Member

sgn commented Mar 5, 2024

@Eloitor
Copy link
Contributor Author

Eloitor commented Mar 5, 2024

$ 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?

@chrysos349
Copy link
Contributor

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
Copy link
Contributor

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 <leah@vuxu.org>"
 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
 }

@classabbyamp
Copy link
Member

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

@chrysos349
Copy link
Contributor

chrysos349 commented Mar 5, 2024

you are correct. forgot about those architectures.

UPD. What about enabling only when crossbuilding?

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

@sgn
Copy link
Member

sgn commented Mar 5, 2024

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

@sgn
Copy link
Member

sgn commented Mar 5, 2024

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
Copy link
Member

sgn commented Mar 8, 2024

#49189

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
request Package request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants