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;
47 // State when doing a scrub operation on a timestamp with the mouse.
48 bool scrubbing = false;
49 int scrub_x_origin; // In pixels on the viewport.
50 int64_t scrub_pts_origin;
52 // Which element (e.g. pts_in on clip 4) we are scrubbing.
53 enum ScrubType { SCRUBBING_CLIP_LIST, SCRUBBING_PLAYLIST } scrub_type;
57 // Used to keep track of small mouse wheel motions on the camera index in the playlist.
58 int last_mousewheel_camera_row = -1;
59 int leftover_angle_degrees = 0;
61 // Some operations, notably scrubbing and scrolling, happen in so large increments
62 // that we want to group them instead of saving to disk every single time.
63 // If they happen (ie., we get a callback from the model that it's changed) while
64 // currently_deferring_model_changes, we fire off this timer. If it manages to elapse
65 // before some other event happens, we count the event. (If the other event is of the
66 // same kind, we just fire off the timer anew instead of taking any action.)
67 QTimer *defer_timeout;
68 std::string deferred_change_id;
69 StateProto deferred_state;
71 // NOTE: The undo stack always has the current state on top.
72 std::deque<StateProto> undo_stack, redo_stack;
74 // Before a change that should be deferred (see above), currently_deferring_model_changes
75 // must be set to true, and current_change_id must be given contents describing what's
76 // changed to avoid accidental grouping.
77 bool currently_deferring_model_changes = false;
78 std::string current_change_id;
80 mutable std::mutex queue_status_mu;
81 std::string queue_status; // Under queue_status_mu.
83 struct FrameAndDisplay {
85 JPEGFrameView *display;
86 QPushButton *preview_btn;
88 std::vector<FrameAndDisplay> displays;
90 void cue_in_clicked();
91 void cue_out_clicked();
93 void preview_clicked();
94 void preview_angle_clicked(unsigned stream_idx);
97 void live_player_clip_done();
98 std::pair<Clip, size_t> live_player_get_next_clip();
99 void live_player_clip_progress(const std::map<size_t, double> &progress);
100 void set_output_status(const std::string &status);
101 void playlist_duplicate();
102 void playlist_remove();
103 void playlist_move(int delta);
105 void defer_timer_expired();
106 void content_changed(); // In clip_list or play_list.
107 void state_changed(const StateProto &state); // Called post-filtering.
108 void save_settings();
110 enum Rounding { FIRST_AT_OR_AFTER, LAST_BEFORE };
111 void preview_single_frame(int64_t pts, unsigned stream_idx, Rounding rounding);
113 // Also covers when the playlist itself changes.
114 void playlist_selection_changed();
116 void clip_list_selection_changed(const QModelIndex ¤t, const QModelIndex &previous);
118 void resizeEvent(QResizeEvent *event) override;
119 bool eventFilter(QObject *watched, QEvent *event) override;
121 void report_disk_space(off_t free_bytes, double estimated_seconds_left);
122 void exit_triggered();
123 void export_cliplist_clip_multitrack_triggered();
124 void export_playlist_clip_interpolated_triggered();
125 void manual_triggered();
126 void about_triggered();
127 void undo_triggered();
128 void redo_triggered();
129 void quality_toggled(int quality, bool checked);
131 void highlight_camera_input(int stream_idx);
133 template <class Model>
134 void replace_model(QTableView *view, Model **model, Model *new_model);
140 extern MainWindow *global_mainwindow;