diff options
| author | Tannin <devnull@localhost> | 2013-10-26 15:02:31 +0200 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2013-10-26 15:02:31 +0200 |
| commit | 09bd3dbead9afd6a57684908e77aba6960ad464d (patch) | |
| tree | 4b0d4e5901473c66b007b33c0100d8941841b3ca /src | |
| parent | 8c0b309bdee2527fab66b00b34171ef18f5055bf (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')
| -rw-r--r-- | src/mainwindow.cpp | 11 | ||||
| -rw-r--r-- | src/mainwindow.h | 2 | ||||
| -rw-r--r-- | src/mainwindow.ui | 26 | ||||
| -rw-r--r-- | src/modinfodialog.cpp | 30 |
4 files changed, 42 insertions, 27 deletions
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; } <enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
- <number>0</number>
+ <number>1</number>
</property>
<widget class="QWidget" name="espTab">
<property name="sizePolicy">
@@ -725,7 +725,7 @@ p, li { white-space: pre-wrap; } <number>6</number>
</property>
<item>
- <widget class="QTreeWidget" name="bsaList">
+ <widget class="MOBase::SortableTreeWidget" name="bsaList">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
@@ -742,7 +742,7 @@ BSAs checked here are loaded in such a way that your installation order is obeye <set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="showDropIndicator" stdset="0">
- <bool>false</bool>
+ <bool>true</bool>
</property>
<property name="dragEnabled">
<bool>false</bool>
@@ -751,10 +751,10 @@ BSAs checked here are loaded in such a way that your installation order is obeye <bool>false</bool>
</property>
<property name="dragDropMode">
- <enum>QAbstractItemView::NoDragDrop</enum>
+ <enum>QAbstractItemView::DragDrop</enum>
</property>
<property name="defaultDropAction">
- <enum>Qt::IgnoreAction</enum>
+ <enum>Qt::MoveAction</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
@@ -768,6 +768,12 @@ BSAs checked here are loaded in such a way that your installation order is obeye <property name="itemsExpandable">
<bool>true</bool>
</property>
+ <property name="columnCount">
+ <number>1</number>
+ </property>
+ <attribute name="headerVisible">
+ <bool>false</bool>
+ </attribute>
<attribute name="headerDefaultSectionSize">
<number>200</number>
</attribute>
@@ -776,11 +782,6 @@ BSAs checked here are loaded in such a way that your installation order is obeye <string>File</string>
</property>
</column>
- <column>
- <property name="text">
- <string>Mod</string>
- </property>
- </column>
</widget>
</item>
<item>
@@ -1224,6 +1225,11 @@ Right now this has very limited functionality</string> <extends>QTreeView</extends>
<header>modlistview.h</header>
</customwidget>
+ <customwidget>
+ <class>MOBase::SortableTreeWidget</class>
+ <extends>QTreeWidget</extends>
+ <header>sortabletreewidget.h</header>
+ </customwidget>
</customwidgets>
<resources>
<include location="resources.qrc"/>
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); |
