CuteLogger
Fast and simple logging solution for Qt based applications
player.h
1 /*
2  * Copyright (c) 2012-2017 Meltytech, LLC
3  * Author: Dan Dennedy <dan@dennedy.org>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef PLAYER_H
20 #define PLAYER_H
21 
22 #include <QWidget>
23 #include <QIcon>
24 #include <QSize>
25 #include <QTimer>
26 #include "sharedframe.h"
27 
28 class ScrubBar;
29 class QSpinBox;
30 class QLabel;
31 class TimeSpinBox;
32 class QFrame;
33 class QSlider;
34 class QAction;
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);
71  void outChanged(int);
72  void played(double speed);
73  void paused();
74  void stopped();
75  void seeked(int position);
76  void rewound();
77  void fastForwarded();
78  void previousSought(int currentPosition);
79  void previousSought();
80  void nextSought(int currentPosition);
81  void nextSought();
82  void zoomChanged(float zoom);
83  void scrolledHorizontally(int x);
84  void scrolledVertically(int y);
85  void tabIndexChanged(int index);
86 
87 public slots:
88  void play(double speed = 1.0);
89  void pause();
90  void stop();
91  void togglePlayPaused();
92  void seek(int position);
93  void reset();
94  void onProducerOpened(bool play = true);
95  void postProducerOpened();
96  void onMeltedUnitOpened();
97  void onDurationChanged();
98  void onShowFrame(int position, double fps, int in, int out, int length, bool isPlaying);
99  void onFrameDisplayed(const SharedFrame& frame);
100  void onVolumeChanged(int);
101  void onCaptureStateChanged(bool);
102  void rewind();
103  void fastForward();
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_zoomInAction;
155  float m_zoomToggleFactor;
156  QTabBar* m_tabs;
157  bool m_pauseAfterOpen;
158  int m_monitorScreen;
159  QWidget* m_videoWidget;
160  QHBoxLayout* m_videoLayout;
161  QWidget* m_videoScrollWidget;
162  const TransportControllable* m_currentTransport;
163  QPushButton * m_statusLabel;
164  QPropertyAnimation* m_statusFadeIn;
165  QPropertyAnimation* m_statusFadeOut;
166  QTimer m_statusTimer;
167 
168 private slots:
169  void updateSelection();
170  void onInChanged(int in);
171  void onOutChanged(int out);
172  void on_actionSkipNext_triggered();
173  void on_actionSkipPrevious_triggered();
174  void on_actionVolume_triggered();
175  void onMuteButtonToggled(bool checked);
176  void setZoom(float factor, const QIcon &icon);
177  void zoomFit();
178  void zoomOriginal();
179  void zoomOut50();
180  void zoomOut25();
181  void zoomIn();
182  void toggleZoom(bool checked);
183  void onFadeOutFinished();
184 };
185 
186 #endif // PLAYER_H
The SharedFrame provides thread safe access to Mlt::Frame data.
Definition: sharedframe.h:48