File indexing completed on 2024-06-09 04:53:06
0001 /* 0002 SPDX-FileCopyrightText: 2007-2009 Sergio Pistone <sergio_pistone@yahoo.com.ar> 0003 SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic <max@smoothware.net> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef PLAYERWIDGET_H 0009 #define PLAYERWIDGET_H 0010 0011 #include "core/time.h" 0012 #include "core/subtitle.h" 0013 #include "core/subtitleline.h" 0014 0015 #include <QExplicitlySharedDataPointer> 0016 #include <QPoint> 0017 #include <QWidget> 0018 0019 QT_FORWARD_DECLARE_CLASS(QGridLayout) 0020 QT_FORWARD_DECLARE_CLASS(QLabel) 0021 QT_FORWARD_DECLARE_CLASS(QToolButton) 0022 QT_FORWARD_DECLARE_CLASS(QSlider) 0023 0024 class LayeredWidget; 0025 class AttachableWidget; 0026 class TimeEdit; 0027 0028 namespace SubtitleComposer { 0029 class TextOverlayWidget; 0030 0031 class PlayerWidget : public QWidget 0032 { 0033 Q_OBJECT 0034 0035 public: 0036 PlayerWidget(QWidget *parent); 0037 virtual ~PlayerWidget(); 0038 0039 void loadConfig(); 0040 void saveConfig(); 0041 0042 inline bool fullScreenMode() const { return m_fullScreenMode; } 0043 void setFullScreenMode(bool fullScreenMode); 0044 0045 inline SubtitleLine * playingLine() { return m_playingLine; } 0046 0047 bool eventFilter(QObject *object, QEvent *event) override; 0048 0049 QWidget *infoSidebarWidget(); 0050 0051 void pauseAfterPlayingLine(const SubtitleLine *line); 0052 0053 public slots: 0054 void setSubtitle(Subtitle *subtitle = 0); 0055 void setTranslationMode(bool enabled); 0056 void setShowTranslation(bool showTranslation); 0057 0058 void increaseFontSize(int size = 1); 0059 void decreaseFontSize(int size = 1); 0060 0061 signals: 0062 void playingLineChanged(SubtitleLine *line); 0063 0064 protected: 0065 void timerEvent(QTimerEvent *event) override; 0066 0067 private: 0068 static QToolButton * toolButton(QWidget *parent, const char *name); 0069 static QToolButton * createToolButton(QWidget *parent, const char *name, int size); 0070 0071 void updatePlayingLine(const Time &videoPosition); 0072 void setPlayingLine(SubtitleLine *line); 0073 0074 void updatePositionEditVisibility(); 0075 0076 private slots: 0077 void setPlayingLineFromVideo(); 0078 0079 void onVolumeSliderMoved(int value); 0080 void onSeekSliderMoved(int value); 0081 void onPositionEditValueChanged(int position); 0082 0083 void onConfigChanged(); 0084 0085 void onPlayerFileOpened(const QString &filePath); 0086 void onPlayerFileOpenError(const QString &filePath, const QString &reason); 0087 void onPlayerFileClosed(); 0088 void onPlayerPlaybackError(const QString &errorMessage); 0089 void onPlayerPlaying(); 0090 void onPlayerStopped(); 0091 void onPlayerPositionChanged(double seconds); 0092 void onPlayerLengthChanged(double seconds); 0093 void onPlayerFramesPerSecondChanged(double fps); 0094 void onPlayerPlaybackRateChanged(double rate); 0095 void onPlayerVolumeChanged(double volume); 0096 0097 void onPlayerLeftClicked(const QPointF &point); 0098 void onPlayerRightClicked(const QPointF &point); 0099 void onPlayerDoubleClicked(const QPointF &point); 0100 0101 private: 0102 QExplicitlySharedDataPointer<Subtitle> m_subtitle; 0103 bool m_translationMode; 0104 bool m_showTranslation; 0105 SubtitleLine *m_playingLine = nullptr; 0106 SubtitleLine *m_prevLine = nullptr; 0107 SubtitleLine *m_nextLine = nullptr; 0108 0109 const SubtitleLine *m_pauseAfterPlayingLine; 0110 0111 int m_fullScreenTID; 0112 bool m_fullScreenMode; 0113 0114 QGridLayout *m_mainLayout; 0115 0116 LayeredWidget *m_layeredWidget; 0117 AttachableWidget *m_fullScreenControls; 0118 0119 QSlider *m_seekSlider; 0120 QSlider *m_fsSeekSlider; 0121 QLabel *m_fsPositionLabel; 0122 QString m_lengthString; 0123 0124 QSlider *m_volumeSlider; 0125 QSlider *m_fsVolumeSlider; 0126 0127 QWidget *m_infoControlsGroupBox; 0128 QLabel *m_positionLabel; 0129 TimeEdit *m_positionEdit; 0130 bool m_showPositionTimeEdit; 0131 QLabel *m_lengthLabel; 0132 QLabel *m_fpsLabel; 0133 QLabel *m_rateLabel; 0134 0135 QPointF m_savedCursorPos; // for hiding the mouse on full screen mode 0136 QPointF m_currentCursorPos; 0137 }; 0138 } 0139 #endif