]> git.sesse.net Git - pkanalytics/blob - mainwindow.h
std::shared_ptr is surprisingly not thread-safe, so we need a mutex.
[pkanalytics] / mainwindow.h
1 #include <QMediaPlayer>
2 #include <QMainWindow>
3 #include <QApplication>
4 #include <stdint.h>
5 #include <optional>
6 #include "ui_mainwindow.h"
7
8 class EventsModel;
9 class PlayersModel;
10 class FormationsModel;
11
12 class MainWindow : public QMainWindow
13 {
14         Q_OBJECT
15
16 public:
17         MainWindow(EventsModel *events, PlayersModel *players,
18                    FormationsModel *offensive_formations, FormationsModel *defensive_formations);
19         ~MainWindow() {
20                 if (ui && ui->video) {
21                         ui->video->stop();
22                 }
23         }
24
25 private:
26         void position_changed(uint64_t pos);
27         void seek(int64_t delta_ms);
28         void insert_player_event(int button_id);
29         void insert_noplayer_event(const std::string &type);
30         void set_current_event_type(const std::string &type);
31         void insert_or_change_formation(bool offense);
32         void delete_current_event();
33         void make_substitution();
34         void formation_double_clicked(bool offense, unsigned row);
35
36         void update_ui_from_time(uint64_t t);
37         void update_status(uint64_t t);
38         void update_player_buttons(uint64_t t);
39         void update_action_buttons(uint64_t t);
40
41         Ui::MainWindow *ui;
42         EventsModel *events;
43         PlayersModel *players;
44         FormationsModel *offensive_formations;
45         FormationsModel *defensive_formations;
46         bool seeking = false;
47         std::atomic<bool> playing{true};
48         std::optional<uint64_t> buffered_seek;
49 };