Call busy indicator from C++
Given the number of identical calls, most pool retrieval functions have been also aggregated in a single function, postDownload.
This commit is contained in:
parent
59ccfb3aac
commit
532d93ae2f
2 changed files with 34 additions and 18 deletions
|
@ -117,6 +117,9 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
|
|||
m_view->rootObject()->setProperty("poolMode", QVariant(false));
|
||||
ctxt->setContextProperty("infiniteScroll", DanbooruSettings::self()->infiniteScrolling());
|
||||
|
||||
auto rootObj = m_view->rootObject();
|
||||
connect(m_service, SIGNAL(postDownloadFinished()), rootObj, SIGNAL(downloadFinished()));
|
||||
|
||||
statusBar()->addPermanentWidget(m_connectWidget);
|
||||
statusBar()->hide();
|
||||
|
||||
|
@ -145,9 +148,9 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
|
|||
actionCollection()->action(QLatin1String("morePosts"))->setEnabled(true);
|
||||
|
||||
if (DanbooruSettings::self()->autoDownload()) {
|
||||
m_view->rootObject()->setProperty("poolMode", QVariant(false));
|
||||
m_service->setPostTags(QStringList());
|
||||
m_service->getPostList();
|
||||
|
||||
postDownload(QStringList(), false);
|
||||
|
||||
}
|
||||
m_connectWidget->hide();
|
||||
statusBar()->hide();
|
||||
|
@ -173,6 +176,7 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
|
|||
auto pool = m_poolModel->poolAt(index.row());
|
||||
clearModels();
|
||||
m_view->rootObject()->setProperty("poolMode", QVariant(true));
|
||||
QMetaObject::invokeMethod(m_view->rootObject(), "downloadStarted");
|
||||
m_service->getPool(pool->id());
|
||||
|
||||
});
|
||||
|
@ -182,11 +186,8 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
|
|||
QDockWidget* searchDockWidget = findChild<QDockWidget*>(QLatin1String("SearchView"));
|
||||
searchDockWidget->hide();
|
||||
|
||||
clearModels();
|
||||
m_service->setPostTags(m_searchWidget->selectedTags());
|
||||
m_view->rootObject()->setProperty("poolMode", QVariant(false));
|
||||
m_service->getPostList();
|
||||
m_service->getRelatedTags(m_searchWidget->selectedTags());
|
||||
postDownload(m_searchWidget->selectedTags(), true /* relatedTags */);
|
||||
|
||||
});
|
||||
|
||||
connect(m_searchWidget, &DanbooruSearchWidget::rejected, [this]() {
|
||||
|
@ -348,7 +349,11 @@ void DanbooruMainWindow::setupActions()
|
|||
|
||||
});
|
||||
|
||||
connect(nextPageAction, &QAction::triggered, [this]() {m_service->nextPostPage();});
|
||||
connect(nextPageAction, &QAction::triggered, [this]() {
|
||||
QMetaObject::invokeMethod(m_view->rootObject(), "downloadStarted");
|
||||
m_service->nextPostPage();
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
@ -429,10 +434,8 @@ void DanbooruMainWindow::downloadPosts()
|
|||
return;
|
||||
}
|
||||
|
||||
clearModels();
|
||||
m_service->setPostTags(QStringList());
|
||||
m_view->rootObject()->setProperty("poolMode", QVariant(false));
|
||||
m_service->getPostList();
|
||||
|
||||
postDownload(QStringList(), false);
|
||||
|
||||
}
|
||||
|
||||
|
@ -499,11 +502,8 @@ void DanbooruMainWindow::searchTag(const QModelIndex &index)
|
|||
|
||||
QString tagName = m_tagModel->itemAt(index.row())->name();
|
||||
QStringList tags = {tagName};
|
||||
clearModels();
|
||||
m_view->rootObject()->setProperty("poolMode", QVariant(false));
|
||||
m_service->getRelatedTags(tags);
|
||||
m_service->setPostTags(tags);
|
||||
m_service->getPostList();
|
||||
|
||||
postDownload(tags, true /* relatedTags */);
|
||||
|
||||
}
|
||||
|
||||
|
@ -516,4 +516,19 @@ void DanbooruMainWindow::clearModels()
|
|||
|
||||
}
|
||||
|
||||
|
||||
void DanbooruMainWindow::postDownload(const QStringList &tags, bool relatedTags)
|
||||
{
|
||||
clearModels();
|
||||
m_view->rootObject()->setProperty("poolMode", QVariant(false));
|
||||
m_service->setPostTags(tags);
|
||||
|
||||
if(relatedTags) {
|
||||
m_service->getRelatedTags(tags);
|
||||
}
|
||||
|
||||
QMetaObject::invokeMethod(m_view->rootObject(), "downloadStarted");
|
||||
m_service->getPostList();
|
||||
}
|
||||
|
||||
} // namespace Danbooru
|
||||
|
|
|
@ -93,6 +93,7 @@ private:
|
|||
void setupDockWidgets();
|
||||
void setupConnections();
|
||||
void clearModels();
|
||||
void postDownload(const QStringList& tags = QStringList(), bool relatedTags = false);
|
||||
|
||||
private Q_SLOTS:
|
||||
void connectToBoard();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue