window-youtube-actions.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #pragma once
  2. #include <QDialog>
  3. #include <QString>
  4. #include <QThread>
  5. #include "ui_OBSYoutubeActions.h"
  6. #include "youtube-api-wrappers.hpp"
  7. class WorkerThread : public QThread {
  8. Q_OBJECT
  9. public:
  10. WorkerThread(YoutubeApiWrappers *api) : QThread(), apiYouTube(api) {}
  11. void stop() { pending = false; }
  12. protected:
  13. YoutubeApiWrappers *apiYouTube;
  14. bool pending = true;
  15. public slots:
  16. void run() override;
  17. signals:
  18. void ready();
  19. void new_item(const QString &title, const QString &dateTimeString,
  20. const QString &broadcast, const QString &status,
  21. bool astart, bool astop);
  22. void failed();
  23. };
  24. class OBSYoutubeActions : public QDialog {
  25. Q_OBJECT
  26. std::unique_ptr<Ui::OBSYoutubeActions> ui;
  27. signals:
  28. void ok(const QString &id, const QString &key, bool autostart,
  29. bool autostop, bool start_now);
  30. protected:
  31. void UpdateOkButtonStatus();
  32. bool CreateEventAction(YoutubeApiWrappers *api,
  33. StreamDescription &stream, bool stream_later,
  34. bool ready_broadcast = false);
  35. bool ChooseAnEventAction(YoutubeApiWrappers *api,
  36. StreamDescription &stream);
  37. void ShowErrorDialog(QWidget *parent, QString text);
  38. public:
  39. explicit OBSYoutubeActions(QWidget *parent, Auth *auth,
  40. bool broadcastReady);
  41. virtual ~OBSYoutubeActions() override;
  42. bool Valid() { return valid; };
  43. private:
  44. void InitBroadcast();
  45. void ReadyBroadcast();
  46. void UiToBroadcast(BroadcastDescription &broadcast);
  47. void OpenYouTubeDashboard();
  48. void Cancel();
  49. void Accept();
  50. QString selectedBroadcast;
  51. bool autostart, autostop;
  52. bool valid = false;
  53. bool broadcastReady = false;
  54. YoutubeApiWrappers *apiYouTube;
  55. WorkerThread *workerThread;
  56. };