]> git.sesse.net Git - nageru/blob - mainwindow.h
Assorted clang-format fixes (not complete).
[nageru] / mainwindow.h
1 #ifndef MAINWINDOW_H
2 #define MAINWINDOW_H
3
4 #include "clip_list.h"
5 #include "db.h"
6 #include "state.pb.h"
7
8 #include <QLabel>
9 #include <QMainWindow>
10 #include <stdbool.h>
11 #include <sys/types.h>
12
13 namespace Ui {
14 class MainWindow;
15 }  // namespace Ui
16
17 class Player;
18
19 class MainWindow : public QMainWindow {
20         Q_OBJECT
21
22 public:
23         MainWindow();
24
25 //private:
26         Ui::MainWindow *ui;
27
28 private:
29         QLabel *disk_free_label;
30         Player *preview_player, *live_player;
31         DB db;
32
33         // State when doing a scrub operation on a timestamp with the mouse.
34         bool scrubbing = false;
35         int scrub_x_origin;  // In pixels on the viewport.
36         int64_t scrub_pts_origin;
37
38         // Which element (e.g. pts_in on clip 4) we are scrubbing.
39         enum ScrubType { SCRUBBING_CLIP_LIST, SCRUBBING_PLAYLIST } scrub_type;
40         int scrub_row;
41         int scrub_column;
42
43         // Used to keep track of small mouse wheel motions on the camera index in the playlist.
44         int last_mousewheel_camera_row = -1;
45         int leftover_angle_degrees = 0;
46
47         // Some operations, notably scrubbing and scrolling, happen in so large increments
48         // that we want to group them instead of saving to disk every single time.
49         // If they happen (ie., we get a callback from the model that it's changed) while
50         // currently_deferring_model_changes, we fire off this timer. If it manages to elapse
51         // before some other event happens, we count the event. (If the other event is of the
52         // same kind, we just fire off the timer anew instead of taking any action.)
53         QTimer *defer_timeout;
54         std::string deferred_change_id;
55         StateProto deferred_state;
56
57         // Before a change that should be deferred (see above), currently_deferring_model_changes
58         // must be set to true, and current_change_id must be given contents describing what's
59         // changed to avoid accidental grouping.
60         bool currently_deferring_model_changes = false;
61         std::string current_change_id;
62
63         void cue_in_clicked();
64         void cue_out_clicked();
65         void queue_clicked();
66         void preview_clicked();
67         void preview_angle_clicked(unsigned stream_idx);
68         void play_clicked();
69         void live_player_clip_done();
70         Clip live_player_get_next_clip();
71         void live_player_clip_progress(double played_this_clip, double total_length);
72         void playlist_duplicate();
73         void playlist_remove();
74         void playlist_move(int delta);
75
76         void defer_timer_expired();
77         void content_changed();  // In clip_list or play_list.
78         void state_changed(const StateProto &state);  // Called post-filtering.
79
80         enum Rounding { FIRST_AT_OR_AFTER, LAST_BEFORE };
81         void preview_single_frame(int64_t pts, unsigned stream_idx, Rounding rounding);
82
83         // Also covers when the playlist itself changes.
84         void playlist_selection_changed();
85
86         void clip_list_selection_changed(const QModelIndex &current, const QModelIndex &previous);
87
88         void resizeEvent(QResizeEvent *event) override;
89         bool eventFilter(QObject *watched, QEvent *event) override;
90
91         void report_disk_space(off_t free_bytes, double estimated_seconds_left);
92         void exit_triggered();
93
94         void highlight_camera_input(int stream_idx);
95
96 private slots:
97         void relayout();
98 };
99
100 extern MainWindow *global_mainwindow;
101
102 #endif