summaryrefslogtreecommitdiff
path: root/src/modinfodialog.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2013-10-26 15:02:31 +0200
committerTannin <devnull@localhost>2013-10-26 15:02:31 +0200
commit09bd3dbead9afd6a57684908e77aba6960ad464d (patch)
tree4b0d4e5901473c66b007b33c0100d8941841b3ca /src/modinfodialog.cpp
parent8c0b309bdee2527fab66b00b34171ef18f5055bf (diff)
- text files encoded in system encoding should now be correctly recognized in the mod info dialog
- archive-list can be user-sorted again (within one mod)
Diffstat (limited to 'src/modinfodialog.cpp')
-rw-r--r--src/modinfodialog.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp
index b4ae57ea..fae21cc4 100644
--- a/src/modinfodialog.cpp
+++ b/src/modinfodialog.cpp
@@ -254,17 +254,19 @@ void ModInfoDialog::refreshLists()
} else if ((fileName.endsWith(".png", Qt::CaseInsensitive)) ||
(fileName.endsWith(".jpg", Qt::CaseInsensitive))) {
QImage image = QImage(fileName);
- if (static_cast<float>(image.width()) / static_cast<float>(image.height()) > 1.34) {
- image = image.scaledToWidth(128);
- } else {
- image = image.scaledToHeight(96);
- }
+ if (!image.isNull()) {
+ if (static_cast<float>(image.width()) / static_cast<float>(image.height()) > 1.34) {
+ image = image.scaledToWidth(128);
+ } else {
+ image = image.scaledToHeight(96);
+ }
- QPushButton *thumbnailButton = new QPushButton(QPixmap::fromImage(image), "");
- thumbnailButton->setIconSize(QSize(image.width(), image.height()));
- connect(thumbnailButton, SIGNAL(clicked()), &m_ThumbnailMapper, SLOT(map()));
- m_ThumbnailMapper.setMapping(thumbnailButton, fileName);
- ui->thumbnailArea->addWidget(thumbnailButton);
+ QPushButton *thumbnailButton = new QPushButton(QPixmap::fromImage(image), "");
+ thumbnailButton->setIconSize(QSize(image.width(), image.height()));
+ connect(thumbnailButton, SIGNAL(clicked()), &m_ThumbnailMapper, SLOT(map()));
+ m_ThumbnailMapper.setMapping(thumbnailButton, fileName);
+ ui->thumbnailArea->addWidget(thumbnailButton);
+ }
}
}
@@ -400,7 +402,13 @@ void ModInfoDialog::openTextFile(const QString &fileName)
textFile.open(QIODevice::ReadOnly);
QByteArray buffer = textFile.readAll();
QTextCodec *codec = QTextCodec::codecForUtfText(buffer, m_UTF8Codec);
- ui->textFileView->setText(codec->toUnicode(buffer));
+ QString text = codec->toUnicode(buffer);
+ if (codec->fromUnicode(text) != buffer) {
+ qDebug("conversion failed assuming local encoding");
+ codec = QTextCodec::codecForLocale();
+ text = codec->toUnicode(buffer);
+ }
+ ui->textFileView->setText(text);
ui->textFileView->setProperty("currentFile", fileName);
ui->textFileView->setProperty("encoding", codec->name());
ui->saveTXTButton->setEnabled(false);