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