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