CuteLogger
Fast and simple logging solution for Qt based applications
player.h
1 /*
2  * Copyright (c) 2012-2018 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 
45 class Player : public QWidget
46 {
47  Q_OBJECT
48 public:
49  typedef enum {
50  SourceTabIndex = 0,
51  ProjectTabIndex
52  } TabIndex;
53 
54  explicit Player(QWidget *parent = 0);
55  void connectTransport(const TransportControllable*);
56  void setIn(int);
57  void setOut(int);
58  void setMarkers(const QList<int>&);
59  QSize videoSize() const;
60  int position() const {
61  return m_position;
62  }
63  void moveVideoToScreen(int screen = -1);
64  void setPauseAfterOpen(bool pause);
65  TabIndex tabIndex() const;
66 
67 signals:
68  void endOfStream();
69  void showStatusMessage(QString);
70  void inChanged(int delta);
71  void outChanged(int delta);
72  void played(double speed);
73  void paused();
74  void stopped();
75  void seeked(int position);
76  void rewound(bool forceChangeDirection);
77  void fastForwarded(bool forceChangeDirection);
78  void previousSought(int currentPosition);
79  void previousSought();
80  void nextSought(int currentPosition);
81  void nextSought();
82  void zoomChanged(float zoom);
83  void gridChanged(int grid);
84  void scrolledHorizontally(int x);
85  void scrolledVertically(int y);
86  void tabIndexChanged(int index);
87 
88 public slots:
89  void play(double speed = 1.0);
90  void pause();
91  void stop();
92  void togglePlayPaused();
93  void seek(int position);
94  void reset();
95  void onProducerOpened(bool play = true);
96  void postProducerOpened();
97  void onMeltedUnitOpened();
98  void onDurationChanged();
99  void onFrameDisplayed(const SharedFrame& frame);
100  void onVolumeChanged(int);
101  void onCaptureStateChanged(bool);
102  void rewind(bool forceChangeDirection = true);
103  void fastForward(bool forceChangeDirection = true);
104  void showPaused();
105  void showPlaying();
106  void switchToTab(TabIndex index);
107  void enableTab(TabIndex index, bool enabled = true);
108  void onTabBarClicked(int index);
109  void setStatusLabel(const QString& text, int timeoutSeconds, QAction* action);
110 
111 protected:
112  void resizeEvent(QResizeEvent* event);
113 
114 private:
115  void setupActions(QWidget* widget);
116  void retranslateUi(QWidget* widget);
117  void adjustScrollBars(float horizontal, float vertical);
118  double setVolume(int volume);
119 
120  QAction *actionPlay;
121  QAction *actionPause;
122  QAction *actionSkipNext;
123  QAction *actionSkipPrevious;
124  QAction *actionRewind;
125  QAction *actionFastForward;
126  QAction *actionVolume;
127 
128  ScrubBar* m_scrubber;
129  TimeSpinBox* m_positionSpinner;
130  QLabel* m_durationLabel;
131  QLabel* m_inPointLabel;
132  QLabel* m_selectedLabel;
133  int m_position;
134  int m_playPosition;
135  QIcon m_playIcon;
136  QIcon m_pauseIcon;
137  QFrame* m_volumePopup;
138  QSlider* m_volumeSlider;
139  QWidget* m_volumeWidget;
140  QPushButton* m_muteButton;
141  int m_previousIn;
142  int m_previousOut;
143  double m_savedVolume;
144  int m_duration;
145  bool m_isSeekable;
146  int m_isMeltedPlaying;
147  QScrollBar* m_horizontalScroll;
148  QScrollBar* m_verticalScroll;
149  QToolButton* m_zoomButton;
150  QAction* m_zoomFitAction;
151  QAction* m_zoomOriginalAction;
152  QAction* m_zoomOutAction50;
153  QAction* m_zoomOutAction25;
154  QAction* m_zoomOutAction10;
155  QAction* m_zoomInAction;
156  QToolButton* m_gridButton;
157  QActionGroup* m_gridActionGroup;
158  QAction* m_gridDefaultAction;
159  float m_zoomToggleFactor;
160  QTabBar* m_tabs;
161  bool m_pauseAfterOpen;
162  int m_monitorScreen;
163  QWidget* m_videoWidget;
164  QHBoxLayout* m_videoLayout;
165  QWidget* m_videoScrollWidget;
166  const TransportControllable* m_currentTransport;
167  QPushButton * m_statusLabel;
168  QPropertyAnimation* m_statusFadeIn;
169  QPropertyAnimation* m_statusFadeOut;
170  QTimer m_statusTimer;
171 
172 private slots:
173  void updateSelection();
174  void onInChanged(int in);
175  void onOutChanged(int out);
176  void on_actionSkipNext_triggered();
177  void on_actionSkipPrevious_triggered();
178  void on_actionVolume_triggered();
179  void onMuteButtonToggled(bool checked);
180  void setZoom(float factor, const QIcon &icon);
181  void zoomFit();
182  void zoomOriginal();
183  void zoomOut50();
184  void zoomOut25();
185  void zoomOut10();
186  void zoomIn();
187  void toggleZoom(bool checked);
188  void grid2();
189  void grid3();
190  void grid4();
191  void grid16();
192  void gridSafeAreas8090();
193  void gridSafeAreasEbuR95();
194  void toggleGrid(bool checked);
195  void onFadeOutFinished();
196 };
197 
198 #endif // PLAYER_H
The SharedFrame provides thread safe access to Mlt::Frame data.
Definition: sharedframe.h:48