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 class QMenu;
45 
46 class Player : public QWidget
47 {
48  Q_OBJECT
49 public:
50  typedef enum {
51  SourceTabIndex = 0,
52  ProjectTabIndex
53  } TabIndex;
54 
55  explicit Player(QWidget *parent = 0);
56  void connectTransport(const TransportControllable*);
57  void setIn(int);
58  void setOut(int);
59  void setMarkers(const QList<int>&);
60  QSize videoSize() const;
61  int position() const {
62  return m_position;
63  }
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 
112 protected:
113  void resizeEvent(QResizeEvent* event);
114 
115 private:
116  void setupActions(QWidget* widget);
117  void retranslateUi(QWidget* widget);
118  void adjustScrollBars(float horizontal, float vertical);
119  double setVolume(int volume);
120 
121  QAction *actionPlay;
122  QAction *actionPause;
123  QAction *actionSkipNext;
124  QAction *actionSkipPrevious;
125  QAction *actionRewind;
126  QAction *actionFastForward;
127  QAction *actionVolume;
128 
129  ScrubBar* m_scrubber;
130  TimeSpinBox* m_positionSpinner;
131  QLabel* m_durationLabel;
132  QLabel* m_inPointLabel;
133  QLabel* m_selectedLabel;
134  int m_position;
135  int m_playPosition;
136  QIcon m_playIcon;
137  QIcon m_pauseIcon;
138  QFrame* m_volumePopup;
139  QSlider* m_volumeSlider;
140  QWidget* m_volumeWidget;
141  QPushButton* m_muteButton;
142  int m_previousIn;
143  int m_previousOut;
144  double m_savedVolume;
145  int m_duration;
146  bool m_isSeekable;
147  int m_isMeltedPlaying;
148  QScrollBar* m_horizontalScroll;
149  QScrollBar* m_verticalScroll;
150  QToolButton* m_zoomButton;
151  QToolButton* m_gridButton;
152  QActionGroup* m_gridActionGroup;
153  QAction* m_gridDefaultAction;
154  float m_zoomToggleFactor;
155  QTabBar* m_tabs;
156  bool m_pauseAfterOpen;
157  int m_monitorScreen;
158  QWidget* m_videoWidget;
159  QHBoxLayout* m_videoLayout;
160  QWidget* m_videoScrollWidget;
161  const TransportControllable* m_currentTransport;
162  QPushButton * m_statusLabel;
163  QPropertyAnimation* m_statusFadeIn;
164  QPropertyAnimation* m_statusFadeOut;
165  QTimer m_statusTimer;
166  QMenu* m_zoomMenu;
167  QWidget* m_projectWidget;
168 
169 private slots:
170  void updateSelection();
171  void onInChanged(int in);
172  void onOutChanged(int out);
173  void on_actionSkipNext_triggered();
174  void on_actionSkipPrevious_triggered();
175  void on_actionVolume_triggered();
176  void onMuteButtonToggled(bool checked);
177  void setZoom(float factor, const QIcon &icon);
178  void onZoomTriggered();
179  void toggleZoom(bool checked);
180  void onGridToggled();
181  void toggleGrid(bool checked);
182  void onFadeOutFinished();
183 };
184 
185 #endif // PLAYER_H
The SharedFrame provides thread safe access to Mlt::Frame data.
Definition: sharedframe.h:48