diff --git a/src/Data.cpp b/src/Data.cpp index e3a5e491..c61a5007 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -57,3 +57,11 @@ QByteArray removeBom(QByteArray& data) return QByteArray(); } } + +QStringList toStringList(const QList list) { + QStringList strings; + for (const QByteArray &item : list) { + strings.append(QString::fromUtf8(item)); + } + return strings; +} diff --git a/src/Data.h b/src/Data.h index 2cbf9ddc..f8a1430c 100644 --- a/src/Data.h +++ b/src/Data.h @@ -17,4 +17,6 @@ bool startsWithBom(const QByteArray& data); // with a BOM an empty byte array is returned and the original data is not modified. QByteArray removeBom(QByteArray& data); +QStringList toStringList(const QList list); + #endif diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 2c60901a..d65d6a96 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -25,6 +25,7 @@ #include "RemoteDock.h" #include "RemoteDatabase.h" #include "FindReplaceDialog.h" +#include "Data.h" #include #include @@ -2773,15 +2774,20 @@ void MainWindow::browseDataSetTableEncoding(bool forAllTables) // Ask the user for a new encoding bool ok; QString question; + QStringList availableCodecs = toStringList(QTextCodec::availableCodecs()); + availableCodecs.removeDuplicates(); + int currentItem = availableCodecs.indexOf(encoding); + if(forAllTables) question = tr("Please choose a new encoding for all tables."); else question = tr("Please choose a new encoding for this table."); - encoding = QInputDialog::getText(this, + encoding = QInputDialog::getItem(this, tr("Set encoding"), tr("%1\nLeave the field empty for using the database encoding.").arg(question), - QLineEdit::Normal, - encoding, + availableCodecs, + currentItem, + true, // editable &ok); // Only set the new encoding if the user clicked the OK button