From c7a90f9506c4711176808f4aeb0b0380a9496fc7 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 20 Jul 2020 19:09:12 -0400 Subject: added turkish translator --- src/aboutdialog.ui | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/aboutdialog.ui b/src/aboutdialog.ui index e34d36f9..88cc96e3 100644 --- a/src/aboutdialog.ui +++ b/src/aboutdialog.ui @@ -395,6 +395,11 @@ Nubbie (Swedish) + + + Hakan "Nyks45" Albayrak (Turkish) + + ...and all other contributors! -- cgit v1.3.1 From 4adfeac9b79318a49f99b978a9f3cf160f1b9afd Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 20 Jul 2020 19:26:33 -0400 Subject: shift+ and ctrl+double-click in mod list will now only open one mod instead of the whole selection since these modifiers are also used for selecting, this is too error prone and users have reported opening a crapload of tabs in their browser or explorer windows --- src/mainwindow.cpp | 66 ++++++++++++++++++++++++++---------------------------- src/mainwindow.h | 3 ++- 2 files changed, 34 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index dfe0fbde..962e401e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3309,6 +3309,29 @@ void MainWindow::visitWebPage_clicked() } } +void MainWindow::visitNexusOrWebPage(const QModelIndex& idx) +{ + int row_idx = idx.data(Qt::UserRole + 1).toInt(); + + ModInfo::Ptr info = ModInfo::getByIndex(row_idx); + if (!info) { + log::error("mod {} not found", row_idx); + return; + } + + int modID = info->getNexusID(); + QString gameName = info->getGameName(); + const auto url = info->parseCustomURL(); + + if (modID > 0) { + linkClicked(NexusInterface::instance(&m_PluginContainer)->getModURL(modID, gameName)); + } else if (url.isValid()) { + linkClicked(url.toString()); + } else { + log::error("mod '{}' has no valid link", info->name()); + } +} + void MainWindow::visitNexusOrWebPage_clicked() { QItemSelectionModel* selection = ui->modList->selectionModel(); if (selection->hasSelection() && selection->selectedRows().count() > 1) { @@ -3320,43 +3343,14 @@ void MainWindow::visitNexusOrWebPage_clicked() { return; } } - int row_idx; - ModInfo::Ptr info; - QString gameName; for (QModelIndex idx : selection->selectedRows()) { - row_idx = idx.data(Qt::UserRole + 1).toInt(); - info = ModInfo::getByIndex(row_idx); - int modID = info->getNexusID(); - gameName = info->getGameName(); - const auto url = info->parseCustomURL(); - if (modID > 0) { - linkClicked(NexusInterface::instance(&m_PluginContainer)->getModURL(modID, gameName)); - } - else if (url.isValid()) { - linkClicked(url.toString()); - } - else { - log::error("mod '{}' has no valid link", info->name()); - } + visitNexusOrWebPage(idx); } } else { - int modID = m_OrganizerCore.modList()->data(m_OrganizerCore.modList()->index(m_ContextRow, 0), Qt::UserRole).toInt(); - QString gameName = m_OrganizerCore.modList()->data(m_OrganizerCore.modList()->index(m_ContextRow, 0), Qt::UserRole + 4).toString(); - if (modID > 0) { - linkClicked(NexusInterface::instance(&m_PluginContainer)->getModURL(modID, gameName)); - } - else { - ModInfo::Ptr info = ModInfo::getByIndex(m_ContextRow); - const auto url = info->parseCustomURL(); - if (url.isValid()) { - linkClicked(url.toString()); - } - else { - MessageDialog::showMessage(tr("No valid Web Page for this mod"), this); - } - } + QModelIndex idx = m_OrganizerCore.modList()->index(m_ContextRow, 0); + visitNexusOrWebPage(idx); } } @@ -3865,7 +3859,10 @@ void MainWindow::on_modList_doubleClicked(const QModelIndex &index) if (modifiers.testFlag(Qt::ControlModifier)) { try { m_ContextRow = m_ModListSortProxy->mapToSource(index).row(); - openExplorer_clicked(); + + ModInfo::Ptr modInfo = ModInfo::getByIndex(m_ContextRow); + shell::Explore(modInfo->absolutePath()); + // workaround to cancel the editor that might have opened because of // selection-click ui->modList->closePersistentEditor(index); @@ -3877,7 +3874,8 @@ void MainWindow::on_modList_doubleClicked(const QModelIndex &index) else if (modifiers.testFlag(Qt::ShiftModifier)) { try { m_ContextRow = m_ModListSortProxy->mapToSource(index).row(); - visitNexusOrWebPage_clicked(); + QModelIndex idx = m_OrganizerCore.modList()->index(m_ContextRow, 0); + visitNexusOrWebPage(idx); ui->modList->closePersistentEditor(index); } catch (const std::exception & e) { diff --git a/src/mainwindow.h b/src/mainwindow.h index 60f22770..814e0363 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -251,7 +251,7 @@ private: void fixCategories(); bool extractProgress(QProgressDialog &extractProgress, int percentage, std::string fileName); - + // Performs checks, sets the m_NumberOfProblems and signals checkForProblemsDone(). void checkForProblemsImpl(); @@ -498,6 +498,7 @@ private slots: ModListSortProxy::FilterMode mode, ModListSortProxy::SeparatorsMode sep); void displayModInformation(const QString &modName, ModInfoTabIDs tabID); + void visitNexusOrWebPage(const QModelIndex& idx); void modRenamed(const QString &oldName, const QString &newName); void modRemoved(const QString &fileName); -- cgit v1.3.1 From 82cc488a18e54d27b10f8fea1cc7f5c435af316e Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 20 Jul 2020 20:01:46 -0400 Subject: conflict model didn't change persistent indexes when sorting --- src/modinfodialogconflictsmodels.cpp | 72 ++++++++++++++++++++++++++++++------ src/modinfodialogconflictsmodels.h | 3 ++ 2 files changed, 63 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/modinfodialogconflictsmodels.cpp b/src/modinfodialogconflictsmodels.cpp index e8ad19ad..17fdef90 100644 --- a/src/modinfodialogconflictsmodels.cpp +++ b/src/modinfodialogconflictsmodels.cpp @@ -96,6 +96,7 @@ ConflictListModel::ConflictListModel(QTreeView* tree, std::vector column void ConflictListModel::clear() { + beginResetModel(); m_items.clear(); endResetModel(); } @@ -129,16 +130,39 @@ int ConflictListModel::columnCount(const QModelIndex&) const return static_cast(m_columns.size()); } -QVariant ConflictListModel::data(const QModelIndex& index, int role) const +const ConflictItem* ConflictListModel::itemFromIndex( + const QModelIndex& index) const { - if (role == Qt::DisplayRole || role == Qt::FontRole) { - const auto row = index.row(); - if (row < 0) { - return {}; + const auto row = index.row(); + if (row < 0) { + return nullptr; + } + + const auto i = static_cast(row); + if (i >= m_items.size()) { + return nullptr; + } + + return &m_items[i]; +} + +QModelIndex ConflictListModel::indexFromItem( + const ConflictItem* item, int col) +{ + for (std::size_t i=0; i(i), col); } + } + + return {}; +} - const auto i = static_cast(row); - if (i >= m_items.size()) { +QVariant ConflictListModel::data(const QModelIndex& index, int role) const +{ + if (role == Qt::DisplayRole || role == Qt::FontRole) { + const ConflictItem* item = itemFromIndex(index); + if (!item) { return {}; } @@ -152,12 +176,10 @@ QVariant ConflictListModel::data(const QModelIndex& index, int role) const return {}; } - const auto& item = m_items[i]; - if (role == Qt::DisplayRole) { - return (item.*m_columns[c].getText)(); + return (item->*m_columns[c].getText)(); } else if (role == Qt::FontRole) { - if (item.isArchive()) { + if (item->isArchive()) { QFont f = m_tree->font(); f.setItalic(true); return f; @@ -191,7 +213,31 @@ void ConflictListModel::sort(int colIndex, Qt::SortOrder order) m_sortColumn = colIndex; m_sortOrder = order; + emit layoutAboutToBeChanged({}, QAbstractItemModel::VerticalSortHint); + + const auto oldList = persistentIndexList(); + std::vector> oldItems; + + const auto itemCount = oldList.size(); + oldItems.reserve(static_cast(itemCount)); + + for (int i=0; i(i)]; + newList.append(indexFromItem(pair.first, pair.second)); + } + + changePersistentIndexList(oldList, newList); + emit layoutChanged({}, QAbstractItemModel::VerticalSortHint); } @@ -202,8 +248,10 @@ void ConflictListModel::add(ConflictItem item) void ConflictListModel::finished() { + beginResetModel(); endResetModel(); - doSort(); + + sort(m_sortColumn, m_sortOrder); } const ConflictItem* ConflictListModel::getItem(std::size_t row) const diff --git a/src/modinfodialogconflictsmodels.h b/src/modinfodialogconflictsmodels.h index a37e85c8..e12460b1 100644 --- a/src/modinfodialogconflictsmodels.h +++ b/src/modinfodialogconflictsmodels.h @@ -78,6 +78,9 @@ private: int m_sortColumn; Qt::SortOrder m_sortOrder; + const ConflictItem* itemFromIndex(const QModelIndex& index) const; + QModelIndex indexFromItem(const ConflictItem* item, int col); + void doSort(); }; -- cgit v1.3.1 From a965a9dc41c50988c7d3629fdc5965c20053937d Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 20 Jul 2020 20:05:15 -0400 Subject: added confirmation for sorting, some users click it by mistake --- src/mainwindow.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 962e401e..55e0a593 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -6218,6 +6218,16 @@ void MainWindow::on_showHiddenBox_toggled(bool checked) void MainWindow::on_bossButton_clicked() { + const auto r = QMessageBox::question( + this, tr("Sorting plugins"), + tr("Are you sure you want to sort your plugins list?"), + QMessageBox::Yes | QMessageBox::No); + + if (r != QMessageBox::Yes) { + return; + } + + m_OrganizerCore.savePluginList(); setEnabled(false); -- cgit v1.3.1