UI: Show loading indicator while fetching YouTube Events

This commit is contained in:
derrod
2021-08-17 13:44:59 +02:00
committed by Rodney
parent a4d37dba73
commit 4ef2a79a19
2 changed files with 17 additions and 0 deletions

View File

@@ -1223,6 +1223,7 @@ YouTube.Actions.Error.NoStreamCreated="No stream created. Please relink your acc
YouTube.Actions.Error.YouTubeApi="YouTube API Error. Please see the log file for more information."
YouTube.Actions.Error.BroadcastNotFound="The selected broadcast was not found."
YouTube.Actions.EventsLoading="Loading list of events..."
YouTube.Actions.EventCreated.Title="Event Created"
YouTube.Actions.EventCreated.Text="Event successfully created."

View File

@@ -135,6 +135,22 @@ OBSYoutubeActions::OBSYoutubeActions(QWidget *parent, Auth *auth)
qDeleteAll(ui->scrollAreaWidgetContents->findChildren<QWidget *>(
QString(), Qt::FindDirectChildrenOnly));
// Add label indicating loading state
QLabel *loadingLabel = new QLabel();
loadingLabel->setTextFormat(Qt::RichText);
loadingLabel->setAlignment(Qt::AlignHCenter);
loadingLabel->setText(
QString("<big>%1</big>")
.arg(QTStr("YouTube.Actions.EventsLoading")));
ui->scrollAreaWidgetContents->layout()->addWidget(loadingLabel);
// Delete "loading..." label on completion
connect(workerThread, &WorkerThread::finished, this, [&] {
QLayoutItem *item =
ui->scrollAreaWidgetContents->layout()->takeAt(0);
item->widget()->deleteLater();
});
connect(workerThread, &WorkerThread::failed, this, [&]() {
auto last_error = apiYouTube->GetLastError();
if (last_error.isEmpty())