Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 12896 → Rev 12895

/trunk/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp
18,8 → 18,7
 
// Initialize members here, if any
AspellPluginImpl::AspellPluginImpl(ScribusDoc* doc, QWidget* parent) :
QDialog( parent ), fdoc( doc ), fpos(0), fidx(0),
m_errorMessage("")
QDialog( parent ), fdoc( doc ), fpos(0), fidx(0)
{
// Constructor.
setupUi( this );
49,28 → 48,8
{
// FIXME: Handle encodings other than UTF-8.
flistDicts->addItem(i->c_str());
// qDebug() << i->c_str();
}
// check the availability of any dict. If == 0 then the plugin
// is disabled in all GUI.
if (flistDicts->count() == 0)
m_errorMessage = tr("No available Aspell dictionaries found. Install some, please.");
// use dict for system local if there are no preferences set before
QString locale(QLocale::system().name().left(2));
if (fentry.isEmpty())
{
int ix = flistDicts->findText(locale, Qt::MatchStartsWith);
if (ix != -1)
flistDicts->setCurrentIndex(ix);
else
{
fentry = kDEF_ASPELL_ENTRY;
setCurrentComboItem(flistDicts, fentry);
}
}
else
setCurrentComboItem(flistDicts, fentry);
handleSpellConfig(flistDicts->currentText());
setCurrentComboItem(flistDicts, fentry);
}
catch( const std::invalid_argument& err )
{
369,34 → 348,26
// of the selected item.
fcurrWord->setText( flistReplacements->currentItem()->text() );
}
 
bool AspellPluginImpl::handleSpellConfig(const QString & dictFullName)
//__________________________________________________________________________
void AspellPluginImpl::on_flistDicts_activated()
{
QString entry(dictFullName);
// Called when an item in the list of available aspell dictionaries is
// selected, i.e., by double-clicking, or pressing enter. Resets
// aspell configuration to use the selected dictionary.
QString entry = flistDicts->currentText();
QStringList fields = entry.split( Speller::Aspell::Suggest::kDICT_DELIM );
// Ensure that we have at least the right no.of fields.
if( fields.size() == 4 )
{
QString value =
fields[0] + Speller::Aspell::Suggest::kDICT_DELIM +
fields[1] + Speller::Aspell::Suggest::kDICT_DELIM +
fields[2] + Speller::Aspell::Suggest::kDICT_DELIM +
fields[3];
fields[0] + Speller::Aspell::Suggest::kDICT_DELIM +
fields[1] + Speller::Aspell::Suggest::kDICT_DELIM +
fields[2] + Speller::Aspell::Suggest::kDICT_DELIM +
fields[3];
fsuggest->resetConfig( fields[1].toAscii().data(), fields[2].toAscii().data() );
// FIXME: Handle encodings other than UTF-8.
setPreferences( fields[1], fields[2], Speller::Aspell::Suggest::kDEF_ENCODING, value );
return true;
}
return false;
}
//__________________________________________________________________________
void AspellPluginImpl::on_flistDicts_activated()
{
// Called when an item in the list of available aspell dictionaries is
// selected, i.e., by double-clicking, or pressing enter. Resets
// aspell configuration to use the selected dictionary.
if (handleSpellConfig(flistDicts->currentText()))
{
 
// PV - 7523: In the spell checker, the only option to change
// the dictionary is to open the spell checker dialog. However,
// changing the dictionary does not recheck first word
422,9 → 393,7
fjargon = fprefs->get( "jargon", Speller::Aspell::Suggest::kDEF_JARGON );
// FIXME: Handle encodings other than UTF-8.
fencoding = fprefs->get( "encoding", Speller::Aspell::Suggest::kDEF_ENCODING );
// Don't use kDEF_ASPELL_ENTRY here. It's checked
// against system locale later when there is no preferences for it.
fentry = fprefs->get( "entry", "");//kDEF_ASPELL_ENTRY );
fentry = fprefs->get( "entry", kDEF_ASPELL_ENTRY );
}
//__________________________________________________________________________
void AspellPluginImpl::setPreferences(const QString& lang,
/trunk/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.h
84,8 → 84,7
QStringList fwordlist;
/*! \brief Pointer to current frame. */
PageItem* fFrame;
//! \brief Internal error message
QString m_errorMessage;
/*! \brief Model for list of dictionaries. */
 
protected:
/*!
150,13 → 149,6
*/
void spellCheckDone();
 
/*! \brief Sets the dict configuration based on given dictFullName
or in the constructor. See on_flistDicts_activated().
\param dictFullName a full dictionary name taken e.g. from flistDicts.
\author Petr Vanek <petr@scribus.info>
*/
bool handleSpellConfig(const QString & dictFullName);
 
public:
/*!
\author Gora Mohanty <gora@srijan.in>
174,11 → 166,6
*/
~AspellPluginImpl();
 
/*! \brief Returns a error message for caller.
It should disable the plugin then
*/
QString errorMessage() { return m_errorMessage; } ;
 
public slots:
/*!
\author Gora Mohanty <gora@srijan.in>
/trunk/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.cpp
4,7 → 4,6
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
#include "scraction.h"
#include "aspellplugin.h"
#include "aspellpluginimpl.h"
 
81,20 → 80,9
 
bool AspellPlugin::run(ScribusDoc* doc, QString target)
{
AspellPluginImpl *myPluginImpl = new AspellPluginImpl( doc );
AspellPluginImpl *myPluginImpl = new AspellPluginImpl( doc );
Q_CHECK_PTR(myPluginImpl);
// The spellcheck is disabled when there are no available
// dictionaries.
if (myPluginImpl->errorMessage().isEmpty())
myPluginImpl->exec();
else
{
doc->scMW()->scrActions[m_actionInfo.name]->setEnabled(false);
doc->scMW()->scrActions[m_actionInfo.name]->setVisible(false);
QMessageBox::warning(doc->scMW(),
tr("Aspell Plugin Error"),
myPluginImpl->errorMessage());
}
myPluginImpl->exec();
delete myPluginImpl;
return true;
}