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_done();
106 void live_player_clip_progress(const std::map<uint64_t, double> &progress, double time_remaining);
107 void set_output_status(const std::string &status);
108 void playlist_duplicate();
109 void playlist_remove();
110 void playlist_move(int delta);
112 void defer_timer_expired();
113 void content_changed(); // In clip_list or play_list.
114 void state_changed(const StateProto &state); // Called post-filtering.
115 void save_settings();
117 enum Rounding { FIRST_AT_OR_AFTER,
119 void preview_single_frame(int64_t pts, unsigned stream_idx, Rounding rounding);
121 // Also covers when the playlist itself changes.
122 void playlist_selection_changed();
124 void clip_list_selection_changed(const QModelIndex ¤t, const QModelIndex &previous);
126 void resizeEvent(QResizeEvent *event) override;
127 bool eventFilter(QObject *watched, QEvent *event) override;
129 void report_disk_space(off_t free_bytes, double estimated_seconds_left);
130 void exit_triggered();
131 void export_cliplist_clip_multitrack_triggered();
132 void export_playlist_clip_interpolated_triggered();
133 void manual_triggered();
134 void about_triggered();
135 void undo_triggered();
136 void redo_triggered();
137 void quality_toggled(int quality, bool checked);
138 void padding_toggled(double seconds, bool checked);
140 void highlight_camera_input(int stream_idx);
142 template<class Model>
143 void replace_model(QTableView *view, Model **model, Model *new_model);
146 void tally_received();
152 extern MainWindow *global_mainwindow;