]> git.sesse.net Git - nageru/blob - futatabi/mainwindow.h
Add a multitrack export action.
[nageru] / futatabi / mainwindow.h
1 #ifndef MAINWINDOW_H
2 #define MAINWINDOW_H
3
4 #include "clip_list.h"
5 #include "db.h"
6 #include "state.pb.h"
7
8 #include <memory>
9 #include <mutex>
10 #include <QLabel>
11 #include <QMainWindow>
12 #include <stdbool.h>
13 #include <sys/types.h>
14 #include <string>
15 #include <utility>
16
17 namespace Ui {
18 class MainWindow;
19 }  // namespace Ui
20
21 class Player;
22
23 class MainWindow : public QMainWindow {
24         Q_OBJECT
25
26 public:
27         MainWindow();
28         ~MainWindow();
29
30         // HTTP callback. TODO: Does perhaps not belong to MainWindow?
31         std::pair<std::string, std::string> get_queue_status() const;
32
33 //private:
34         Ui::MainWindow *ui;
35
36 private:
37         QLabel *disk_free_label;
38         std::unique_ptr<Player> preview_player, live_player;
39         DB db;
40
41         // State when doing a scrub operation on a timestamp with the mouse.
42         bool scrubbing = false;
43         int scrub_x_origin;  // In pixels on the viewport.
44         int64_t scrub_pts_origin;
45
46         // Which element (e.g. pts_in on clip 4) we are scrubbing.
47         enum ScrubType { SCRUBBING_CLIP_LIST, SCRUBBING_PLAYLIST } scrub_type;
48         int scrub_row;
49         int scrub_column;
50
51         // Used to keep track of small mouse wheel motions on the camera index in the playlist.
52         int last_mousewheel_camera_row = -1;
53         int leftover_angle_degrees = 0;
54
55         // Some operations, notably scrubbing and scrolling, happen in so large increments
56         // that we want to group them instead of saving to disk every single time.
57         // If they happen (ie., we get a callback from the model that it's changed) while
58         // currently_deferring_model_changes, we fire off this timer. If it manages to elapse
59         // before some other event happens, we count the event. (If the other event is of the
60         // same kind, we just fire off the timer anew instead of taking any action.)
61         QTimer *defer_timeout;
62         std::string deferred_change_id;
63         StateProto deferred_state;
64
65         // Before a change that should be deferred (see above), currently_deferring_model_changes
66         // must be set to true, and current_change_id must be given contents describing what's
67         // changed to avoid accidental grouping.
68         bool currently_deferring_model_changes = false;
69         std::string current_change_id;
70
71         mutable std::mutex queue_status_mu;
72         std::string queue_status;  // Under queue_status_mu.
73
74         void cue_in_clicked();
75         void cue_out_clicked();
76         void queue_clicked();
77         void preview_clicked();
78         void preview_angle_clicked(unsigned stream_idx);
79         void play_clicked();
80         void live_player_clip_done();
81         std::pair<Clip, size_t> live_player_get_next_clip();
82         void live_player_clip_progress(const std::map<size_t, double> &progress);
83         void set_output_status(const std::string &status);
84         void playlist_duplicate();
85         void playlist_remove();
86         void playlist_move(int delta);
87
88         void defer_timer_expired();
89         void content_changed();  // In clip_list or play_list.
90         void state_changed(const StateProto &state);  // Called post-filtering.
91
92         enum Rounding { FIRST_AT_OR_AFTER, LAST_BEFORE };
93         void preview_single_frame(int64_t pts, unsigned stream_idx, Rounding rounding);
94
95         // Also covers when the playlist itself changes.
96         void playlist_selection_changed();
97
98         void clip_list_selection_changed(const QModelIndex &current, const QModelIndex &previous);
99
100         void resizeEvent(QResizeEvent *event) override;
101         bool eventFilter(QObject *watched, QEvent *event) override;
102
103         void report_disk_space(off_t free_bytes, double estimated_seconds_left);
104         void exit_triggered();
105         void export_cliplist_clip_multitrack_triggered();
106         void manual_triggered();
107         void about_triggered();
108
109         void highlight_camera_input(int stream_idx);
110
111 private slots:
112         void relayout();
113 };
114
115 extern MainWindow *global_mainwindow;
116
117 #endif