NOISSUE only watch mod folders when the user is looking at them

This commit is contained in:
Petr Mrázek 2015-05-11 22:50:35 +02:00
parent 11c376f6f1
commit 88f975eff7
3 changed files with 13 additions and 1 deletions

View File

@ -47,12 +47,21 @@ ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<ModList> mods,
m_helpName = helpPage;
ui->modTreeView->setModel(m_mods.get());
ui->modTreeView->installEventFilter(this);
m_mods->startWatching();
auto smodel = ui->modTreeView->selectionModel();
connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
SLOT(modCurrent(QModelIndex, QModelIndex)));
}
void ModFolderPage::opened()
{
m_mods->startWatching();
}
void ModFolderPage::closed()
{
m_mods->stopWatching();
}
CoreModFolderPage::CoreModFolderPage(BaseInstance *inst, std::shared_ptr<ModList> mods,
QString id, QString iconName, QString displayName,
QString helpPage, QWidget *parent)

View File

@ -54,6 +54,8 @@ public:
}
virtual bool shouldDisplay() const;
virtual void opened();
virtual void closed();
protected:
bool eventFilter(QObject *obj, QEvent *ev);
bool modListFilter(QKeyEvent *ev);

View File

@ -38,6 +38,7 @@ ModList::ModList(const QString &dir, const QString &list_file)
void ModList::startWatching()
{
update();
is_watching = m_watcher->addPath(m_dir.absolutePath());
if (is_watching)
{