File indexing completed on 2024-12-22 04:40:09
0001 /* 0002 SPDX-FileCopyrightText: 2017-2022 Mladen Milinkovic <max@smoothware.net> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef VOBSUBINPUTPROCESSDIALOG_H 0008 #define VOBSUBINPUTPROCESSDIALOG_H 0009 0010 #include "core/subtitle.h" 0011 0012 #include "streamprocessor/streamprocessor.h" 0013 0014 #include <QDialog> 0015 #include <QExplicitlySharedDataPointer> 0016 #include <QHash> 0017 0018 namespace Ui { 0019 class VobSubInputProcessDialog; 0020 } 0021 0022 namespace SubtitleComposer { 0023 class VobSubInputProcessDialog : public QDialog 0024 { 0025 Q_OBJECT 0026 0027 public: 0028 class Frame; 0029 typedef QExplicitlySharedDataPointer<Frame> FramePtr; 0030 class Piece; 0031 typedef QExplicitlySharedDataPointer<Piece> PiecePtr; 0032 class Line; 0033 typedef QExplicitlySharedDataPointer<Line> LinePtr; 0034 0035 VobSubInputProcessDialog(Subtitle *subtitle, QWidget *parent = 0); 0036 ~VobSubInputProcessDialog(); 0037 0038 bool symFileOpen(const QString &filename); 0039 bool symFileSave(const QString &filename); 0040 0041 bool eventFilter(QObject *obj, QEvent *event) override; 0042 0043 void processFrames(StreamProcessor *streamProcessor); 0044 0045 private slots: 0046 void onOkClicked(); 0047 void onAbortClicked(); 0048 void onPrevImageClicked(); 0049 void onNextImageClicked(); 0050 void onPrevSymbolClicked(); 0051 void onNextSymbolClicked(); 0052 void onSymbolCountChanged(int symbolCount); 0053 0054 void onStreamData(const QImage &image, quint64 msecStart, quint64 msecDuration); 0055 void onStreamError(int code, const QString &message, const QString &debug); 0056 void onStreamFinished(); 0057 0058 private: 0059 friend class VobSubInputFormat; 0060 Ui::VobSubInputProcessDialog *ui; 0061 0062 Q_INVOKABLE void processNextImage(); 0063 void processCurrentPiece(); 0064 void updateCurrentPiece(); 0065 void processNextPiece(); 0066 void recognizePiece(); 0067 0068 RichString currentText(); 0069 PiecePtr currentNormalizedPiece(int symbolCount); 0070 void currentSymbolCountSet(int symbolCount); 0071 0072 QList<FramePtr> m_frames; 0073 QList<FramePtr>::iterator m_frameCurrent; 0074 0075 QExplicitlySharedDataPointer<Subtitle> m_subtitle; 0076 0077 qint32 m_spaceWidth; 0078 0079 QList<PiecePtr> m_pieces; 0080 QList<PiecePtr>::iterator m_pieceCurrent; 0081 0082 QHash<Piece, RichString> m_recognizedPieces; 0083 qint32 m_recognizedPiecesMaxSymbolLength; 0084 }; 0085 } 0086 0087 #endif // VOBSUBINPUTPROCESSDIALOG_H