obs-studio/UI/window-youtube-actions.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

85 lines
2.1 KiB
C++
Raw Normal View History

2021-06-27 22:30:00 +00:00
#pragma once
#include <QDialog>
#include <QString>
#include <QThread>
#include "ui_OBSYoutubeActions.h"
#include "youtube-api-wrappers.hpp"
class WorkerThread : public QThread {
Q_OBJECT
public:
WorkerThread(YoutubeApiWrappers *api) : QThread(), apiYouTube(api) {}
void stop() { pending = false; }
protected:
YoutubeApiWrappers *apiYouTube;
bool pending = true;
public slots:
void run() override;
signals:
void ready();
void new_item(const QString &title, const QString &dateTimeString,
const QString &broadcast, const QString &status,
bool astart, bool astop);
2021-06-27 22:30:00 +00:00
void failed();
};
class OBSYoutubeActions : public QDialog {
Q_OBJECT
Q_PROPERTY(QIcon thumbPlaceholder READ GetPlaceholder WRITE
SetPlaceholder DESIGNABLE true)
2021-06-27 22:30:00 +00:00
std::unique_ptr<Ui::OBSYoutubeActions> ui;
signals:
void ok(const QString &broadcast_id, const QString &stream_id,
const QString &key, bool autostart, bool autostop,
bool start_now);
2021-06-27 22:30:00 +00:00
protected:
void showEvent(QShowEvent *event) override;
2021-06-27 22:30:00 +00:00
void UpdateOkButtonStatus();
bool CreateEventAction(YoutubeApiWrappers *api,
BroadcastDescription &broadcast,
StreamDescription &stream, bool stream_later,
bool ready_broadcast = false);
2021-06-27 22:30:00 +00:00
bool ChooseAnEventAction(YoutubeApiWrappers *api,
StreamDescription &stream);
2021-06-27 22:30:00 +00:00
void ShowErrorDialog(QWidget *parent, QString text);
public:
explicit OBSYoutubeActions(QWidget *parent, Auth *auth,
bool broadcastReady);
2021-06-27 22:30:00 +00:00
virtual ~OBSYoutubeActions() override;
bool Valid() { return valid; };
private:
void InitBroadcast();
void ReadyBroadcast();
2021-06-27 22:30:00 +00:00
void UiToBroadcast(BroadcastDescription &broadcast);
void OpenYouTubeDashboard();
void Cancel();
void Accept();
void SaveSettings(BroadcastDescription &broadcast);
void LoadSettings();
2021-06-27 22:30:00 +00:00
QIcon GetPlaceholder() { return thumbPlaceholder; }
void SetPlaceholder(const QIcon &icon) { thumbPlaceholder = icon; }
2021-06-27 22:30:00 +00:00
QString selectedBroadcast;
bool autostart, autostop;
bool valid = false;
YoutubeApiWrappers *apiYouTube;
WorkerThread *workerThread = nullptr;
bool broadcastReady = false;
QString thumbnailFile;
QIcon thumbPlaceholder;
2021-06-27 22:30:00 +00:00
};