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);
111  void showIdleStatus();
112 
113 protected:
114  void resizeEvent(QResizeEvent* event) override;
115  bool event(QEvent* event) override;
116  void keyPressEvent(QKeyEvent* event) override;
117 
118 private:
119  void setupActions(QWidget* widget);
120  void retranslateUi(QWidget* widget);
121  void adjustScrollBars(float horizontal, float vertical);
122  double setVolume(int volume);
123 
124  QAction *actionPlay;
125  QAction *actionPause;
126  QAction *actionSkipNext;
127  QAction *actionSkipPrevious;
128  QAction *actionRewind;
129  QAction *actionFastForward;
130  QAction *actionVolume;
131 
132  ScrubBar* m_scrubber;
133  TimeSpinBox* m_positionSpinner;
134  QLabel* m_durationLabel;
135  QLabel* m_inPointLabel;
136  QLabel* m_selectedLabel;
137  int m_position;
138  int m_playPosition;
139  QIcon m_playIcon;
140  QIcon m_pauseIcon;
141  QFrame* m_volumePopup;
142  QSlider* m_volumeSlider;
143  QWidget* m_volumeWidget;
144  QPushButton* m_muteButton;
145  int m_previousIn;
146  int m_previousOut;
147  double m_savedVolume;
148  int m_duration;
149  bool m_isSeekable;
150  int m_isMeltedPlaying;
151  QScrollBar* m_horizontalScroll;
152  QScrollBar* m_verticalScroll;
153  QToolButton* m_zoomButton;
154  QToolButton* m_gridButton;
155  QActionGroup* m_gridActionGroup;
156  QAction* m_gridDefaultAction;
157  float m_zoomToggleFactor;
158  QTabBar* m_tabs;
159  bool m_pauseAfterOpen;
160  int m_monitorScreen;
161  QWidget* m_videoWidget;
162  QHBoxLayout* m_videoLayout;
163  QWidget* m_videoScrollWidget;
164  const TransportControllable* m_currentTransport;
165  QPushButton * m_statusLabel;
166  QPropertyAnimation* m_statusFadeIn;
167  QPropertyAnimation* m_statusFadeOut;
168  QTimer m_statusTimer;
169  QMenu* m_zoomMenu;
170  NewProjectFolder* m_projectWidget;
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 onZoomTriggered();
182  void toggleZoom(bool checked);
183  void onGridToggled();
184  void toggleGrid(bool checked);
185  void onFadeOutFinished();
186 };
187 
188 #endif // PLAYER_H
SharedFrame
The SharedFrame provides thread safe access to Mlt::Frame data.
Definition: sharedframe.h:49