forked from mirror/openmw-tes3mp
Merge remote-tracking branch 'pvdk/encoding'
This commit is contained in:
commit
ce67fbdfca
5 changed files with 59 additions and 21 deletions
|
@ -1,6 +1,9 @@
|
||||||
#include "datafilespage.hpp"
|
#include "datafilespage.hpp"
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QPushButton>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
|
||||||
|
@ -97,7 +100,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
|
||||||
connect(mastersTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
|
connect(mastersTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
|
||||||
|
|
||||||
connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
|
connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
|
||||||
|
|
||||||
connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
||||||
|
|
||||||
connect(splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(updateSplitter()));
|
connect(splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(updateSplitter()));
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "graphicspage.hpp"
|
#include "graphicspage.hpp"
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QDesktopWidget>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
#include "maindialog.hpp"
|
#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"
|
#include "utils/checkablemessagebox.hpp"
|
||||||
|
|
||||||
|
@ -203,10 +212,15 @@ bool MainDialog::showFirstRunDialog()
|
||||||
// Construct the arguments to run the importer
|
// Construct the arguments to run the importer
|
||||||
QStringList arguments;
|
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(iniPaths.first());
|
||||||
|
arguments.append(QString("--cfg"));
|
||||||
arguments.append(path);
|
arguments.append(path);
|
||||||
|
|
||||||
if (!startProgram(QString("mwiniimport"), arguments, false))
|
if (!startProgram(QString("mwiniimport"), arguments, false))
|
||||||
|
@ -659,7 +673,7 @@ bool MainDialog::startProgram(const QString &name, const QStringList &arguments,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.exitCode() != 0) {
|
if (process.exitCode() != 0 || process.exitStatus() == QProcess::CrashExit) {
|
||||||
QString error(process.readAllStandardError());
|
QString error(process.readAllStandardError());
|
||||||
error.append(tr("\nArguments:\n"));
|
error.append(tr("\nArguments:\n"));
|
||||||
error.append(arguments.join(" "));
|
error.append(arguments.join(" "));
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#include "playpage.hpp"
|
#include "playpage.hpp"
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QListView>
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
#include <QPlastiqueStyle>
|
||||||
|
#endif
|
||||||
|
|
||||||
PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
|
PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QTextDecoder>
|
||||||
|
#include <QTextCodec>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
|
@ -157,7 +159,7 @@ Qt::ItemFlags DataFilesModel::flags(const QModelIndex &index) const
|
||||||
if (!file)
|
if (!file)
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
|
|
||||||
if (canBeChecked(file)) {
|
if (canBeChecked(file)) {
|
||||||
if (index.column() == 0) {
|
if (index.column() == 0) {
|
||||||
return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
} else {
|
} else {
|
||||||
|
@ -226,7 +228,7 @@ bool lessThanEsmFile(const EsmFile *e1, const EsmFile *e2)
|
||||||
return true;
|
return true;
|
||||||
if (!e1->fileName().endsWith(".esm") && e2->fileName().endsWith(".esm"))
|
if (!e1->fileName().endsWith(".esm") && e2->fileName().endsWith(".esm"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return e1->fileName().toLower() < e2->fileName().toLower();
|
return e1->fileName().toLower() < e2->fileName().toLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,10 +239,6 @@ bool lessThanDate(const EsmFile *e1, const EsmFile *e2)
|
||||||
} else {
|
} else {
|
||||||
return false;
|
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)
|
void DataFilesModel::sort(int column, Qt::SortOrder order)
|
||||||
|
@ -270,17 +268,32 @@ void DataFilesModel::addFiles(const QString &path)
|
||||||
filters << "*.esp" << "*.esm";
|
filters << "*.esp" << "*.esm";
|
||||||
dir.setNameFilters(filters);
|
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()) {
|
foreach (const QString &path, dir.entryList()) {
|
||||||
QFileInfo info(dir.absoluteFilePath(path));
|
QFileInfo info(dir.absoluteFilePath(path));
|
||||||
EsmFile *file = new EsmFile(path);
|
EsmFile *file = new EsmFile(path);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ESM::ESMReader fileReader;
|
ESM::ESMReader fileReader;
|
||||||
ToUTF8::Utf8Encoder encoder (ToUTF8::calculateEncoding(mEncoding.toStdString()));
|
ToUTF8::Utf8Encoder encoder(ToUTF8::calculateEncoding(mEncoding.toStdString()));
|
||||||
fileReader.setEncoder(&encoder);
|
fileReader.setEncoder(&encoder);
|
||||||
fileReader.open(dir.absoluteFilePath(path).toStdString());
|
fileReader.open(dir.absoluteFilePath(path).toStdString());
|
||||||
|
|
||||||
|
|
||||||
ESM::ESMReader::MasterList mlist = fileReader.getMasters();
|
ESM::ESMReader::MasterList mlist = fileReader.getMasters();
|
||||||
QStringList masters;
|
QStringList masters;
|
||||||
|
|
||||||
|
@ -289,13 +302,13 @@ void DataFilesModel::addFiles(const QString &path)
|
||||||
masters.append(master);
|
masters.append(master);
|
||||||
}
|
}
|
||||||
|
|
||||||
file->setAuthor(QString::fromStdString(fileReader.getAuthor()));
|
file->setAuthor(decoder->toUnicode(fileReader.getAuthor().c_str()));
|
||||||
file->setSize(info.size());
|
file->setSize(info.size());
|
||||||
file->setDates(info.lastModified(), info.lastRead());
|
file->setDates(info.lastModified(), info.lastRead());
|
||||||
file->setVersion(fileReader.getFVer());
|
file->setVersion(fileReader.getFVer());
|
||||||
file->setPath(info.absoluteFilePath());
|
file->setPath(info.absoluteFilePath());
|
||||||
file->setMasters(masters);
|
file->setMasters(masters);
|
||||||
file->setDescription(QString::fromStdString(fileReader.getDesc()));
|
file->setDescription(decoder->toUnicode(fileReader.getDesc().c_str()));
|
||||||
|
|
||||||
|
|
||||||
// Put the file in the table
|
// Put the file in the table
|
||||||
|
@ -308,6 +321,8 @@ void DataFilesModel::addFiles(const QString &path)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete decoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex DataFilesModel::indexFromItem(EsmFile *item) const
|
QModelIndex DataFilesModel::indexFromItem(EsmFile *item) const
|
||||||
|
@ -369,10 +384,10 @@ QStringList DataFilesModel::checkedItems()
|
||||||
QStringList DataFilesModel::checkedItemsPaths()
|
QStringList DataFilesModel::checkedItemsPaths()
|
||||||
{
|
{
|
||||||
QStringList list;
|
QStringList list;
|
||||||
|
|
||||||
QList<EsmFile *>::ConstIterator it;
|
QList<EsmFile *>::ConstIterator it;
|
||||||
QList<EsmFile *>::ConstIterator itEnd = mFiles.constEnd();
|
QList<EsmFile *>::ConstIterator itEnd = mFiles.constEnd();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (it = mFiles.constBegin(); it != itEnd; ++it) {
|
for (it = mFiles.constBegin(); it != itEnd; ++it) {
|
||||||
EsmFile *file = item(i);
|
EsmFile *file = item(i);
|
||||||
|
@ -381,7 +396,7 @@ QStringList DataFilesModel::checkedItemsPaths()
|
||||||
if (mCheckStates[file->fileName()] == Qt::Checked && canBeChecked(file))
|
if (mCheckStates[file->fileName()] == Qt::Checked && canBeChecked(file))
|
||||||
list << file->path();
|
list << file->path();
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue