CuteLogger
Fast and simple logging solution for Qt based applications
player.h
1 /*
2  * Copyright (c) 2012-2020 Meltytech, LLC
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef PLAYER_H
19 #define PLAYER_H
20 
21 #include <QWidget>
22 #include <QIcon>
23 #include <QSize>
24 #include <QTimer>
25 #include "sharedframe.h"
26 
27 class ScrubBar;
28 class QSpinBox;
29 class QLabel;
30 class TimeSpinBox;
31 class QFrame;
32 class QSlider;
33 class QAction;
34 class QActionGroup;
35 class QScrollBar;
36 class QToolButton;
37 class QTabBar;
38 class QHBoxLayout;
39 class QPushButton;
40 class TransportControllable;
41 class QLabel;
42 class QPropertyAnimation;
43 class QPushButton;
44 class QMenu;
45 class NewProjectFolder;
46 
47 class Player : public QWidget
48 {
49  Q_OBJECT
50 public:
51  typedef enum {
52  SourceTabIndex = 0,
53  ProjectTabIndex
54  } TabIndex;
55 
56  explicit Player(QWidget *parent = 0);
57  void connectTransport(const TransportControllable*);
58  void setIn(int);
59  void setOut(int);
60  void setMarkers(const QList<int>&);
61  QSize videoSize() const;
62  int position() const { return m_position; }
63  NewProjectFolder* projectWidget() const { return m_projectWidget; }
64  void moveVideoToScreen(int screen = -1);
65  void setPauseAfterOpen(bool pause);
66  TabIndex tabIndex() const;
67 
68 signals:
69  void endOfStream();
70  void showStatusMessage(QString);
71  void inChanged(int delta);
72  void outChanged(int delta);
73  void played(double speed);
74  void paused();
75  void stopped();
76  void seeked(int position);
77  void rewound(bool forceChangeDirection);
78  void fastForwarded(bool forceChangeDirection);
79  void previousSought(int currentPosition);
80  void previousSought();
81  void nextSought(int currentPosition);
82  void nextSought();
83  void zoomChanged(float zoom);
84  void gridChanged(int grid);
85  void scrolledHorizontally(int x);
86  void scrolledVertically(int y);
87  void tabIndexChanged(int index);
88 
89 public slots:
90  void play(double speed = 1.0);
91  void pause();
92  void stop();
93  void togglePlayPaused();
94  void seek(int position);
95  void reset();
96  void onProducerOpened(bool play = true);
97  void postProducerOpened();
98  void onMeltedUnitOpened();
99  void onDurationChanged();
100  void onFrameDisplayed(const SharedFrame& frame);
101  void onVolumeChanged(int);
102  void onCaptureStateChanged(bool);
103  void rewind(bool forceChangeDirection = true);
104  void fastForward(bool forceChangeDirection = true);
105  void showPaused();
106  void showPlaying();
107  void switchToTab(TabIndex index);
108  void enableTab(TabIndex index, bool enabled = true);
109  void onTabBarClicked(int index);
110  void setStatusLabel(const QString& text, int timeoutSeconds, QAction* action, QPalette::ColorRole role = QPalette::ToolTipBase);
111  void showIdleStatus();
112  void focusPositionSpinner() const;
113 
114 protected:
115  void resizeEvent(QResizeEvent* event) override;
116  bool event(QEvent* event) override;
117  void keyPressEvent(QKeyEvent* event) override;
118 
119 private:
120  void setupActions(QWidget* widget);
121  void retranslateUi(QWidget* widget);
122  void adjustScrollBars(float horizontal, float vertical);
123  double setVolume(int volume);
124 
125  QAction *actionPlay;
126  QAction *actionPause;
127  QAction *actionSkipNext;
128  QAction *actionSkipPrevious;
129  QAction *actionRewind;
130  QAction *actionFastForward;
131  QAction *actionVolume;
132 
133  ScrubBar* m_scrubber;
134  TimeSpinBox* m_positionSpinner;
135  QLabel* m_durationLabel;
136  QLabel* m_inPointLabel;
137  QLabel* m_selectedLabel;
138  int m_position;
139  int m_playPosition;
140  QIcon m_playIcon;
141  QIcon m_pauseIcon;
142  QFrame* m_volumePopup;
143  QSlider* m_volumeSlider;
144  QWidget* m_volumeWidget;
145  QPushButton* m_muteButton;
146  int m_previousIn;
147  int m_previousOut;
148  double m_savedVolume;
149  int m_duration;
150  bool m_isSeekable;
151  int m_isMeltedPlaying;
152  QScrollBar* m_horizontalScroll;
153  QScrollBar* m_verticalScroll;
154  QToolButton* m_zoomButton;
155  QToolButton* m_gridButton;
156  QActionGroup* m_gridActionGroup;
157  QAction* m_gridDefaultAction;
158  float m_zoomToggleFactor;
159  QTabBar* m_tabs;
160  bool m_pauseAfterOpen;
161  int m_monitorScreen;
162  QWidget* m_videoWidget;
163  QHBoxLayout* m_videoLayout;
164  QWidget* m_videoScrollWidget;
165  const TransportControllable* m_currentTransport;
166  QPushButton * m_statusLabel;
167  QPropertyAnimation* m_statusFadeIn;
168  QPropertyAnimation* m_statusFadeOut;
169  QTimer m_statusTimer;
170  QMenu* m_zoomMenu;
171  NewProjectFolder* m_projectWidget;
172 
173 private slots:
174  void updateSelection();
175  void onInChanged(int in);
176  void onOutChanged(int out);
177  void on_actionSkipNext_triggered();
178  void on_actionSkipPrevious_triggered();
179  void on_actionVolume_triggered();
180  void onMuteButtonToggled(bool checked);
181  void setZoom(float factor, const QIcon &icon);
182  void onZoomTriggered();
183  void toggleZoom(bool checked);
184  void onGridToggled();
185  void toggleGrid(bool checked);
186  void onFadeOutFinished();
187 };
188 
189 #endif // PLAYER_H
The SharedFrame provides thread safe access to Mlt::Frame data.
Definition: sharedframe.h:49