]> git.sesse.net Git - nageru/blobdiff - mainwindow.cpp
Add some very basic playback.
[nageru] / mainwindow.cpp
index e14834502e216cac0ba61a9672f6a9dafbf223b0..bbeeef9f7fa6fe76c927ac552337d03df8e80ef8 100644 (file)
@@ -1,6 +1,7 @@
 #include "mainwindow.h"
 
 #include "clip_list.h"
+#include "player.h"
 #include "ui_mainwindow.h"
 
 #include <string>
@@ -11,6 +12,8 @@
 using namespace std;
 
 MainWindow *global_mainwindow = nullptr;
+extern int64_t current_pts;
+ClipList *clips;
 
 MainWindow::MainWindow()
        : ui(new Ui::MainWindow)
@@ -18,11 +21,35 @@ MainWindow::MainWindow()
        global_mainwindow = this;
        ui->setupUi(this);
 
-       ClipList *clips = new ClipList;
+       clips = new ClipList;
        ui->clip_list->setModel(clips);
 
-       QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_Q), this);
-       connect(shortcut, &QShortcut::activated, [clips]{
-               clips->add_clip(12345);
+       // TODO: Make these into buttons.
+       // TODO: These are too big for lambdas.
+       QShortcut *cue_in = new QShortcut(QKeySequence(Qt::Key_A), this);
+       connect(cue_in, &QShortcut::activated, []{
+               if (!clips->empty() && clips->back()->pts_out < 0) {
+                       clips->back()->pts_in = current_pts;
+                       return;
+               }
+               Clip clip;
+               clip.pts_in = current_pts;
+               clips->add_clip(clip);
        });
+
+       QShortcut *cue_out = new QShortcut(QKeySequence(Qt::Key_S), this);
+       connect(cue_out, &QShortcut::activated, []{
+               if (!clips->empty()) {
+                       clips->back()->pts_out = current_pts;
+                       // TODO: select the row in the clip list?
+               }
+       });
+
+       QShortcut *preview_shortcut = new QShortcut(QKeySequence(Qt::Key_W), this);
+       connect(preview_shortcut, &QShortcut::activated, this, &MainWindow::preview_clicked);
+}
+
+void MainWindow::preview_clicked()
+{
+       play_clip(*clips->back(), 0);
 }