Skip to content

Commit

Permalink
Merge pull request #1426 from xiaoyifang/staged
Browse files Browse the repository at this point in the history
merge staged to dev
  • Loading branch information
xiaoyifang authored Mar 20, 2024
2 parents 6e00732 + 52c07b9 commit 1e261ac
Show file tree
Hide file tree
Showing 32 changed files with 181 additions and 142 deletions.
29 changes: 10 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ cmake_minimum_required(VERSION 3.25) # ubuntu 23.04 Fedora 36

option(WITH_FFMPEG_PLAYER "Enable support for FFMPEG player" ON)
option(WITH_EPWING_SUPPORT "Enable epwing support" ON)
option(WITH_XAPIAN "enable Xapian support" ON)
option(WITH_ZIM "enable zim support" ON)
option(WITH_TTS "enable QTexttoSpeech support" ON)

Expand Down Expand Up @@ -36,18 +35,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

#### Qt

find_package(Qt6 REQUIRED COMPONENTS
Concurrent
Core5Compat
LinguistTools
Multimedia
PrintSupport
WebEngineWidgets
Widgets
Svg
Xml
TextToSpeech
)
set(GD_QT_COMPONENTS Concurrent Core5Compat LinguistTools Multimedia PrintSupport WebEngineWidgets Widgets Svg Xml)

if (WITH_TTS)
list(APPEND GD_QT_COMPONENTS TextToSpeech)
endif ()

find_package(Qt6 REQUIRED COMPONENTS ${GD_QT_COMPONENTS})

qt_standard_project_setup() # availiable after find_package(Qt6 .... Core
set(CMAKE_AUTORCC ON) # not included in the qt_standard_project_setup
Expand Down Expand Up @@ -130,9 +124,11 @@ target_link_libraries(${GOLDENDICT} PRIVATE
Qt6::WebEngineWidgets
Qt6::Widgets
Qt6::Svg
Qt6::TextToSpeech
)

if (WITH_TTS)
target_link_libraries(${GOLDENDICT} PRIVATE Qt6::TextToSpeech)
endif ()

target_include_directories(${GOLDENDICT} PRIVATE
${PROJECT_SOURCE_DIR}/thirdparty/qtsingleapplication/src
Expand Down Expand Up @@ -172,11 +168,6 @@ if (NOT WITH_EPWING_SUPPORT)
target_compile_definitions(${GOLDENDICT} PUBLIC NO_EPWING_SUPPORT)
endif ()


if (WITH_XAPIAN)
target_compile_definitions(${GOLDENDICT} PUBLIC USE_XAPIAN)
endif ()

if (WITH_ZIM)
target_compile_definitions(${GOLDENDICT} PUBLIC MAKE_ZIM_SUPPORT)
endif ()
Expand Down
13 changes: 3 additions & 10 deletions CMake_Unix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ endif ()

##### Finding packages from package manager


find_package(PkgConfig REQUIRED)
# Provided by Cmake
find_package(ZLIB REQUIRED)
find_package(BZip2 REQUIRED)


# Consider all PkgConfig dependencies as one
pkg_check_modules(PKGCONFIG_DEPS IMPORTED_TARGET
hunspell
Expand All @@ -43,7 +40,8 @@ pkg_check_modules(PKGCONFIG_DEPS IMPORTED_TARGET
vorbis # .ogg
vorbisfile
liblzma
)
xapian-core
)

target_link_libraries(${GOLDENDICT} PRIVATE
PkgConfig::PKGCONFIG_DEPS
Expand All @@ -69,15 +67,10 @@ if (WITH_FFMPEG_PLAYER)
libavformat
libavutil
libswresample
)
)
target_link_libraries(${GOLDENDICT} PRIVATE PkgConfig::FFMPEG)
endif ()

if (WITH_XAPIAN)
find_package(Xapian REQUIRED) # https://github.com/xapian/xapian/tree/master/xapian-core/cmake
target_link_libraries(${GOLDENDICT} PRIVATE ${XAPIAN_LIBRARIES})
endif ()

if (WITH_EPWING_SUPPORT)
find_library(EB_LIBRARY eb REQUIRED)
target_link_libraries(${GOLDENDICT} PRIVATE ${EB_LIBRARY})
Expand Down
4 changes: 2 additions & 2 deletions redist/io.github.xiaoyifang.goldendict_ng.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ GenericName=Multiformat Dictionary
GenericName[zh_CN]=多格式字典
Comment=A feature-rich dictionary lookup program
Comment[zh_CN]=多功能字典查询软件
Keywords=dict;dictioanry;
Keywords[zh_CN]=dict;dictioanry;字典;
Keywords=dict;dictionary;
Keywords[zh_CN]=dict;dictionary;字典;
Icon=goldendict
Exec=goldendict %u
MimeType=x-scheme-handler/goldendict;x-scheme-handler/dict;
1 change: 1 addition & 0 deletions redist/io.github.xiaoyifang.goldendict_ng.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>
<name>GoldenDict-ng</name>
<developer_name>The GoldenDict-ng Community</developer_name>
<summary>Advanced dictionary lookup program</summary>
<categories>
<category>Education</category>
Expand Down
6 changes: 4 additions & 2 deletions src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ Class load()
// Upgrading
c.dictServers = makeDefaultDictServers();
}

#ifndef NO_TTS_SUPPORT
QDomNode ves = root.namedItem( "voiceEngines" );

if ( !ves.isNull() ) {
Expand All @@ -872,6 +872,7 @@ Class load()
c.voiceEngines.push_back( v );
}
}
#endif

c.mutedDictionaries = loadMutedDictionaries( root.namedItem( "mutedDictionaries" ) );
c.popupMutedDictionaries = loadMutedDictionaries( root.namedItem( "popupMutedDictionaries" ) );
Expand Down Expand Up @@ -1664,7 +1665,7 @@ void save( Class const & c )
p.setAttributeNode( icon );
}
}

#ifndef NO_TTS_SUPPORT
{
QDomNode ves = dd.createElement( "voiceEngines" );
root.appendChild( ves );
Expand Down Expand Up @@ -1706,6 +1707,7 @@ void save( Class const & c )
v.setAttributeNode( rate );
}
}
#endif

{
QDomElement muted = dd.createElement( "mutedDictionaries" );
Expand Down
4 changes: 4 additions & 0 deletions src/config.hh
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ struct Program

typedef QVector< Program > Programs;

#ifndef NO_TTS_SUPPORT
struct VoiceEngine
{
bool enabled;
Expand Down Expand Up @@ -823,6 +824,7 @@ struct VoiceEngine
};

typedef QVector< VoiceEngine > VoiceEngines;
#endif

struct HeadwordsDialog
{
Expand Down Expand Up @@ -856,7 +858,9 @@ struct Class
Lingua lingua;
Forvo forvo;
Programs programs;
#ifndef NO_TTS_SUPPORT
VoiceEngines voiceEngines;
#endif

unsigned lastMainGroupId; // Last used group in main window
unsigned lastPopupGroupId; // Last used group in popup window
Expand Down
2 changes: 2 additions & 0 deletions src/dict/loaddictionaries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ void loadDictionaries( QWidget * parent,
addDicts( Forvo::makeDictionaries( loadDicts, cfg.forvo, dictNetMgr ) );
addDicts( Lingua::makeDictionaries( loadDicts, cfg.lingua, dictNetMgr ) );
addDicts( Programs::makeDictionaries( cfg.programs ) );
#ifndef NO_TTS_SUPPORT
addDicts( VoiceEngines::makeDictionaries( cfg.voiceEngines ) );
#endif
addDicts( DictServer::makeDictionaries( cfg.dictServers ) );


Expand Down
4 changes: 4 additions & 0 deletions src/dict/sources.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ Sources::Sources( QWidget * parent, Config::Class const & cfg ):
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT
chineseConversion( new ChineseConversion( this, cfg.transliteration.chinese ) ),
#endif
#ifndef NO_TTS_SUPPORT
textToSpeechSource( nullptr ),
#endif
itemDelegate( new QItemDelegate( this ) ),
itemEditorFactory( new QItemEditorFactory() ),
mediawikisModel( this, cfg.mediawikis ),
Expand Down Expand Up @@ -317,12 +319,14 @@ void Sources::on_removeProgram_clicked()
programsModel.removeProgram( current.row() );
}

#ifndef NO_TTS_SUPPORT
Config::VoiceEngines Sources::getVoiceEngines() const
{
if ( !textToSpeechSource )
return Config::VoiceEngines();
return textToSpeechSource->getVoiceEnginesModel().getCurrentVoiceEngines();
}
#endif

Config::Hunspell Sources::getHunspell() const
{
Expand Down
8 changes: 4 additions & 4 deletions src/dict/sources.hh
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ public:
{
return programsModel.getCurrentPrograms();
}

#ifndef NO_TTS_SUPPORT
Config::VoiceEngines getVoiceEngines() const;

#endif
Config::Hunspell getHunspell() const;

Config::Transliteration getTransliteration() const;
Expand All @@ -318,9 +318,9 @@ private:
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT
ChineseConversion * chineseConversion;
#endif

#ifndef NO_TTS_SUPPORT
TextToSpeechSource * textToSpeechSource;

#endif
QItemDelegate * itemDelegate;
QScopedPointer< QItemEditorFactory > itemEditorFactory;

Expand Down
25 changes: 14 additions & 11 deletions src/dict/voiceengines.cc
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/* This file is (c) 2013 Timon Wong <[email protected]>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef NO_TTS_SUPPORT

#include "voiceengines.hh"
#include "audiolink.hh"
#include "htmlescape.hh"
#include "utf8.hh"
#include "wstring_qt.hh"
#include "voiceengines.hh"
#include "audiolink.hh"
#include "htmlescape.hh"
#include "utf8.hh"
#include "wstring_qt.hh"

#include <string>
#include <map>
#include <string>
#include <map>

#include <QDir>
#include <QFileInfo>
#include <QCryptographicHash>
#include <QDir>
#include <QFileInfo>
#include <QCryptographicHash>

#include "utils.hh"
#include "utils.hh"

namespace VoiceEngines {

Expand Down Expand Up @@ -137,3 +138,5 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Config::VoiceEngines const
}

} // namespace VoiceEngines

#endif
13 changes: 6 additions & 7 deletions src/dict/voiceengines.hh
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/* This file is (c) 2013 Timon Wong <[email protected]>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#pragma once
#ifndef NO_TTS_SUPPORT

#ifndef __VOICEENGINES_HH_INCLUDED__
#define __VOICEENGINES_HH_INCLUDED__
#include "dictionary.hh"
#include "config.hh"
#include "wstring.hh"

#include "dictionary.hh"
#include "config.hh"
#include "wstring.hh"

#include <QCryptographicHash>
#include <QCryptographicHash>


namespace VoiceEngines {
Expand Down
14 changes: 10 additions & 4 deletions src/ffmpegaudio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ AudioService::~AudioService()
void AudioService::playMemory( const char * ptr, int size )
{
emit cancelPlaying( false );
if ( !thread.isNull() ) {
thread->wait();
}
QByteArray audioData( ptr, size );
thread = std::make_shared< DecoderThread >( audioData, this );
connect( this, &AudioService::cancelPlaying, thread.get(), [ this ]( bool waitFinished ) {
thread->cancel( waitFinished );
} );
thread.reset( new DecoderThread( audioData, this ) );
connect( this, &AudioService::cancelPlaying, thread.get(), &DecoderThread::cancel );
thread->start();
}

Expand Down Expand Up @@ -263,6 +264,11 @@ bool DecoderContext::openOutputDevice( QString & errorString )
}
#endif

if ( audioOutput == nullptr ) {
errorString += QStringLiteral( "Failed to create audioOutput." );
return false;
}

audioOutput->setAudioFormat( 44100, codecContext_->channels );
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ffmpegaudio.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DecoderThread;
class AudioService: public QObject
{
Q_OBJECT
std::shared_ptr< DecoderThread > thread;
QScopedPointer< DecoderThread > thread;

public:
static AudioService & instance();
Expand Down
16 changes: 9 additions & 7 deletions src/gestures.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* This file is (c) 2014 Abs62
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */

#include <QTouchEvent>
#include <QSwipeGesture>
#include <QVariant>
#include <math.h>
#include "ui/articleview.hh"
#include "gestures.hh"
#ifndef __APPLE__
#include <QTouchEvent>
#include <QSwipeGesture>
#include <QVariant>
#include <math.h>
#include "ui/articleview.hh"
#include "gestures.hh"

namespace Gestures {

Expand Down Expand Up @@ -351,3 +351,5 @@ void unregisterRecognizers()
}

} // namespace Gestures

#endif
17 changes: 9 additions & 8 deletions src/gestures.hh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef __GESTURES_HH_INCLUDED__
#define __GESTURES_HH_INCLUDED__
#pragma once

#include <QGestureRecognizer>
#include <QGesture>
#include <QTimer>
#include <QEvent>
#include <QAction>
#ifndef __APPLE__
#include <QGestureRecognizer>
#include <QGesture>
#include <QTimer>
#include <QEvent>
#include <QAction>

namespace Gestures {

Expand Down Expand Up @@ -120,4 +120,5 @@ bool handleGestureEvent( QObject * obj, QEvent * event, GestureResult & result,

} // namespace Gestures

#endif // __GESTURES_HH_INCLUDED__

#endif
Loading

0 comments on commit 1e261ac

Please sign in to comment.