Olive
loadthread.h
1 /***
2 
3  Olive - Non-Linear Video Editor
4  Copyright (C) 2019 Olive Team
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 ***/
20 
21 #ifndef LOADTHREAD_H
22 #define LOADTHREAD_H
23 
24 #include <QThread>
25 #include <QDir>
26 #include <QXmlStreamReader>
27 #include <QMutex>
28 #include <QWaitCondition>
29 #include <QMessageBox>
30 
31 class Media;
32 struct Footage;
33 class Clip;
34 struct Sequence;
35 class LoadDialog;
36 struct TransitionData;
37 struct EffectMeta;
38 
39 class LoadThread : public QThread
40 {
41  Q_OBJECT
42 public:
43  LoadThread(LoadDialog* l, bool a);
44  void run();
45  void cancel();
46 signals:
47  void start_question(const QString &title, const QString &text, int buttons);
48  void success();
49  void error();
50  void start_create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled);
51  void start_create_dual_transition(const TransitionData* td, Clip* primary, Clip* secondary, const EffectMeta* meta);
52  void report_progress(int p);
53 private slots:
54  void question_func(const QString &title, const QString &text, int buttons);
55  void error_func();
56  void success_func();
57  void create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled);
58  void create_dual_transition(const TransitionData* td, Clip* primary, Clip* secondary, const EffectMeta* meta);
59 private:
60  LoadDialog* ld;
61  bool autorecovery;
62 
63  bool load_worker(QFile& f, QXmlStreamReader& stream, int type);
64  void load_effect(QXmlStreamReader& stream, Clip* c);
65 
66  void read_next(QXmlStreamReader& stream);
67  void read_next_start_element(QXmlStreamReader& stream);
68  void update_current_element_count(QXmlStreamReader& stream);
69 
70  Sequence* open_seq;
71  QVector<Media*> loaded_media_items;
72  QDir proj_dir;
73  QDir internal_proj_dir;
74  QString internal_proj_url;
75  bool show_err;
76  QString error_str;
77 
78  bool is_element(QXmlStreamReader& stream);
79 
80  QVector<Media*> loaded_folders;
81  QVector<Clip*> loaded_clips;
82  QVector<Media*> loaded_sequences;
83  Media* find_loaded_folder_by_id(int id);
84 
85  int current_element_count;
86  int total_element_count;
87 
88  QMutex mutex;
89  QWaitCondition waitCond;
90 
91  bool cancelled;
92  bool xml_error;
93 
94  QMessageBox::StandardButton question_btn;
95 };
96 
97 #endif // LOADTHREAD_H
Definition: loadthread.h:39
Definition: sequence.h:33
Definition: effect.h:47
Definition: loadthread.cpp:41
Definition: loaddialog.h:33
Definition: media.h:40
Definition: clip.h:53
Definition: footage.h:66