summaryrefslogtreecommitdiff
path: root/src/modlistview.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2021-01-10 19:29:41 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-10 19:29:41 +0100
commit32e441897fb5dc5d49764c8ce2cb8b3475bcdd20 (patch)
tree4ae026e61cb2c397229df590b01a8b39278b0c45 /src/modlistview.cpp
parent5bb48d5e525660ba408d586226754a0f00326bb5 (diff)
Request window focus when dropping external folder and scroll to new mod.
Diffstat (limited to 'src/modlistview.cpp')
-rw-r--r--src/modlistview.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/modlistview.cpp b/src/modlistview.cpp
index c23cd34b..13c34226 100644
--- a/src/modlistview.cpp
+++ b/src/modlistview.cpp
@@ -390,6 +390,15 @@ void ModListView::setSelected(const QModelIndex& current, const QModelIndexList&
}
}
+void ModListView::scrollToAndSelect(const QModelIndex& index)
+{
+ // focus, scroll to and select
+ scrollTo(index);
+ setCurrentIndex(index);
+ selectionModel()->select(index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
+ QTimer::singleShot(0, [=] { setFocus(); });
+}
+
void ModListView::refreshExpandedItems()
{
auto* model = m_sortProxy->sourceModel();
@@ -470,11 +479,7 @@ void ModListView::onModInstalled(const QString& modName)
setExpanded(qIndex.parent(), true);
}
- // focus, scroll to and select
- setFocus(Qt::OtherFocusReason);
- scrollTo(qIndex);
- setCurrentIndex(qIndex);
- selectionModel()->select(qIndex, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
+ scrollToAndSelect(qIndex);
}
void ModListView::onModFilterActive(bool filterActive)
@@ -589,6 +594,8 @@ void ModListView::refreshFilters()
void ModListView::onExternalFolderDropped(const QUrl& url, int priority)
{
+ setWindowState(Qt::WindowActive);
+
QFileInfo fileInfo(url.toLocalFile());
GuessedValue<QString> name;
@@ -624,9 +631,12 @@ void ModListView::onExternalFolderDropped(const QUrl& url, int priority)
m_core->refresh();
+ const auto index = ModInfo::getIndex(name);
if (priority != -1) {
- m_core->modList()->changeModPriority(ModInfo::getIndex(name), priority);
+ m_core->modList()->changeModPriority(index, priority);
}
+
+ scrollToAndSelect(indexModelToView(m_core->modList()->index(index, 0)));
}
bool ModListView::moveSelection(int key)