Added a new global function to get a list of all available Text Codecs.
This commit is contained in:
parent
b633f40e4c
commit
621ddc8179
@ -30,7 +30,7 @@
|
||||
#define VER_LAMEXP_MINOR_LO 4
|
||||
#define VER_LAMEXP_TYPE Alpha
|
||||
#define VER_LAMEXP_PATCH 8
|
||||
#define VER_LAMEXP_BUILD 806
|
||||
#define VER_LAMEXP_BUILD 807
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Tool versions (minimum expected versions!)
|
||||
|
@ -130,16 +130,9 @@ int CueImportDialog::exec(void)
|
||||
{
|
||||
const QString systemDefault = tr("(System Default)");
|
||||
|
||||
QStringList codecList; codecList << systemDefault;
|
||||
QList<QByteArray> availableCodecs = QTextCodec::availableCodecs();
|
||||
while(!availableCodecs.isEmpty())
|
||||
{
|
||||
QByteArray current = availableCodecs.takeFirst();
|
||||
if(!(current.startsWith("system") || current.startsWith("System")))
|
||||
{
|
||||
codecList << QString::fromLatin1(current.constData(), current.size());
|
||||
}
|
||||
}
|
||||
QStringList codecList;
|
||||
codecList.append(systemDefault);
|
||||
codecList.append(lamexp_available_codepages());
|
||||
|
||||
QInputDialog *input = new QInputDialog(progress);
|
||||
input->setLabelText(EXPAND(tr("Select ANSI Codepage for Cue Sheet file:")));
|
||||
@ -148,17 +141,20 @@ int CueImportDialog::exec(void)
|
||||
input->setTextEchoMode(QLineEdit::Normal);
|
||||
input->setComboBoxItems(codecList);
|
||||
|
||||
if(input->exec() > 0)
|
||||
if(input->exec() < 1)
|
||||
{
|
||||
qDebug("User-selected codec is: %s", input->textValue().toLatin1().constData());
|
||||
if(input->textValue().compare(systemDefault, Qt::CaseInsensitive))
|
||||
{
|
||||
qDebug("Going to use a user-selected codec!");
|
||||
codec = QTextCodec::codecForName(input->textValue().toLatin1().constData());
|
||||
}
|
||||
progress->close();
|
||||
LAMEXP_DELETE(input);
|
||||
LAMEXP_DELETE(progress);
|
||||
return Rejected;
|
||||
}
|
||||
|
||||
if(!codec)
|
||||
if(input->textValue().compare(systemDefault, Qt::CaseInsensitive))
|
||||
{
|
||||
qDebug("User-selected codec is: %s", input->textValue().toLatin1().constData());
|
||||
codec = QTextCodec::codecForName(input->textValue().toLatin1().constData());
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Going to use the system's default codec!");
|
||||
codec = QTextCodec::codecForName("System");
|
||||
|
@ -1643,6 +1643,35 @@ const QString lamexp_clean_filepath(const QString &str)
|
||||
return parts.join("/");
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a list of all available Qt Text Codecs
|
||||
*/
|
||||
QStringList lamexp_available_codepages(bool noAliases)
|
||||
{
|
||||
QStringList codecList;
|
||||
|
||||
QList<QByteArray> availableCodecs = QTextCodec::availableCodecs();
|
||||
while(!availableCodecs.isEmpty())
|
||||
{
|
||||
QByteArray current = availableCodecs.takeFirst();
|
||||
if(!(current.startsWith("system") || current.startsWith("System")))
|
||||
{
|
||||
codecList << QString::fromLatin1(current.constData(), current.size());
|
||||
if(noAliases)
|
||||
{
|
||||
if(QTextCodec *currentCodec = QTextCodec::codecForName(current.constData()))
|
||||
{
|
||||
|
||||
QList<QByteArray> aliases = currentCodec->aliases();
|
||||
while(!aliases.isEmpty()) availableCodecs.removeAll(aliases.takeFirst());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return codecList;
|
||||
}
|
||||
|
||||
/*
|
||||
* Finalization function (final clean-up)
|
||||
*/
|
||||
|
@ -116,6 +116,7 @@ QString lamexp_translation_name(const QString &language);
|
||||
unsigned int lamexp_translation_sysid(const QString &langId);
|
||||
bool lamexp_install_translator_from_file(const QString &qmFile);
|
||||
bool lamexp_install_translator(const QString &language);
|
||||
QStringList lamexp_available_codepages(bool noAliases = true);
|
||||
static const char* LAMEXP_DEFAULT_LANGID = "en";
|
||||
|
||||
//Auxiliary functions
|
||||
|
Loading…
Reference in New Issue
Block a user