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