app-text/goldendict: new package, add 24.05.05

Signed-off-by: Yongxiang Liang <tanekliang@gmail.com>
This commit is contained in:
Yongxiang Liang 2024-08-24 18:21:48 +08:00 committed by 梁永祥
parent 7fcd8fbec1
commit 55c83cc157
4 changed files with 352 additions and 0 deletions

View File

@ -0,0 +1 @@
DIST v24.05.05-LiXia.ecd1138c.tar.gz 15674416 BLAKE2B 2c313c555db2718b8828e49d27ed7913c4bab4a951aaf77f51c2f471c6e39e5c86a5a13ac7bbe74b4325ffce112d9c6442c1f84370a65b9ee87fb7d89fc6f408 SHA512 23de261e0c95a554d8d6d05e291ada079f5682a115437cfe386a0d2ac83c0fa31ddd5229d12b17f346f62dca26e21d1a28e0960b064cb6fa88f28a2e64437e92

View File

@ -0,0 +1,224 @@
diff --git a/goldendict.pro b/goldendict.pro
index 5ce531a1..4f7895c7 100644
--- a/goldendict.pro
+++ b/goldendict.pro
@@ -185,10 +185,6 @@ win32 {
}
unix:!mac {
- DEFINES += HAVE_X11
-
- lessThan(QT_MAJOR_VERSION, 6): QT += x11extras
-
CONFIG += link_pkgconfig
PKGCONFIG += vorbisfile \
@@ -201,9 +197,6 @@ unix:!mac {
libavcodec \
libswresample \
}
- !arm {
- LIBS += -lX11 -lXtst
- }
# Install prefix: first try to use qmake's PREFIX variable,
# then $PREFIX from system environment, and if both fails,
diff --git a/src/hotkeywrapper.cc b/src/hotkeywrapper.cc
index 5efe49cd..16b038be 100644
--- a/src/hotkeywrapper.cc
+++ b/src/hotkeywrapper.cc
@@ -525,11 +525,13 @@ bool QHotkeyApplication::nativeEventFilter( const QByteArray & /*eventType*/, vo
#else
//////////////////////////////////////////////////////////////////////////
-
+#ifdef HAVE_X11
#include <X11/keysym.h>
+#endif
void HotkeyWrapper::init()
{
+#ifdef HAVE_X11
keyToUngrab = grabbedKeys.end();
#if QT_VERSION < 0x060000
@@ -591,17 +593,20 @@ void HotkeyWrapper::init()
XSync( display, False );
connect( this, &HotkeyWrapper::keyRecorded, this, &HotkeyWrapper::checkState, Qt::QueuedConnection );
-
+#endif
start();
}
void HotkeyWrapper::run() // Runs in a separate thread
{
+#ifdef HAVE_X11
if ( !XRecordEnableContext( dataDisplay, recordContext, recordEventCallback, (XPointer)this ) )
GD_DPRINTF( "Failed to enable record context\n" );
+#endif
}
+#ifdef HAVE_X11
void HotkeyWrapper::recordEventCallback( XPointer ptr, XRecordInterceptData * data )
{
( (HotkeyWrapper *)ptr )->handleRecordEvent( data );
@@ -648,6 +653,7 @@ void HotkeyWrapper::handleRecordEvent( XRecordInterceptData * data )
XRecordFreeData( data );
}
+#endif
bool HotkeyWrapper::setGlobalKey( QKeySequence const & seq, int handle )
{
@@ -657,6 +663,7 @@ bool HotkeyWrapper::setGlobalKey( QKeySequence const & seq, int handle )
bool HotkeyWrapper::setGlobalKey( int key, int key2, Qt::KeyboardModifiers modifier, int handle )
{
+#ifdef HAVE_X11
if ( !key )
return false; // We don't monitor empty combinations
@@ -679,8 +686,12 @@ bool HotkeyWrapper::setGlobalKey( int key, int key2, Qt::KeyboardModifiers modif
grabKey( vk, mod ); // Make sure it doesn't get caught by other apps
return true;
+#else
+ return false;
+#endif
}
+#ifdef HAVE_X11
bool HotkeyWrapper::isCopyToClipboardKey( quint32 keyCode, quint32 modifiers ) const
{
return modifiers == ControlMask && ( keyCode == cCode || keyCode == insertCode || keyCode == kpInsertCode );
@@ -796,9 +807,11 @@ void HotkeyWrapper::ungrabKey( GrabbedKeys::iterator i )
gdWarning( "Cannot ungrab the hotkey" );
}
}
+#endif
quint32 HotkeyWrapper::nativeKey( int key )
{
+#ifdef HAVE_X11
QString keySymName;
switch ( key ) {
@@ -817,10 +830,14 @@ quint32 HotkeyWrapper::nativeKey( int key )
#endif
Display * display = displayID;
return XKeysymToKeycode( display, XStringToKeysym( keySymName.toLatin1().data() ) );
+#else
+ return 0;
+#endif
}
void HotkeyWrapper::unregister()
{
+#ifdef HAVE_X11
#if QT_VERSION < 0x060000
Display * displayID = QX11Info::display();
#else
@@ -841,6 +858,7 @@ void HotkeyWrapper::unregister()
while ( grabbedKeys.size() )
ungrabKey( grabbedKeys.begin() );
+#endif
( static_cast< QHotkeyApplication * >( qApp ) )->unregisterWrapper( this );
}
diff --git a/src/hotkeywrapper.hh b/src/hotkeywrapper.hh
index 718ef82a..e9a4651e 100644
--- a/src/hotkeywrapper.hh
+++ b/src/hotkeywrapper.hh
@@ -123,13 +123,15 @@ private:
#else
+#ifdef HAVE_X11
static void recordEventCallback( XPointer, XRecordInterceptData * );
/// Called by recordEventCallback()
void handleRecordEvent( XRecordInterceptData * );
-
+#endif
void run(); // QThread
+#ifdef HAVE_X11
// We do one-time init of those, translating keysyms to keycodes
KeyCode lShiftCode, rShiftCode, lCtrlCode, rCtrlCode, lAltCode, rAltCode, cCode, insertCode, kpInsertCode, lMetaCode,
rMetaCode;
@@ -160,6 +162,7 @@ private:
/// Ungrabs the given key. erasing it from grabbedKeys. The key's provided
/// as an interator inside the grabbedKeys set.
void ungrabKey( GrabbedKeys::iterator );
+#endif
signals:
diff --git a/src/keyboardstate.cc b/src/keyboardstate.cc
index c201b85b..d13cd00c 100644
--- a/src/keyboardstate.cc
+++ b/src/keyboardstate.cc
@@ -40,7 +40,7 @@ bool KeyboardState::checkModifiersPressed( int mask )
return !( ( mask & Alt && !( keys & ( 1 << optionKeyBit ) ) ) || ( mask & Ctrl && !( keys & ( 1 << cmdKeyBit ) ) )
|| ( mask & Shift && !( keys & ( 1 << shiftKeyBit ) ) )
|| ( mask & Win && !( keys & ( 1 << controlKeyBit ) ) ) );
-#else
+#elif defined(HAVE_X11)
#if QT_VERSION < 0x060000
Display * displayID = QX11Info::display();
@@ -56,5 +56,7 @@ bool KeyboardState::checkModifiersPressed( int mask )
return !( ( mask & Alt && !( state.base_mods & Mod1Mask ) ) || ( mask & Ctrl && !( state.base_mods & ControlMask ) )
|| ( mask & Shift && !( state.base_mods & ShiftMask ) )
|| ( mask & Win && !( state.base_mods & Mod4Mask ) ) );
+#else
+ return false;
#endif
}
diff --git a/src/main.cc b/src/main.cc
index 9fda4c60..f3a8b35a 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -307,7 +307,7 @@ void processCommandLine( QCoreApplication * app, GDOptions * result )
int main( int argc, char ** argv )
{
-#if defined( Q_OS_UNIX ) && !defined( Q_OS_MACOS )
+#if defined( Q_OS_UNIX ) && !defined( Q_OS_MACOS ) && defined(HAVE_X11)
// GoldenDict use lots of X11 functions and it currently cannot work
// natively on Wayland. This workaround will force GoldenDict to use
// XWayland.
diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc
index 026fc2b1..04b73ff8 100644
--- a/src/ui/scanpopup.cc
+++ b/src/ui/scanpopup.cc
@@ -40,7 +40,7 @@ static const Qt::WindowFlags pinnedWindowFlags =
/// Qt::Window allows to use the scan popup and the main window independently.
Qt::Window
#else
- Qt::Dialog
+ Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint
#endif
;
@@ -557,7 +557,7 @@ void ScanPopup::engagePopup( bool forcePopup, bool giveFocus )
#endif
if ( ui.pinButton->isChecked() )
- setWindowTitle( tr( "%1 - %2" ).arg( elideInputWord(), "GoldenDict" ) );
+ setWindowTitle( tr( "%1 - %2" ).arg( elideInputWord(), "GoldenDict Popup" ) );
/// Too large strings make window expand which is probably not what user
/// wants
@@ -919,7 +919,7 @@ void ScanPopup::pinButtonClicked( bool checked )
setAttribute( Qt::WA_MacAlwaysShowToolWindow );
#endif
- setWindowTitle( tr( "%1 - %2" ).arg( elideInputWord(), "GoldenDict" ) );
+ setWindowTitle( tr( "%1 - %2" ).arg( elideInputWord(), "GoldenDict Popup" ) );
dictionaryBar.setMovable( true );
hideTimer.stop();
}

View File

@ -0,0 +1,107 @@
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PLOCALES="ar_SA ay_BO be_BY bg_BG crowdin cs_CZ de_CH de_DE el_GR eo_UY es_AR es_BO es_ES fa_IR fi_FI fr_FR hi_IN ie_001 it_IT ja_JP jbo_EN ko_KR lt_LT mk_MK nl_NL pl_PL pt_BR pt_PT qt_extra_es qt_extra_it qt_extra_lt qtwebengine_zh_CN qu_PE ru_RU sk_SK sq_AL sr_SP sv_SE tg_TJ tk_TM tr_TR uk_UA vi_VN zh_CN zh_TW"
inherit desktop qmake-utils flag-o-matic xdg-utils plocale
MY_PV="24.05.05-LiXia.ecd1138c"
DESCRIPTION="Feature-rich dictionary lookup program (qtwebengine fork)"
HOMEPAGE="https://xiaoyifang.github.io/goldendict-ng/"
SRC_URI="https://github.com/xiaoyifang/goldendict-ng/archive/v${MY_PV}.tar.gz"
S="${WORKDIR}/goldendict-ng-${MY_PV}"
LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64"
IUSE="debug ffmpeg opencc multimedia wayland xapian zim"
RDEPEND="
app-arch/bzip2
app-arch/xz-utils
virtual/libiconv
>=app-text/hunspell-1.2:=
dev-libs/eb
dev-libs/lzo
dev-qt/qtbase:6[X,concurrent,gui,network,sql,widgets,xml]
dev-qt/qtmultimedia:6
dev-qt/qtspeech:6
dev-qt/qtsvg:6
dev-qt/qtwebengine:6[widgets]
dev-qt/qtdeclarative:6
dev-qt/qt5compat:6
media-libs/libvorbis
sys-libs/zlib
x11-libs/libX11
x11-libs/libXtst
virtual/opengl
ffmpeg? (
media-libs/libao
media-video/ffmpeg:0=
)
opencc? ( app-i18n/opencc )
multimedia? ( dev-qt/qtmultimedia[gstreamer] )
xapian? ( dev-libs/xapian )
zim? ( app-arch/libzim )
"
DEPEND="${RDEPEND}"
BDEPEND="
dev-qt/qttools:6[assistant,linguist]
virtual/pkgconfig
"
src_prepare() {
default
use wayland && eapply "${FILESDIR}/remove-X11.patch"
# disable git
sed -i -e '/git describe/s/^/#/' ${PN}.pro || die
# fix flags
echo "QMAKE_CXXFLAGS_RELEASE = ${CFLAGS}" >> goldendict.pro
echo "QMAKE_CFLAGS_RELEASE = ${CXXFLAGS}" >> goldendict.pro
local loc_dir="${S}/locale"
plocale_find_changes "${loc_dir}" "" ".ts"
rm_loc() {
rm -vf "locale/${1}.ts" || die
sed -i "/${1}.ts/d" ${PN}.pro || die
}
plocale_for_each_disabled_locale rm_loc
}
src_configure() {
local myconf=( CONFIG+=use_iconv CONFIG+=release )
use opencc && myconf+=( CONFIG+=chinese_conversion_support )
use ffmpeg || myconf+=( CONFIG+=no_ffmpeg_player )
use multimedia || myconf+=( CONFIG+=no_qtmultimedia_player )
use xapian && myconf+=( CONFIG+=use_xapian )
use zim && myconf+=( CONFIG+=zim_support )
# stack overfow & std::bad_alloc on musl
use elibc_musl && append-ldflags -Wl,-z,stack-size=2097152
eqmake6 "${myconf[@]}" PREFIX="/usr" goldendict.pro
}
src_install() {
dobin ${PN}
domenu redist/io.github.xiaoyifang.goldendict_ng.desktop
doicon redist/icons/${PN}.png
insinto /usr/share/${PN}/locale
doins .qm/*.qm
}
pkg_postinst() {
xdg_icon_cache_update
xdg_desktop_database_update
}
pkg_postrm() {
xdg_icon_cache_update
xdg_desktop_database_update
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>tanekliang@gmail.com</email>
<name>Yongxiang Liang</name>
</maintainer>
<upstream>
<remote-id type="sourceforge">goldendict</remote-id>
<remote-id type="github">xiaoyifang/goldendict-ng</remote-id>
</upstream>
<use>
<flag name="ffmpeg">Use ffmpeg to play audio</flag>
<flag name="multimedia">Use Qt5 Multimedia and GStreamer to play audio</flag>
<flag name="opencc">Add chinese conversion support</flag>
<flag name="wayland">Allow run under wayland.</flag>
<flag name="zim">Add Zim and Slob formats support</flag>
<flag name="xapian">Add Xapian full text search support</flag>
</use>
</pkgmetadata>