Skip to content

Commit

Permalink
fix: address CMake problems found by openBSD package
Browse files Browse the repository at this point in the history
* remove unused WITH_XAPIAN option
* don't link Qt TTS if not requested
* Disable some code when TTS is not requested
  • Loading branch information
shenlebantongying committed Mar 19, 2024
1 parent c55aad4 commit 900cc02
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 17 deletions.
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
3 changes: 3 additions & 0 deletions src/dict/voiceengines.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef NO_TTS_SUPPORT

#include "voiceengines.hh"
#include "audiolink.hh"
Expand Down Expand Up @@ -137,3 +138,5 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Config::VoiceEngines const
}

} // namespace VoiceEngines

#endif
5 changes: 2 additions & 3 deletions src/dict/voiceengines.hh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */

#ifndef __VOICEENGINES_HH_INCLUDED__
#define __VOICEENGINES_HH_INCLUDED__
#pragma once
#ifndef NO_TTS_SUPPORT

#include "dictionary.hh"
#include "config.hh"
Expand Down
2 changes: 2 additions & 0 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,9 @@ int main( int argc, char ** argv )

if ( gdcl.notts ) {
cfg.notts = true;
#ifndef NO_TTS_SUPPORT
cfg.voiceEngines.clear();
#endif
}

cfg.resetState = gdcl.resetState;
Expand Down
4 changes: 4 additions & 0 deletions src/speechclient.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef NO_TTS_SUPPORT

#include "speechclient.hh"

#include <QtCore>
Expand Down Expand Up @@ -67,3 +69,5 @@ bool SpeechClient::tell( QString const & text ) const
{
return tell( text, internalData->engine.volume, internalData->engine.rate );
}

#endif
6 changes: 3 additions & 3 deletions src/speechclient.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __SPEECHCLIENT_HH_INCLUDED__
#define __SPEECHCLIENT_HH_INCLUDED__
#pragma once
#ifndef NO_TTS_SUPPORT

#include <QObject>
#include "config.hh"
Expand Down Expand Up @@ -81,4 +81,4 @@ private:
QSharedPointer< InternalData > internalData;
};

#endif // __SPEECHCLIENT_HH_INCLUDED__
#endif
3 changes: 3 additions & 0 deletions src/texttospeechsource.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef NO_TTS_SUPPORT

#include "texttospeechsource.hh"
#include <QVariant>
Expand Down Expand Up @@ -431,3 +432,5 @@ void VoiceEngineItemDelegate::setModelData( QWidget * uncastedEditor,
model->setData( engineIdIndex, editor->engineId() );
model->setData( engineNameIndex, editor->engineName() );
}

#endif
7 changes: 4 additions & 3 deletions src/texttospeechsource.hh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */

#ifndef __TEXTTOSPEECHSOURCE_HH_INCLUDED__
#define __TEXTTOSPEECHSOURCE_HH_INCLUDED__
#pragma once

#ifndef NO_TTS_SUPPORT

#include "ui_texttospeechsource.h"
#include "config.hh"
Expand Down Expand Up @@ -116,4 +117,4 @@ private:
void adjustSliders();
};

#endif // __TEXTTOSPEECHSOURCE_HH_INCLUDED__
#endif
5 changes: 5 additions & 0 deletions src/ui/articleview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref, QString const &
QMessageBox::critical( this, "GoldenDict", tr( "The referenced audio program doesn't exist." ) );
}
else if ( url.scheme() == "gdtts" ) {
#ifndef NO_TTS_SUPPORT
// Text to speech
QString md5Id = Utils::Url::queryItemValue( url, "engine" );
QString text( url.path().mid( 1 ) );
Expand All @@ -1197,7 +1198,11 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref, QString const &
break;
}
}
#else
qDebug() << "gdtts:// is not supported due to missing TTS support";
#endif
}

else if ( Utils::isExternalLink( url ) ) {
// Use the system handler for the conventional external links
QDesktopServices::openUrl( url );
Expand Down
9 changes: 7 additions & 2 deletions src/ui/editdictionaries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ bool EditDictionaries::isSourcesChanged() const
|| sources.getHunspell() != cfg.hunspell || sources.getTransliteration() != cfg.transliteration
|| sources.getLingua() != cfg.lingua || sources.getForvo() != cfg.forvo || sources.getMediaWikis() != cfg.mediawikis
|| sources.getWebSites() != cfg.webSites || sources.getDictServers() != cfg.dictServers
|| sources.getPrograms() != cfg.programs || sources.getVoiceEngines() != cfg.voiceEngines;
|| sources.getPrograms() != cfg.programs
#ifndef NO_TTS_SUPPORT
|| sources.getVoiceEngines() != cfg.voiceEngines
#endif
;
}

void EditDictionaries::acceptChangedSources( bool rebuildGroups )
Expand All @@ -192,8 +196,9 @@ void EditDictionaries::acceptChangedSources( bool rebuildGroups )
cfg.webSites = sources.getWebSites();
cfg.dictServers = sources.getDictServers();
cfg.programs = sources.getPrograms();
#ifndef NO_TTS_SUPPORT
cfg.voiceEngines = sources.getVoiceEngines();

#endif
ui.tabs->setUpdatesEnabled( false );
// Those hold pointers to dictionaries, we need to free them.
groupInstances.clear();
Expand Down

0 comments on commit 900cc02

Please sign in to comment.