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