1 #include "mainwindow.h"
5 #include "ui_mainwindow.h"
14 MainWindow *global_mainwindow = nullptr;
15 extern int64_t current_pts;
18 MainWindow::MainWindow()
19 : ui(new Ui::MainWindow)
21 global_mainwindow = this;
25 ui->clip_list->setModel(clips);
27 // TODO: Make these into buttons.
28 // TODO: These are too big for lambdas.
29 QShortcut *cue_in = new QShortcut(QKeySequence(Qt::Key_A), this);
30 connect(cue_in, &QShortcut::activated, []{
31 if (!clips->empty() && clips->back()->pts_out < 0) {
32 clips->back()->pts_in = current_pts;
36 clip.pts_in = current_pts;
37 clips->add_clip(clip);
40 QShortcut *cue_out = new QShortcut(QKeySequence(Qt::Key_S), this);
41 connect(cue_out, &QShortcut::activated, []{
42 if (!clips->empty()) {
43 clips->back()->pts_out = current_pts;
44 // TODO: select the row in the clip list?
48 QShortcut *preview_shortcut = new QShortcut(QKeySequence(Qt::Key_W), this);
49 connect(preview_shortcut, &QShortcut::activated, this, &MainWindow::preview_clicked);
52 void MainWindow::preview_clicked()
54 QItemSelectionModel *selected = ui->clip_list->selectionModel();
55 if (!selected->hasSelection()) {
56 play_clip(*clips->back(), 0);
60 QModelIndex index = selected->currentIndex();
61 if (index.column() >= ClipList::Column::CAMERA_1 &&
62 index.column() <= ClipList::Column::CAMERA_4) {
63 unsigned stream_idx = index.column() - ClipList::Column::CAMERA_1;
64 play_clip(*clips->clip(index.row()), stream_idx);