window-youtube-actions.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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, bool astart, bool astop);
  21. void failed();
  22. };
  23. class OBSYoutubeActions : public QDialog {
  24. Q_OBJECT
  25. std::unique_ptr<Ui::OBSYoutubeActions> ui;
  26. signals:
  27. void ok(const QString &id, const QString &key, bool autostart,
  28. bool autostop);
  29. protected:
  30. void UpdateOkButtonStatus();
  31. bool StreamNowAction(YoutubeApiWrappers *api,
  32. StreamDescription &stream);
  33. bool StreamLaterAction(YoutubeApiWrappers *api);
  34. bool ChooseAnEventAction(YoutubeApiWrappers *api,
  35. StreamDescription &stream, bool start);
  36. void ShowErrorDialog(QWidget *parent, QString text);
  37. public:
  38. explicit OBSYoutubeActions(QWidget *parent, Auth *auth);
  39. virtual ~OBSYoutubeActions() override;
  40. bool Valid() { return valid; };
  41. private:
  42. void InitBroadcast();
  43. void UiToBroadcast(BroadcastDescription &broadcast);
  44. void OpenYouTubeDashboard();
  45. void Cancel();
  46. void Accept();
  47. QString selectedBroadcast;
  48. bool autostart, autostop;
  49. bool valid = false;
  50. YoutubeApiWrappers *apiYouTube;
  51. WorkerThread *workerThread;
  52. };