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