12 #include <QMainWindow>
14 #include <sys/types.h>
28 class MainWindow : public QMainWindow {
35 // HTTP callback. TODO: Does perhaps not belong to MainWindow?
36 std::pair<std::string, std::string> get_queue_status() const;
38 void display_frame(unsigned stream_idx, const FrameOnDisk &frame);
43 QLabel *disk_free_label;
44 std::unique_ptr<Player> preview_player, live_player;
48 // State when doing a scrub operation on a timestamp with the mouse.
49 bool scrubbing = false;
50 int scrub_x_origin; // In pixels on the viewport.
51 int64_t scrub_pts_origin;
53 // Which element (e.g. pts_in on clip 4) we are scrubbing.
54 enum ScrubType { SCRUBBING_CLIP_LIST, SCRUBBING_PLAYLIST } scrub_type;
58 // Used to keep track of small mouse wheel motions on the camera index in the playlist.
59 int last_mousewheel_camera_row = -1;
60 int leftover_angle_degrees = 0;
62 // Some operations, notably scrubbing and scrolling, happen in so large increments
63 // that we want to group them instead of saving to disk every single time.
64 // If they happen (ie., we get a callback from the model that it's changed) while
65 // currently_deferring_model_changes, we fire off this timer. If it manages to elapse
66 // before some other event happens, we count the event. (If the other event is of the
67 // same kind, we just fire off the timer anew instead of taking any action.)
68 QTimer *defer_timeout;
69 std::string deferred_change_id;
70 StateProto deferred_state;
72 // NOTE: The undo stack always has the current state on top.
73 std::deque<StateProto> undo_stack, redo_stack;
75 // Before a change that should be deferred (see above), currently_deferring_model_changes
76 // must be set to true, and current_change_id must be given contents describing what's
77 // changed to avoid accidental grouping.
78 bool currently_deferring_model_changes = false;
79 std::string current_change_id;
81 mutable std::mutex queue_status_mu;
82 std::string queue_status; // Under queue_status_mu.
84 struct FrameAndDisplay {
86 JPEGFrameView *display;
87 QPushButton *preview_btn;
89 std::vector<FrameAndDisplay> displays;
91 void change_num_cameras();
92 void cue_in_clicked();
93 void cue_out_clicked();
95 void preview_clicked();
96 void preview_angle_clicked(unsigned stream_idx);
99 void live_player_clip_done();
100 std::pair<Clip, size_t> live_player_get_next_clip();
101 void live_player_clip_progress(const std::map<size_t, double> &progress);
102 void set_output_status(const std::string &status);
103 void playlist_duplicate();
104 void playlist_remove();
105 void playlist_move(int delta);
107 void defer_timer_expired();
108 void content_changed(); // In clip_list or play_list.
109 void state_changed(const StateProto &state); // Called post-filtering.
110 void save_settings();
112 enum Rounding { FIRST_AT_OR_AFTER, LAST_BEFORE };
113 void preview_single_frame(int64_t pts, unsigned stream_idx, Rounding rounding);
115 // Also covers when the playlist itself changes.
116 void playlist_selection_changed();
118 void clip_list_selection_changed(const QModelIndex ¤t, const QModelIndex &previous);
120 void resizeEvent(QResizeEvent *event) override;
121 bool eventFilter(QObject *watched, QEvent *event) override;
123 void report_disk_space(off_t free_bytes, double estimated_seconds_left);
124 void exit_triggered();
125 void export_cliplist_clip_multitrack_triggered();
126 void export_playlist_clip_interpolated_triggered();
127 void manual_triggered();
128 void about_triggered();
129 void undo_triggered();
130 void redo_triggered();
131 void quality_toggled(int quality, bool checked);
133 void highlight_camera_input(int stream_idx);
135 template <class Model>
136 void replace_model(QTableView *view, Model **model, Model *new_model);
142 extern MainWindow *global_mainwindow;