play_control_window.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef AVPLAYER2_PLAY_CONTROL_WINDOW_H
  2. #define AVPLAYER2_PLAY_CONTROL_WINDOW_H
  3. #pragma once
  4. #include <QSlider>
  5. #include <QWidget>
  6. #include <memory>
  7. #include <QPushButton>
  8. #include <QLabel>
  9. #include <QCheckBox>
  10. #include <QHBoxLayout>
  11. #include <QVBoxLayout>
  12. #include <QGridLayout>
  13. #include "clickable_slider.h"
  14. QT_BEGIN_NAMESPACE
  15. namespace Ui
  16. {
  17. class play_control_window;
  18. };
  19. QT_END_NAMESPACE
  20. class PlayerController;
  21. class PlayControlWnd : public QWidget
  22. {
  23. Q_OBJECT
  24. public:
  25. explicit PlayControlWnd(PlayerController* playerController, QWidget* parent = Q_NULLPTR);
  26. ~PlayControlWnd();
  27. public:
  28. void update_play_time(int64_t total_secs);
  29. void set_total_time(int64_t hours, int64_t mins, int64_t secs);
  30. inline QSlider* get_progress_slider() const;
  31. inline QSlider* get_volume_slider() const;
  32. inline QSlider* get_speed_slider() const;
  33. int get_volum_slider_max();
  34. int get_progress_slider_max();
  35. int get_progress_slider_value();
  36. void set_volume_slider(float volume);
  37. void clear_all();
  38. void update_btn_play(bool bPause = true);
  39. double get_total_time() const;
  40. double get_speed() const;
  41. void speed_adjust(bool up = true);
  42. public:
  43. static void get_play_time_params(int64_t total_secs, int64_t& hours, int64_t& mins, int64_t& secs);
  44. static QString get_play_time(int64_t hours, int64_t mins, int64_t secs);
  45. static inline double get_time_secs(int64_t hours, int64_t mins, int64_t secs);
  46. public slots:
  47. void volume_muted(int mute);
  48. void speed_changed(int speed);
  49. private:
  50. void enable_progressbar(bool enable = true);
  51. void enable_slider_vol(bool enable = true);
  52. void enable_slider_speed(bool enable = true);
  53. void init_slider_speed();
  54. void clear_time();
  55. void enable_play_buttons(bool enable = true);
  56. void update_play_time(int64_t hours, int64_t mins, int64_t secs);
  57. void set_progress_bar(double total_secs);
  58. void set_focus_policy();
  59. void keyPressEvent(QKeyEvent* event) override;
  60. private:
  61. // UI控件成员
  62. QPushButton* btn_pre = nullptr;
  63. QPushButton* btn_play = nullptr;
  64. QPushButton* btn_next = nullptr;
  65. QPushButton* btn_stop = nullptr;
  66. QSlider* slider_speed = nullptr;
  67. QLabel* label_speed = nullptr;
  68. QCheckBox* check_mute = nullptr;
  69. QSlider* slider_vol = nullptr;
  70. QLabel* label_vol = nullptr;
  71. ClickableSlider* progress_slider = nullptr;
  72. QLabel* label_curTime = nullptr;
  73. QLabel* label_totalTime = nullptr;
  74. QLabel* label_divider = nullptr;
  75. QGridLayout* gridLayout = nullptr;
  76. QHBoxLayout* hLayout_controls = nullptr;
  77. QHBoxLayout* hLayout_progress = nullptr;
  78. QVBoxLayout* mainLayout = nullptr;
  79. // ... 其它需要的布局和控件 ...
  80. int64_t m_hours{0};
  81. int64_t m_mins{0};
  82. int64_t m_secs{0};
  83. };
  84. #endif // AVPLAYER2_PLAY_CONTROL_WINDOW_H