OBSYoutubeActions.hpp 2.0 KB

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