mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
Compare commits
19 commits
a4d58a4b38
...
5842d6bf5d
Author | SHA1 | Date | |
---|---|---|---|
5842d6bf5d | |||
3c5233f2a1 | |||
c5ca1b7d63 | |||
5092ebe2ee | |||
5bef4cef22 | |||
59d01868da | |||
10b0496cce | |||
1cf495e7dd | |||
c2fc90801b | |||
2de2141758 | |||
db4c352d6c | |||
7c32cad65a | |||
160402e1d0 | |||
fb48f66370 | |||
dcc4579544 | |||
d3ad40f988 | |||
081cba6b23 | |||
59f9b3d04f | |||
f6434f4219 |
3
src/audio/README.md
Normal file
3
src/audio/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Code to support GD's internal/external audio players.
|
||||
|
||||
Only `audioplayerinterface.hh` is supposed to be used outside this folder.
|
|
@ -111,7 +111,7 @@ HotKey::HotKey( QKeySequence const & seq ):
|
|||
|
||||
QKeySequence HotKey::toKeySequence() const
|
||||
{
|
||||
if ( key2 != 0 || key2 != Qt::Key::Key_unknown ) {
|
||||
if ( key2 != 0 && key2 != Qt::Key::Key_unknown ) {
|
||||
return { QKeyCombination( modifiers, static_cast< Qt::Key >( key1 ) ),
|
||||
QKeyCombination( modifiers, static_cast< Qt::Key >( key2 ) ) };
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ void loadDictionaries( QWidget * parent,
|
|||
|
||||
loadDicts.wait();
|
||||
|
||||
if ( loadDicts.getExceptionText().size() ) {
|
||||
if ( !loadDicts.getExceptionText().empty() ) {
|
||||
QMessageBox::critical( parent,
|
||||
QCoreApplication::translate( "LoadDictionaries", "Error loading dictionaries" ),
|
||||
QString::fromUtf8( loadDicts.getExceptionText().c_str() ) );
|
||||
|
|
|
@ -53,9 +53,8 @@ Group::Group( Config::Group const & cfgGroup,
|
|||
}
|
||||
}
|
||||
|
||||
Group::Group( QString name_ ):
|
||||
id( 0 ),
|
||||
name( std::move( name_ ) )
|
||||
Group::Group():
|
||||
id( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ struct Group
|
|||
Config::Group const & inactiveGroup );
|
||||
|
||||
/// Creates an empty group.
|
||||
explicit Group( QString name_ );
|
||||
explicit Group();
|
||||
|
||||
Group( unsigned id, QString name_ );
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <QWebEngineView>
|
||||
#include <list>
|
||||
#include "article_netmgr.hh"
|
||||
#include "audioplayerinterface.hh"
|
||||
#include "audio/audioplayerinterface.hh"
|
||||
#include "instances.hh"
|
||||
#include "groupcombobox.hh"
|
||||
#include "globalbroadcaster.hh"
|
||||
|
|
|
@ -200,32 +200,17 @@ void EditDictionaries::acceptChangedSources( bool rebuildGroups )
|
|||
#ifndef NO_TTS_SUPPORT
|
||||
cfg.voiceEngines = sources.getVoiceEngines();
|
||||
#endif
|
||||
ui.tabs->setUpdatesEnabled( false );
|
||||
setUpdatesEnabled( false );
|
||||
// Those hold pointers to dictionaries, we need to free them.
|
||||
groupInstances.clear();
|
||||
|
||||
groups.clear();
|
||||
orderAndProps.clear();
|
||||
|
||||
loadDictionaries( this, cfg, dictionaries, dictNetMgr );
|
||||
|
||||
Instances::updateNames( savedGroups, dictionaries );
|
||||
Instances::updateNames( savedOrder, dictionaries );
|
||||
Instances::updateNames( savedInactive, dictionaries );
|
||||
|
||||
if ( rebuildGroups ) {
|
||||
ui.tabs->removeTab( 1 );
|
||||
ui.tabs->removeTab( 1 );
|
||||
|
||||
orderAndProps = new OrderAndProps( this, savedOrder, savedInactive, dictionaries );
|
||||
groups = new Groups( this, dictionaries, savedGroups, orderAndProps->getCurrentDictionaryOrder() );
|
||||
|
||||
ui.tabs->insertTab( 1, orderAndProps, QIcon( ":/icons/book.svg" ), tr( "&Dictionaries" ) );
|
||||
ui.tabs->insertTab( 2, groups, QIcon( ":/icons/bookcase.svg" ), tr( "&Groups" ) );
|
||||
connect( groups, &Groups::showDictionaryInfo, this, &EditDictionaries::showDictionaryInfo );
|
||||
connect( orderAndProps, &OrderAndProps::showDictionaryHeadwords, this, &EditDictionaries::showDictionaryHeadwords );
|
||||
orderAndProps->rebuild( savedOrder, savedInactive, dictionaries );
|
||||
groups->rebuild( dictionaries, savedGroups, orderAndProps->getCurrentDictionaryOrder() );
|
||||
}
|
||||
ui.tabs->setUpdatesEnabled( true );
|
||||
setUpdatesEnabled( true );
|
||||
}
|
||||
EditDictionaries::~EditDictionaries()
|
||||
{
|
||||
|
|
|
@ -64,6 +64,24 @@ Groups::Groups( QWidget * parent,
|
|||
countChanged();
|
||||
}
|
||||
|
||||
void Groups::rebuild( vector< sptr< Dictionary::Class > > const & dicts_,
|
||||
Config::Groups const & groups_,
|
||||
Config::Group const & order )
|
||||
{
|
||||
this->setUpdatesEnabled( false );
|
||||
dicts = dicts_;
|
||||
groups = groups_;
|
||||
|
||||
ui.dictionaries->setAsSource();
|
||||
ui.dictionaries->populate( Instances::Group( order, dicts, Config::Group() ).dictionaries, dicts );
|
||||
|
||||
// Populate groups' widget
|
||||
ui.groups->populate( groups, dicts, ui.dictionaries->getCurrentDictionaries() );
|
||||
|
||||
countChanged();
|
||||
this->setUpdatesEnabled( true );
|
||||
}
|
||||
|
||||
void Groups::editGroup( unsigned id )
|
||||
{
|
||||
for ( int x = 0; x < groups.size(); ++x ) {
|
||||
|
|
|
@ -18,7 +18,9 @@ public:
|
|||
std::vector< sptr< Dictionary::Class > > const &,
|
||||
Config::Groups const &,
|
||||
Config::Group const & order );
|
||||
|
||||
void rebuild( std::vector< sptr< Dictionary::Class > > const & dicts_,
|
||||
Config::Groups const & groups_,
|
||||
Config::Group const & order );
|
||||
/// Instructs the dialog to position itself on editing the given group.
|
||||
void editGroup( unsigned id );
|
||||
|
||||
|
@ -31,7 +33,7 @@ public:
|
|||
|
||||
private:
|
||||
Ui::Groups ui;
|
||||
std::vector< sptr< Dictionary::Class > > const & dicts;
|
||||
std::vector< sptr< Dictionary::Class > > dicts;
|
||||
Config::Groups groups;
|
||||
|
||||
QToolButton * groupsListButton;
|
||||
|
|
|
@ -122,7 +122,7 @@ void DictGroupWidget::groupIconActivated( int index )
|
|||
|
||||
Config::Group DictGroupWidget::makeGroup() const
|
||||
{
|
||||
Instances::Group g( "" );
|
||||
Instances::Group g;
|
||||
|
||||
g.id = groupId;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "config.hh"
|
||||
#include "dict/dictionary.hh"
|
||||
#include "article_netmgr.hh"
|
||||
#include "audioplayerfactory.hh"
|
||||
#include "audio/audioplayerfactory.hh"
|
||||
#include "instances.hh"
|
||||
#include "article_maker.hh"
|
||||
#include "scanpopup.hh"
|
||||
|
|
|
@ -133,9 +133,28 @@ OrderAndProps::OrderAndProps( QWidget * parent,
|
|||
showDictNumbers();
|
||||
}
|
||||
|
||||
void OrderAndProps::rebuild( Config::Group const & dictionaryOrder,
|
||||
Config::Group const & inactiveDictionaries,
|
||||
std::vector< sptr< Dictionary::Class > > const & allDictionaries )
|
||||
{
|
||||
Instances::Group order( dictionaryOrder, allDictionaries, Config::Group() );
|
||||
Instances::Group inactive( inactiveDictionaries, allDictionaries, Config::Group() );
|
||||
|
||||
Instances::complementDictionaryOrder( order, inactive, allDictionaries );
|
||||
|
||||
setUpdatesEnabled( false );
|
||||
ui.dictionaryOrder->populate( order.dictionaries, allDictionaries );
|
||||
ui.inactiveDictionaries->populate( inactive.dictionaries, allDictionaries );
|
||||
|
||||
disableDictionaryDescription();
|
||||
|
||||
showDictNumbers();
|
||||
setUpdatesEnabled( true );
|
||||
}
|
||||
|
||||
Config::Group OrderAndProps::getCurrentDictionaryOrder() const
|
||||
{
|
||||
Instances::Group g( "" );
|
||||
Instances::Group g;
|
||||
|
||||
g.dictionaries = ui.dictionaryOrder->getCurrentDictionaries();
|
||||
|
||||
|
@ -144,7 +163,7 @@ Config::Group OrderAndProps::getCurrentDictionaryOrder() const
|
|||
|
||||
Config::Group OrderAndProps::getCurrentInactiveDictionaries() const
|
||||
{
|
||||
Instances::Group g( "" );
|
||||
Instances::Group g;
|
||||
|
||||
g.dictionaries = ui.inactiveDictionaries->getCurrentDictionaries();
|
||||
|
||||
|
|
|
@ -17,7 +17,9 @@ public:
|
|||
Config::Group const & dictionaryOrder,
|
||||
Config::Group const & inactiveDictionaries,
|
||||
std::vector< sptr< Dictionary::Class > > const & allDictionaries );
|
||||
|
||||
void rebuild( Config::Group const & dictionaryOrder,
|
||||
Config::Group const & inactiveDictionaries,
|
||||
std::vector< sptr< Dictionary::Class > > const & allDictionaries );
|
||||
Config::Group getCurrentDictionaryOrder() const;
|
||||
Config::Group getCurrentInactiveDictionaries() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue