From 09bd3dbead9afd6a57684908e77aba6960ad464d Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 26 Oct 2013 15:02:31 +0200 Subject: - 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) --- src/mainwindow.cpp | 11 ++++++----- src/mainwindow.h | 2 +- src/mainwindow.ui | 26 ++++++++++++++++---------- src/modinfodialog.cpp | 30 +++++++++++++++++++----------- 4 files changed, 42 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cf8e355f..967a3842 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -205,7 +205,6 @@ MainWindow::MainWindow(const QString &exeName, QSettings &initSettings, QWidget resizeLists(initSettings.contains("mod_list_state"), initSettings.contains("plugin_list_state")); - QMenu *linkMenu = new QMenu(this); linkMenu->addAction(QIcon(":/MO/gui/link"), tr("Toolbar"), this, SLOT(linkToolbar())); linkMenu->addAction(QIcon(":/MO/gui/link"), tr("Desktop"), this, SLOT(linkDesktop())); @@ -247,6 +246,8 @@ MainWindow::MainWindow(const QString &exeName, QSettings &initSettings, QWidget connect(ui->espFilterEdit, SIGNAL(textChanged(QString)), this, SLOT(espFilterChanged(QString))); connect(&m_PluginList, SIGNAL(saveTimer()), this, SLOT(savePluginList())); + connect(ui->bsaList, SIGNAL(itemsMoved()), this, SLOT(on_bsaList_itemMoved())); + connect(ui->bsaWarning, SIGNAL(linkActivated(QString)), this, SLOT(linkClicked(QString))); connect(&m_DirectoryRefresher, SIGNAL(refreshed()), this, SLOT(directory_refreshed())); @@ -681,7 +682,7 @@ bool MainWindow::saveCurrentLists() reportError(tr("failed to save load order: %1").arg(e.what())); } - // ensure the archive list exists + // save only if the file doesn't exist at all, changes made in the ui are saved immediately if (!QFile::exists(m_CurrentProfile->getArchivesFileName())) { saveArchiveList(); } @@ -883,8 +884,7 @@ void MainWindow::hideSaveGameInfo() } } - -bool MainWindow::eventFilter(QObject* object, QEvent *event) +bool MainWindow::eventFilter(QObject *object, QEvent *event) { if ((object == ui->savegameList) && ((event->type() == QEvent::Leave) || (event->type() == QEvent::WindowDeactivate))) { @@ -1802,6 +1802,7 @@ void MainWindow::refreshBSAList() subItem = items.at(0); } else { subItem = new QTreeWidgetItem(QStringList(ToQString(origin.getName()))); + subItem->setFlags(subItem->flags() & ~Qt::ItemIsDragEnabled); ui->bsaList->addTopLevelItem(subItem); } subItem->addChild(iter->second); @@ -4649,7 +4650,7 @@ void MainWindow::on_bsaList_customContextMenuRequested(const QPoint &pos) menu.exec(ui->bsaList->mapToGlobal(pos)); } -void MainWindow::on_bsaList_itemChanged(QTreeWidgetItem*, int) +void MainWindow::on_bsaList_itemMoved() { saveArchiveList(); m_CheckBSATimer.start(500); diff --git a/src/mainwindow.h b/src/mainwindow.h index a96e5fcf..93a6af80 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -510,7 +510,7 @@ private slots: // ui slots void on_actionEndorseMO_triggered(); void on_bsaList_customContextMenuRequested(const QPoint &pos); - void on_bsaList_itemChanged(QTreeWidgetItem *item, int column); + void on_bsaList_itemMoved(); void on_btnRefreshData_clicked(); void on_categoriesList_customContextMenuRequested(const QPoint &pos); void on_compactBox_toggled(bool checked); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index b29136ff..73ca868e 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -577,7 +577,7 @@ p, li { white-space: pre-wrap; } QTabWidget::Rounded - 0 + 1 @@ -725,7 +725,7 @@ p, li { white-space: pre-wrap; } 6 - + Qt::CustomContextMenu @@ -742,7 +742,7 @@ BSAs checked here are loaded in such a way that your installation order is obeye QAbstractItemView::NoEditTriggers - false + true false @@ -751,10 +751,10 @@ BSAs checked here are loaded in such a way that your installation order is obeye false - QAbstractItemView::NoDragDrop + QAbstractItemView::DragDrop - Qt::IgnoreAction + Qt::MoveAction QAbstractItemView::SingleSelection @@ -768,6 +768,12 @@ BSAs checked here are loaded in such a way that your installation order is obeye true + + 1 + + + false + 200 @@ -776,11 +782,6 @@ BSAs checked here are loaded in such a way that your installation order is obeye File - - - Mod - - @@ -1224,6 +1225,11 @@ Right now this has very limited functionality QTreeView
modlistview.h
+ + MOBase::SortableTreeWidget + QTreeWidget +
sortabletreewidget.h
+
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(image.width()) / static_cast(image.height()) > 1.34) { - image = image.scaledToWidth(128); - } else { - image = image.scaledToHeight(96); - } + if (!image.isNull()) { + if (static_cast(image.width()) / static_cast(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); -- cgit v1.3.1