From 4ef2a79a1985ba9366f15b41382b20e35cb72e97 Mon Sep 17 00:00:00 2001 From: derrod Date: Tue, 17 Aug 2021 13:44:59 +0200 Subject: [PATCH] UI: Show loading indicator while fetching YouTube Events --- UI/data/locale/en-US.ini | 1 + UI/window-youtube-actions.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index 88f8ba3af..c37557ed8 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -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." diff --git a/UI/window-youtube-actions.cpp b/UI/window-youtube-actions.cpp index 668147c62..eda0a25d8 100644 --- a/UI/window-youtube-actions.cpp +++ b/UI/window-youtube-actions.cpp @@ -135,6 +135,22 @@ OBSYoutubeActions::OBSYoutubeActions(QWidget *parent, Auth *auth) qDeleteAll(ui->scrollAreaWidgetContents->findChildren( QString(), Qt::FindDirectChildrenOnly)); + // Add label indicating loading state + QLabel *loadingLabel = new QLabel(); + loadingLabel->setTextFormat(Qt::RichText); + loadingLabel->setAlignment(Qt::AlignHCenter); + loadingLabel->setText( + QString("%1") + .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())