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