mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-15 18:39:51 +00:00
Merge remote-tracking branch 'pvdk/encoding'
This commit is contained in:
commit
ce67fbdfca
@ -1,6 +1,9 @@
|
||||
#include "datafilespage.hpp"
|
||||
|
||||
#include <QtGui>
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
#include <QCheckBox>
|
||||
#include <QMenu>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "graphicspage.hpp"
|
||||
|
||||
#include <QtGui>
|
||||
#include <QDesktopWidget>
|
||||
#include <QMessageBox>
|
||||
#include <QDir>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
|
@ -1,6 +1,15 @@
|
||||
#include "maindialog.hpp"
|
||||
|
||||
#include <QtGui>
|
||||
#include <QFontDatabase>
|
||||
#include <QInputDialog>
|
||||
#include <QFileDialog>
|
||||
#include <QCloseEvent>
|
||||
#include <QTextCodec>
|
||||
#include <QProcess>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "utils/checkablemessagebox.hpp"
|
||||
|
||||
@ -203,10 +212,15 @@ bool MainDialog::showFirstRunDialog()
|
||||
// Construct the arguments to run the importer
|
||||
QStringList arguments;
|
||||
|
||||
if (msgBox.isChecked())
|
||||
arguments.append(QString("-g"));
|
||||
|
||||
if (msgBox.isChecked())
|
||||
arguments.append(QString("--game-files"));
|
||||
|
||||
arguments.append(QString("--encoding"));
|
||||
arguments.append(mGameSettings.value(QString("encoding"), QString("win1252")));
|
||||
arguments.append(QString("--ini"));
|
||||
arguments.append(iniPaths.first());
|
||||
arguments.append(QString("--cfg"));
|
||||
arguments.append(path);
|
||||
|
||||
if (!startProgram(QString("mwiniimport"), arguments, false))
|
||||
@ -659,7 +673,7 @@ bool MainDialog::startProgram(const QString &name, const QStringList &arguments,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (process.exitCode() != 0) {
|
||||
if (process.exitCode() != 0 || process.exitStatus() == QProcess::CrashExit) {
|
||||
QString error(process.readAllStandardError());
|
||||
error.append(tr("\nArguments:\n"));
|
||||
error.append(arguments.join(" "));
|
||||
|
@ -1,6 +1,10 @@
|
||||
#include "playpage.hpp"
|
||||
|
||||
#include <QtGui>
|
||||
#include <QListView>
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include <QPlastiqueStyle>
|
||||
#endif
|
||||
|
||||
PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include <QDebug>
|
||||
#include <QTextDecoder>
|
||||
#include <QTextCodec>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
|
||||
@ -237,10 +239,6 @@ bool lessThanDate(const EsmFile *e1, const EsmFile *e2)
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// if (!e1->fileName().endsWith(".esm") && e2->fileName().endsWith(".esm"))
|
||||
// return false;
|
||||
|
||||
// return e1->fileName().toLower() < e2->fileName().toLower();
|
||||
}
|
||||
|
||||
void DataFilesModel::sort(int column, Qt::SortOrder order)
|
||||
@ -270,17 +268,32 @@ void DataFilesModel::addFiles(const QString &path)
|
||||
filters << "*.esp" << "*.esm";
|
||||
dir.setNameFilters(filters);
|
||||
|
||||
// Create a decoder for non-latin characters in esx metadata
|
||||
QTextCodec *codec;
|
||||
|
||||
if (mEncoding == QLatin1String("win1252")) {
|
||||
codec = QTextCodec::codecForName("windows-1252");
|
||||
} else if (mEncoding == QLatin1String("win1251")) {
|
||||
codec = QTextCodec::codecForName("windows-1251");
|
||||
} else if (mEncoding == QLatin1String("win1250")) {
|
||||
codec = QTextCodec::codecForName("windows-1250");
|
||||
} else {
|
||||
return; // This should never happen;
|
||||
}
|
||||
|
||||
QTextDecoder *decoder = codec->makeDecoder();
|
||||
|
||||
foreach (const QString &path, dir.entryList()) {
|
||||
QFileInfo info(dir.absoluteFilePath(path));
|
||||
EsmFile *file = new EsmFile(path);
|
||||
|
||||
|
||||
try {
|
||||
ESM::ESMReader fileReader;
|
||||
ToUTF8::Utf8Encoder encoder (ToUTF8::calculateEncoding(mEncoding.toStdString()));
|
||||
ToUTF8::Utf8Encoder encoder(ToUTF8::calculateEncoding(mEncoding.toStdString()));
|
||||
fileReader.setEncoder(&encoder);
|
||||
fileReader.open(dir.absoluteFilePath(path).toStdString());
|
||||
|
||||
|
||||
ESM::ESMReader::MasterList mlist = fileReader.getMasters();
|
||||
QStringList masters;
|
||||
|
||||
@ -289,13 +302,13 @@ void DataFilesModel::addFiles(const QString &path)
|
||||
masters.append(master);
|
||||
}
|
||||
|
||||
file->setAuthor(QString::fromStdString(fileReader.getAuthor()));
|
||||
file->setAuthor(decoder->toUnicode(fileReader.getAuthor().c_str()));
|
||||
file->setSize(info.size());
|
||||
file->setDates(info.lastModified(), info.lastRead());
|
||||
file->setVersion(fileReader.getFVer());
|
||||
file->setPath(info.absoluteFilePath());
|
||||
file->setMasters(masters);
|
||||
file->setDescription(QString::fromStdString(fileReader.getDesc()));
|
||||
file->setDescription(decoder->toUnicode(fileReader.getDesc().c_str()));
|
||||
|
||||
|
||||
// Put the file in the table
|
||||
@ -308,6 +321,8 @@ void DataFilesModel::addFiles(const QString &path)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
delete decoder;
|
||||
}
|
||||
|
||||
QModelIndex DataFilesModel::indexFromItem(EsmFile *item) const
|
||||
|
Loading…
x
Reference in New Issue
Block a user