CuteLogger
Fast and simple logging solution for Qt based applications
player.h
1/*
2 * Copyright (c) 2012-2024 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(int position);
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(int position = -1);
101 void stop();
102 void seek(int position);
103 void reset();
104 void onProducerOpened(bool play = true);
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
122protected:
123 void resizeEvent(QResizeEvent *event) override;
124 bool event(QEvent *event) override;
125 void keyPressEvent(QKeyEvent *event) override;
126
127private:
128 void setupActions();
129 void adjustScrollBars(float horizontal, float vertical);
130 double setVolume(int volume);
131 void setLoopRange(int start, int end);
132 void layoutToolbars();
133
134 ScrubBar *m_scrubber;
135 TimeSpinBox *m_positionSpinner;
136 QLabel *m_durationLabel;
137 QLabel *m_inPointLabel;
138 QLabel *m_selectedLabel;
139 int m_position;
140 int m_playPosition;
141 QIcon m_playIcon;
142 QIcon m_loopIcon;
143 QIcon m_pauseIcon;
144 QIcon m_stopIcon;
145 QFrame *m_volumePopup;
146 QSlider *m_volumeSlider;
147 QPushButton *m_muteButton;
148 int m_previousIn;
149 int m_previousOut;
150 double m_savedVolume;
151 int m_duration;
152 bool m_isSeekable;
153 QScrollBar *m_horizontalScroll;
154 QScrollBar *m_verticalScroll;
155 QToolButton *m_zoomButton;
156 QToolButton *m_gridButton;
157 QActionGroup *m_gridActionGroup;
158 QAction *m_gridDefaultAction;
159 QToolButton *m_volumeButton;
160 float m_zoomToggleFactor;
161 QTabBar *m_tabs;
162 bool m_pauseAfterOpen;
163 int m_monitorScreen;
164 QWidget *m_videoWidget;
165 QHBoxLayout *m_videoLayout;
166 QWidget *m_videoScrollWidget;
167 const TransportControllable *m_currentTransport;
168 StatusLabelWidget *m_statusLabel;
169 QMenu *m_zoomMenu;
170 QMenu *m_mainMenu;
171 NewProjectFolder *m_projectWidget;
172 int m_loopStart;
173 int m_loopEnd;
174 DockToolBar *m_currentDurationToolBar;
175 DockToolBar *m_controlsToolBar;
176 DockToolBar *m_optionsToolBar;
177 DockToolBar *m_inSelectedToolBar;
178 QHBoxLayout *m_toolRow1;
179 QHBoxLayout *m_toolRow2;
180
181private slots:
182 void updateSelection();
183 void onInChanged(int in);
184 void onOutChanged(int out);
185 void onVolumeTriggered();
186 void setZoom(float factor, const QIcon &icon);
187 void onZoomTriggered();
188 void toggleZoom(bool checked);
189 void onGridToggled();
190 void toggleGrid(bool checked);
191 void onStatusFinished();
192 void onOffsetChanged(const QPoint &offset);
193};
194
195#endif // PLAYER_H