CuteLogger
Fast and simple logging solution for Qt based applications
player.h
1/*
2 * Copyright (c) 2012-2023 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
26class DockToolBar;
27class ScrubBar;
28class QSpinBox;
29class QLabel;
30class TimeSpinBox;
31class QFrame;
32class QSlider;
33class QAction;
34class QActionGroup;
35class QScrollBar;
36class QToolButton;
37class QTabBar;
38class QHBoxLayout;
39class QPushButton;
40class TransportControllable;
41class QLabel;
42class QPushButton;
43class QMenu;
44class NewProjectFolder;
45class StatusLabelWidget;
46
47class Player : public QWidget
48{
49 Q_OBJECT
50public:
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
63 {
64 return m_position;
65 }
66 NewProjectFolder *projectWidget() const
67 {
68 return m_projectWidget;
69 }
70 void moveVideoToScreen(int screen = -1);
71 void setPauseAfterOpen(bool pause);
72 TabIndex tabIndex() const;
73
74signals:
75 void endOfStream();
76 void showStatusMessage(QString);
77 void inChanged(int delta);
78 void outChanged(int delta);
79 void played(double speed);
80 void paused();
81 void stopped();
82 void seeked(int position);
83 void rewound(bool forceChangeDirection);
84 void fastForwarded(bool forceChangeDirection);
85 void previousSought(int currentPosition);
86 void previousSought();
87 void nextSought(int currentPosition);
88 void nextSought();
89 void zoomChanged(float zoom);
90 void gridChanged(int grid);
91 void scrolledHorizontally(int x);
92 void scrolledVertically(int y);
93 void tabIndexChanged(int index);
94 void trimIn();
95 void trimOut();
96 void loopChanged(int start, int end);
97
98public slots:
99 void play(double speed = 1.0);
100 void pause();
101 void stop();
102 void seek(int position);
103 void reset();
104 void onProducerOpened(bool play = true);
105 void postProducerOpened();
106 void onMeltedUnitOpened();
107 void onDurationChanged();
108 void onFrameDisplayed(const SharedFrame &frame);
109 void onVolumeChanged(int);
110 void onCaptureStateChanged(bool);
111 void rewind(bool forceChangeDirection = true);
112 void fastForward(bool forceChangeDirection = true);
113 void showPaused();
114 void showPlaying();
115 void switchToTab(TabIndex index);
116 void enableTab(TabIndex index, bool enabled = true);
117 void onTabBarClicked(int index);
118 void setStatusLabel(const QString &text, int timeoutSeconds, QAction *action,
119 QPalette::ColorRole role = QPalette::ToolTipBase);
120 void showIdleStatus();
121 void focusPositionSpinner() const;
122 void onMuteButtonToggled(bool checked);
123
124protected:
125 void resizeEvent(QResizeEvent *event) override;
126 bool event(QEvent *event) override;
127 void keyPressEvent(QKeyEvent *event) override;
128
129private:
130 void setupActions();
131 void adjustScrollBars(float horizontal, float vertical);
132 double setVolume(int volume);
133 void setLoopRange(int start, int end);
134 void layoutToolbars();
135
136 ScrubBar *m_scrubber;
137 TimeSpinBox *m_positionSpinner;
138 QLabel *m_durationLabel;
139 QLabel *m_inPointLabel;
140 QLabel *m_selectedLabel;
141 int m_position;
142 int m_playPosition;
143 QIcon m_playIcon;
144 QIcon m_loopIcon;
145 QIcon m_pauseIcon;
146 QIcon m_stopIcon;
147 QFrame *m_volumePopup;
148 QSlider *m_volumeSlider;
149 QPushButton *m_muteButton;
150 int m_previousIn;
151 int m_previousOut;
152 double m_savedVolume;
153 int m_duration;
154 bool m_isSeekable;
155 int m_isMeltedPlaying;
156 QScrollBar *m_horizontalScroll;
157 QScrollBar *m_verticalScroll;
158 QToolButton *m_zoomButton;
159 QToolButton *m_gridButton;
160 QActionGroup *m_gridActionGroup;
161 QAction *m_gridDefaultAction;
162 QToolButton *m_volumeButton;
163 float m_zoomToggleFactor;
164 QTabBar *m_tabs;
165 bool m_pauseAfterOpen;
166 int m_monitorScreen;
167 QWidget *m_videoWidget;
168 QHBoxLayout *m_videoLayout;
169 QWidget *m_videoScrollWidget;
170 const TransportControllable *m_currentTransport;
171 StatusLabelWidget *m_statusLabel;
172 QMenu *m_zoomMenu;
173 QMenu *m_mainMenu;
174 NewProjectFolder *m_projectWidget;
175 int m_loopStart;
176 int m_loopEnd;
177 DockToolBar *m_currentDurationToolBar;
178 DockToolBar *m_controlsToolBar;
179 DockToolBar *m_optionsToolBar;
180 DockToolBar *m_inSelectedToolBar;
181 QHBoxLayout *m_toolRow1;
182 QHBoxLayout *m_toolRow2;
183
184private slots:
185 void updateSelection();
186 void onInChanged(int in);
187 void onOutChanged(int out);
188 void onVolumeTriggered();
189 void setZoom(float factor, const QIcon &icon);
190 void onZoomTriggered();
191 void toggleZoom(bool checked);
192 void onGridToggled();
193 void toggleGrid(bool checked);
194 void onStatusFinished();
195 void onOffsetChanged(const QPoint &offset);
196};
197
198#endif // PLAYER_H
The SharedFrame provides thread safe access to Mlt::Frame data.
Definition sharedframe.h:49