]> git.sesse.net Git - pkanalytics/blobdiff - mainwindow.cpp
Add a menu.
[pkanalytics] / mainwindow.cpp
index b8322cbb856c20f0c5902251d45e8135afd242e2..feaf3abc525ed4b0c88fe53e849004a7513b72c4 100644 (file)
@@ -231,7 +231,8 @@ MainWindow::MainWindow(EventsModel *events, PlayersModel *players,
        });
        connect(ui->pull_or_was_d, &QPushButton::clicked, [this, events]() {
                EventsModel::Status s = events->get_status_at(ui->video->get_position());
-               if (s.pull_state == EventsModel::Status::SHOULD_PULL) {
+               if (s.pull_state == EventsModel::Status::SHOULD_PULL ||
+                   events->get_status_at(ui->video->get_position() - 1).pull_state == EventsModel::Status::SHOULD_PULL) {
                        set_current_event_type("pull");
                } else if (s.pull_state == EventsModel::Status::PULL_IN_AIR) {
                        insert_noplayer_event("pull_landed");
@@ -271,6 +272,10 @@ MainWindow::MainWindow(EventsModel *events, PlayersModel *players,
        QShortcut *key_delete = new QShortcut(QKeySequence(Qt::Key_Delete), this);
        connect(key_delete, &QShortcut::activated, [this]() { ui->delete_->animateClick(); });
        connect(ui->delete_, &QPushButton::clicked, [this]() { delete_current_event(); });
+
+       // Menus.
+       connect(ui->action_exit, &QAction::triggered, [this] { close(); });
+       connect(ui->action_export_json, &QAction::triggered, [db] { export_to_json(db, "ultimate.json"); });
 }
 
 void MainWindow::position_changed(uint64_t pos)
@@ -351,7 +356,7 @@ void MainWindow::insert_or_change_formation(bool offense)
        QItemSelectionModel *select = ui->event_view->selectionModel();
        if (select->hasSelection()) {
                int row = select->selectedRows().front().row();  // Should only be one, due to our selection behavior.
-               string expected_type = offense ? "formation_offense" : "formation_defense";
+               EventType expected_type = offense ? EventType::FORMATION_OFFENSE : EventType::FORMATION_DEFENSE;
                if (events->get_event_type(row) == expected_type) {
                        events->set_event_formation(row, formation_id);
                        update_ui_from_time(ui->video->get_position());
@@ -521,7 +526,8 @@ void MainWindow::update_action_buttons(uint64_t t)
        ui->throwaway->setText("Throwaway (&t)");
        ui->throwaway->setShortcut(QCoreApplication::translate("MainWindow", "T", nullptr));
 
-       if (s.pull_state == EventsModel::Status::SHOULD_PULL) {
+       if (s.pull_state == EventsModel::Status::SHOULD_PULL ||
+           (has_selection_with_player && events->get_status_at(ui->video->get_position() - 1).pull_state == EventsModel::Status::SHOULD_PULL)) {  // Can change this event to pull.
                ui->pull_or_was_d->setEnabled(s.attack_state == EventsModel::Status::DEFENSE && has_selection_with_player);
                ui->their_pull->setEnabled(s.attack_state == EventsModel::Status::OFFENSE);