Ver código fonte

UI: Show loading indicator while fetching YouTube Events

derrod 4 anos atrás
pai
commit
4ef2a79a19
2 arquivos alterados com 17 adições e 0 exclusões
  1. 1 0
      UI/data/locale/en-US.ini
  2. 16 0
      UI/window-youtube-actions.cpp

+ 1 - 0
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."
 

+ 16 - 0
UI/window-youtube-actions.cpp

@@ -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())