CuteLogger
Fast and simple logging solution for Qt based applications
player.h
1 /*
2  * Copyright (c) 2012-2022 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 "sharedframe.h"
25 
26 class ScrubBar;
27 class QSpinBox;
28 class QLabel;
29 class TimeSpinBox;
30 class QFrame;
31 class QSlider;
32 class QAction;
33 class QActionGroup;
34 class QScrollBar;
35 class QToolButton;
36 class QTabBar;
37 class QHBoxLayout;
38 class QPushButton;
39 class TransportControllable;
40 class QLabel;
41 class QPushButton;
42 class QMenu;
43 class NewProjectFolder;
44 class StatusLabelWidget;
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  {
63  return m_position;
64  }
65  NewProjectFolder *projectWidget() const
66  {
67  return m_projectWidget;
68  }
69  void moveVideoToScreen(int screen = -1);
70  void setPauseAfterOpen(bool pause);
71  TabIndex tabIndex() const;
72 
73 signals:
74  void endOfStream();
75  void showStatusMessage(QString);
76  void inChanged(int delta);
77  void outChanged(int delta);
78  void played(double speed);
79  void paused();
80  void stopped();
81  void seeked(int position);
82  void rewound(bool forceChangeDirection);
83  void fastForwarded(bool forceChangeDirection);
84  void previousSought(int currentPosition);
85  void previousSought();
86  void nextSought(int currentPosition);
87  void nextSought();
88  void zoomChanged(float zoom);
89  void gridChanged(int grid);
90  void scrolledHorizontally(int x);
91  void scrolledVertically(int y);
92  void tabIndexChanged(int index);
93  void trimIn();
94  void trimOut();
95 
96 public slots:
97  void play(double speed = 1.0);
98  void pause();
99  void stop();
100  void seek(int position);
101  void reset();
102  void onProducerOpened(bool play = true);
103  void postProducerOpened();
104  void onMeltedUnitOpened();
105  void onDurationChanged();
106  void onFrameDisplayed(const SharedFrame &frame);
107  void onVolumeChanged(int);
108  void onCaptureStateChanged(bool);
109  void rewind(bool forceChangeDirection = true);
110  void fastForward(bool forceChangeDirection = true);
111  void showPaused();
112  void showPlaying();
113  void switchToTab(TabIndex index);
114  void enableTab(TabIndex index, bool enabled = true);
115  void onTabBarClicked(int index);
116  void setStatusLabel(const QString &text, int timeoutSeconds, QAction *action,
117  QPalette::ColorRole role = QPalette::ToolTipBase);
118  void showIdleStatus();
119  void focusPositionSpinner() const;
120  void onMuteButtonToggled(bool checked);
121 
122 protected:
123  void resizeEvent(QResizeEvent *event) override;
124  bool event(QEvent *event) override;
125  void keyPressEvent(QKeyEvent *event) override;
126 
127 private:
128  void setupActions();
129  void adjustScrollBars(float horizontal, float vertical);
130  double setVolume(int volume);
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  QPushButton *m_muteButton;
144  int m_previousIn;
145  int m_previousOut;
146  double m_savedVolume;
147  int m_duration;
148  bool m_isSeekable;
149  int m_isMeltedPlaying;
150  QScrollBar *m_horizontalScroll;
151  QScrollBar *m_verticalScroll;
152  QToolButton *m_zoomButton;
153  QToolButton *m_gridButton;
154  QActionGroup *m_gridActionGroup;
155  QAction *m_gridDefaultAction;
156  QToolButton *m_volumeButton;
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  StatusLabelWidget *m_statusLabel;
166  QMenu *m_zoomMenu;
167  QMenu *m_mainMenu;
168  NewProjectFolder *m_projectWidget;
169 
170 private slots:
171  void updateSelection();
172  void onInChanged(int in);
173  void onOutChanged(int out);
174  void onVolumeTriggered();
175  void setZoom(float factor, const QIcon &icon);
176  void onZoomTriggered();
177  void toggleZoom(bool checked);
178  void onGridToggled();
179  void toggleGrid(bool checked);
180  void onStatusFinished();
181  void onOffsetChanged(const QPoint &offset);
182 };
183 
184 #endif // PLAYER_H
The SharedFrame provides thread safe access to Mlt::Frame data.
Definition: sharedframe.h:49