CuteLogger
Fast and simple logging solution for Qt based applications
subtitlesdock.h
1/*
2 * Copyright (c) 2024-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 SUBTITLESDOCK_H
19#define SUBTITLESDOCK_H
20
21#include <MltPlaylist.h>
22#include <QDockWidget>
23
24class SubtitlesModel;
25class SubtitlesSelectionModel;
26class QComboBox;
27class QItemSelection;
28class QLabel;
29class QLineEdit;
30class QTextEdit;
31class QTreeView;
32class SpeechDialog;
33
34class SubtitlesDock : public QDockWidget
35{
36 Q_OBJECT
37
38public:
39 explicit SubtitlesDock(QWidget *parent = 0);
40 ~SubtitlesDock();
41 void setModel(SubtitlesModel *model, SubtitlesSelectionModel *selectionModel);
42 void importSrtFromFile(const QString &srtPath,
43 const QString &trackName,
44 const QString &lang,
45 bool includeNonspoken);
46
47signals:
48 void seekRequested(int pos);
49 void addAllTimeline(Mlt::Playlist *, bool skipProxy, bool emptyTrack);
50 void createOrEditFilterOnOutput(Mlt::Filter *, const QStringList &key_properties);
51
52private slots:
53 void onPositionChanged(int position);
54 void onStartColumnToggled(bool checked);
55 void onEndColumnToggled(bool checked);
56 void onDurationColumnToggled(bool checked);
57
58protected:
59 void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
60
61private:
62 void setupActions();
63 void onCreateOrEditRequested();
64 void onAddRequested();
65 void onRemoveRequested();
66 void onSetStartRequested();
67 void onSetEndRequested();
68 void onMoveRequested();
69 void onTextEdited();
70 void onModelReset();
71 void updateActionAvailablity();
72 void addSubtitleTrack();
73 void removeSubtitleTrack();
74 void editSubtitleTrack();
75 void refreshTracksCombo();
76 void importSubtitles();
77 void exportSubtitles();
78 void onItemDoubleClicked(const QModelIndex &index);
79 void resizeTextWidgets();
80 void updateTextWidgets();
81 void setCurrentItem(int trackIndex, int itemIndex);
82 void refreshWidgets();
83 void selectItemForTime();
84 QString availableTrackName();
85 bool trackNameExists(const QString &name);
86 void ensureTrackExists();
87 void burnInOnTimeline();
88 void generateTextOnTimeline();
89 void speechToText();
90 void textToSpeech();
91 bool findWhisperExe();
92 void seekToText(QString text, int step);
93
94 SubtitlesModel *m_model;
95 SubtitlesSelectionModel *m_selectionModel;
96 QLabel *m_addToTimelineLabel;
97 QComboBox *m_trackCombo;
98 QTreeView *m_treeView;
99 QTextEdit *m_text;
100 QTextEdit *m_prev;
101 QTextEdit *m_next;
102 QLabel *m_prevLabel;
103 QLabel *m_textLabel;
104 QLabel *m_nextLabel;
105 QLineEdit *m_searchField;
106 int m_pos;
107 bool m_textEditInProgress;
108 std::unique_ptr<SpeechDialog> m_speechDialog;
109};
110
111#endif // SUBTITLESDOCK_H