50
53
// Get list of available aspell dictionaries
51
54
std::vector<std::string> entries;
52
55
fsuggest->listDicts( entries );
53
for( std::vector<std::string>::const_iterator i = entries.begin(); i != entries.end(); ++i )
56
dictCount=entries.size();
55
// FIXME: Handle encodings other than UTF-8.
56
flistDicts->addItem(i->c_str());
57
// qDebug() << i->c_str();
59
//qDebug()<<"Listing dictionaries";
60
for( std::vector<std::string>::const_iterator i = entries.begin(); i != entries.end(); ++i )
62
// FIXME: Handle encodings other than UTF-8.
63
flistDicts->addItem(i->c_str());
64
//qDebug() << i->c_str();
59
67
// check the availability of any dict. If == 0 then the plugin
60
68
// is disabled in all GUI.
61
if (flistDicts->count() == 0)
69
if (entries.empty() || flistDicts->count() == 0)
71
//qDebug() << "Dictionaries found:"<<flistDicts->count();
62
72
m_errorMessage = tr("No available Aspell dictionaries found. Install some, please.");
63
// use dict for system local if there are no preferences set before
64
QString locale(QLocale::system().name().left(2));
73
qWarning()<<m_errorMessage.toUtf8().data();
67
int ix = flistDicts->findText(locale, Qt::MatchStartsWith);
69
flistDicts->setCurrentIndex(ix);
77
// use dict for system local if there are no preferences set before
78
QString locale(QLocale::system().name().left(2));
81
int ix = flistDicts->findText(locale, Qt::MatchStartsWith);
83
flistDicts->setCurrentIndex(ix);
86
fentry = kDEF_ASPELL_ENTRY;
87
setCurrentComboItem(flistDicts, fentry);
72
fentry = kDEF_ASPELL_ENTRY;
73
91
setCurrentComboItem(flistDicts, fentry);
92
handleSpellConfig(flistDicts->currentText());
77
setCurrentComboItem(flistDicts, fentry);
78
handleSpellConfig(flistDicts->currentText());
80
95
catch( const std::invalid_argument& err )
82
QString warn = tr( "aspellplugin (AspellPluginImpl::"
83
"AspellPluginImpl): Error in aspell "
84
"speller configuration." );
85
qWarning( "%s", warn.toUtf8().data() );
97
QString warn = tr( "Spell Checker Plugin Failed to Initialise.\nConfiguration invalid" );
98
qWarning()<<warn.toUtf8().data();
99
if (m_errorMessage.isEmpty())
87
102
catch( const std::runtime_error& err )
89
QString warn = tr( "aspellplugin (AspellPluginImpl::"
90
"AspellPluginImpl): Error in creating "
92
qWarning( "%s", warn.toUtf8().data() );
94
activateSpellGUI(true);
104
QString warn = tr( "Spell Checker Plugin Failed to Initialise.");
106
warn+="\n"+tr( "No Aspell dictionaries could be found." );
107
qWarning()<<warn.toUtf8().data();
108
if (m_errorMessage.isEmpty())
111
if (m_errorMessage.isEmpty())
113
activateSpellGUI(true);
97
117
//__________________________________________________________________________
98
118
AspellPluginImpl::~AspellPluginImpl()
103
fsuggest->saveLists();
105
catch( const std::runtime_error& err )
107
qWarning( "aspellplugin (AspellPluginImpl::~AspellPlugin"
108
"Impl): Error in saving aspell word lists." );
120
if (m_errorMessage.isEmpty())
125
fsuggest->saveLists();
127
catch( const std::runtime_error& err )
129
qWarning( "aspellplugin (AspellPluginImpl::~AspellPlugin"
130
"Impl): Error in saving aspell word lists." );
113
136
//__________________________________________________________________________
114
137
void AspellPluginImpl::activateSpellGUI(bool active)